bootstrap 4.1.3 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bootstrap might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/assets/javascripts/bootstrap-sprockets.js +6 -5
- data/assets/javascripts/bootstrap.js +3290 -2985
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/javascripts/bootstrap/alert.js +127 -132
- data/assets/javascripts/bootstrap/button.js +119 -124
- data/assets/javascripts/bootstrap/carousel.js +492 -393
- data/assets/javascripts/bootstrap/collapse.js +276 -279
- data/assets/javascripts/bootstrap/dropdown.js +413 -374
- data/assets/javascripts/bootstrap/modal.js +455 -445
- data/assets/javascripts/bootstrap/popover.js +155 -160
- data/assets/javascripts/bootstrap/scrollspy.js +246 -250
- data/assets/javascripts/bootstrap/tab.js +180 -192
- data/assets/javascripts/bootstrap/toast.js +277 -0
- data/assets/javascripts/bootstrap/tooltip.js +533 -522
- data/assets/javascripts/bootstrap/util.js +140 -116
- data/assets/stylesheets/_bootstrap-grid.scss +2 -5
- data/assets/stylesheets/_bootstrap-reboot.scss +1 -1
- data/assets/stylesheets/_bootstrap.scss +3 -1
- data/assets/stylesheets/bootstrap/_alert.scss +1 -1
- data/assets/stylesheets/bootstrap/_badge.scss +6 -0
- data/assets/stylesheets/bootstrap/_button-group.scss +9 -18
- data/assets/stylesheets/bootstrap/_buttons.scss +7 -10
- data/assets/stylesheets/bootstrap/_card.scss +30 -21
- data/assets/stylesheets/bootstrap/_carousel.scss +36 -74
- data/assets/stylesheets/bootstrap/_close.scss +15 -6
- data/assets/stylesheets/bootstrap/_custom-forms.scss +103 -29
- data/assets/stylesheets/bootstrap/_dropdown.scss +30 -5
- data/assets/stylesheets/bootstrap/_forms.scss +12 -11
- data/assets/stylesheets/bootstrap/_functions.scss +4 -4
- data/assets/stylesheets/bootstrap/_images.scss +1 -1
- data/assets/stylesheets/bootstrap/_input-group.scss +24 -4
- data/assets/stylesheets/bootstrap/_list-group.scss +6 -0
- data/assets/stylesheets/bootstrap/_modal.scss +16 -10
- data/assets/stylesheets/bootstrap/_nav.scss +2 -0
- data/assets/stylesheets/bootstrap/_navbar.scss +4 -4
- data/assets/stylesheets/bootstrap/_popover.scss +1 -1
- data/assets/stylesheets/bootstrap/_reboot.scss +14 -35
- data/assets/stylesheets/bootstrap/_spinners.scss +53 -0
- data/assets/stylesheets/bootstrap/_tables.scss +2 -2
- data/assets/stylesheets/bootstrap/_toasts.scss +43 -0
- data/assets/stylesheets/bootstrap/_type.scss +2 -2
- data/assets/stylesheets/bootstrap/_utilities.scss +1 -0
- data/assets/stylesheets/bootstrap/_variables.scss +220 -81
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +1 -2
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +9 -7
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +0 -4
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +61 -10
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +3 -4
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +9 -10
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +10 -1
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +5 -2
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +4 -0
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +7 -20
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +5 -0
- data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +8 -0
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +23 -1
- data/assets/stylesheets/bootstrap/utilities/_text.scss +13 -4
- data/bootstrap.gemspec +6 -3
- data/lib/bootstrap.rb +10 -7
- data/lib/bootstrap/engine.rb +3 -0
- data/lib/bootstrap/version.rb +4 -2
- metadata +15 -11
@@ -1,3 +1,8 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap dropdown.js v4.2.1 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
5
|
+
*/
|
1
6
|
(function (global, factory) {
|
2
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) :
|
3
8
|
typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) :
|
@@ -59,492 +64,526 @@
|
|
59
64
|
}
|
60
65
|
|
61
66
|
/**
|
62
|
-
*
|
63
|
-
*
|
64
|
-
*
|
65
|
-
* --------------------------------------------------------------------------
|
67
|
+
* ------------------------------------------------------------------------
|
68
|
+
* Constants
|
69
|
+
* ------------------------------------------------------------------------
|
66
70
|
*/
|
67
71
|
|
68
|
-
var
|
72
|
+
var NAME = 'dropdown';
|
73
|
+
var VERSION = '4.2.1';
|
74
|
+
var DATA_KEY = 'bs.dropdown';
|
75
|
+
var EVENT_KEY = "." + DATA_KEY;
|
76
|
+
var DATA_API_KEY = '.data-api';
|
77
|
+
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
78
|
+
var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
|
79
|
+
|
80
|
+
var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
|
81
|
+
|
82
|
+
var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
|
83
|
+
|
84
|
+
var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
|
85
|
+
|
86
|
+
var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
|
87
|
+
|
88
|
+
var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
|
89
|
+
|
90
|
+
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
|
91
|
+
var Event = {
|
92
|
+
HIDE: "hide" + EVENT_KEY,
|
93
|
+
HIDDEN: "hidden" + EVENT_KEY,
|
94
|
+
SHOW: "show" + EVENT_KEY,
|
95
|
+
SHOWN: "shown" + EVENT_KEY,
|
96
|
+
CLICK: "click" + EVENT_KEY,
|
97
|
+
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
|
98
|
+
KEYDOWN_DATA_API: "keydown" + EVENT_KEY + DATA_API_KEY,
|
99
|
+
KEYUP_DATA_API: "keyup" + EVENT_KEY + DATA_API_KEY
|
100
|
+
};
|
101
|
+
var ClassName = {
|
102
|
+
DISABLED: 'disabled',
|
103
|
+
SHOW: 'show',
|
104
|
+
DROPUP: 'dropup',
|
105
|
+
DROPRIGHT: 'dropright',
|
106
|
+
DROPLEFT: 'dropleft',
|
107
|
+
MENURIGHT: 'dropdown-menu-right',
|
108
|
+
MENULEFT: 'dropdown-menu-left',
|
109
|
+
POSITION_STATIC: 'position-static'
|
110
|
+
};
|
111
|
+
var Selector = {
|
112
|
+
DATA_TOGGLE: '[data-toggle="dropdown"]',
|
113
|
+
FORM_CHILD: '.dropdown form',
|
114
|
+
MENU: '.dropdown-menu',
|
115
|
+
NAVBAR_NAV: '.navbar-nav',
|
116
|
+
VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
|
117
|
+
};
|
118
|
+
var AttachmentMap = {
|
119
|
+
TOP: 'top-start',
|
120
|
+
TOPEND: 'top-end',
|
121
|
+
BOTTOM: 'bottom-start',
|
122
|
+
BOTTOMEND: 'bottom-end',
|
123
|
+
RIGHT: 'right-start',
|
124
|
+
RIGHTEND: 'right-end',
|
125
|
+
LEFT: 'left-start',
|
126
|
+
LEFTEND: 'left-end'
|
127
|
+
};
|
128
|
+
var Default = {
|
129
|
+
offset: 0,
|
130
|
+
flip: true,
|
131
|
+
boundary: 'scrollParent',
|
132
|
+
reference: 'toggle',
|
133
|
+
display: 'dynamic'
|
134
|
+
};
|
135
|
+
var DefaultType = {
|
136
|
+
offset: '(number|string|function)',
|
137
|
+
flip: 'boolean',
|
138
|
+
boundary: '(string|element)',
|
139
|
+
reference: '(string|element)',
|
140
|
+
display: 'string'
|
69
141
|
/**
|
70
142
|
* ------------------------------------------------------------------------
|
71
|
-
*
|
143
|
+
* Class Definition
|
72
144
|
* ------------------------------------------------------------------------
|
73
145
|
*/
|
74
|
-
var NAME = 'dropdown';
|
75
|
-
var VERSION = '4.1.3';
|
76
|
-
var DATA_KEY = 'bs.dropdown';
|
77
|
-
var EVENT_KEY = "." + DATA_KEY;
|
78
|
-
var DATA_API_KEY = '.data-api';
|
79
|
-
var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
|
80
|
-
var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
|
81
|
-
|
82
|
-
var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
|
83
|
-
|
84
|
-
var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
|
85
|
-
|
86
|
-
var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
|
87
|
-
|
88
|
-
var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
|
89
|
-
|
90
|
-
var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
|
91
|
-
|
92
|
-
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
|
93
|
-
var Event = {
|
94
|
-
HIDE: "hide" + EVENT_KEY,
|
95
|
-
HIDDEN: "hidden" + EVENT_KEY,
|
96
|
-
SHOW: "show" + EVENT_KEY,
|
97
|
-
SHOWN: "shown" + EVENT_KEY,
|
98
|
-
CLICK: "click" + EVENT_KEY,
|
99
|
-
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
|
100
|
-
KEYDOWN_DATA_API: "keydown" + EVENT_KEY + DATA_API_KEY,
|
101
|
-
KEYUP_DATA_API: "keyup" + EVENT_KEY + DATA_API_KEY
|
102
|
-
};
|
103
|
-
var ClassName = {
|
104
|
-
DISABLED: 'disabled',
|
105
|
-
SHOW: 'show',
|
106
|
-
DROPUP: 'dropup',
|
107
|
-
DROPRIGHT: 'dropright',
|
108
|
-
DROPLEFT: 'dropleft',
|
109
|
-
MENURIGHT: 'dropdown-menu-right',
|
110
|
-
MENULEFT: 'dropdown-menu-left',
|
111
|
-
POSITION_STATIC: 'position-static'
|
112
|
-
};
|
113
|
-
var Selector = {
|
114
|
-
DATA_TOGGLE: '[data-toggle="dropdown"]',
|
115
|
-
FORM_CHILD: '.dropdown form',
|
116
|
-
MENU: '.dropdown-menu',
|
117
|
-
NAVBAR_NAV: '.navbar-nav',
|
118
|
-
VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
|
119
|
-
};
|
120
|
-
var AttachmentMap = {
|
121
|
-
TOP: 'top-start',
|
122
|
-
TOPEND: 'top-end',
|
123
|
-
BOTTOM: 'bottom-start',
|
124
|
-
BOTTOMEND: 'bottom-end',
|
125
|
-
RIGHT: 'right-start',
|
126
|
-
RIGHTEND: 'right-end',
|
127
|
-
LEFT: 'left-start',
|
128
|
-
LEFTEND: 'left-end'
|
129
|
-
};
|
130
|
-
var Default = {
|
131
|
-
offset: 0,
|
132
|
-
flip: true,
|
133
|
-
boundary: 'scrollParent',
|
134
|
-
reference: 'toggle',
|
135
|
-
display: 'dynamic'
|
136
|
-
};
|
137
|
-
var DefaultType = {
|
138
|
-
offset: '(number|string|function)',
|
139
|
-
flip: 'boolean',
|
140
|
-
boundary: '(string|element)',
|
141
|
-
reference: '(string|element)',
|
142
|
-
display: 'string'
|
143
|
-
/**
|
144
|
-
* ------------------------------------------------------------------------
|
145
|
-
* Class Definition
|
146
|
-
* ------------------------------------------------------------------------
|
147
|
-
*/
|
148
146
|
|
149
|
-
|
150
|
-
|
151
|
-
var Dropdown =
|
152
|
-
/*#__PURE__*/
|
153
|
-
function () {
|
154
|
-
function Dropdown(element, config) {
|
155
|
-
this._element = element;
|
156
|
-
this._popper = null;
|
157
|
-
this._config = this._getConfig(config);
|
158
|
-
this._menu = this._getMenuElement();
|
159
|
-
this._inNavbar = this._detectNavbar();
|
147
|
+
};
|
160
148
|
|
161
|
-
|
162
|
-
|
149
|
+
var Dropdown =
|
150
|
+
/*#__PURE__*/
|
151
|
+
function () {
|
152
|
+
function Dropdown(element, config) {
|
153
|
+
this._element = element;
|
154
|
+
this._popper = null;
|
155
|
+
this._config = this._getConfig(config);
|
156
|
+
this._menu = this._getMenuElement();
|
157
|
+
this._inNavbar = this._detectNavbar();
|
163
158
|
|
159
|
+
this._addEventListeners();
|
160
|
+
} // Getters
|
164
161
|
|
165
|
-
var _proto = Dropdown.prototype;
|
166
162
|
|
167
|
-
|
168
|
-
_proto.toggle = function toggle() {
|
169
|
-
if (this._element.disabled || $$$1(this._element).hasClass(ClassName.DISABLED)) {
|
170
|
-
return;
|
171
|
-
}
|
163
|
+
var _proto = Dropdown.prototype;
|
172
164
|
|
173
|
-
|
174
|
-
|
175
|
-
|
165
|
+
// Public
|
166
|
+
_proto.toggle = function toggle() {
|
167
|
+
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
|
168
|
+
return;
|
169
|
+
}
|
176
170
|
|
177
|
-
|
171
|
+
var parent = Dropdown._getParentFromElement(this._element);
|
178
172
|
|
179
|
-
|
180
|
-
return;
|
181
|
-
}
|
173
|
+
var isActive = $(this._menu).hasClass(ClassName.SHOW);
|
182
174
|
|
183
|
-
|
184
|
-
relatedTarget: this._element
|
185
|
-
};
|
186
|
-
var showEvent = $$$1.Event(Event.SHOW, relatedTarget);
|
187
|
-
$$$1(parent).trigger(showEvent);
|
175
|
+
Dropdown._clearMenus();
|
188
176
|
|
189
|
-
|
190
|
-
|
191
|
-
|
177
|
+
if (isActive) {
|
178
|
+
return;
|
179
|
+
}
|
192
180
|
|
181
|
+
var relatedTarget = {
|
182
|
+
relatedTarget: this._element
|
183
|
+
};
|
184
|
+
var showEvent = $.Event(Event.SHOW, relatedTarget);
|
185
|
+
$(parent).trigger(showEvent);
|
193
186
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
* Popper - https://popper.js.org
|
198
|
-
*/
|
199
|
-
if (typeof Popper === 'undefined') {
|
200
|
-
throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)');
|
201
|
-
}
|
187
|
+
if (showEvent.isDefaultPrevented()) {
|
188
|
+
return;
|
189
|
+
} // Disable totally Popper.js for Dropdown in Navbar
|
202
190
|
|
203
|
-
var referenceElement = this._element;
|
204
191
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
192
|
+
if (!this._inNavbar) {
|
193
|
+
/**
|
194
|
+
* Check for Popper dependency
|
195
|
+
* Popper - https://popper.js.org
|
196
|
+
*/
|
197
|
+
if (typeof Popper === 'undefined') {
|
198
|
+
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
|
199
|
+
}
|
209
200
|
|
210
|
-
|
211
|
-
referenceElement = this._config.reference[0];
|
212
|
-
}
|
213
|
-
} // If boundary is not `scrollParent`, then set position to `static`
|
214
|
-
// to allow the menu to "escape" the scroll parent's boundaries
|
215
|
-
// https://github.com/twbs/bootstrap/issues/24251
|
201
|
+
var referenceElement = this._element;
|
216
202
|
|
203
|
+
if (this._config.reference === 'parent') {
|
204
|
+
referenceElement = parent;
|
205
|
+
} else if (Util.isElement(this._config.reference)) {
|
206
|
+
referenceElement = this._config.reference; // Check if it's jQuery element
|
217
207
|
|
218
|
-
if (this._config.
|
219
|
-
|
208
|
+
if (typeof this._config.reference.jquery !== 'undefined') {
|
209
|
+
referenceElement = this._config.reference[0];
|
220
210
|
}
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
// empty mouseover listeners to the body's immediate children;
|
225
|
-
// only needed because of broken event delegation on iOS
|
226
|
-
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
211
|
+
} // If boundary is not `scrollParent`, then set position to `static`
|
212
|
+
// to allow the menu to "escape" the scroll parent's boundaries
|
213
|
+
// https://github.com/twbs/bootstrap/issues/24251
|
227
214
|
|
228
215
|
|
229
|
-
if (
|
230
|
-
|
216
|
+
if (this._config.boundary !== 'scrollParent') {
|
217
|
+
$(parent).addClass(ClassName.POSITION_STATIC);
|
231
218
|
}
|
232
219
|
|
233
|
-
this.
|
220
|
+
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
|
221
|
+
} // If this is a touch-enabled device we add extra
|
222
|
+
// empty mouseover listeners to the body's immediate children;
|
223
|
+
// only needed because of broken event delegation on iOS
|
224
|
+
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
234
225
|
|
235
|
-
this._element.setAttribute('aria-expanded', true);
|
236
226
|
|
237
|
-
|
238
|
-
|
239
|
-
}
|
227
|
+
if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) {
|
228
|
+
$(document.body).children().on('mouseover', null, $.noop);
|
229
|
+
}
|
240
230
|
|
241
|
-
|
242
|
-
$$$1.removeData(this._element, DATA_KEY);
|
243
|
-
$$$1(this._element).off(EVENT_KEY);
|
244
|
-
this._element = null;
|
245
|
-
this._menu = null;
|
231
|
+
this._element.focus();
|
246
232
|
|
247
|
-
|
248
|
-
this._popper.destroy();
|
233
|
+
this._element.setAttribute('aria-expanded', true);
|
249
234
|
|
250
|
-
|
251
|
-
|
235
|
+
$(this._menu).toggleClass(ClassName.SHOW);
|
236
|
+
$(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
|
237
|
+
};
|
238
|
+
|
239
|
+
_proto.show = function show() {
|
240
|
+
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) {
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
|
244
|
+
var relatedTarget = {
|
245
|
+
relatedTarget: this._element
|
252
246
|
};
|
247
|
+
var showEvent = $.Event(Event.SHOW, relatedTarget);
|
253
248
|
|
254
|
-
|
255
|
-
this._inNavbar = this._detectNavbar();
|
249
|
+
var parent = Dropdown._getParentFromElement(this._element);
|
256
250
|
|
257
|
-
|
258
|
-
this._popper.scheduleUpdate();
|
259
|
-
}
|
260
|
-
}; // Private
|
251
|
+
$(parent).trigger(showEvent);
|
261
252
|
|
253
|
+
if (showEvent.isDefaultPrevented()) {
|
254
|
+
return;
|
255
|
+
}
|
262
256
|
|
263
|
-
|
264
|
-
|
257
|
+
$(this._menu).toggleClass(ClassName.SHOW);
|
258
|
+
$(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
|
259
|
+
};
|
265
260
|
|
266
|
-
|
267
|
-
|
268
|
-
|
261
|
+
_proto.hide = function hide() {
|
262
|
+
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || !$(this._menu).hasClass(ClassName.SHOW)) {
|
263
|
+
return;
|
264
|
+
}
|
269
265
|
|
270
|
-
|
271
|
-
|
266
|
+
var relatedTarget = {
|
267
|
+
relatedTarget: this._element
|
272
268
|
};
|
269
|
+
var hideEvent = $.Event(Event.HIDE, relatedTarget);
|
273
270
|
|
274
|
-
|
275
|
-
config = _objectSpread({}, this.constructor.Default, $$$1(this._element).data(), config);
|
276
|
-
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
277
|
-
return config;
|
278
|
-
};
|
271
|
+
var parent = Dropdown._getParentFromElement(this._element);
|
279
272
|
|
280
|
-
|
281
|
-
if (!this._menu) {
|
282
|
-
var parent = Dropdown._getParentFromElement(this._element);
|
273
|
+
$(parent).trigger(hideEvent);
|
283
274
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
}
|
275
|
+
if (hideEvent.isDefaultPrevented()) {
|
276
|
+
return;
|
277
|
+
}
|
288
278
|
|
289
|
-
|
290
|
-
|
279
|
+
$(this._menu).toggleClass(ClassName.SHOW);
|
280
|
+
$(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
|
281
|
+
};
|
291
282
|
|
292
|
-
|
293
|
-
|
294
|
-
|
283
|
+
_proto.dispose = function dispose() {
|
284
|
+
$.removeData(this._element, DATA_KEY);
|
285
|
+
$(this._element).off(EVENT_KEY);
|
286
|
+
this._element = null;
|
287
|
+
this._menu = null;
|
295
288
|
|
296
|
-
|
297
|
-
|
289
|
+
if (this._popper !== null) {
|
290
|
+
this._popper.destroy();
|
298
291
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
} else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) {
|
303
|
-
placement = AttachmentMap.RIGHT;
|
304
|
-
} else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) {
|
305
|
-
placement = AttachmentMap.LEFT;
|
306
|
-
} else if ($$$1(this._menu).hasClass(ClassName.MENURIGHT)) {
|
307
|
-
placement = AttachmentMap.BOTTOMEND;
|
308
|
-
}
|
292
|
+
this._popper = null;
|
293
|
+
}
|
294
|
+
};
|
309
295
|
|
310
|
-
|
311
|
-
|
296
|
+
_proto.update = function update() {
|
297
|
+
this._inNavbar = this._detectNavbar();
|
312
298
|
|
313
|
-
|
314
|
-
|
315
|
-
}
|
299
|
+
if (this._popper !== null) {
|
300
|
+
this._popper.scheduleUpdate();
|
301
|
+
}
|
302
|
+
}; // Private
|
316
303
|
|
317
|
-
_proto._getPopperConfig = function _getPopperConfig() {
|
318
|
-
var _this2 = this;
|
319
304
|
|
320
|
-
|
305
|
+
_proto._addEventListeners = function _addEventListeners() {
|
306
|
+
var _this = this;
|
321
307
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
return data;
|
326
|
-
};
|
327
|
-
} else {
|
328
|
-
offsetConf.offset = this._config.offset;
|
329
|
-
}
|
308
|
+
$(this._element).on(Event.CLICK, function (event) {
|
309
|
+
event.preventDefault();
|
310
|
+
event.stopPropagation();
|
330
311
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
offset: offsetConf,
|
335
|
-
flip: {
|
336
|
-
enabled: this._config.flip
|
337
|
-
},
|
338
|
-
preventOverflow: {
|
339
|
-
boundariesElement: this._config.boundary
|
340
|
-
}
|
341
|
-
} // Disable Popper.js if we have a static display
|
312
|
+
_this.toggle();
|
313
|
+
});
|
314
|
+
};
|
342
315
|
|
343
|
-
|
316
|
+
_proto._getConfig = function _getConfig(config) {
|
317
|
+
config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config);
|
318
|
+
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
319
|
+
return config;
|
320
|
+
};
|
321
|
+
|
322
|
+
_proto._getMenuElement = function _getMenuElement() {
|
323
|
+
if (!this._menu) {
|
324
|
+
var parent = Dropdown._getParentFromElement(this._element);
|
344
325
|
|
345
|
-
if (
|
346
|
-
|
347
|
-
enabled: false
|
348
|
-
};
|
326
|
+
if (parent) {
|
327
|
+
this._menu = parent.querySelector(Selector.MENU);
|
349
328
|
}
|
329
|
+
}
|
350
330
|
|
351
|
-
|
352
|
-
|
331
|
+
return this._menu;
|
332
|
+
};
|
353
333
|
|
334
|
+
_proto._getPlacement = function _getPlacement() {
|
335
|
+
var $parentDropdown = $(this._element.parentNode);
|
336
|
+
var placement = AttachmentMap.BOTTOM; // Handle dropup
|
354
337
|
|
355
|
-
|
356
|
-
|
357
|
-
var data = $$$1(this).data(DATA_KEY);
|
338
|
+
if ($parentDropdown.hasClass(ClassName.DROPUP)) {
|
339
|
+
placement = AttachmentMap.TOP;
|
358
340
|
|
359
|
-
|
341
|
+
if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
|
342
|
+
placement = AttachmentMap.TOPEND;
|
343
|
+
}
|
344
|
+
} else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) {
|
345
|
+
placement = AttachmentMap.RIGHT;
|
346
|
+
} else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) {
|
347
|
+
placement = AttachmentMap.LEFT;
|
348
|
+
} else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
|
349
|
+
placement = AttachmentMap.BOTTOMEND;
|
350
|
+
}
|
360
351
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
352
|
+
return placement;
|
353
|
+
};
|
354
|
+
|
355
|
+
_proto._detectNavbar = function _detectNavbar() {
|
356
|
+
return $(this._element).closest('.navbar').length > 0;
|
357
|
+
};
|
358
|
+
|
359
|
+
_proto._getPopperConfig = function _getPopperConfig() {
|
360
|
+
var _this2 = this;
|
365
361
|
|
366
|
-
|
367
|
-
if (typeof data[config] === 'undefined') {
|
368
|
-
throw new TypeError("No method named \"" + config + "\"");
|
369
|
-
}
|
362
|
+
var offsetConf = {};
|
370
363
|
|
371
|
-
|
364
|
+
if (typeof this._config.offset === 'function') {
|
365
|
+
offsetConf.fn = function (data) {
|
366
|
+
data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets) || {});
|
367
|
+
return data;
|
368
|
+
};
|
369
|
+
} else {
|
370
|
+
offsetConf.offset = this._config.offset;
|
371
|
+
}
|
372
|
+
|
373
|
+
var popperConfig = {
|
374
|
+
placement: this._getPlacement(),
|
375
|
+
modifiers: {
|
376
|
+
offset: offsetConf,
|
377
|
+
flip: {
|
378
|
+
enabled: this._config.flip
|
379
|
+
},
|
380
|
+
preventOverflow: {
|
381
|
+
boundariesElement: this._config.boundary
|
372
382
|
}
|
373
|
-
}
|
374
|
-
};
|
383
|
+
} // Disable Popper.js if we have a static display
|
375
384
|
|
376
|
-
|
377
|
-
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
|
378
|
-
return;
|
379
|
-
}
|
385
|
+
};
|
380
386
|
|
381
|
-
|
387
|
+
if (this._config.display === 'static') {
|
388
|
+
popperConfig.modifiers.applyStyle = {
|
389
|
+
enabled: false
|
390
|
+
};
|
391
|
+
}
|
382
392
|
|
383
|
-
|
384
|
-
|
393
|
+
return popperConfig;
|
394
|
+
}; // Static
|
385
395
|
|
386
|
-
var context = $$$1(toggles[i]).data(DATA_KEY);
|
387
|
-
var relatedTarget = {
|
388
|
-
relatedTarget: toggles[i]
|
389
|
-
};
|
390
396
|
|
391
|
-
|
392
|
-
|
393
|
-
|
397
|
+
Dropdown._jQueryInterface = function _jQueryInterface(config) {
|
398
|
+
return this.each(function () {
|
399
|
+
var data = $(this).data(DATA_KEY);
|
394
400
|
|
395
|
-
|
396
|
-
continue;
|
397
|
-
}
|
401
|
+
var _config = typeof config === 'object' ? config : null;
|
398
402
|
|
399
|
-
|
403
|
+
if (!data) {
|
404
|
+
data = new Dropdown(this, _config);
|
405
|
+
$(this).data(DATA_KEY, data);
|
406
|
+
}
|
400
407
|
|
401
|
-
|
402
|
-
|
408
|
+
if (typeof config === 'string') {
|
409
|
+
if (typeof data[config] === 'undefined') {
|
410
|
+
throw new TypeError("No method named \"" + config + "\"");
|
403
411
|
}
|
404
412
|
|
405
|
-
|
406
|
-
|
407
|
-
|
413
|
+
data[config]();
|
414
|
+
}
|
415
|
+
});
|
416
|
+
};
|
408
417
|
|
409
|
-
|
410
|
-
|
418
|
+
Dropdown._clearMenus = function _clearMenus(event) {
|
419
|
+
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
|
420
|
+
return;
|
421
|
+
}
|
411
422
|
|
412
|
-
|
413
|
-
continue;
|
414
|
-
} // If this is a touch-enabled device we remove the extra
|
415
|
-
// empty mouseover listeners we added for iOS support
|
423
|
+
var toggles = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE));
|
416
424
|
|
425
|
+
for (var i = 0, len = toggles.length; i < len; i++) {
|
426
|
+
var parent = Dropdown._getParentFromElement(toggles[i]);
|
417
427
|
|
418
|
-
|
419
|
-
|
420
|
-
|
428
|
+
var context = $(toggles[i]).data(DATA_KEY);
|
429
|
+
var relatedTarget = {
|
430
|
+
relatedTarget: toggles[i]
|
431
|
+
};
|
421
432
|
|
422
|
-
|
423
|
-
|
424
|
-
$$$1(parent).removeClass(ClassName.SHOW).trigger($$$1.Event(Event.HIDDEN, relatedTarget));
|
433
|
+
if (event && event.type === 'click') {
|
434
|
+
relatedTarget.clickEvent = event;
|
425
435
|
}
|
426
|
-
};
|
427
|
-
|
428
|
-
Dropdown._getParentFromElement = function _getParentFromElement(element) {
|
429
|
-
var parent;
|
430
|
-
var selector = Util.getSelectorFromElement(element);
|
431
436
|
|
432
|
-
if (
|
433
|
-
|
437
|
+
if (!context) {
|
438
|
+
continue;
|
434
439
|
}
|
435
440
|
|
436
|
-
|
437
|
-
}; // eslint-disable-next-line complexity
|
441
|
+
var dropdownMenu = context._menu;
|
438
442
|
|
443
|
+
if (!$(parent).hasClass(ClassName.SHOW)) {
|
444
|
+
continue;
|
445
|
+
}
|
439
446
|
|
440
|
-
|
441
|
-
|
442
|
-
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
|
443
|
-
// If input/textarea:
|
444
|
-
// - If space key => not a dropdown command
|
445
|
-
// - If key is other than escape
|
446
|
-
// - If key is not up or down => not a dropdown command
|
447
|
-
// - If trigger inside the menu => not a dropdown command
|
448
|
-
if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $$$1(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
|
449
|
-
return;
|
447
|
+
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
|
448
|
+
continue;
|
450
449
|
}
|
451
450
|
|
452
|
-
|
453
|
-
|
451
|
+
var hideEvent = $.Event(Event.HIDE, relatedTarget);
|
452
|
+
$(parent).trigger(hideEvent);
|
453
|
+
|
454
|
+
if (hideEvent.isDefaultPrevented()) {
|
455
|
+
continue;
|
456
|
+
} // If this is a touch-enabled device we remove the extra
|
457
|
+
// empty mouseover listeners we added for iOS support
|
458
|
+
|
454
459
|
|
455
|
-
if (
|
456
|
-
|
460
|
+
if ('ontouchstart' in document.documentElement) {
|
461
|
+
$(document.body).children().off('mouseover', null, $.noop);
|
457
462
|
}
|
458
463
|
|
459
|
-
|
464
|
+
toggles[i].setAttribute('aria-expanded', 'false');
|
465
|
+
$(dropdownMenu).removeClass(ClassName.SHOW);
|
466
|
+
$(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
|
467
|
+
}
|
468
|
+
};
|
460
469
|
|
461
|
-
|
470
|
+
Dropdown._getParentFromElement = function _getParentFromElement(element) {
|
471
|
+
var parent;
|
472
|
+
var selector = Util.getSelectorFromElement(element);
|
462
473
|
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
$$$1(toggle).trigger('focus');
|
467
|
-
}
|
474
|
+
if (selector) {
|
475
|
+
parent = document.querySelector(selector);
|
476
|
+
}
|
468
477
|
|
469
|
-
|
470
|
-
|
471
|
-
}
|
478
|
+
return parent || element.parentNode;
|
479
|
+
}; // eslint-disable-next-line complexity
|
472
480
|
|
473
|
-
var items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS));
|
474
481
|
|
475
|
-
|
476
|
-
|
477
|
-
|
482
|
+
Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
|
483
|
+
// If not input/textarea:
|
484
|
+
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
|
485
|
+
// If input/textarea:
|
486
|
+
// - If space key => not a dropdown command
|
487
|
+
// - If key is other than escape
|
488
|
+
// - If key is not up or down => not a dropdown command
|
489
|
+
// - If trigger inside the menu => not a dropdown command
|
490
|
+
if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
|
491
|
+
return;
|
492
|
+
}
|
478
493
|
|
479
|
-
|
494
|
+
event.preventDefault();
|
495
|
+
event.stopPropagation();
|
480
496
|
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
}
|
497
|
+
if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
|
498
|
+
return;
|
499
|
+
}
|
485
500
|
|
486
|
-
|
487
|
-
// Down
|
488
|
-
index++;
|
489
|
-
}
|
501
|
+
var parent = Dropdown._getParentFromElement(this);
|
490
502
|
|
491
|
-
|
492
|
-
|
503
|
+
var isActive = $(parent).hasClass(ClassName.SHOW);
|
504
|
+
|
505
|
+
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
|
506
|
+
if (event.which === ESCAPE_KEYCODE) {
|
507
|
+
var toggle = parent.querySelector(Selector.DATA_TOGGLE);
|
508
|
+
$(toggle).trigger('focus');
|
493
509
|
}
|
494
510
|
|
495
|
-
|
496
|
-
|
511
|
+
$(this).trigger('click');
|
512
|
+
return;
|
513
|
+
}
|
497
514
|
|
498
|
-
|
499
|
-
key: "VERSION",
|
500
|
-
get: function get() {
|
501
|
-
return VERSION;
|
502
|
-
}
|
503
|
-
}, {
|
504
|
-
key: "Default",
|
505
|
-
get: function get() {
|
506
|
-
return Default;
|
507
|
-
}
|
508
|
-
}, {
|
509
|
-
key: "DefaultType",
|
510
|
-
get: function get() {
|
511
|
-
return DefaultType;
|
512
|
-
}
|
513
|
-
}]);
|
515
|
+
var items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS));
|
514
516
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
* ------------------------------------------------------------------------
|
519
|
-
* Data Api implementation
|
520
|
-
* ------------------------------------------------------------------------
|
521
|
-
*/
|
517
|
+
if (items.length === 0) {
|
518
|
+
return;
|
519
|
+
}
|
522
520
|
|
521
|
+
var index = items.indexOf(event.target);
|
523
522
|
|
524
|
-
|
525
|
-
|
526
|
-
|
523
|
+
if (event.which === ARROW_UP_KEYCODE && index > 0) {
|
524
|
+
// Up
|
525
|
+
index--;
|
526
|
+
}
|
527
527
|
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
/**
|
533
|
-
* ------------------------------------------------------------------------
|
534
|
-
* jQuery
|
535
|
-
* ------------------------------------------------------------------------
|
536
|
-
*/
|
528
|
+
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
|
529
|
+
// Down
|
530
|
+
index++;
|
531
|
+
}
|
537
532
|
|
538
|
-
|
539
|
-
|
533
|
+
if (index < 0) {
|
534
|
+
index = 0;
|
535
|
+
}
|
540
536
|
|
541
|
-
|
542
|
-
$$$1.fn[NAME] = JQUERY_NO_CONFLICT;
|
543
|
-
return Dropdown._jQueryInterface;
|
537
|
+
items[index].focus();
|
544
538
|
};
|
545
539
|
|
540
|
+
_createClass(Dropdown, null, [{
|
541
|
+
key: "VERSION",
|
542
|
+
get: function get() {
|
543
|
+
return VERSION;
|
544
|
+
}
|
545
|
+
}, {
|
546
|
+
key: "Default",
|
547
|
+
get: function get() {
|
548
|
+
return Default;
|
549
|
+
}
|
550
|
+
}, {
|
551
|
+
key: "DefaultType",
|
552
|
+
get: function get() {
|
553
|
+
return DefaultType;
|
554
|
+
}
|
555
|
+
}]);
|
556
|
+
|
546
557
|
return Dropdown;
|
547
|
-
}(
|
558
|
+
}();
|
559
|
+
/**
|
560
|
+
* ------------------------------------------------------------------------
|
561
|
+
* Data Api implementation
|
562
|
+
* ------------------------------------------------------------------------
|
563
|
+
*/
|
564
|
+
|
565
|
+
|
566
|
+
$(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + " " + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
|
567
|
+
event.preventDefault();
|
568
|
+
event.stopPropagation();
|
569
|
+
|
570
|
+
Dropdown._jQueryInterface.call($(this), 'toggle');
|
571
|
+
}).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
|
572
|
+
e.stopPropagation();
|
573
|
+
});
|
574
|
+
/**
|
575
|
+
* ------------------------------------------------------------------------
|
576
|
+
* jQuery
|
577
|
+
* ------------------------------------------------------------------------
|
578
|
+
*/
|
579
|
+
|
580
|
+
$.fn[NAME] = Dropdown._jQueryInterface;
|
581
|
+
$.fn[NAME].Constructor = Dropdown;
|
582
|
+
|
583
|
+
$.fn[NAME].noConflict = function () {
|
584
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
585
|
+
return Dropdown._jQueryInterface;
|
586
|
+
};
|
548
587
|
|
549
588
|
return Dropdown;
|
550
589
|
|