bootstrap 4.6.2.1 → 5.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -4
- data/README.md +1 -7
- data/Rakefile +4 -16
- data/assets/javascripts/bootstrap/alert.js +148 -73
- data/assets/javascripts/bootstrap/button.js +71 -154
- data/assets/javascripts/bootstrap/carousel.js +315 -209
- data/assets/javascripts/bootstrap/collapse.js +307 -153
- data/assets/javascripts/bootstrap/dom/data.js +81 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +311 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +100 -0
- data/assets/javascripts/bootstrap/dom/polyfill.js +110 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +98 -0
- data/assets/javascripts/bootstrap/dropdown.js +257 -205
- data/assets/javascripts/bootstrap/modal.js +354 -250
- data/assets/javascripts/bootstrap/popover.js +85 -94
- data/assets/javascripts/bootstrap/scrollspy.js +179 -107
- data/assets/javascripts/bootstrap/tab.js +170 -99
- data/assets/javascripts/bootstrap/toast.js +181 -110
- data/assets/javascripts/bootstrap/tooltip.js +375 -226
- data/assets/javascripts/bootstrap-sprockets.js +5 -1
- data/assets/javascripts/bootstrap.js +2260 -1550
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +53 -18
- data/assets/stylesheets/_bootstrap-reboot.scss +6 -3
- data/assets/stylesheets/_bootstrap.scss +16 -10
- data/assets/stylesheets/bootstrap/_alert.scss +3 -4
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
- data/assets/stylesheets/bootstrap/_buttons.scss +27 -45
- data/assets/stylesheets/bootstrap/_card.scss +22 -68
- data/assets/stylesheets/bootstrap/_carousel.scss +15 -20
- data/assets/stylesheets/bootstrap/_close.scss +9 -13
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +12 -9
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +82 -69
- data/assets/stylesheets/bootstrap/_grid.scss +3 -54
- data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
- data/assets/stylesheets/bootstrap/_images.scss +1 -1
- data/assets/stylesheets/bootstrap/_list-group.scss +7 -4
- data/assets/stylesheets/bootstrap/_mixins.scss +6 -12
- data/assets/stylesheets/bootstrap/_modal.scss +36 -41
- data/assets/stylesheets/bootstrap/_nav.scss +7 -9
- data/assets/stylesheets/bootstrap/_navbar.scss +42 -82
- data/assets/stylesheets/bootstrap/_pagination.scss +7 -20
- data/assets/stylesheets/bootstrap/_popover.scss +14 -14
- data/assets/stylesheets/bootstrap/_progress.scss +3 -5
- data/assets/stylesheets/bootstrap/_reboot.scss +304 -172
- data/assets/stylesheets/bootstrap/_root.scss +5 -8
- data/assets/stylesheets/bootstrap/_spinners.scss +8 -17
- data/assets/stylesheets/bootstrap/_tables.scss +80 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +2 -4
- data/assets/stylesheets/bootstrap/_tooltip.scss +9 -9
- data/assets/stylesheets/bootstrap/_transitions.scss +0 -7
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +503 -18
- data/assets/stylesheets/bootstrap/_variables.scss +548 -437
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +142 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +116 -0
- data/assets/stylesheets/bootstrap/forms/_form-file.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +136 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +82 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +140 -0
- data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
- data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_embed.scss +31 -0
- data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_screenreaders.scss +8 -0
- data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +0 -4
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +11 -8
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +62 -47
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +4 -4
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +23 -85
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +86 -34
- data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -1
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +15 -8
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +3 -3
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +18 -24
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +49 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +214 -130
- data/bootstrap.gemspec +3 -1
- data/lib/bootstrap/engine.rb +1 -17
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +6 -18
- data/tasks/updater/network.rb +1 -7
- metadata +49 -47
- data/assets/javascripts/bootstrap/util.js +0 -189
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -526
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -211
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -132
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -23
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -80
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
- data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
- data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_interactions.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
- data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
- data/test/gemfiles/rails_7_0_dartsass.gemfile +0 -8
- data/test/gemfiles/rails_7_0_sassc.gemfile +0 -8
- /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,86 +1,124 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap dropdown.js
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap dropdown.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
8
|
-
typeof define === 'function' && define.amd ? define(['
|
9
|
-
(global =
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('popper.js'), require('./dom/selector-engine.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', 'popper.js', './dom/selector-engine.js'], factory) :
|
9
|
+
(global = global || self, global.Dropdown = factory(global.Data, global.EventHandler, global.Manipulator, global.Popper, global.SelectorEngine));
|
10
|
+
}(this, (function (Data, EventHandler, Manipulator, Popper, SelectorEngine) { 'use strict';
|
11
|
+
|
12
|
+
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
|
13
|
+
EventHandler = EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default') ? EventHandler['default'] : EventHandler;
|
14
|
+
Manipulator = Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default') ? Manipulator['default'] : Manipulator;
|
15
|
+
Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
|
16
|
+
SelectorEngine = SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default') ? SelectorEngine['default'] : SelectorEngine;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* --------------------------------------------------------------------------
|
20
|
+
* Bootstrap (v5.0.0-alpha1): util/index.js
|
21
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
22
|
+
* --------------------------------------------------------------------------
|
23
|
+
*/
|
24
|
+
|
25
|
+
var toType = function toType(obj) {
|
26
|
+
if (obj === null || obj === undefined) {
|
27
|
+
return "" + obj;
|
25
28
|
}
|
26
|
-
}
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
31
|
-
Object.defineProperty(Constructor, "prototype", {
|
32
|
-
writable: false
|
33
|
-
});
|
34
|
-
return Constructor;
|
35
|
-
}
|
30
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
31
|
+
};
|
36
32
|
|
37
|
-
function
|
38
|
-
|
39
|
-
for (var i = 1; i < arguments.length; i++) {
|
40
|
-
var source = arguments[i];
|
33
|
+
var getSelector = function getSelector(element) {
|
34
|
+
var selector = element.getAttribute('data-target');
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
if (!selector || selector === '#') {
|
37
|
+
var hrefAttr = element.getAttribute('href');
|
38
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
39
|
+
}
|
40
|
+
|
41
|
+
return selector;
|
42
|
+
};
|
43
|
+
|
44
|
+
var getElementFromSelector = function getElementFromSelector(element) {
|
45
|
+
var selector = getSelector(element);
|
46
|
+
return selector ? document.querySelector(selector) : null;
|
47
|
+
};
|
48
|
+
|
49
|
+
var isElement = function isElement(obj) {
|
50
|
+
return (obj[0] || obj).nodeType;
|
51
|
+
};
|
52
|
+
|
53
|
+
var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
|
54
|
+
Object.keys(configTypes).forEach(function (property) {
|
55
|
+
var expectedTypes = configTypes[property];
|
56
|
+
var value = config[property];
|
57
|
+
var valueType = value && isElement(value) ? 'element' : toType(value);
|
58
|
+
|
59
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
60
|
+
throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
|
47
61
|
}
|
62
|
+
});
|
63
|
+
};
|
48
64
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
65
|
+
var isVisible = function isVisible(element) {
|
66
|
+
if (!element) {
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
|
70
|
+
if (element.style && element.parentNode && element.parentNode.style) {
|
71
|
+
var elementStyle = getComputedStyle(element);
|
72
|
+
var parentNodeStyle = getComputedStyle(element.parentNode);
|
73
|
+
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
|
74
|
+
}
|
75
|
+
|
76
|
+
return false;
|
77
|
+
};
|
78
|
+
|
79
|
+
var noop = function noop() {
|
80
|
+
return function () {};
|
81
|
+
};
|
82
|
+
|
83
|
+
var getjQuery = function getjQuery() {
|
84
|
+
var _window = window,
|
85
|
+
jQuery = _window.jQuery;
|
86
|
+
|
87
|
+
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
|
88
|
+
return jQuery;
|
89
|
+
}
|
90
|
+
|
91
|
+
return null;
|
92
|
+
};
|
93
|
+
|
94
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
95
|
+
|
96
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
97
|
+
|
98
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
53
99
|
|
100
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
101
|
+
|
102
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
54
103
|
/**
|
104
|
+
* ------------------------------------------------------------------------
|
55
105
|
* Constants
|
106
|
+
* ------------------------------------------------------------------------
|
56
107
|
*/
|
57
108
|
|
58
109
|
var NAME = 'dropdown';
|
59
|
-
var VERSION = '
|
110
|
+
var VERSION = '5.0.0-alpha1';
|
60
111
|
var DATA_KEY = 'bs.dropdown';
|
61
112
|
var EVENT_KEY = "." + DATA_KEY;
|
62
113
|
var DATA_API_KEY = '.data-api';
|
63
|
-
var
|
64
|
-
var
|
65
|
-
|
66
|
-
var
|
67
|
-
|
68
|
-
var
|
69
|
-
|
70
|
-
var
|
71
|
-
|
72
|
-
var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
|
73
|
-
|
74
|
-
var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
|
75
|
-
|
76
|
-
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
|
77
|
-
var CLASS_NAME_DISABLED = 'disabled';
|
78
|
-
var CLASS_NAME_SHOW = 'show';
|
79
|
-
var CLASS_NAME_DROPUP = 'dropup';
|
80
|
-
var CLASS_NAME_DROPRIGHT = 'dropright';
|
81
|
-
var CLASS_NAME_DROPLEFT = 'dropleft';
|
82
|
-
var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
|
83
|
-
var CLASS_NAME_POSITION_STATIC = 'position-static';
|
114
|
+
var ESCAPE_KEY = 'Escape';
|
115
|
+
var SPACE_KEY = 'Space';
|
116
|
+
var TAB_KEY = 'Tab';
|
117
|
+
var ARROW_UP_KEY = 'ArrowUp';
|
118
|
+
var ARROW_DOWN_KEY = 'ArrowDown';
|
119
|
+
var RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
|
120
|
+
|
121
|
+
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEY + "|" + ARROW_DOWN_KEY + "|" + ESCAPE_KEY);
|
84
122
|
var EVENT_HIDE = "hide" + EVENT_KEY;
|
85
123
|
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
86
124
|
var EVENT_SHOW = "show" + EVENT_KEY;
|
@@ -89,6 +127,14 @@
|
|
89
127
|
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
90
128
|
var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY + DATA_API_KEY;
|
91
129
|
var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY + DATA_API_KEY;
|
130
|
+
var CLASS_NAME_DISABLED = 'disabled';
|
131
|
+
var CLASS_NAME_SHOW = 'show';
|
132
|
+
var CLASS_NAME_DROPUP = 'dropup';
|
133
|
+
var CLASS_NAME_DROPRIGHT = 'dropright';
|
134
|
+
var CLASS_NAME_DROPLEFT = 'dropleft';
|
135
|
+
var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
|
136
|
+
var CLASS_NAME_NAVBAR = 'navbar';
|
137
|
+
var CLASS_NAME_POSITION_STATIC = 'position-static';
|
92
138
|
var SELECTOR_DATA_TOGGLE = '[data-toggle="dropdown"]';
|
93
139
|
var SELECTOR_FORM_CHILD = '.dropdown form';
|
94
140
|
var SELECTOR_MENU = '.dropdown-menu';
|
@@ -117,7 +163,9 @@
|
|
117
163
|
popperConfig: '(null|object)'
|
118
164
|
};
|
119
165
|
/**
|
120
|
-
*
|
166
|
+
* ------------------------------------------------------------------------
|
167
|
+
* Class Definition
|
168
|
+
* ------------------------------------------------------------------------
|
121
169
|
*/
|
122
170
|
|
123
171
|
var Dropdown = /*#__PURE__*/function () {
|
@@ -129,6 +177,8 @@
|
|
129
177
|
this._inNavbar = this._detectNavbar();
|
130
178
|
|
131
179
|
this._addEventListeners();
|
180
|
+
|
181
|
+
Data.setData(element, DATA_KEY, this);
|
132
182
|
} // Getters
|
133
183
|
|
134
184
|
|
@@ -136,55 +186,47 @@
|
|
136
186
|
|
137
187
|
// Public
|
138
188
|
_proto.toggle = function toggle() {
|
139
|
-
if (this._element.disabled ||
|
189
|
+
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) {
|
140
190
|
return;
|
141
191
|
}
|
142
192
|
|
143
|
-
var isActive =
|
193
|
+
var isActive = this._element.classList.contains(CLASS_NAME_SHOW);
|
144
194
|
|
145
|
-
Dropdown.
|
195
|
+
Dropdown.clearMenus();
|
146
196
|
|
147
197
|
if (isActive) {
|
148
198
|
return;
|
149
199
|
}
|
150
200
|
|
151
|
-
this.show(
|
201
|
+
this.show();
|
152
202
|
};
|
153
203
|
|
154
|
-
_proto.show = function show(
|
155
|
-
if (
|
156
|
-
usePopper = false;
|
157
|
-
}
|
158
|
-
|
159
|
-
if (this._element.disabled || $__default["default"](this._element).hasClass(CLASS_NAME_DISABLED) || $__default["default"](this._menu).hasClass(CLASS_NAME_SHOW)) {
|
204
|
+
_proto.show = function show() {
|
205
|
+
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
160
206
|
return;
|
161
207
|
}
|
162
208
|
|
209
|
+
var parent = Dropdown.getParentFromElement(this._element);
|
163
210
|
var relatedTarget = {
|
164
211
|
relatedTarget: this._element
|
165
212
|
};
|
166
|
-
var showEvent =
|
213
|
+
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget);
|
167
214
|
|
168
|
-
|
169
|
-
|
170
|
-
$__default["default"](parent).trigger(showEvent);
|
171
|
-
|
172
|
-
if (showEvent.isDefaultPrevented()) {
|
215
|
+
if (showEvent.defaultPrevented) {
|
173
216
|
return;
|
174
|
-
} //
|
217
|
+
} // Disable totally Popper.js for Dropdown in Navbar
|
175
218
|
|
176
219
|
|
177
|
-
if (!this._inNavbar
|
178
|
-
|
179
|
-
|
180
|
-
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
|
220
|
+
if (!this._inNavbar) {
|
221
|
+
if (typeof Popper === 'undefined') {
|
222
|
+
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)');
|
181
223
|
}
|
182
224
|
|
183
225
|
var referenceElement = this._element;
|
184
226
|
|
185
227
|
if (this._config.reference === 'parent') {
|
186
228
|
referenceElement = parent;
|
187
|
-
} else if (
|
229
|
+
} else if (isElement(this._config.reference)) {
|
188
230
|
referenceElement = this._config.reference; // Check if it's jQuery element
|
189
231
|
|
190
232
|
if (typeof this._config.reference.jquery !== 'undefined') {
|
@@ -196,43 +238,45 @@
|
|
196
238
|
|
197
239
|
|
198
240
|
if (this._config.boundary !== 'scrollParent') {
|
199
|
-
|
241
|
+
parent.classList.add(CLASS_NAME_POSITION_STATIC);
|
200
242
|
}
|
201
243
|
|
202
|
-
this._popper = new
|
244
|
+
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
|
203
245
|
} // If this is a touch-enabled device we add extra
|
204
246
|
// empty mouseover listeners to the body's immediate children;
|
205
247
|
// only needed because of broken event delegation on iOS
|
206
248
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
207
249
|
|
208
250
|
|
209
|
-
if ('ontouchstart' in document.documentElement &&
|
210
|
-
|
251
|
+
if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
|
252
|
+
var _ref;
|
253
|
+
|
254
|
+
(_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) {
|
255
|
+
return EventHandler.on(elem, 'mouseover', null, noop());
|
256
|
+
});
|
211
257
|
}
|
212
258
|
|
213
259
|
this._element.focus();
|
214
260
|
|
215
261
|
this._element.setAttribute('aria-expanded', true);
|
216
262
|
|
217
|
-
|
218
|
-
|
263
|
+
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
|
264
|
+
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
|
265
|
+
EventHandler.trigger(parent, EVENT_SHOWN, relatedTarget);
|
219
266
|
};
|
220
267
|
|
221
268
|
_proto.hide = function hide() {
|
222
|
-
if (this._element.disabled ||
|
269
|
+
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
223
270
|
return;
|
224
271
|
}
|
225
272
|
|
273
|
+
var parent = Dropdown.getParentFromElement(this._element);
|
226
274
|
var relatedTarget = {
|
227
275
|
relatedTarget: this._element
|
228
276
|
};
|
229
|
-
var hideEvent =
|
230
|
-
|
231
|
-
var parent = Dropdown._getParentFromElement(this._element);
|
277
|
+
var hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
|
232
278
|
|
233
|
-
|
234
|
-
|
235
|
-
if (hideEvent.isDefaultPrevented()) {
|
279
|
+
if (hideEvent.defaultPrevented) {
|
236
280
|
return;
|
237
281
|
}
|
238
282
|
|
@@ -240,17 +284,18 @@
|
|
240
284
|
this._popper.destroy();
|
241
285
|
}
|
242
286
|
|
243
|
-
|
244
|
-
|
287
|
+
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
|
288
|
+
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
|
289
|
+
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
|
245
290
|
};
|
246
291
|
|
247
292
|
_proto.dispose = function dispose() {
|
248
|
-
|
249
|
-
|
293
|
+
Data.removeData(this._element, DATA_KEY);
|
294
|
+
EventHandler.off(this._element, EVENT_KEY);
|
250
295
|
this._element = null;
|
251
296
|
this._menu = null;
|
252
297
|
|
253
|
-
if (this._popper
|
298
|
+
if (this._popper) {
|
254
299
|
this._popper.destroy();
|
255
300
|
|
256
301
|
this._popper = null;
|
@@ -260,7 +305,7 @@
|
|
260
305
|
_proto.update = function update() {
|
261
306
|
this._inNavbar = this._detectNavbar();
|
262
307
|
|
263
|
-
if (this._popper
|
308
|
+
if (this._popper) {
|
264
309
|
this._popper.scheduleUpdate();
|
265
310
|
}
|
266
311
|
} // Private
|
@@ -269,7 +314,7 @@
|
|
269
314
|
_proto._addEventListeners = function _addEventListeners() {
|
270
315
|
var _this = this;
|
271
316
|
|
272
|
-
|
317
|
+
EventHandler.on(this._element, EVENT_CLICK, function (event) {
|
273
318
|
event.preventDefault();
|
274
319
|
event.stopPropagation();
|
275
320
|
|
@@ -278,34 +323,30 @@
|
|
278
323
|
};
|
279
324
|
|
280
325
|
_proto._getConfig = function _getConfig(config) {
|
281
|
-
config =
|
282
|
-
|
326
|
+
config = _objectSpread(_objectSpread(_objectSpread({}, this.constructor.Default), Manipulator.getDataAttributes(this._element)), config);
|
327
|
+
typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
283
328
|
return config;
|
284
329
|
};
|
285
330
|
|
286
331
|
_proto._getMenuElement = function _getMenuElement() {
|
287
|
-
|
288
|
-
var parent = Dropdown._getParentFromElement(this._element);
|
289
|
-
|
290
|
-
if (parent) {
|
291
|
-
this._menu = parent.querySelector(SELECTOR_MENU);
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
295
|
-
return this._menu;
|
332
|
+
return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
|
296
333
|
};
|
297
334
|
|
298
335
|
_proto._getPlacement = function _getPlacement() {
|
299
|
-
var
|
336
|
+
var parentDropdown = this._element.parentNode;
|
300
337
|
var placement = PLACEMENT_BOTTOM; // Handle dropup
|
301
338
|
|
302
|
-
if (
|
303
|
-
placement =
|
304
|
-
|
339
|
+
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
|
340
|
+
placement = PLACEMENT_TOP;
|
341
|
+
|
342
|
+
if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
|
343
|
+
placement = PLACEMENT_TOPEND;
|
344
|
+
}
|
345
|
+
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
|
305
346
|
placement = PLACEMENT_RIGHT;
|
306
|
-
} else if (
|
347
|
+
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
|
307
348
|
placement = PLACEMENT_LEFT;
|
308
|
-
} else if (
|
349
|
+
} else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
|
309
350
|
placement = PLACEMENT_BOTTOMEND;
|
310
351
|
}
|
311
352
|
|
@@ -313,7 +354,7 @@
|
|
313
354
|
};
|
314
355
|
|
315
356
|
_proto._detectNavbar = function _detectNavbar() {
|
316
|
-
return
|
357
|
+
return Boolean(this._element.closest("." + CLASS_NAME_NAVBAR));
|
317
358
|
};
|
318
359
|
|
319
360
|
_proto._getOffset = function _getOffset() {
|
@@ -323,7 +364,7 @@
|
|
323
364
|
|
324
365
|
if (typeof this._config.offset === 'function') {
|
325
366
|
offset.fn = function (data) {
|
326
|
-
data.offsets =
|
367
|
+
data.offsets = _objectSpread(_objectSpread({}, data.offsets), _this2._config.offset(data.offsets, _this2._element) || {});
|
327
368
|
return data;
|
328
369
|
};
|
329
370
|
} else {
|
@@ -345,7 +386,7 @@
|
|
345
386
|
boundariesElement: this._config.boundary
|
346
387
|
}
|
347
388
|
}
|
348
|
-
}; // Disable Popper if we have a static display
|
389
|
+
}; // Disable Popper.js if we have a static display
|
349
390
|
|
350
391
|
if (this._config.display === 'static') {
|
351
392
|
popperConfig.modifiers.applyStyle = {
|
@@ -353,42 +394,44 @@
|
|
353
394
|
};
|
354
395
|
}
|
355
396
|
|
356
|
-
return
|
397
|
+
return _objectSpread(_objectSpread({}, popperConfig), this._config.popperConfig);
|
357
398
|
} // Static
|
358
399
|
;
|
359
400
|
|
360
|
-
Dropdown.
|
361
|
-
|
362
|
-
var data = $__default["default"](this).data(DATA_KEY);
|
401
|
+
Dropdown.dropdownInterface = function dropdownInterface(element, config) {
|
402
|
+
var data = Data.getData(element, DATA_KEY);
|
363
403
|
|
364
|
-
|
404
|
+
var _config = typeof config === 'object' ? config : null;
|
365
405
|
|
366
|
-
|
367
|
-
|
368
|
-
|
406
|
+
if (!data) {
|
407
|
+
data = new Dropdown(element, _config);
|
408
|
+
}
|
409
|
+
|
410
|
+
if (typeof config === 'string') {
|
411
|
+
if (typeof data[config] === 'undefined') {
|
412
|
+
throw new TypeError("No method named \"" + config + "\"");
|
369
413
|
}
|
370
414
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
415
|
+
data[config]();
|
416
|
+
}
|
417
|
+
};
|
375
418
|
|
376
|
-
|
377
|
-
|
419
|
+
Dropdown.jQueryInterface = function jQueryInterface(config) {
|
420
|
+
return this.each(function () {
|
421
|
+
Dropdown.dropdownInterface(this, config);
|
378
422
|
});
|
379
423
|
};
|
380
424
|
|
381
|
-
Dropdown.
|
382
|
-
if (event && (event.
|
425
|
+
Dropdown.clearMenus = function clearMenus(event) {
|
426
|
+
if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) {
|
383
427
|
return;
|
384
428
|
}
|
385
429
|
|
386
|
-
var toggles =
|
430
|
+
var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
|
387
431
|
|
388
432
|
for (var i = 0, len = toggles.length; i < len; i++) {
|
389
|
-
var parent = Dropdown.
|
390
|
-
|
391
|
-
var context = $__default["default"](toggles[i]).data(DATA_KEY);
|
433
|
+
var parent = Dropdown.getParentFromElement(toggles[i]);
|
434
|
+
var context = Data.getData(toggles[i], DATA_KEY);
|
392
435
|
var relatedTarget = {
|
393
436
|
relatedTarget: toggles[i]
|
394
437
|
};
|
@@ -403,25 +446,28 @@
|
|
403
446
|
|
404
447
|
var dropdownMenu = context._menu;
|
405
448
|
|
406
|
-
if (
|
449
|
+
if (!toggles[i].classList.contains(CLASS_NAME_SHOW)) {
|
407
450
|
continue;
|
408
451
|
}
|
409
452
|
|
410
|
-
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.
|
453
|
+
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.key === TAB_KEY) && dropdownMenu.contains(event.target)) {
|
411
454
|
continue;
|
412
455
|
}
|
413
456
|
|
414
|
-
var hideEvent =
|
415
|
-
$__default["default"](parent).trigger(hideEvent);
|
457
|
+
var hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
|
416
458
|
|
417
|
-
if (hideEvent.
|
459
|
+
if (hideEvent.defaultPrevented) {
|
418
460
|
continue;
|
419
461
|
} // If this is a touch-enabled device we remove the extra
|
420
462
|
// empty mouseover listeners we added for iOS support
|
421
463
|
|
422
464
|
|
423
465
|
if ('ontouchstart' in document.documentElement) {
|
424
|
-
|
466
|
+
var _ref2;
|
467
|
+
|
468
|
+
(_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) {
|
469
|
+
return EventHandler.off(elem, 'mouseover', null, noop());
|
470
|
+
});
|
425
471
|
}
|
426
472
|
|
427
473
|
toggles[i].setAttribute('aria-expanded', 'false');
|
@@ -430,24 +476,17 @@
|
|
430
476
|
context._popper.destroy();
|
431
477
|
}
|
432
478
|
|
433
|
-
|
434
|
-
|
479
|
+
dropdownMenu.classList.remove(CLASS_NAME_SHOW);
|
480
|
+
toggles[i].classList.remove(CLASS_NAME_SHOW);
|
481
|
+
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
|
435
482
|
}
|
436
483
|
};
|
437
484
|
|
438
|
-
Dropdown.
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
if (selector) {
|
443
|
-
parent = document.querySelector(selector);
|
444
|
-
}
|
445
|
-
|
446
|
-
return parent || element.parentNode;
|
447
|
-
} // eslint-disable-next-line complexity
|
448
|
-
;
|
485
|
+
Dropdown.getParentFromElement = function getParentFromElement(element) {
|
486
|
+
return getElementFromSelector(element) || element.parentNode;
|
487
|
+
};
|
449
488
|
|
450
|
-
Dropdown.
|
489
|
+
Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) {
|
451
490
|
// If not input/textarea:
|
452
491
|
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
|
453
492
|
// If input/textarea:
|
@@ -455,61 +494,59 @@
|
|
455
494
|
// - If key is other than escape
|
456
495
|
// - If key is not up or down => not a dropdown command
|
457
496
|
// - If trigger inside the menu => not a dropdown command
|
458
|
-
if (/input|textarea/i.test(event.target.tagName) ? event.
|
497
|
+
if (/input|textarea/i.test(event.target.tagName) ? event.key === SPACE_KEY || event.key !== ESCAPE_KEY && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) {
|
459
498
|
return;
|
460
499
|
}
|
461
500
|
|
462
|
-
|
501
|
+
event.preventDefault();
|
502
|
+
event.stopPropagation();
|
503
|
+
|
504
|
+
if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED)) {
|
463
505
|
return;
|
464
506
|
}
|
465
507
|
|
466
|
-
var parent = Dropdown.
|
467
|
-
|
468
|
-
var isActive = $__default["default"](parent).hasClass(CLASS_NAME_SHOW);
|
508
|
+
var parent = Dropdown.getParentFromElement(this);
|
509
|
+
var isActive = this.classList.contains(CLASS_NAME_SHOW);
|
469
510
|
|
470
|
-
if (
|
511
|
+
if (event.key === ESCAPE_KEY) {
|
512
|
+
var button = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0];
|
513
|
+
button.focus();
|
514
|
+
Dropdown.clearMenus();
|
471
515
|
return;
|
472
516
|
}
|
473
517
|
|
474
|
-
event.
|
475
|
-
|
476
|
-
|
477
|
-
if (!isActive || event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE) {
|
478
|
-
if (event.which === ESCAPE_KEYCODE) {
|
479
|
-
$__default["default"](parent.querySelector(SELECTOR_DATA_TOGGLE)).trigger('focus');
|
480
|
-
}
|
481
|
-
|
482
|
-
$__default["default"](this).trigger('click');
|
518
|
+
if (!isActive || event.key === SPACE_KEY) {
|
519
|
+
Dropdown.clearMenus();
|
483
520
|
return;
|
484
521
|
}
|
485
522
|
|
486
|
-
var items =
|
487
|
-
return $__default["default"](item).is(':visible');
|
488
|
-
});
|
523
|
+
var items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible);
|
489
524
|
|
490
|
-
if (items.length
|
525
|
+
if (!items.length) {
|
491
526
|
return;
|
492
527
|
}
|
493
528
|
|
494
529
|
var index = items.indexOf(event.target);
|
495
530
|
|
496
|
-
if (event.
|
531
|
+
if (event.key === ARROW_UP_KEY && index > 0) {
|
497
532
|
// Up
|
498
533
|
index--;
|
499
534
|
}
|
500
535
|
|
501
|
-
if (event.
|
536
|
+
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
|
502
537
|
// Down
|
503
538
|
index++;
|
504
|
-
}
|
539
|
+
} // index is -1 if the first keydown is an ArrowUp
|
505
540
|
|
506
|
-
if (index < 0) {
|
507
|
-
index = 0;
|
508
|
-
}
|
509
541
|
|
542
|
+
index = index === -1 ? 0 : index;
|
510
543
|
items[index].focus();
|
511
544
|
};
|
512
545
|
|
546
|
+
Dropdown.getInstance = function getInstance(element) {
|
547
|
+
return Data.getData(element, DATA_KEY);
|
548
|
+
};
|
549
|
+
|
513
550
|
_createClass(Dropdown, null, [{
|
514
551
|
key: "VERSION",
|
515
552
|
get: function get() {
|
@@ -530,30 +567,45 @@
|
|
530
567
|
return Dropdown;
|
531
568
|
}();
|
532
569
|
/**
|
533
|
-
*
|
570
|
+
* ------------------------------------------------------------------------
|
571
|
+
* Data Api implementation
|
572
|
+
* ------------------------------------------------------------------------
|
534
573
|
*/
|
535
574
|
|
536
575
|
|
537
|
-
|
576
|
+
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
|
577
|
+
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
|
578
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
|
579
|
+
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
|
580
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
538
581
|
event.preventDefault();
|
539
582
|
event.stopPropagation();
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
e.stopPropagation();
|
583
|
+
Dropdown.dropdownInterface(this, 'toggle');
|
584
|
+
});
|
585
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, function (e) {
|
586
|
+
return e.stopPropagation();
|
544
587
|
});
|
588
|
+
var $ = getjQuery();
|
545
589
|
/**
|
590
|
+
* ------------------------------------------------------------------------
|
546
591
|
* jQuery
|
592
|
+
* ------------------------------------------------------------------------
|
593
|
+
* add .dropdown to jQuery only if jQuery is present
|
547
594
|
*/
|
548
595
|
|
549
|
-
|
550
|
-
$__default["default"].fn[NAME].Constructor = Dropdown;
|
596
|
+
/* istanbul ignore if */
|
551
597
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
598
|
+
if ($) {
|
599
|
+
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
600
|
+
$.fn[NAME] = Dropdown.jQueryInterface;
|
601
|
+
$.fn[NAME].Constructor = Dropdown;
|
602
|
+
|
603
|
+
$.fn[NAME].noConflict = function () {
|
604
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
605
|
+
return Dropdown.jQueryInterface;
|
606
|
+
};
|
607
|
+
}
|
556
608
|
|
557
609
|
return Dropdown;
|
558
610
|
|
559
|
-
}));
|
611
|
+
})));
|