vendor: 4,385 bytes, lines 1-151
1/* ======================================================================== 2 * Bootstrap: dropdown.js v3.2.0 3 * http://getbootstrap.com/javascript/#dropdowns 4 * ======================================================================== 5 * Copyright 2011-2014 Twitter, Inc. 6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 7 * ======================================================================== */ 8 9 10+function ($) { 11 'use strict'; 12 13 // DROPDOWN CLASS DEFINITION 14 // ========================= 15 16 var backdrop = '.dropdown-backdrop' 17 var toggle = '[data-toggle="dropdown"]' 18 var Dropdown = function (element) { 19 $(element).on('click.bs.dropdown', this.toggle) 20 } 21 22 Dropdown.VERSION = '3.2.0' 23 24 Dropdown.prototype.toggle = function (e) { 25 var $this = $(this) 26 27 if ($this.is('.disabled, :disabled')) return 28 29 var $parent = getParent($this) 30 var isActive = $parent.hasClass('open') 31 32 clearMenus() 33 34 if (!isActive) { 35 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 36 // if mobile we use a backdrop because click events don't delegate 37 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) 38 } 39 40 var relatedTarget = { relatedTarget: this } 41 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) 42 43 if (e.isDefaultPrevented()) return 44 45 $this.trigger('focus') 46 47 $parent 48 .toggleClass('open') 49 .trigger('shown.bs.dropdown', relatedTarget) 50 } 51 52 return false 53 } 54 55 Dropdown.prototype.keydown = function (e) { 56 if (!/(38|40|27)/.test(e.keyCode)) return 57 58 var $this = $(this) 59 60 e.preventDefault() 61 e.stopPropagation() 62 63 if ($this.is('.disabled, :disabled')) return 64 65 var $parent = getParent($this) 66 var isActive = $parent.hasClass('open') 67 68 if (!isActive || (isActive && e.keyCode == 27)) { 69 if (e.which == 27) $parent.find(toggle).trigger('focus') 70 return $this.trigger('click') 71 } 72 73 var desc = ' li:not(.divider):visible a' 74 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc) 75 76 if (!$items.length) return 77 78 var index = $items.index($items.filter(':focus')) 79 80 if (e.keyCode == 38 && index > 0) index-- // up 81 if (e.keyCode == 40 && index < $items.length - 1) index++ // down 82 if (!~index) index = 0 83 84 $items.eq(index).trigger('focus') 85 } 86 87 function clearMenus(e) { 88 if (e && e.which === 3) return 89 $(backdrop).remove() 90 $(toggle).each(function () { 91 var $parent = getParent($(this)) 92 var relatedTarget = { relatedTarget: this } 93 if (!$parent.hasClass('open')) return 94 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) 95 if (e.isDefaultPrevented()) return 96 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) 97 }) 98 } 99 100 function getParent($this) { 101 var selector = $this.attr('data-target') 102 103 if (!selector) { 104 selector = $this.attr('href') 105 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 106 } 107 108 var $parent = selector && $(selector) 109 110 return $parent && $parent.length ? $parent : $this.parent() 111 } 112 113 114 // DROPDOWN PLUGIN DEFINITION 115 // ========================== 116 117 function Plugin(option) { 118 return this.each(function () { 119 var $this = $(this) 120 var data = $this.data('bs.dropdown') 121 122 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) 123 if (typeof option == 'string') data[option].call($this) 124 }) 125 } 126 127 var old = $.fn.dropdown 128 129 $.fn.dropdown = Plugin 130 $.fn.dropdown.Constructor = Dropdown 131 132 133 // DROPDOWN NO CONFLICT 134 // ==================== 135 136 $.fn.dropdown.noConflict = function () { 137 $.fn.dropdown = old 138 return this 139 } 140 141 142 // APPLY TO STANDARD DROPDOWN ELEMENTS 143 // =================================== 144 145 $(document) 146 .on('click.bs.dropdown.data-api', clearMenus) 147 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 148 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) 149 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown) 150 151}(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.