File indexing completed on 2024-12-22 05:33:16

0001 /* ============================================================
0002  * bootstrap-dropdown.js v2.0.4
0003  * http://twitter.github.com/bootstrap/javascript.html#dropdowns
0004  * ============================================================
0005  * Copyright 2012 Twitter, Inc.
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License");
0008  * you may not use this file except in compliance with the License.
0009  * You may obtain a copy of the License at
0010  *
0011  * http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software
0014  * distributed under the License is distributed on an "AS IS" BASIS,
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016  * See the License for the specific language governing permissions and
0017  * limitations under the License.
0018  * ============================================================ */
0019 
0020 
0021 !function ($) {
0022 
0023   "use strict"; // jshint ;_;
0024 
0025 
0026  /* DROPDOWN CLASS DEFINITION
0027   * ========================= */
0028 
0029   var toggle = '[data-toggle="dropdown"]'
0030     , Dropdown = function (element) {
0031         var $el = $(element).on('click.dropdown.data-api', this.toggle)
0032         $('html').on('click.dropdown.data-api', function () {
0033           $el.parent().removeClass('open')
0034         })
0035       }
0036 
0037   Dropdown.prototype = {
0038 
0039     constructor: Dropdown
0040 
0041   , toggle: function (e) {
0042       var $this = $(this)
0043         , $parent
0044         , selector
0045         , isActive
0046 
0047       if ($this.is('.disabled, :disabled')) return
0048 
0049       selector = $this.attr('data-target')
0050 
0051       if (!selector) {
0052         selector = $this.attr('href')
0053         selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
0054       }
0055 
0056       $parent = $(selector)
0057       $parent.length || ($parent = $this.parent())
0058 
0059       isActive = $parent.hasClass('open')
0060 
0061       clearMenus()
0062 
0063       if (!isActive) $parent.toggleClass('open')
0064 
0065       return false
0066     }
0067 
0068   }
0069 
0070   function clearMenus() {
0071     $(toggle).parent().removeClass('open')
0072   }
0073 
0074 
0075   /* DROPDOWN PLUGIN DEFINITION
0076    * ========================== */
0077 
0078   $.fn.dropdown = function (option) {
0079     return this.each(function () {
0080       var $this = $(this)
0081         , data = $this.data('dropdown')
0082       if (!data) $this.data('dropdown', (data = new Dropdown(this)))
0083       if (typeof option == 'string') data[option].call($this)
0084     })
0085   }
0086 
0087   $.fn.dropdown.Constructor = Dropdown
0088 
0089 
0090   /* APPLY TO STANDARD DROPDOWN ELEMENTS
0091    * =================================== */
0092 
0093   $(function () {
0094     $('html').on('click.dropdown.data-api', clearMenus)
0095     $('body')
0096       .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
0097       .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
0098   })
0099 
0100 }(window.jQuery);