Mercurial > wikked
annotate static/bootstrap/js/dropdown.js @ 149:d29e2f337b00
Updated to Bootstrap 3.0.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 12 Dec 2013 21:54:04 -0800 |
parents | |
children |
rev | line source |
---|---|
149
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 /* ======================================================================== |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 * Bootstrap: dropdown.js v3.0.3 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 * http://getbootstrap.com/javascript/#dropdowns |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 * ======================================================================== |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 * Copyright 2013 Twitter, Inc. |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 * |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 * Licensed under the Apache License, Version 2.0 (the "License"); |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 * you may not use this file except in compliance with the License. |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 * You may obtain a copy of the License at |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 * |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 * http://www.apache.org/licenses/LICENSE-2.0 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 * |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 * Unless required by applicable law or agreed to in writing, software |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 * distributed under the License is distributed on an "AS IS" BASIS, |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 * See the License for the specific language governing permissions and |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 * limitations under the License. |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 * ======================================================================== */ |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 +function ($) { "use strict"; |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 // DROPDOWN CLASS DEFINITION |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 // ========================= |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 var backdrop = '.dropdown-backdrop' |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 var toggle = '[data-toggle=dropdown]' |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 var Dropdown = function (element) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 $(element).on('click.bs.dropdown', this.toggle) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 Dropdown.prototype.toggle = function (e) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 var $this = $(this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 if ($this.is('.disabled, :disabled')) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 var $parent = getParent($this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 var isActive = $parent.hasClass('open') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 clearMenus() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 if (!isActive) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 // if mobile we use a backdrop because click events don't delegate |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
47 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 $parent.trigger(e = $.Event('show.bs.dropdown')) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
49 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
50 if (e.isDefaultPrevented()) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
51 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
52 $parent |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
53 .toggleClass('open') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
54 .trigger('shown.bs.dropdown') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
55 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
56 $this.focus() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
57 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
58 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
59 return false |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
60 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
61 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
62 Dropdown.prototype.keydown = function (e) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
63 if (!/(38|40|27)/.test(e.keyCode)) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
64 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
65 var $this = $(this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
66 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
67 e.preventDefault() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
68 e.stopPropagation() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
69 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
70 if ($this.is('.disabled, :disabled')) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
71 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
72 var $parent = getParent($this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
73 var isActive = $parent.hasClass('open') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
74 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
75 if (!isActive || (isActive && e.keyCode == 27)) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
76 if (e.which == 27) $parent.find(toggle).focus() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
77 return $this.click() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
78 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
79 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
80 var $items = $('[role=menu] li:not(.divider):visible a', $parent) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
81 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
82 if (!$items.length) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
83 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
84 var index = $items.index($items.filter(':focus')) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
85 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
86 if (e.keyCode == 38 && index > 0) index-- // up |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
87 if (e.keyCode == 40 && index < $items.length - 1) index++ // down |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
88 if (!~index) index=0 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 $items.eq(index).focus() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
92 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
93 function clearMenus() { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
94 $(backdrop).remove() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
95 $(toggle).each(function (e) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
96 var $parent = getParent($(this)) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
97 if (!$parent.hasClass('open')) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
98 $parent.trigger(e = $.Event('hide.bs.dropdown')) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
99 if (e.isDefaultPrevented()) return |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
100 $parent.removeClass('open').trigger('hidden.bs.dropdown') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
101 }) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
102 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
103 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
104 function getParent($this) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
105 var selector = $this.attr('data-target') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
106 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
107 if (!selector) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
108 selector = $this.attr('href') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
109 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
110 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
111 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
112 var $parent = selector && $(selector) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
113 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
114 return $parent && $parent.length ? $parent : $this.parent() |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
115 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
116 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
117 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
118 // DROPDOWN PLUGIN DEFINITION |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
119 // ========================== |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
120 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
121 var old = $.fn.dropdown |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
122 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
123 $.fn.dropdown = function (option) { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
124 return this.each(function () { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
125 var $this = $(this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
126 var data = $this.data('bs.dropdown') |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
127 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
128 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
129 if (typeof option == 'string') data[option].call($this) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
130 }) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
131 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
132 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
133 $.fn.dropdown.Constructor = Dropdown |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
134 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
135 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
136 // DROPDOWN NO CONFLICT |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
137 // ==================== |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
138 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
139 $.fn.dropdown.noConflict = function () { |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
140 $.fn.dropdown = old |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
141 return this |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
142 } |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
143 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
144 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
145 // APPLY TO STANDARD DROPDOWN ELEMENTS |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
146 // =================================== |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
147 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
148 $(document) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
149 .on('click.bs.dropdown.data-api', clearMenus) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
150 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
151 .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
152 .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
153 |
d29e2f337b00
Updated to Bootstrap 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
154 }(jQuery); |