Skip to content
Browse files

close nav_bar_dropdown when clicking anywhere else on page

  • Loading branch information...
1 parent e04dfae commit 025710441a467a2a6c3e5c4bd1e5165ddf2967bc Adeel Ahmad Khan committed Feb 15, 2012
Showing with 290 additions and 257 deletions.
  1. +23 −8 site/javascripts/nav_bar.js
  2. +258 −248 site/stylesheets/screen.css
  3. +9 −1 src/stylesheets/screen.sass
View
31 site/javascripts/nav_bar.js
@@ -8,21 +8,36 @@ var nav_bar = (function() {
}, 300);
}
+ function collapse(dropdown, bar) {
+ dropdown.setStyle("display", "none");
+ bar.setStyle("margin-bottom",
+ getComputedStyle(dropdown.getParent()).getPropertyValue("margin-bottom"));
+ dropdown.getParent().setStyle("margin-bottom", "0px");
+ }
+
+ function expand(dropdown, bar) {
+ dropdown.setStyle("display", "block");
+ dropdown.getParent().setStyle("margin-bottom",
+ getComputedStyle(bar).getPropertyValue("margin-bottom"));
+ bar.setStyle("margin-bottom", "0px");
+
+ var overlay = new Element(".nav_bar_overlay");
+ overlay.inject(bar, "after");
+ overlay.addEvent("click", function() {
+ overlay.dispose();
+ collapse(dropdown, bar);
+ });
+ }
+
self.observe = function(dropdown, bar) {
var item = bar.getElement(".user_container").getParent().getParent();
item.addEvent("click", function(e) {
e.stop();
if (dropdown.getStyle("display") == "none") {
- dropdown.setStyle("display", "block");
- dropdown.getParent().setStyle("margin-bottom",
- getComputedStyle(bar).getPropertyValue("margin-bottom"));
- bar.setStyle("margin-bottom", "0px");
+ expand(dropdown, bar);
} else {
- dropdown.setStyle("display", "none");
- bar.setStyle("margin-bottom",
- getComputedStyle(dropdown.getParent()).getPropertyValue("margin-bottom"));
- dropdown.getParent().setStyle("margin-bottom", "0px");
+ collapse(dropdown, bar);
}
return false;
View
506 site/stylesheets/screen.css
258 additions, 248 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
10 src/stylesheets/screen.sass
@@ -130,7 +130,7 @@ body
.nav_bar_dropdown
position: absolute
display: none
- z-index: 999
+ z-index: 1000
top: 0
right: 0
background-color: #090d1c
@@ -147,6 +147,14 @@ body
&:hover
color: #f7ad00
+.nav_bar_overlay
+ position: fixed
+ top: 0
+ left: 0
+ width: 100%
+ height: 100%
+ z-index: 999
+
/**/
.notification_bar

0 comments on commit 0257104

Please sign in to comment.
Something went wrong with that request. Please try again.