diff options
author | Joe Fiorini <joe@joefiorini.com> | 2012-04-05 00:53:10 -0400 |
---|---|---|
committer | Joe Fiorini <joe@joefiorini.com> | 2012-10-06 16:40:51 -0400 |
commit | 65a2977cdd55678d3eab06434625375914511786 (patch) | |
tree | ab2dbb879196f0879af1d4bce06480975492ff6e /guides | |
parent | 03bcd416b04c411973456e33a95756edab4244cd (diff) | |
download | rails-65a2977cdd55678d3eab06434625375914511786.tar.gz rails-65a2977cdd55678d3eab06434625375914511786.tar.bz2 rails-65a2977cdd55678d3eab06434625375914511786.zip |
[Guides] Format content for small devices
Diffstat (limited to 'guides')
-rwxr-xr-x | guides/assets/javascripts/responsive-tables.js | 43 | ||||
-rw-r--r-- | guides/assets/stylesheets/main.css | 68 | ||||
-rwxr-xr-x | guides/assets/stylesheets/responsive-tables.css | 50 | ||||
-rw-r--r-- | guides/source/action_controller_overview.md | 4 | ||||
-rw-r--r-- | guides/source/layout.html.erb | 1 | ||||
-rw-r--r-- | guides/source/migrations.md | 2 |
6 files changed, 163 insertions, 5 deletions
diff --git a/guides/assets/javascripts/responsive-tables.js b/guides/assets/javascripts/responsive-tables.js new file mode 100755 index 0000000000..8554a1343b --- /dev/null +++ b/guides/assets/javascripts/responsive-tables.js @@ -0,0 +1,43 @@ +$(document).ready(function() { + var switched = false; + $("table").not(".syntaxhighlighter").addClass("responsive"); + var updateTables = function() { + if (($(window).width() < 767) && !switched ){ + switched = true; + $("table.responsive").each(function(i, element) { + splitTable($(element)); + }); + return true; + } + else if (switched && ($(window).width() > 767)) { + switched = false; + $("table.responsive").each(function(i, element) { + unsplitTable($(element)); + }); + } + }; + + $(window).load(updateTables); + $(window).bind("resize", updateTables); + + + function splitTable(original) + { + original.wrap("<div class='table-wrapper' />"); + + var copy = original.clone(); + copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none"); + copy.removeClass("responsive"); + + original.closest(".table-wrapper").append(copy); + copy.wrap("<div class='pinned' />"); + original.wrap("<div class='scrollable' />"); + } + + function unsplitTable(original) { + original.closest(".table-wrapper").find(".pinned").remove(); + original.unwrap(); + original.unwrap(); + } + +}); diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css index abce24dd00..9f5e101d1c 100644 --- a/guides/assets/stylesheets/main.css +++ b/guides/assets/stylesheets/main.css @@ -32,6 +32,13 @@ pre,code { font-family: "Anonymous Pro", "Inconsolata", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; line-height: 1.5; } +pre,tt,code,.note>p { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} abbr, acronym { border-bottom: 1px dotted #666; } address { margin: 0 0 1.5em; font-style: italic; } @@ -91,6 +98,7 @@ body { text-align: left; margin: 0 auto; max-width: 960px; + padding: 0 1em; } .red-button { @@ -238,7 +246,19 @@ body { width: 17em; font-size: 0.9285em; line-height: 1.3846em; + margin-right: 1em; + } + + +@media screen and (max-width: 800px) { + #subCol { + position: static; + width: inherit; + margin-left: -1em; + margin-right: 0; + padding-right: 1.25em; } +} #extraCol {display: none;} @@ -254,7 +274,7 @@ body { #header .wrapper, #topNav .wrapper, #feature .wrapper {padding-left: 1em; max-width: 960px;} #feature .wrapper {max-width: 640px; padding-right: 23em; position: relative; z-index: 0;} -@media screen and (max-width: 480px) { +@media screen and (max-width: 800px) { #feature .wrapper { padding-right: 0; } } @@ -360,6 +380,7 @@ a, a:link, a:visited { font-size: .95em; background-position: 96% -65px; -webkit-appearance: none; + } } #guides { @@ -415,6 +436,12 @@ h2 { font-weight: bold; } +@media screen and (max-width: 480px) { + h2 { + font-size: 1.45em; + } +} + h3 { font-size: 1.7142em; line-height: 1.286em; @@ -422,6 +449,12 @@ h3 { font-weight: bold; } +@media screen and (max-width: 480px) { + h3 { + font-size: 1.45em; + } +} + h4 { font-size: 1.2857em; line-height: 1.2em; @@ -484,6 +517,12 @@ h6 { margin-bottom: 0.75em; } +@media screen and (max-width: 480px) { + #feature p { + font-size: 1em; + } +} + #feature ul {margin-left: 0;} #feature ul li { list-style: none; @@ -503,7 +542,7 @@ h6 { } #mainCol dt, #subCol dt { - font-size: 1.2857em; + font-size: 1em; padding: 0.125em 0 0.25em 0; margin-bottom: 0; /*background: url(../images/book_icon.gif) no-repeat left top; @@ -635,3 +674,28 @@ div.important p, div.caution p, div.warning p, div.note p, div.info p { z-index: 100; border: none; } + +/* Foundation v2.1.4 http://foundation.zurb.com */ +/* Artfully masterminded by ZURB */ + +table th { font-weight: bold; } +table td, table th { padding: 9px 10px; text-align: left; } + +/* Mobile */ +@media only screen and (max-width: 767px) { + + table.responsive { margin-bottom: 0; } + + .pinned { position: absolute; left: 0; top: 0; background: #fff; width: 35%; overflow: hidden; overflow-x: scroll; border-right: 1px solid #ccc; border-left: 1px solid #ccc; } + .pinned table { border-right: none; border-left: none; width: 100%; } + .pinned table th, .pinned table td { white-space: nowrap; } + .pinned td:last-child { border-bottom: 0; } + + div.table-wrapper { position: relative; margin-bottom: 20px; overflow: hidden; border-right: 1px solid #ccc; } + div.table-wrapper div.scrollable table { margin-left: 35%; } + div.table-wrapper div.scrollable { overflow: scroll; overflow-y: hidden; } + + table.responsive td, table.responsive th { position: relative; white-space: nowrap; overflow: hidden; } + table.responsive th:first-child, table.responsive td:first-child, table.responsive td:first-child, table.responsive.pinned td { display: none; } + +} diff --git a/guides/assets/stylesheets/responsive-tables.css b/guides/assets/stylesheets/responsive-tables.css new file mode 100755 index 0000000000..f5fbcbf948 --- /dev/null +++ b/guides/assets/stylesheets/responsive-tables.css @@ -0,0 +1,50 @@ +/* Foundation v2.1.4 http://foundation.zurb.com */ +/* Artfully masterminded by ZURB */ + +/* -------------------------------------------------- + Table of Contents +----------------------------------------------------- +:: Shared Styles +:: Page Name 1 +:: Page Name 2 +*/ + + +/* ----------------------------------------- + Shared Styles +----------------------------------------- */ + +table th { font-weight: bold; } +table td, table th { padding: 9px 10px; text-align: left; } + +/* Mobile */ +@media only screen and (max-width: 767px) { + + table { margin-bottom: 0; } + + .pinned { position: absolute; left: 0; top: 0; background: #fff; width: 35%; overflow: hidden; overflow-x: scroll; border-right: 1px solid #ccc; border-left: 1px solid #ccc; } + .pinned table { border-right: none; border-left: none; width: 100%; } + .pinned table th, .pinned table td { white-space: nowrap; } + .pinned td:last-child { border-bottom: 0; } + + div.table-wrapper { position: relative; margin-bottom: 20px; overflow: hidden; border-right: 1px solid #ccc; } + div.table-wrapper div.scrollable table { margin-left: 35%; } + div.table-wrapper div.scrollable { overflow: scroll; overflow-y: hidden; } + + table td, table th { position: relative; white-space: nowrap; overflow: hidden; } + table th:first-child, table td:first-child, table td:first-child, table.pinned td { display: none; } + +} + +/* ----------------------------------------- + Page Name 1 +----------------------------------------- */ + + + + +/* ----------------------------------------- + Page Name 2 +----------------------------------------- */ + + diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index e6a6b05166..824ffb5d7a 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -174,8 +174,8 @@ Your application has a session for each user in which you can store small amount * ActionDispatch::Session::CookieStore - Stores everything on the client. * ActionDispatch::Session::CacheStore - Stores the data in the Rails cache. -* ActionDispatch::Session::ActiveRecordStore - Stores the data in a database using Active Record. (require `activerecord-session_store` gem). -* ActionDispatch::Session::MemCacheStore - Stores the data in a memcached cluster (this is a legacy implementation; consider using CacheStore instead). +* @ActionDispatch::Session::ActiveRecordStore@ - Stores the data in a database using Active Record. (require `activerecord-session_store` gem). +* @ActionDispatch::Session::MemCacheStore@ - Stores the data in a memcached cluster (this is a legacy implementation; consider using CacheStore instead). All session stores use a cookie to store a unique ID for each session (you must use a cookie, Rails will not allow you to pass the session ID in the URL as this is less secure). diff --git a/guides/source/layout.html.erb b/guides/source/layout.html.erb index 0c368c658d..397dd62638 100644 --- a/guides/source/layout.html.erb +++ b/guides/source/layout.html.erb @@ -133,6 +133,7 @@ </div> <script type="text/javascript" src="javascripts/jquery.min.js"></script> + <script type="text/javascript" src="javascripts/responsive-tables.js"></script> <script type="text/javascript" src="javascripts/guides.js"></script> <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script> <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script> diff --git a/guides/source/migrations.md b/guides/source/migrations.md index ccbdffc9c7..705b65ee8b 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -330,7 +330,7 @@ end As always, what has been generated for you is just a starting point. You can add or remove from it as you see fit by editing the -db/migrate/YYYYMMDDHHMMSS_add_details_to_products.rb file. +@db/migrate/YYYYMMDDHHMMSS_add_details_to_products.rb@ file. NOTE: The generated migration file for destructive migrations will still be old-style using the `up` and `down` methods. This is because Rails needs to know |