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,74 +1,175 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap modal.js
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap modal.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
|
-
|
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
|
+
|
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;
|
16
|
+
|
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;
|
24
29
|
}
|
25
|
-
}
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
30
|
-
Object.defineProperty(Constructor, "prototype", {
|
31
|
-
writable: false
|
32
|
-
});
|
33
|
-
return Constructor;
|
34
|
-
}
|
31
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
32
|
+
};
|
35
33
|
|
36
|
-
function
|
37
|
-
|
38
|
-
for (var i = 1; i < arguments.length; i++) {
|
39
|
-
var source = arguments[i];
|
34
|
+
var getSelector = function getSelector(element) {
|
35
|
+
var selector = element.getAttribute('data-target');
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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);
|
46
95
|
}
|
96
|
+
}, emulatedDuration);
|
97
|
+
};
|
47
98
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
+
};
|
52
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; }
|
145
|
+
|
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); } }
|
147
|
+
|
148
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
53
149
|
/**
|
150
|
+
* ------------------------------------------------------------------------
|
54
151
|
* Constants
|
152
|
+
* ------------------------------------------------------------------------
|
55
153
|
*/
|
56
154
|
|
57
155
|
var NAME = 'modal';
|
58
|
-
var VERSION = '
|
156
|
+
var VERSION = '5.0.0-alpha1';
|
59
157
|
var DATA_KEY = 'bs.modal';
|
60
158
|
var EVENT_KEY = "." + DATA_KEY;
|
61
159
|
var DATA_API_KEY = '.data-api';
|
62
|
-
var
|
63
|
-
var
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
var
|
70
|
-
|
71
|
-
|
160
|
+
var ESCAPE_KEY = 'Escape';
|
161
|
+
var Default = {
|
162
|
+
backdrop: true,
|
163
|
+
keyboard: true,
|
164
|
+
focus: true,
|
165
|
+
show: true
|
166
|
+
};
|
167
|
+
var DefaultType = {
|
168
|
+
backdrop: '(boolean|string)',
|
169
|
+
keyboard: 'boolean',
|
170
|
+
focus: 'boolean',
|
171
|
+
show: 'boolean'
|
172
|
+
};
|
72
173
|
var EVENT_HIDE = "hide" + EVENT_KEY;
|
73
174
|
var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY;
|
74
175
|
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
@@ -81,39 +182,36 @@
|
|
81
182
|
var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY;
|
82
183
|
var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY;
|
83
184
|
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
185
|
+
var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
|
186
|
+
var CLASS_NAME_BACKDROP = 'modal-backdrop';
|
187
|
+
var CLASS_NAME_OPEN = 'modal-open';
|
188
|
+
var CLASS_NAME_FADE = 'fade';
|
189
|
+
var CLASS_NAME_SHOW = 'show';
|
190
|
+
var CLASS_NAME_STATIC = 'modal-static';
|
84
191
|
var SELECTOR_DIALOG = '.modal-dialog';
|
85
192
|
var SELECTOR_MODAL_BODY = '.modal-body';
|
86
193
|
var SELECTOR_DATA_TOGGLE = '[data-toggle="modal"]';
|
87
194
|
var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
|
88
195
|
var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
|
89
196
|
var SELECTOR_STICKY_CONTENT = '.sticky-top';
|
90
|
-
var Default = {
|
91
|
-
backdrop: true,
|
92
|
-
keyboard: true,
|
93
|
-
focus: true,
|
94
|
-
show: true
|
95
|
-
};
|
96
|
-
var DefaultType = {
|
97
|
-
backdrop: '(boolean|string)',
|
98
|
-
keyboard: 'boolean',
|
99
|
-
focus: 'boolean',
|
100
|
-
show: 'boolean'
|
101
|
-
};
|
102
197
|
/**
|
103
|
-
*
|
198
|
+
* ------------------------------------------------------------------------
|
199
|
+
* Class Definition
|
200
|
+
* ------------------------------------------------------------------------
|
104
201
|
*/
|
105
202
|
|
106
203
|
var Modal = /*#__PURE__*/function () {
|
107
204
|
function Modal(element, config) {
|
108
205
|
this._config = this._getConfig(config);
|
109
206
|
this._element = element;
|
110
|
-
this._dialog =
|
207
|
+
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
|
111
208
|
this._backdrop = null;
|
112
209
|
this._isShown = false;
|
113
210
|
this._isBodyOverflowing = false;
|
114
211
|
this._ignoreBackdropClick = false;
|
115
212
|
this._isTransitioning = false;
|
116
213
|
this._scrollbarWidth = 0;
|
214
|
+
Data.setData(element, DATA_KEY, this);
|
117
215
|
} // Getters
|
118
216
|
|
119
217
|
|
@@ -131,21 +229,20 @@
|
|
131
229
|
return;
|
132
230
|
}
|
133
231
|
|
134
|
-
|
232
|
+
if (this._element.classList.contains(CLASS_NAME_FADE)) {
|
233
|
+
this._isTransitioning = true;
|
234
|
+
}
|
235
|
+
|
236
|
+
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
|
135
237
|
relatedTarget: relatedTarget
|
136
238
|
});
|
137
|
-
$__default["default"](this._element).trigger(showEvent);
|
138
239
|
|
139
|
-
if (showEvent.
|
240
|
+
if (this._isShown || showEvent.defaultPrevented) {
|
140
241
|
return;
|
141
242
|
}
|
142
243
|
|
143
244
|
this._isShown = true;
|
144
245
|
|
145
|
-
if ($__default["default"](this._element).hasClass(CLASS_NAME_FADE)) {
|
146
|
-
this._isTransitioning = true;
|
147
|
-
}
|
148
|
-
|
149
246
|
this._checkScrollbar();
|
150
247
|
|
151
248
|
this._setScrollbar();
|
@@ -156,12 +253,12 @@
|
|
156
253
|
|
157
254
|
this._setResizeEvent();
|
158
255
|
|
159
|
-
|
256
|
+
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
|
160
257
|
return _this.hide(event);
|
161
258
|
});
|
162
|
-
|
163
|
-
|
164
|
-
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) {
|
165
262
|
_this._ignoreBackdropClick = true;
|
166
263
|
}
|
167
264
|
});
|
@@ -183,15 +280,15 @@
|
|
183
280
|
return;
|
184
281
|
}
|
185
282
|
|
186
|
-
var hideEvent =
|
187
|
-
$__default["default"](this._element).trigger(hideEvent);
|
283
|
+
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
|
188
284
|
|
189
|
-
if (
|
285
|
+
if (hideEvent.defaultPrevented) {
|
190
286
|
return;
|
191
287
|
}
|
192
288
|
|
193
289
|
this._isShown = false;
|
194
|
-
|
290
|
+
|
291
|
+
var transition = this._element.classList.contains(CLASS_NAME_FADE);
|
195
292
|
|
196
293
|
if (transition) {
|
197
294
|
this._isTransitioning = true;
|
@@ -201,16 +298,19 @@
|
|
201
298
|
|
202
299
|
this._setResizeEvent();
|
203
300
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
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);
|
208
307
|
|
209
308
|
if (transition) {
|
210
|
-
var transitionDuration =
|
211
|
-
|
309
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
310
|
+
EventHandler.one(this._element, TRANSITION_END, function (event) {
|
212
311
|
return _this2._hideModal(event);
|
213
|
-
})
|
312
|
+
});
|
313
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
214
314
|
} else {
|
215
315
|
this._hideModal();
|
216
316
|
}
|
@@ -218,7 +318,7 @@
|
|
218
318
|
|
219
319
|
_proto.dispose = function dispose() {
|
220
320
|
[window, this._element, this._dialog].forEach(function (htmlElement) {
|
221
|
-
return
|
321
|
+
return EventHandler.off(htmlElement, EVENT_KEY);
|
222
322
|
});
|
223
323
|
/**
|
224
324
|
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
|
@@ -226,8 +326,8 @@
|
|
226
326
|
* It will remove `EVENT_CLICK_DATA_API` event that should remain
|
227
327
|
*/
|
228
328
|
|
229
|
-
|
230
|
-
|
329
|
+
EventHandler.off(document, EVENT_FOCUSIN);
|
330
|
+
Data.removeData(this._element, DATA_KEY);
|
231
331
|
this._config = null;
|
232
332
|
this._element = null;
|
233
333
|
this._dialog = null;
|
@@ -245,49 +345,17 @@
|
|
245
345
|
;
|
246
346
|
|
247
347
|
_proto._getConfig = function _getConfig(config) {
|
248
|
-
config =
|
249
|
-
|
348
|
+
config = _objectSpread(_objectSpread({}, Default), config);
|
349
|
+
typeCheckConfig(NAME, config, DefaultType);
|
250
350
|
return config;
|
251
351
|
};
|
252
352
|
|
253
|
-
_proto.
|
353
|
+
_proto._showElement = function _showElement(relatedTarget) {
|
254
354
|
var _this3 = this;
|
255
355
|
|
256
|
-
var
|
257
|
-
$__default["default"](this._element).trigger(hideEventPrevented);
|
258
|
-
|
259
|
-
if (hideEventPrevented.isDefaultPrevented()) {
|
260
|
-
return;
|
261
|
-
}
|
262
|
-
|
263
|
-
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
|
264
|
-
|
265
|
-
if (!isModalOverflowing) {
|
266
|
-
this._element.style.overflowY = 'hidden';
|
267
|
-
}
|
268
|
-
|
269
|
-
this._element.classList.add(CLASS_NAME_STATIC);
|
270
|
-
|
271
|
-
var modalTransitionDuration = Util__default["default"].getTransitionDurationFromElement(this._dialog);
|
272
|
-
$__default["default"](this._element).off(Util__default["default"].TRANSITION_END);
|
273
|
-
$__default["default"](this._element).one(Util__default["default"].TRANSITION_END, function () {
|
274
|
-
_this3._element.classList.remove(CLASS_NAME_STATIC);
|
275
|
-
|
276
|
-
if (!isModalOverflowing) {
|
277
|
-
$__default["default"](_this3._element).one(Util__default["default"].TRANSITION_END, function () {
|
278
|
-
_this3._element.style.overflowY = '';
|
279
|
-
}).emulateTransitionEnd(_this3._element, modalTransitionDuration);
|
280
|
-
}
|
281
|
-
}).emulateTransitionEnd(modalTransitionDuration);
|
282
|
-
|
283
|
-
this._element.focus();
|
284
|
-
};
|
285
|
-
|
286
|
-
_proto._showElement = function _showElement(relatedTarget) {
|
287
|
-
var _this4 = this;
|
356
|
+
var transition = this._element.classList.contains(CLASS_NAME_FADE);
|
288
357
|
|
289
|
-
var
|
290
|
-
var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
|
358
|
+
var modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
|
291
359
|
|
292
360
|
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
293
361
|
// Don't move modal's DOM position
|
@@ -302,86 +370,86 @@
|
|
302
370
|
|
303
371
|
this._element.setAttribute('role', 'dialog');
|
304
372
|
|
305
|
-
|
373
|
+
this._element.scrollTop = 0;
|
374
|
+
|
375
|
+
if (modalBody) {
|
306
376
|
modalBody.scrollTop = 0;
|
307
|
-
} else {
|
308
|
-
this._element.scrollTop = 0;
|
309
377
|
}
|
310
378
|
|
311
379
|
if (transition) {
|
312
|
-
|
380
|
+
reflow(this._element);
|
313
381
|
}
|
314
382
|
|
315
|
-
|
383
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
316
384
|
|
317
385
|
if (this._config.focus) {
|
318
386
|
this._enforceFocus();
|
319
387
|
}
|
320
388
|
|
321
|
-
var shownEvent = $__default["default"].Event(EVENT_SHOWN, {
|
322
|
-
relatedTarget: relatedTarget
|
323
|
-
});
|
324
|
-
|
325
389
|
var transitionComplete = function transitionComplete() {
|
326
|
-
if (
|
327
|
-
|
390
|
+
if (_this3._config.focus) {
|
391
|
+
_this3._element.focus();
|
328
392
|
}
|
329
393
|
|
330
|
-
|
331
|
-
|
394
|
+
_this3._isTransitioning = false;
|
395
|
+
EventHandler.trigger(_this3._element, EVENT_SHOWN, {
|
396
|
+
relatedTarget: relatedTarget
|
397
|
+
});
|
332
398
|
};
|
333
399
|
|
334
400
|
if (transition) {
|
335
|
-
var transitionDuration =
|
336
|
-
|
401
|
+
var transitionDuration = getTransitionDurationFromElement(this._dialog);
|
402
|
+
EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
|
403
|
+
emulateTransitionEnd(this._dialog, transitionDuration);
|
337
404
|
} else {
|
338
405
|
transitionComplete();
|
339
406
|
}
|
340
407
|
};
|
341
408
|
|
342
409
|
_proto._enforceFocus = function _enforceFocus() {
|
343
|
-
var
|
410
|
+
var _this4 = this;
|
344
411
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
412
|
+
EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop
|
413
|
+
|
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();
|
349
417
|
}
|
350
418
|
});
|
351
419
|
};
|
352
420
|
|
353
421
|
_proto._setEscapeEvent = function _setEscapeEvent() {
|
354
|
-
var
|
422
|
+
var _this5 = this;
|
355
423
|
|
356
424
|
if (this._isShown) {
|
357
|
-
|
358
|
-
if (
|
425
|
+
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
|
426
|
+
if (_this5._config.keyboard && event.key === ESCAPE_KEY) {
|
359
427
|
event.preventDefault();
|
360
428
|
|
361
|
-
|
362
|
-
} else if (!
|
363
|
-
|
429
|
+
_this5.hide();
|
430
|
+
} else if (!_this5._config.keyboard && event.key === ESCAPE_KEY) {
|
431
|
+
_this5._triggerBackdropTransition();
|
364
432
|
}
|
365
433
|
});
|
366
|
-
} else
|
367
|
-
|
434
|
+
} else {
|
435
|
+
EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
|
368
436
|
}
|
369
437
|
};
|
370
438
|
|
371
439
|
_proto._setResizeEvent = function _setResizeEvent() {
|
372
|
-
var
|
440
|
+
var _this6 = this;
|
373
441
|
|
374
442
|
if (this._isShown) {
|
375
|
-
|
376
|
-
return
|
443
|
+
EventHandler.on(window, EVENT_RESIZE, function () {
|
444
|
+
return _this6._adjustDialog();
|
377
445
|
});
|
378
446
|
} else {
|
379
|
-
|
447
|
+
EventHandler.off(window, EVENT_RESIZE);
|
380
448
|
}
|
381
449
|
};
|
382
450
|
|
383
451
|
_proto._hideModal = function _hideModal() {
|
384
|
-
var
|
452
|
+
var _this7 = this;
|
385
453
|
|
386
454
|
this._element.style.display = 'none';
|
387
455
|
|
@@ -394,27 +462,26 @@
|
|
394
462
|
this._isTransitioning = false;
|
395
463
|
|
396
464
|
this._showBackdrop(function () {
|
397
|
-
|
465
|
+
document.body.classList.remove(CLASS_NAME_OPEN);
|
398
466
|
|
399
|
-
|
467
|
+
_this7._resetAdjustments();
|
400
468
|
|
401
|
-
|
469
|
+
_this7._resetScrollbar();
|
402
470
|
|
403
|
-
|
471
|
+
EventHandler.trigger(_this7._element, EVENT_HIDDEN);
|
404
472
|
});
|
405
473
|
};
|
406
474
|
|
407
475
|
_proto._removeBackdrop = function _removeBackdrop() {
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
}
|
476
|
+
this._backdrop.parentNode.removeChild(this._backdrop);
|
477
|
+
|
478
|
+
this._backdrop = null;
|
412
479
|
};
|
413
480
|
|
414
481
|
_proto._showBackdrop = function _showBackdrop(callback) {
|
415
|
-
var
|
482
|
+
var _this8 = this;
|
416
483
|
|
417
|
-
var animate =
|
484
|
+
var animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
|
418
485
|
|
419
486
|
if (this._isShown && this._config.backdrop) {
|
420
487
|
this._backdrop = document.createElement('div');
|
@@ -424,10 +491,10 @@
|
|
424
491
|
this._backdrop.classList.add(animate);
|
425
492
|
}
|
426
493
|
|
427
|
-
|
428
|
-
|
429
|
-
if (
|
430
|
-
|
494
|
+
document.body.appendChild(this._backdrop);
|
495
|
+
EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) {
|
496
|
+
if (_this8._ignoreBackdropClick) {
|
497
|
+
_this8._ignoreBackdropClick = false;
|
431
498
|
return;
|
432
499
|
}
|
433
500
|
|
@@ -435,54 +502,69 @@
|
|
435
502
|
return;
|
436
503
|
}
|
437
504
|
|
438
|
-
|
439
|
-
_this9._triggerBackdropTransition();
|
440
|
-
} else {
|
441
|
-
_this9.hide();
|
442
|
-
}
|
505
|
+
_this8._triggerBackdropTransition();
|
443
506
|
});
|
444
507
|
|
445
508
|
if (animate) {
|
446
|
-
|
509
|
+
reflow(this._backdrop);
|
447
510
|
}
|
448
511
|
|
449
|
-
|
450
|
-
|
451
|
-
if (!callback) {
|
452
|
-
return;
|
453
|
-
}
|
512
|
+
this._backdrop.classList.add(CLASS_NAME_SHOW);
|
454
513
|
|
455
514
|
if (!animate) {
|
456
515
|
callback();
|
457
516
|
return;
|
458
517
|
}
|
459
518
|
|
460
|
-
var backdropTransitionDuration =
|
461
|
-
|
519
|
+
var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
|
520
|
+
EventHandler.one(this._backdrop, TRANSITION_END, callback);
|
521
|
+
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
|
462
522
|
} else if (!this._isShown && this._backdrop) {
|
463
|
-
|
523
|
+
this._backdrop.classList.remove(CLASS_NAME_SHOW);
|
464
524
|
|
465
525
|
var callbackRemove = function callbackRemove() {
|
466
|
-
|
526
|
+
_this8._removeBackdrop();
|
467
527
|
|
468
|
-
|
469
|
-
callback();
|
470
|
-
}
|
528
|
+
callback();
|
471
529
|
};
|
472
530
|
|
473
|
-
if (
|
474
|
-
var _backdropTransitionDuration =
|
531
|
+
if (this._element.classList.contains(CLASS_NAME_FADE)) {
|
532
|
+
var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
|
475
533
|
|
476
|
-
|
534
|
+
EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
|
535
|
+
emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
|
477
536
|
} else {
|
478
537
|
callbackRemove();
|
479
538
|
}
|
480
|
-
} else
|
539
|
+
} else {
|
481
540
|
callback();
|
482
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
|
+
}
|
483
566
|
} // ----------------------------------------------------------------------
|
484
567
|
// the following methods are used to handle overflowing modals
|
485
|
-
// todo (fat): these should probably be refactored out of modal.js
|
486
568
|
// ----------------------------------------------------------------------
|
487
569
|
;
|
488
570
|
|
@@ -515,50 +597,58 @@
|
|
515
597
|
if (this._isBodyOverflowing) {
|
516
598
|
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
|
517
599
|
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
$__default["default"](fixedContent).each(function (index, element) {
|
600
|
+
// Adjust fixed content padding
|
601
|
+
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
|
522
602
|
var actualPadding = element.style.paddingRight;
|
523
|
-
var calculatedPadding =
|
524
|
-
|
603
|
+
var calculatedPadding = window.getComputedStyle(element)['padding-right'];
|
604
|
+
Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
|
605
|
+
element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px";
|
525
606
|
}); // Adjust sticky content margin
|
526
607
|
|
527
|
-
|
608
|
+
SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
|
528
609
|
var actualMargin = element.style.marginRight;
|
529
|
-
var calculatedMargin =
|
530
|
-
|
610
|
+
var calculatedMargin = window.getComputedStyle(element)['margin-right'];
|
611
|
+
Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
|
612
|
+
element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
|
531
613
|
}); // Adjust body padding
|
532
614
|
|
533
615
|
var actualPadding = document.body.style.paddingRight;
|
534
|
-
var calculatedPadding =
|
535
|
-
|
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";
|
536
619
|
}
|
537
620
|
|
538
|
-
|
621
|
+
document.body.classList.add(CLASS_NAME_OPEN);
|
539
622
|
};
|
540
623
|
|
541
624
|
_proto._resetScrollbar = function _resetScrollbar() {
|
542
625
|
// Restore fixed content padding
|
543
|
-
|
544
|
-
|
545
|
-
var padding = $__default["default"](element).data('padding-right');
|
546
|
-
$__default["default"](element).removeData('padding-right');
|
547
|
-
element.style.paddingRight = padding ? padding : '';
|
548
|
-
}); // Restore sticky content
|
626
|
+
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
|
627
|
+
var padding = Manipulator.getDataAttribute(element, 'padding-right');
|
549
628
|
|
550
|
-
|
551
|
-
|
552
|
-
|
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');
|
553
637
|
|
554
638
|
if (typeof margin !== 'undefined') {
|
555
|
-
|
639
|
+
Manipulator.removeDataAttribute(element, 'margin-right');
|
640
|
+
element.style.marginRight = margin;
|
556
641
|
}
|
557
642
|
}); // Restore body padding
|
558
643
|
|
559
|
-
var padding =
|
560
|
-
|
561
|
-
|
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
|
+
}
|
562
652
|
};
|
563
653
|
|
564
654
|
_proto._getScrollbarWidth = function _getScrollbarWidth() {
|
@@ -572,15 +662,14 @@
|
|
572
662
|
} // Static
|
573
663
|
;
|
574
664
|
|
575
|
-
Modal.
|
665
|
+
Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
|
576
666
|
return this.each(function () {
|
577
|
-
var data =
|
667
|
+
var data = Data.getData(this, DATA_KEY);
|
578
668
|
|
579
|
-
var _config =
|
669
|
+
var _config = _objectSpread(_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(this)), typeof config === 'object' && config ? config : {});
|
580
670
|
|
581
671
|
if (!data) {
|
582
672
|
data = new Modal(this, _config);
|
583
|
-
$__default["default"](this).data(DATA_KEY, data);
|
584
673
|
}
|
585
674
|
|
586
675
|
if (typeof config === 'string') {
|
@@ -595,6 +684,10 @@
|
|
595
684
|
});
|
596
685
|
};
|
597
686
|
|
687
|
+
Modal.getInstance = function getInstance(element) {
|
688
|
+
return Data.getData(element, DATA_KEY);
|
689
|
+
};
|
690
|
+
|
598
691
|
_createClass(Modal, null, [{
|
599
692
|
key: "VERSION",
|
600
693
|
get: function get() {
|
@@ -610,53 +703,64 @@
|
|
610
703
|
return Modal;
|
611
704
|
}();
|
612
705
|
/**
|
613
|
-
*
|
706
|
+
* ------------------------------------------------------------------------
|
707
|
+
* Data Api implementation
|
708
|
+
* ------------------------------------------------------------------------
|
614
709
|
*/
|
615
710
|
|
616
711
|
|
617
|
-
|
712
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
618
713
|
var _this11 = this;
|
619
714
|
|
620
|
-
var target;
|
621
|
-
var selector = Util__default["default"].getSelectorFromElement(this);
|
622
|
-
|
623
|
-
if (selector) {
|
624
|
-
target = document.querySelector(selector);
|
625
|
-
}
|
626
|
-
|
627
|
-
var config = $__default["default"](target).data(DATA_KEY) ? 'toggle' : _extends({}, $__default["default"](target).data(), $__default["default"](this).data());
|
715
|
+
var target = getElementFromSelector(this);
|
628
716
|
|
629
717
|
if (this.tagName === 'A' || this.tagName === 'AREA') {
|
630
718
|
event.preventDefault();
|
631
719
|
}
|
632
720
|
|
633
|
-
|
634
|
-
if (showEvent.
|
635
|
-
//
|
721
|
+
EventHandler.one(target, EVENT_SHOW, function (showEvent) {
|
722
|
+
if (showEvent.defaultPrevented) {
|
723
|
+
// only register focus restorer if modal will actually get shown
|
636
724
|
return;
|
637
725
|
}
|
638
726
|
|
639
|
-
|
640
|
-
if (
|
727
|
+
EventHandler.one(target, EVENT_HIDDEN, function () {
|
728
|
+
if (isVisible(_this11)) {
|
641
729
|
_this11.focus();
|
642
730
|
}
|
643
731
|
});
|
644
732
|
});
|
733
|
+
var data = Data.getData(target, DATA_KEY);
|
734
|
+
|
735
|
+
if (!data) {
|
736
|
+
var config = _objectSpread(_objectSpread({}, Manipulator.getDataAttributes(target)), Manipulator.getDataAttributes(this));
|
645
737
|
|
646
|
-
|
738
|
+
data = new Modal(target, config);
|
739
|
+
}
|
740
|
+
|
741
|
+
data.show(this);
|
647
742
|
});
|
743
|
+
var $ = getjQuery();
|
648
744
|
/**
|
745
|
+
* ------------------------------------------------------------------------
|
649
746
|
* jQuery
|
747
|
+
* ------------------------------------------------------------------------
|
748
|
+
* add .modal to jQuery only if jQuery is present
|
650
749
|
*/
|
651
750
|
|
652
|
-
|
653
|
-
$__default["default"].fn[NAME].Constructor = Modal;
|
751
|
+
/* istanbul ignore if */
|
654
752
|
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
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
|
+
}
|
659
763
|
|
660
764
|
return Modal;
|
661
765
|
|
662
|
-
}));
|
766
|
+
})));
|