From a91a407bd60a266f928b5fea70d3c4332394b3c8 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 4 Oct 2011 21:48:53 -0700 Subject: start updating to data- driven js --- js/bootstrap-dropdown.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'js/bootstrap-dropdown.js') diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index 75320c0f8..6379653c5 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -20,23 +20,14 @@ (function( $ ){ - var d = '.dropdown-toggle' - - function clearMenus() { - $(d).parent('li').removeClass('open') - } - - $(function () { - $('html').bind("click", clearMenus) - $('body').dropdown( '[data-dropdown] .dropdown-toggle' ) - }) + var d = '[data-dropdown]' /* DROPDOWN PLUGIN DEFINITION * ========================== */ - $.fn.dropdown = function ( selector ) { + $.fn.dropdown = function () { return this.each(function () { - $(this).delegate(selector || d, 'click', function (e) { + $(this).delegate(d, 'click', function (e) { var li = $(this).parent('li') , isActive = li.hasClass('open') @@ -47,4 +38,16 @@ }) } + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + function clearMenus() { + $(d).parent('li').removeClass('open') + } + + $(function () { + $('html').bind("click", clearMenus) + $('body').dropdown() + }) + })( window.jQuery || window.ender ) \ No newline at end of file -- cgit v1.2.3