bootstrap 4.5.2 → 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/README.md +1 -1
- data/assets/javascripts/bootstrap-sprockets.js +12 -8
- data/assets/javascripts/bootstrap.js +1876 -1220
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/javascripts/bootstrap/alert.js +133 -48
- data/assets/javascripts/bootstrap/button.js +56 -123
- data/assets/javascripts/bootstrap/carousel.js +268 -129
- data/assets/javascripts/bootstrap/collapse.js +285 -106
- 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 +235 -161
- data/assets/javascripts/bootstrap/modal.js +322 -193
- data/assets/javascripts/bootstrap/popover.js +72 -41
- data/assets/javascripts/bootstrap/scrollspy.js +151 -56
- data/assets/javascripts/bootstrap/tab.js +151 -64
- data/assets/javascripts/bootstrap/toast.js +163 -65
- data/assets/javascripts/bootstrap/tooltip.js +336 -155
- data/assets/stylesheets/_bootstrap-grid.scss +51 -15
- data/assets/stylesheets/_bootstrap-reboot.scss +4 -1
- data/assets/stylesheets/_bootstrap.scss +14 -8
- data/assets/stylesheets/bootstrap/_alert.scss +3 -3
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +3 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
- data/assets/stylesheets/bootstrap/_buttons.scss +27 -45
- data/assets/stylesheets/bootstrap/_card.scss +18 -64
- data/assets/stylesheets/bootstrap/_carousel.scss +13 -15
- data/assets/stylesheets/bootstrap/_close.scss +9 -13
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +10 -7
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +82 -20
- data/assets/stylesheets/bootstrap/_grid.scss +3 -54
- data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +6 -3
- data/assets/stylesheets/bootstrap/_mixins.scss +6 -12
- data/assets/stylesheets/bootstrap/_modal.scss +34 -39
- data/assets/stylesheets/bootstrap/_nav.scss +8 -8
- data/assets/stylesheets/bootstrap/_navbar.scss +42 -74
- data/assets/stylesheets/bootstrap/_pagination.scss +7 -20
- data/assets/stylesheets/bootstrap/_popover.scss +5 -5
- data/assets/stylesheets/bootstrap/_progress.scss +2 -4
- data/assets/stylesheets/bootstrap/_reboot.scss +300 -164
- data/assets/stylesheets/bootstrap/_root.scss +5 -9
- data/assets/stylesheets/bootstrap/_spinners.scss +2 -2
- data/assets/stylesheets/bootstrap/_tables.scss +80 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +2 -4
- data/assets/stylesheets/bootstrap/_tooltip.scss +5 -5
- data/assets/stylesheets/bootstrap/_transitions.scss +0 -1
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +503 -18
- data/assets/stylesheets/bootstrap/_variables.scss +544 -424
- 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/{utilities → helpers}/_clearfix.scss +0 -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/_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 +22 -67
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +84 -32
- 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 +2 -2
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +16 -22
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +1 -1
- 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 +234 -126
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +3 -3
- metadata +31 -39
- data/assets/javascripts/bootstrap/util.js +0 -192
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -523
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -192
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -141
- 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
@@ -1,18 +1,147 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap modal.js
|
2
|
+
* Bootstrap modal.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
3
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
|
-
}(this, (function (
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) :
|
9
|
+
(global = global || self, global.Modal = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine));
|
10
|
+
}(this, (function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
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
|
+
SelectorEngine = SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default') ? SelectorEngine['default'] : SelectorEngine;
|
14
16
|
|
15
|
-
|
17
|
+
/**
|
18
|
+
* --------------------------------------------------------------------------
|
19
|
+
* Bootstrap (v5.0.0-alpha1): util/index.js
|
20
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
21
|
+
* --------------------------------------------------------------------------
|
22
|
+
*/
|
23
|
+
var MILLISECONDS_MULTIPLIER = 1000;
|
24
|
+
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
25
|
+
|
26
|
+
var toType = function toType(obj) {
|
27
|
+
if (obj === null || obj === undefined) {
|
28
|
+
return "" + obj;
|
29
|
+
}
|
30
|
+
|
31
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
32
|
+
};
|
33
|
+
|
34
|
+
var getSelector = function getSelector(element) {
|
35
|
+
var selector = element.getAttribute('data-target');
|
36
|
+
|
37
|
+
if (!selector || selector === '#') {
|
38
|
+
var hrefAttr = element.getAttribute('href');
|
39
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
40
|
+
}
|
41
|
+
|
42
|
+
return selector;
|
43
|
+
};
|
44
|
+
|
45
|
+
var getElementFromSelector = function getElementFromSelector(element) {
|
46
|
+
var selector = getSelector(element);
|
47
|
+
return selector ? document.querySelector(selector) : null;
|
48
|
+
};
|
49
|
+
|
50
|
+
var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
|
51
|
+
if (!element) {
|
52
|
+
return 0;
|
53
|
+
} // Get transition-duration of the element
|
54
|
+
|
55
|
+
|
56
|
+
var _window$getComputedSt = window.getComputedStyle(element),
|
57
|
+
transitionDuration = _window$getComputedSt.transitionDuration,
|
58
|
+
transitionDelay = _window$getComputedSt.transitionDelay;
|
59
|
+
|
60
|
+
var floatTransitionDuration = parseFloat(transitionDuration);
|
61
|
+
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
62
|
+
|
63
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
64
|
+
return 0;
|
65
|
+
} // If multiple durations are defined, take the first
|
66
|
+
|
67
|
+
|
68
|
+
transitionDuration = transitionDuration.split(',')[0];
|
69
|
+
transitionDelay = transitionDelay.split(',')[0];
|
70
|
+
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
71
|
+
};
|
72
|
+
|
73
|
+
var triggerTransitionEnd = function triggerTransitionEnd(element) {
|
74
|
+
element.dispatchEvent(new Event(TRANSITION_END));
|
75
|
+
};
|
76
|
+
|
77
|
+
var isElement = function isElement(obj) {
|
78
|
+
return (obj[0] || obj).nodeType;
|
79
|
+
};
|
80
|
+
|
81
|
+
var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
|
82
|
+
var called = false;
|
83
|
+
var durationPadding = 5;
|
84
|
+
var emulatedDuration = duration + durationPadding;
|
85
|
+
|
86
|
+
function listener() {
|
87
|
+
called = true;
|
88
|
+
element.removeEventListener(TRANSITION_END, listener);
|
89
|
+
}
|
90
|
+
|
91
|
+
element.addEventListener(TRANSITION_END, listener);
|
92
|
+
setTimeout(function () {
|
93
|
+
if (!called) {
|
94
|
+
triggerTransitionEnd(element);
|
95
|
+
}
|
96
|
+
}, emulatedDuration);
|
97
|
+
};
|
98
|
+
|
99
|
+
var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
|
100
|
+
Object.keys(configTypes).forEach(function (property) {
|
101
|
+
var expectedTypes = configTypes[property];
|
102
|
+
var value = config[property];
|
103
|
+
var valueType = value && isElement(value) ? 'element' : toType(value);
|
104
|
+
|
105
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
106
|
+
throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
|
107
|
+
}
|
108
|
+
});
|
109
|
+
};
|
110
|
+
|
111
|
+
var isVisible = function isVisible(element) {
|
112
|
+
if (!element) {
|
113
|
+
return false;
|
114
|
+
}
|
115
|
+
|
116
|
+
if (element.style && element.parentNode && element.parentNode.style) {
|
117
|
+
var elementStyle = getComputedStyle(element);
|
118
|
+
var parentNodeStyle = getComputedStyle(element.parentNode);
|
119
|
+
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
|
120
|
+
}
|
121
|
+
|
122
|
+
return false;
|
123
|
+
};
|
124
|
+
|
125
|
+
var reflow = function reflow(element) {
|
126
|
+
return element.offsetHeight;
|
127
|
+
};
|
128
|
+
|
129
|
+
var getjQuery = function getjQuery() {
|
130
|
+
var _window = window,
|
131
|
+
jQuery = _window.jQuery;
|
132
|
+
|
133
|
+
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
|
134
|
+
return jQuery;
|
135
|
+
}
|
136
|
+
|
137
|
+
return null;
|
138
|
+
};
|
139
|
+
|
140
|
+
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; }
|
141
|
+
|
142
|
+
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; }
|
143
|
+
|
144
|
+
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; }
|
16
145
|
|
17
146
|
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); } }
|
18
147
|
|
@@ -24,13 +153,11 @@
|
|
24
153
|
*/
|
25
154
|
|
26
155
|
var NAME = 'modal';
|
27
|
-
var VERSION = '
|
156
|
+
var VERSION = '5.0.0-alpha1';
|
28
157
|
var DATA_KEY = 'bs.modal';
|
29
158
|
var EVENT_KEY = "." + DATA_KEY;
|
30
159
|
var DATA_API_KEY = '.data-api';
|
31
|
-
var
|
32
|
-
var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
|
33
|
-
|
160
|
+
var ESCAPE_KEY = 'Escape';
|
34
161
|
var Default = {
|
35
162
|
backdrop: true,
|
36
163
|
keyboard: true,
|
@@ -55,7 +182,6 @@
|
|
55
182
|
var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY;
|
56
183
|
var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY;
|
57
184
|
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
58
|
-
var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
|
59
185
|
var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
|
60
186
|
var CLASS_NAME_BACKDROP = 'modal-backdrop';
|
61
187
|
var CLASS_NAME_OPEN = 'modal-open';
|
@@ -78,13 +204,14 @@
|
|
78
204
|
function Modal(element, config) {
|
79
205
|
this._config = this._getConfig(config);
|
80
206
|
this._element = element;
|
81
|
-
this._dialog =
|
207
|
+
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
|
82
208
|
this._backdrop = null;
|
83
209
|
this._isShown = false;
|
84
210
|
this._isBodyOverflowing = false;
|
85
211
|
this._ignoreBackdropClick = false;
|
86
212
|
this._isTransitioning = false;
|
87
213
|
this._scrollbarWidth = 0;
|
214
|
+
Data.setData(element, DATA_KEY, this);
|
88
215
|
} // Getters
|
89
216
|
|
90
217
|
|
@@ -102,16 +229,15 @@
|
|
102
229
|
return;
|
103
230
|
}
|
104
231
|
|
105
|
-
if (
|
232
|
+
if (this._element.classList.contains(CLASS_NAME_FADE)) {
|
106
233
|
this._isTransitioning = true;
|
107
234
|
}
|
108
235
|
|
109
|
-
var showEvent =
|
236
|
+
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
|
110
237
|
relatedTarget: relatedTarget
|
111
238
|
});
|
112
|
-
$(this._element).trigger(showEvent);
|
113
239
|
|
114
|
-
if (this._isShown || showEvent.
|
240
|
+
if (this._isShown || showEvent.defaultPrevented) {
|
115
241
|
return;
|
116
242
|
}
|
117
243
|
|
@@ -127,12 +253,12 @@
|
|
127
253
|
|
128
254
|
this._setResizeEvent();
|
129
255
|
|
130
|
-
|
256
|
+
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
|
131
257
|
return _this.hide(event);
|
132
258
|
});
|
133
|
-
|
134
|
-
|
135
|
-
if (
|
259
|
+
EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, function () {
|
260
|
+
EventHandler.one(_this._element, EVENT_MOUSEUP_DISMISS, function (event) {
|
261
|
+
if (event.target === _this._element) {
|
136
262
|
_this._ignoreBackdropClick = true;
|
137
263
|
}
|
138
264
|
});
|
@@ -154,15 +280,15 @@
|
|
154
280
|
return;
|
155
281
|
}
|
156
282
|
|
157
|
-
var hideEvent =
|
158
|
-
$(this._element).trigger(hideEvent);
|
283
|
+
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
|
159
284
|
|
160
|
-
if (
|
285
|
+
if (hideEvent.defaultPrevented) {
|
161
286
|
return;
|
162
287
|
}
|
163
288
|
|
164
289
|
this._isShown = false;
|
165
|
-
|
290
|
+
|
291
|
+
var transition = this._element.classList.contains(CLASS_NAME_FADE);
|
166
292
|
|
167
293
|
if (transition) {
|
168
294
|
this._isTransitioning = true;
|
@@ -172,16 +298,19 @@
|
|
172
298
|
|
173
299
|
this._setResizeEvent();
|
174
300
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
301
|
+
EventHandler.off(document, EVENT_FOCUSIN);
|
302
|
+
|
303
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
304
|
+
|
305
|
+
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
|
306
|
+
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
|
179
307
|
|
180
308
|
if (transition) {
|
181
|
-
var transitionDuration =
|
182
|
-
|
309
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
310
|
+
EventHandler.one(this._element, TRANSITION_END, function (event) {
|
183
311
|
return _this2._hideModal(event);
|
184
|
-
})
|
312
|
+
});
|
313
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
185
314
|
} else {
|
186
315
|
this._hideModal();
|
187
316
|
}
|
@@ -189,7 +318,7 @@
|
|
189
318
|
|
190
319
|
_proto.dispose = function dispose() {
|
191
320
|
[window, this._element, this._dialog].forEach(function (htmlElement) {
|
192
|
-
return
|
321
|
+
return EventHandler.off(htmlElement, EVENT_KEY);
|
193
322
|
});
|
194
323
|
/**
|
195
324
|
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
|
@@ -197,8 +326,8 @@
|
|
197
326
|
* It will remove `EVENT_CLICK_DATA_API` event that should remain
|
198
327
|
*/
|
199
328
|
|
200
|
-
|
201
|
-
|
329
|
+
EventHandler.off(document, EVENT_FOCUSIN);
|
330
|
+
Data.removeData(this._element, DATA_KEY);
|
202
331
|
this._config = null;
|
203
332
|
this._element = null;
|
204
333
|
this._dialog = null;
|
@@ -216,53 +345,17 @@
|
|
216
345
|
;
|
217
346
|
|
218
347
|
_proto._getConfig = function _getConfig(config) {
|
219
|
-
config =
|
220
|
-
|
348
|
+
config = _objectSpread(_objectSpread({}, Default), config);
|
349
|
+
typeCheckConfig(NAME, config, DefaultType);
|
221
350
|
return config;
|
222
351
|
};
|
223
352
|
|
224
|
-
_proto.
|
353
|
+
_proto._showElement = function _showElement(relatedTarget) {
|
225
354
|
var _this3 = this;
|
226
355
|
|
227
|
-
|
228
|
-
var hideEventPrevented = $.Event(EVENT_HIDE_PREVENTED);
|
229
|
-
$(this._element).trigger(hideEventPrevented);
|
230
|
-
|
231
|
-
if (hideEventPrevented.defaultPrevented) {
|
232
|
-
return;
|
233
|
-
}
|
234
|
-
|
235
|
-
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
|
236
|
-
|
237
|
-
if (!isModalOverflowing) {
|
238
|
-
this._element.style.overflowY = 'hidden';
|
239
|
-
}
|
240
|
-
|
241
|
-
this._element.classList.add(CLASS_NAME_STATIC);
|
242
|
-
|
243
|
-
var modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog);
|
244
|
-
$(this._element).off(Util.TRANSITION_END);
|
245
|
-
$(this._element).one(Util.TRANSITION_END, function () {
|
246
|
-
_this3._element.classList.remove(CLASS_NAME_STATIC);
|
247
|
-
|
248
|
-
if (!isModalOverflowing) {
|
249
|
-
$(_this3._element).one(Util.TRANSITION_END, function () {
|
250
|
-
_this3._element.style.overflowY = '';
|
251
|
-
}).emulateTransitionEnd(_this3._element, modalTransitionDuration);
|
252
|
-
}
|
253
|
-
}).emulateTransitionEnd(modalTransitionDuration);
|
254
|
-
|
255
|
-
this._element.focus();
|
256
|
-
} else {
|
257
|
-
this.hide();
|
258
|
-
}
|
259
|
-
};
|
356
|
+
var transition = this._element.classList.contains(CLASS_NAME_FADE);
|
260
357
|
|
261
|
-
|
262
|
-
var _this4 = this;
|
263
|
-
|
264
|
-
var transition = $(this._element).hasClass(CLASS_NAME_FADE);
|
265
|
-
var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
|
358
|
+
var modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
|
266
359
|
|
267
360
|
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
268
361
|
// Don't move modal's DOM position
|
@@ -277,86 +370,86 @@
|
|
277
370
|
|
278
371
|
this._element.setAttribute('role', 'dialog');
|
279
372
|
|
280
|
-
|
373
|
+
this._element.scrollTop = 0;
|
374
|
+
|
375
|
+
if (modalBody) {
|
281
376
|
modalBody.scrollTop = 0;
|
282
|
-
} else {
|
283
|
-
this._element.scrollTop = 0;
|
284
377
|
}
|
285
378
|
|
286
379
|
if (transition) {
|
287
|
-
|
380
|
+
reflow(this._element);
|
288
381
|
}
|
289
382
|
|
290
|
-
|
383
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
291
384
|
|
292
385
|
if (this._config.focus) {
|
293
386
|
this._enforceFocus();
|
294
387
|
}
|
295
388
|
|
296
|
-
var shownEvent = $.Event(EVENT_SHOWN, {
|
297
|
-
relatedTarget: relatedTarget
|
298
|
-
});
|
299
|
-
|
300
389
|
var transitionComplete = function transitionComplete() {
|
301
|
-
if (
|
302
|
-
|
390
|
+
if (_this3._config.focus) {
|
391
|
+
_this3._element.focus();
|
303
392
|
}
|
304
393
|
|
305
|
-
|
306
|
-
|
394
|
+
_this3._isTransitioning = false;
|
395
|
+
EventHandler.trigger(_this3._element, EVENT_SHOWN, {
|
396
|
+
relatedTarget: relatedTarget
|
397
|
+
});
|
307
398
|
};
|
308
399
|
|
309
400
|
if (transition) {
|
310
|
-
var transitionDuration =
|
311
|
-
|
401
|
+
var transitionDuration = getTransitionDurationFromElement(this._dialog);
|
402
|
+
EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
|
403
|
+
emulateTransitionEnd(this._dialog, transitionDuration);
|
312
404
|
} else {
|
313
405
|
transitionComplete();
|
314
406
|
}
|
315
407
|
};
|
316
408
|
|
317
409
|
_proto._enforceFocus = function _enforceFocus() {
|
318
|
-
var
|
410
|
+
var _this4 = this;
|
411
|
+
|
412
|
+
EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop
|
319
413
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
_this5._element.focus();
|
414
|
+
EventHandler.on(document, EVENT_FOCUSIN, function (event) {
|
415
|
+
if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) {
|
416
|
+
_this4._element.focus();
|
324
417
|
}
|
325
418
|
});
|
326
419
|
};
|
327
420
|
|
328
421
|
_proto._setEscapeEvent = function _setEscapeEvent() {
|
329
|
-
var
|
422
|
+
var _this5 = this;
|
330
423
|
|
331
424
|
if (this._isShown) {
|
332
|
-
|
333
|
-
if (
|
425
|
+
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
|
426
|
+
if (_this5._config.keyboard && event.key === ESCAPE_KEY) {
|
334
427
|
event.preventDefault();
|
335
428
|
|
336
|
-
|
337
|
-
} else if (!
|
338
|
-
|
429
|
+
_this5.hide();
|
430
|
+
} else if (!_this5._config.keyboard && event.key === ESCAPE_KEY) {
|
431
|
+
_this5._triggerBackdropTransition();
|
339
432
|
}
|
340
433
|
});
|
341
|
-
} else
|
342
|
-
|
434
|
+
} else {
|
435
|
+
EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
|
343
436
|
}
|
344
437
|
};
|
345
438
|
|
346
439
|
_proto._setResizeEvent = function _setResizeEvent() {
|
347
|
-
var
|
440
|
+
var _this6 = this;
|
348
441
|
|
349
442
|
if (this._isShown) {
|
350
|
-
|
351
|
-
return
|
443
|
+
EventHandler.on(window, EVENT_RESIZE, function () {
|
444
|
+
return _this6._adjustDialog();
|
352
445
|
});
|
353
446
|
} else {
|
354
|
-
|
447
|
+
EventHandler.off(window, EVENT_RESIZE);
|
355
448
|
}
|
356
449
|
};
|
357
450
|
|
358
451
|
_proto._hideModal = function _hideModal() {
|
359
|
-
var
|
452
|
+
var _this7 = this;
|
360
453
|
|
361
454
|
this._element.style.display = 'none';
|
362
455
|
|
@@ -369,27 +462,26 @@
|
|
369
462
|
this._isTransitioning = false;
|
370
463
|
|
371
464
|
this._showBackdrop(function () {
|
372
|
-
|
465
|
+
document.body.classList.remove(CLASS_NAME_OPEN);
|
373
466
|
|
374
|
-
|
467
|
+
_this7._resetAdjustments();
|
375
468
|
|
376
|
-
|
469
|
+
_this7._resetScrollbar();
|
377
470
|
|
378
|
-
|
471
|
+
EventHandler.trigger(_this7._element, EVENT_HIDDEN);
|
379
472
|
});
|
380
473
|
};
|
381
474
|
|
382
475
|
_proto._removeBackdrop = function _removeBackdrop() {
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
}
|
476
|
+
this._backdrop.parentNode.removeChild(this._backdrop);
|
477
|
+
|
478
|
+
this._backdrop = null;
|
387
479
|
};
|
388
480
|
|
389
481
|
_proto._showBackdrop = function _showBackdrop(callback) {
|
390
|
-
var
|
482
|
+
var _this8 = this;
|
391
483
|
|
392
|
-
var animate =
|
484
|
+
var animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
|
393
485
|
|
394
486
|
if (this._isShown && this._config.backdrop) {
|
395
487
|
this._backdrop = document.createElement('div');
|
@@ -399,10 +491,10 @@
|
|
399
491
|
this._backdrop.classList.add(animate);
|
400
492
|
}
|
401
493
|
|
402
|
-
|
403
|
-
|
404
|
-
if (
|
405
|
-
|
494
|
+
document.body.appendChild(this._backdrop);
|
495
|
+
EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) {
|
496
|
+
if (_this8._ignoreBackdropClick) {
|
497
|
+
_this8._ignoreBackdropClick = false;
|
406
498
|
return;
|
407
499
|
}
|
408
500
|
|
@@ -410,50 +502,69 @@
|
|
410
502
|
return;
|
411
503
|
}
|
412
504
|
|
413
|
-
|
505
|
+
_this8._triggerBackdropTransition();
|
414
506
|
});
|
415
507
|
|
416
508
|
if (animate) {
|
417
|
-
|
509
|
+
reflow(this._backdrop);
|
418
510
|
}
|
419
511
|
|
420
|
-
|
421
|
-
|
422
|
-
if (!callback) {
|
423
|
-
return;
|
424
|
-
}
|
512
|
+
this._backdrop.classList.add(CLASS_NAME_SHOW);
|
425
513
|
|
426
514
|
if (!animate) {
|
427
515
|
callback();
|
428
516
|
return;
|
429
517
|
}
|
430
518
|
|
431
|
-
var backdropTransitionDuration =
|
432
|
-
|
519
|
+
var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
|
520
|
+
EventHandler.one(this._backdrop, TRANSITION_END, callback);
|
521
|
+
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
|
433
522
|
} else if (!this._isShown && this._backdrop) {
|
434
|
-
|
523
|
+
this._backdrop.classList.remove(CLASS_NAME_SHOW);
|
435
524
|
|
436
525
|
var callbackRemove = function callbackRemove() {
|
437
|
-
|
526
|
+
_this8._removeBackdrop();
|
438
527
|
|
439
|
-
|
440
|
-
callback();
|
441
|
-
}
|
528
|
+
callback();
|
442
529
|
};
|
443
530
|
|
444
|
-
if (
|
445
|
-
var _backdropTransitionDuration =
|
531
|
+
if (this._element.classList.contains(CLASS_NAME_FADE)) {
|
532
|
+
var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
|
446
533
|
|
447
|
-
|
534
|
+
EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
|
535
|
+
emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
|
448
536
|
} else {
|
449
537
|
callbackRemove();
|
450
538
|
}
|
451
|
-
} else
|
539
|
+
} else {
|
452
540
|
callback();
|
453
541
|
}
|
542
|
+
};
|
543
|
+
|
544
|
+
_proto._triggerBackdropTransition = function _triggerBackdropTransition() {
|
545
|
+
var _this9 = this;
|
546
|
+
|
547
|
+
if (this._config.backdrop === 'static') {
|
548
|
+
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
|
549
|
+
|
550
|
+
if (hideEvent.defaultPrevented) {
|
551
|
+
return;
|
552
|
+
}
|
553
|
+
|
554
|
+
this._element.classList.add(CLASS_NAME_STATIC);
|
555
|
+
|
556
|
+
var modalTransitionDuration = getTransitionDurationFromElement(this._element);
|
557
|
+
EventHandler.one(this._element, TRANSITION_END, function () {
|
558
|
+
_this9._element.classList.remove(CLASS_NAME_STATIC);
|
559
|
+
});
|
560
|
+
emulateTransitionEnd(this._element, modalTransitionDuration);
|
561
|
+
|
562
|
+
this._element.focus();
|
563
|
+
} else {
|
564
|
+
this.hide();
|
565
|
+
}
|
454
566
|
} // ----------------------------------------------------------------------
|
455
567
|
// the following methods are used to handle overflowing modals
|
456
|
-
// todo (fat): these should probably be refactored out of modal.js
|
457
568
|
// ----------------------------------------------------------------------
|
458
569
|
;
|
459
570
|
|
@@ -486,50 +597,58 @@
|
|
486
597
|
if (this._isBodyOverflowing) {
|
487
598
|
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
|
488
599
|
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
$(fixedContent).each(function (index, element) {
|
600
|
+
// Adjust fixed content padding
|
601
|
+
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
|
493
602
|
var actualPadding = element.style.paddingRight;
|
494
|
-
var calculatedPadding =
|
495
|
-
|
603
|
+
var calculatedPadding = window.getComputedStyle(element)['padding-right'];
|
604
|
+
Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
|
605
|
+
element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px";
|
496
606
|
}); // Adjust sticky content margin
|
497
607
|
|
498
|
-
|
608
|
+
SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
|
499
609
|
var actualMargin = element.style.marginRight;
|
500
|
-
var calculatedMargin =
|
501
|
-
|
610
|
+
var calculatedMargin = window.getComputedStyle(element)['margin-right'];
|
611
|
+
Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
|
612
|
+
element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
|
502
613
|
}); // Adjust body padding
|
503
614
|
|
504
615
|
var actualPadding = document.body.style.paddingRight;
|
505
|
-
var calculatedPadding =
|
506
|
-
|
616
|
+
var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
|
617
|
+
Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
|
618
|
+
document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
|
507
619
|
}
|
508
620
|
|
509
|
-
|
621
|
+
document.body.classList.add(CLASS_NAME_OPEN);
|
510
622
|
};
|
511
623
|
|
512
624
|
_proto._resetScrollbar = function _resetScrollbar() {
|
513
625
|
// Restore fixed content padding
|
514
|
-
|
515
|
-
|
516
|
-
var padding = $(element).data('padding-right');
|
517
|
-
$(element).removeData('padding-right');
|
518
|
-
element.style.paddingRight = padding ? padding : '';
|
519
|
-
}); // Restore sticky content
|
626
|
+
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
|
627
|
+
var padding = Manipulator.getDataAttribute(element, 'padding-right');
|
520
628
|
|
521
|
-
|
522
|
-
|
523
|
-
|
629
|
+
if (typeof padding !== 'undefined') {
|
630
|
+
Manipulator.removeDataAttribute(element, 'padding-right');
|
631
|
+
element.style.paddingRight = padding;
|
632
|
+
}
|
633
|
+
}); // Restore sticky content and navbar-toggler margin
|
634
|
+
|
635
|
+
SelectorEngine.find("" + SELECTOR_STICKY_CONTENT).forEach(function (element) {
|
636
|
+
var margin = Manipulator.getDataAttribute(element, 'margin-right');
|
524
637
|
|
525
638
|
if (typeof margin !== 'undefined') {
|
526
|
-
|
639
|
+
Manipulator.removeDataAttribute(element, 'margin-right');
|
640
|
+
element.style.marginRight = margin;
|
527
641
|
}
|
528
642
|
}); // Restore body padding
|
529
643
|
|
530
|
-
var padding =
|
531
|
-
|
532
|
-
|
644
|
+
var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
|
645
|
+
|
646
|
+
if (typeof padding === 'undefined') {
|
647
|
+
document.body.style.paddingRight = '';
|
648
|
+
} else {
|
649
|
+
Manipulator.removeDataAttribute(document.body, 'padding-right');
|
650
|
+
document.body.style.paddingRight = padding;
|
651
|
+
}
|
533
652
|
};
|
534
653
|
|
535
654
|
_proto._getScrollbarWidth = function _getScrollbarWidth() {
|
@@ -543,15 +662,14 @@
|
|
543
662
|
} // Static
|
544
663
|
;
|
545
664
|
|
546
|
-
Modal.
|
665
|
+
Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
|
547
666
|
return this.each(function () {
|
548
|
-
var data =
|
667
|
+
var data = Data.getData(this, DATA_KEY);
|
549
668
|
|
550
|
-
var _config =
|
669
|
+
var _config = _objectSpread(_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(this)), typeof config === 'object' && config ? config : {});
|
551
670
|
|
552
671
|
if (!data) {
|
553
672
|
data = new Modal(this, _config);
|
554
|
-
$(this).data(DATA_KEY, data);
|
555
673
|
}
|
556
674
|
|
557
675
|
if (typeof config === 'string') {
|
@@ -566,6 +684,10 @@
|
|
566
684
|
});
|
567
685
|
};
|
568
686
|
|
687
|
+
Modal.getInstance = function getInstance(element) {
|
688
|
+
return Data.getData(element, DATA_KEY);
|
689
|
+
};
|
690
|
+
|
569
691
|
_createClass(Modal, null, [{
|
570
692
|
key: "VERSION",
|
571
693
|
get: function get() {
|
@@ -587,50 +709,57 @@
|
|
587
709
|
*/
|
588
710
|
|
589
711
|
|
590
|
-
|
712
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
591
713
|
var _this11 = this;
|
592
714
|
|
593
|
-
var target;
|
594
|
-
var selector = Util.getSelectorFromElement(this);
|
595
|
-
|
596
|
-
if (selector) {
|
597
|
-
target = document.querySelector(selector);
|
598
|
-
}
|
599
|
-
|
600
|
-
var config = $(target).data(DATA_KEY) ? 'toggle' : _extends({}, $(target).data(), $(this).data());
|
715
|
+
var target = getElementFromSelector(this);
|
601
716
|
|
602
717
|
if (this.tagName === 'A' || this.tagName === 'AREA') {
|
603
718
|
event.preventDefault();
|
604
719
|
}
|
605
720
|
|
606
|
-
|
607
|
-
if (showEvent.
|
608
|
-
//
|
721
|
+
EventHandler.one(target, EVENT_SHOW, function (showEvent) {
|
722
|
+
if (showEvent.defaultPrevented) {
|
723
|
+
// only register focus restorer if modal will actually get shown
|
609
724
|
return;
|
610
725
|
}
|
611
726
|
|
612
|
-
|
613
|
-
if (
|
727
|
+
EventHandler.one(target, EVENT_HIDDEN, function () {
|
728
|
+
if (isVisible(_this11)) {
|
614
729
|
_this11.focus();
|
615
730
|
}
|
616
731
|
});
|
617
732
|
});
|
733
|
+
var data = Data.getData(target, DATA_KEY);
|
618
734
|
|
619
|
-
|
735
|
+
if (!data) {
|
736
|
+
var config = _objectSpread(_objectSpread({}, Manipulator.getDataAttributes(target)), Manipulator.getDataAttributes(this));
|
737
|
+
|
738
|
+
data = new Modal(target, config);
|
739
|
+
}
|
740
|
+
|
741
|
+
data.show(this);
|
620
742
|
});
|
743
|
+
var $ = getjQuery();
|
621
744
|
/**
|
622
745
|
* ------------------------------------------------------------------------
|
623
746
|
* jQuery
|
624
747
|
* ------------------------------------------------------------------------
|
748
|
+
* add .modal to jQuery only if jQuery is present
|
625
749
|
*/
|
626
750
|
|
627
|
-
|
628
|
-
$.fn[NAME].Constructor = Modal;
|
751
|
+
/* istanbul ignore if */
|
629
752
|
|
630
|
-
|
631
|
-
$.fn[NAME]
|
632
|
-
|
633
|
-
|
753
|
+
if ($) {
|
754
|
+
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
755
|
+
$.fn[NAME] = Modal.jQueryInterface;
|
756
|
+
$.fn[NAME].Constructor = Modal;
|
757
|
+
|
758
|
+
$.fn[NAME].noConflict = function () {
|
759
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
760
|
+
return Modal.jQueryInterface;
|
761
|
+
};
|
762
|
+
}
|
634
763
|
|
635
764
|
return Modal;
|
636
765
|
|