From 1727cd7c2b066a4442f6714be7aa170f4d8c1eef Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 16 Jul 2013 16:37:58 -0700 Subject: [PATCH] Compact user menu --- Vendorfile | 1 + app/assets/javascripts/application.js | 1 + app/assets/stylesheets/common.css.scss | 185 +++++++++++++++++- app/assets/stylesheets/small.css.scss | 9 +- app/views/layouts/_inbox.html.erb | 16 +- app/views/layouts/_user_menu.html.erb | 55 ++++++ app/views/layouts/site.html.erb | 19 +- app/views/site/_home_link.html.erb | 3 +- config/locales/en.yml | 27 +-- vendor/assets/bootstrap/bootstrap.dropdown.js | 169 ++++++++++++++++ 10 files changed, 428 insertions(+), 57 deletions(-) create mode 100644 app/views/layouts/_user_menu.html.erb create mode 100644 vendor/assets/bootstrap/bootstrap.dropdown.js diff --git a/Vendorfile b/Vendorfile index 88f999a40..c1242beb7 100644 --- a/Vendorfile +++ b/Vendorfile @@ -5,6 +5,7 @@ folder 'vendor/assets' do folder 'bootstrap' do file 'bootstrap.tooltip.js', 'https://raw.github.com/twbs/bootstrap/v2.3.2/js/bootstrap-tooltip.js' + file 'bootstrap.dropdown.js', 'https://raw.github.com/twbs/bootstrap/v2.3.2/js/bootstrap-dropdown.js' end folder 'leaflet' do diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index a33e281ce..564089f3a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -4,6 +4,7 @@ //= require jquery.cookie //= require jquery.throttle-debounce //= require bootstrap.tooltip +//= require bootstrap.dropdown //= require augment //= require osm //= require leaflet diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index 0e03da6de..0c2d8ed01 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -202,6 +202,7 @@ h6:first-child { .icon.close { background-position: -200px 0; } .icon.check { background-position: -220px 0; } .icon.note { background-position: -240px 0; } +.icon.gear { background-position: -260px 0; } /* Rules for links */ @@ -472,7 +473,11 @@ a.donate { height: 30px; border-bottom: 1px solid #ccc; background: white; - z-index: 100; + z-index: 1001; + + .caret { + margin-top: 10px; + } } .site-edit #top-bar, @@ -544,12 +549,52 @@ a.donate { #greeting { float: right; - padding-top: 3px; - margin-right: $lineheight/4; -} + height: 100%; -.greeting-bar-unread { - font-weight: bold; + &.secondary-actions { + padding: 3px $lineheight/2; + } + + &.dropdown { + background-color: #EEE; + &:hover { + background-color: #CCC; + } + } + + img { + vertical-align: top; + border-radius: 2px 0 0 2px; + padding-right: 5px; + } + + #inboxanchor { + display: inline-block; + position: relative; + height: 20px; + top: -2px; + margin: 0 2px 0 0; + padding: 0 5px 0 0; + border-radius: 2px; + } + + .dropdown-toggle { + display: block; + padding: 3px 7px; + color: #000; + text-decoration: none; + } + + .dropdown-menu { + left: auto; + right: 0; + + .count-number { + float: right; + padding: 0 5px; + margin: 0; + } + } } /* Rules for the message shown in place of the map when javascript is disabled */ @@ -2292,6 +2337,134 @@ a.button { background: #fff; } +/* Rules for dropdown menus */ + +.dropdown { + position: relative; +} + +.dropdown-toggle { + *margin-bottom: -3px; +} + +.dropdown-toggle:active, +.open .dropdown-toggle { + outline: 0; +} + +.caret { + display: inline-block; + width: 0; + height: 0; + vertical-align: top; + border-top: 4px solid #000000; + border-right: 4px solid transparent; + border-left: 4px solid transparent; + content: ""; +} + +.dropdown .caret { + margin-top: 8px; + margin-left: 2px; +} + +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 0; + list-style: none; + background-color: #ffffff; + border: 1px solid #ccc; + *border-right-width: 2px; + *border-bottom-width: 2px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.dropdown-menu .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.dropdown-menu > li > a { + display: block; + padding: 3px 10px; + clear: both; + font-weight: normal; + line-height: 20px; + color: #333333; + white-space: nowrap; +} + +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus, +.dropdown-submenu:hover > a, +.dropdown-submenu:focus > a { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; +} + +.dropdown-menu > .active > a, +.dropdown-menu > .active > a:hover, +.dropdown-menu > .active > a:focus { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + outline: 0; +} + +.dropdown-menu > .disabled > a, +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + color: #999999; +} + +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; + background-image: none; +} + +.open { + *z-index: 1000; +} + +.open > .dropdown-menu { + display: block; +} + +.dropdown-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 990; +} + /* Rules for the "Welcome" page */ .site-welcome { .center { diff --git a/app/assets/stylesheets/small.css.scss b/app/assets/stylesheets/small.css.scss index 3f9088311..419abeac4 100644 --- a/app/assets/stylesheets/small.css.scss +++ b/app/assets/stylesheets/small.css.scss @@ -84,13 +84,6 @@ h2, h3, h4 { /* Rules for greeting bar in the top right corner */ -#greeting { - position: absolute; - right: 0; - top: 0; - background: none; -} - #browse_map ul.secondary-actions { float: right; font-size: 10px; @@ -267,4 +260,4 @@ p.search_results_entry { .aside { display: none; } -} \ No newline at end of file +} diff --git a/app/views/layouts/_inbox.html.erb b/app/views/layouts/_inbox.html.erb index fcaa5ae64..6dd6218ee 100644 --- a/app/views/layouts/_inbox.html.erb +++ b/app/views/layouts/_inbox.html.erb @@ -1,13 +1,3 @@ -<%= - link_to( - t("layouts.inbox_html", - :count => @user.new_messages.size > 0 ? - content_tag( - :span, @user.new_messages.size, :class => "count-number" - ) : - "" - ), - inbox_path(:display_name => @user.display_name), - :id => "inboxanchor" - ) -%> + + <%= @user.new_messages.size %> + \ No newline at end of file diff --git a/app/views/layouts/_user_menu.html.erb b/app/views/layouts/_user_menu.html.erb new file mode 100644 index 000000000..19ac93dc0 --- /dev/null +++ b/app/views/layouts/_user_menu.html.erb @@ -0,0 +1,55 @@ + diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index a0e894e46..512b95905 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -99,17 +99,14 @@
- + <% if @user and @user.id %> + <%= render :partial => "layouts/user_menu" %> + <% else %> + + <% end %>