Skip to content

Commit 71bb964

Browse files
authored
Merge pull request #72 from sman591/fix-dist
Fix dist build
2 parents d0f295f + f845c42 commit 71bb964

8 files changed

+3550
-18728
lines changed

dist/bootstrap-dropdown.js

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

0 commit comments

Comments
 (0)