1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-25 21:09:06 +02:00

greatly simply js plugins - remove js api where reasonable

This commit is contained in:
Jacob Thornton
2011-10-19 21:56:06 -07:00
parent c9669be1ec
commit 8545fe9787
10 changed files with 138 additions and 206 deletions

View File

@@ -20,34 +20,22 @@
(function( $ ){
var d = '[data-dropdown]'
/* DROPDOWN PLUGIN DEFINITION
* ========================== */
$.fn.dropdown = function () {
return this.each(function () {
$(this).delegate(d, 'click', function (e) {
var li = $(this).parent('li')
, isActive = li.hasClass('open')
clearMenus()
!isActive && li.toggleClass('open')
return false
})
})
}
/* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */
function clearMenus() {
$(d).parent('li').removeClass('open')
$(selector).parent('li').removeClass('open')
}
$(function () {
$('html').bind("click", clearMenus)
$('body').dropdown()
$('body').delegate('[data-dropdown]', 'click', function (e) {
var li = $(this).parent('li')
, isActive = li.hasClass('open')
clearMenus()
!isActive && li.toggleClass('open')
return false
})
})
})( window.jQuery || window.ender )