vendor/assets/javascripts/twitter/bootstrap/dropdown.js in less-rails-bootstrap-2.0.10 vs vendor/assets/javascripts/twitter/bootstrap/dropdown.js in less-rails-bootstrap-2.0.11

- old
+ new

@@ -1,7 +1,7 @@ /* ============================================================ - * bootstrap-dropdown.js v2.0.2 + * bootstrap-dropdown.js v2.0.3 * http://twitter.github.com/bootstrap/javascript.html#dropdowns * ============================================================ * Copyright 2012 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,35 +16,40 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============================================================ */ -!function( $ ){ +!function ($) { - "use strict" + "use strict"; // jshint ;_; + /* DROPDOWN CLASS DEFINITION * ========================= */ var toggle = '[data-toggle="dropdown"]' - , Dropdown = function ( element ) { + , Dropdown = function (element) { var $el = $(element).on('click.dropdown.data-api', this.toggle) $('html').on('click.dropdown.data-api', function () { $el.parent().removeClass('open') }) } Dropdown.prototype = { constructor: Dropdown - , toggle: function ( e ) { + , toggle: function (e) { var $this = $(this) - , selector = $this.attr('data-target') , $parent + , selector , isActive + if ($this.is('.disabled, :disabled')) return + + selector = $this.attr('data-target') + if (!selector) { selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } @@ -52,12 +57,13 @@ $parent.length || ($parent = $this.parent()) isActive = $parent.hasClass('open') clearMenus() - !isActive && $parent.toggleClass('open') + if (!isActive) $parent.toggleClass('open') + return false } } @@ -67,11 +73,11 @@ /* DROPDOWN PLUGIN DEFINITION * ========================== */ - $.fn.dropdown = function ( option ) { + $.fn.dropdown = function (option) { return this.each(function () { var $this = $(this) , data = $this.data('dropdown') if (!data) $this.data('dropdown', (data = new Dropdown(this))) if (typeof option == 'string') data[option].call($this) @@ -84,9 +90,11 @@ /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ $(function () { $('html').on('click.dropdown.data-api', clearMenus) - $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) + $('body') + .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) }) -}( window.jQuery ); +}(window.jQuery); \ No newline at end of file