/* ============================================================ * bootstrap-dropdown.js v2.0.1 * http://twitter.github.com/bootstrap/javascript.html#dropdowns * ============================================================ * copyright 2012 twitter, inc. * * licensed under the apache license, version 2.0 (the "license"); * you may not use this file except in compliance with the license. * you may obtain a copy of the license at * * http://www.apache.org/licenses/license-2.0 * * unless required by applicable law or agreed to in writing, software * distributed under the license is distributed on an "as is" basis, * without warranties or conditions of any kind, either express or implied. * see the license for the specific language governing permissions and * limitations under the license. * ============================================================ */ !function( $ ){ "use strict" /* dropdown class definition * ========================= */ var toggle = '[data-toggle="dropdown"]' , 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 ) { var $this = $(this) , selector = $this.attr('data-target') , $parent , isactive if (!selector) { selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } $parent = $(selector) $parent.length || ($parent = $this.parent()) isactive = $parent.hasclass('open') clearmenus() !isactive && $parent.toggleclass('open') return false } } function clearmenus() { $(toggle).parent().removeclass('open') } /* dropdown plugin definition * ========================== */ $.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) }) } $.fn.dropdown.constructor = dropdown /* apply to standard dropdown elements * =================================== */ $(function () { $('html').on('click.dropdown.data-api', clearmenus) $('body').on('click.dropdown.data-api', toggle, dropdown.prototype.toggle) }) }( window.jquery );