-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleDropDowns.js
18 lines (18 loc) · 1.03 KB
/
simpleDropDowns.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Simple Dropdowns
// Called via onClick="simpleDropDown(this);return false;
function simpleDropDown(clickedObj, parentName) {
// "cache" this from onClick call
var o_clicked = $(clickedObj);
// Capture parent of clicked object dropdowns, if there was a parentName parameter given, use that
var o_dropDownParent = parentName ? o_clicked.closest(parentName) : o_clicked.closest(".dropdown-parent");
// Capture all dropdowns, if there was a parentName parameter given, use that
var o_allDropDownParents = parentName ? $(parentName) : $(".dropdown-parent");
// If you click on another dropdown, hide the open one
if ( !o_dropDownParent.hasClass("active") && o_allDropDownParents.hasClass("active") ) { o_allDropDownParents.removeClass("active"); }
// Big Money Toggling
o_dropDownParent.toggleClass("active");
// Add click listener to everything to hide the dropdown
$('html').click(function() { o_dropDownParent.removeClass("active"); });
// Overrides the dropdown hide set above
o_dropDownParent.click(function(e) { e.stopPropagation(); });
}