Last active
April 5, 2016 14:44
-
-
Save mrkrand/91fcf32088d81a00a4864606c1ac3797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generic dropdown script */ | |
$.fn.edaDropdown = function() { | |
var dropDowns = this; | |
dropDowns.each(function( index, element ) { | |
jQuery(this).find('> span').click(function(e){ | |
e.stopPropagation(); | |
var currentOpen = false; | |
var a = jQuery(this); | |
if (a.parent().hasClass('open')) { | |
currentOpen = true; | |
} | |
dropDowns.removeClass('open'); | |
if(!currentOpen) { | |
a.parent().addClass('open'); | |
} | |
}); | |
}); | |
jQuery("body").click(function(){ | |
dropDowns.removeClass('open'); | |
}); | |
}; | |
/* Dropdown init */ | |
jQuery('.dropdown').edaDropdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment