Skip to content

Commit 7df4423

Browse files
committed
Merge pull request jquery#34 from eddiemonge/patch-1
Fix the all projects dropdown
2 parents ea62968 + 3178d54 commit 7df4423

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

content/assets/js/scripts.js

+17-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*******************************************************************************/
32
/* Subscriptions */
43
/*******************************************************************************/
@@ -41,30 +40,26 @@ App.subscribe("init", function(){
4140
//
4241
// Project Select Show/Hide
4342
//
44-
$(".toggle-projects").bind("click", function(e){
43+
$(".toggle-projects").bind( "click", function( e ) {
4544
e.preventDefault();
46-
var el = $(this);
47-
if(el.hasClass('active')){
48-
el.removeClass('active');
49-
$("body").css({"marginTop":"0"});
50-
el.removeClass('down');
51-
} else {
52-
el.addClass('active');
53-
$("body").css({"marginTop":"150px"});
54-
el.addClass('down');
55-
}
45+
46+
var el = $( this ).toggleClass("active");
47+
48+
$("body").animate({ "marginTop": ( el.hasClass("active") ? "150px" : "0" ) }, 300, function() {
49+
el.toggleClass("down");
50+
});
5651
});
57-
58-
//
52+
5953
// Project Select Clickoutside
60-
//
61-
$(".project-select").bind("clickoutside", function(e, el){
62-
var target = $(".toggle-projects");
63-
if($(el).parent(".toggle-projects").length != 1){
64-
if(target.hasClass('down')){
65-
target.removeClass("active down");
66-
$("body").css({"marginTop":"0"}, 300);
67-
}
54+
$(".project-select").bind( "clickoutside", function( e ) {
55+
var el = $(".toggle-projects");
56+
57+
if ( e.target.parentNode === el[0] || e.target === el[0] ) {
58+
return;
59+
}
60+
61+
if ( el.hasClass("down") ) {
62+
el.click();
6863
}
6964
});
7065

0 commit comments

Comments
 (0)