mrkrand
4/5/2016 - 1:37 PM

jQuery-dropdown.js

/* 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();