1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-20 20:31:26 +02:00
This commit is contained in:
XhmikosR
2019-04-18 14:47:52 +03:00
committed by GitHub
parent 5c5b15a077
commit 091aa1e9fd
48 changed files with 2632 additions and 2060 deletions

View File

@@ -135,7 +135,9 @@
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
element.dispatchEvent(new Event(TRANSITION_END));
var evt = document.createEvent('HTMLEvents');
evt.initEvent(TRANSITION_END, true, true);
element.dispatchEvent(evt);
};
var isElement = function isElement(obj) {
@@ -291,93 +293,145 @@
}
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.3.1): dom/polyfill.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
/* istanbul ignore next */
/* istanbul ignore file */
var _Element$prototype = Element.prototype,
matches = _Element$prototype.matches,
closest = _Element$prototype.closest;
var find = Element.prototype.querySelectorAll;
var findOne = Element.prototype.querySelector;
var Polyfill = function () {
// MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
var defaultPreventedPreservedOnDispatch = function () {
var e = new CustomEvent('Bootstrap', {
cancelable: true
});
var element = document.createElement('div');
element.addEventListener('Bootstrap', function () {
return null;
});
e.preventDefault();
element.dispatchEvent(e);
return e.defaultPrevented;
}();
var createCustomEvent = function createCustomEvent(eventName, params) {
var cEvent = new CustomEvent(eventName, params);
return cEvent;
};
var find = Element.prototype.querySelectorAll;
var findOne = Element.prototype.querySelector;
var scopeSelectorRegex = /:scope\b/;
if (typeof window.CustomEvent !== 'function') {
createCustomEvent = function createCustomEvent(eventName, params) {
params = params || {
bubbles: false,
cancelable: false,
detail: null
};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
return evt;
};
}
var supportScopeQuery = function () {
var element = document.createElement('div');
var workingDefaultPrevented = function () {
var e = document.createEvent('CustomEvent');
e.initEvent('Bootstrap', true, true);
e.preventDefault();
return e.defaultPrevented;
}();
try {
element.querySelectorAll(':scope *');
} catch (error) {
return false;
if (!workingDefaultPrevented) {
var origPreventDefault = Event.prototype.preventDefault;
Event.prototype.preventDefault = function () {
if (!this.cancelable) {
return;
}
return true;
}();
origPreventDefault.call(this);
Object.defineProperty(this, 'defaultPrevented', {
get: function get() {
return true;
},
configurable: true
});
};
} // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
if (!supportScopeQuery) {
find = function find(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector);
var defaultPreventedPreservedOnDispatch = function () {
var e = createCustomEvent('Bootstrap', {
cancelable: true
});
var element = document.createElement('div');
element.addEventListener('Bootstrap', function () {
return null;
});
e.preventDefault();
element.dispatchEvent(e);
return e.defaultPrevented;
}();
if (!matches) {
matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
if (!closest) {
closest = function closest(selector) {
var element = this;
do {
if (matches.call(element, selector)) {
return element;
}
var hasId = Boolean(this.id);
element = element.parentElement || element.parentNode;
} while (element !== null && element.nodeType === 1);
if (!hasId) {
this.id = getUID('scope');
}
return null;
};
}
var nodeList = null;
var scopeSelectorRegex = /:scope\b/;
try {
selector = selector.replace(scopeSelectorRegex, "#" + this.id);
nodeList = this.querySelectorAll(selector);
} finally {
if (!hasId) {
this.removeAttribute('id');
}
}
var supportScopeQuery = function () {
var element = document.createElement('div');
return nodeList;
};
findOne = function findOne(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelector(selector);
}
var matches = find.call(this, selector);
if (typeof matches[0] !== 'undefined') {
return matches[0];
}
return null;
};
try {
element.querySelectorAll(':scope *');
} catch (error) {
return false;
}
return {
defaultPreventedPreservedOnDispatch: defaultPreventedPreservedOnDispatch,
find: find,
findOne: findOne
};
return true;
}();
if (!supportScopeQuery) {
find = function find(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector);
}
var hasId = Boolean(this.id);
if (!hasId) {
this.id = getUID('scope');
}
var nodeList = null;
try {
selector = selector.replace(scopeSelectorRegex, "#" + this.id);
nodeList = this.querySelectorAll(selector);
} finally {
if (!hasId) {
this.removeAttribute('id');
}
}
return nodeList;
};
findOne = function findOne(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelector(selector);
}
var matches = find.call(this, selector);
if (typeof matches[0] !== 'undefined') {
return matches[0];
}
return null;
};
}
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.3.1): dom/eventHandler.js
@@ -468,10 +522,8 @@
delegationSelector = null;
}
var uidList = Object.keys(events);
for (var i = 0; i < uidList.length; i++) {
var uid = uidList[i];
for (var _i = 0, _Object$keys = Object.keys(events); _i < _Object$keys.length; _i++) {
var uid = _Object$keys[_i];
var event = events[uid];
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
@@ -630,7 +682,7 @@
evt = document.createEvent('HTMLEvents');
evt.initEvent(typeEvent, bubbles, true);
} else {
evt = new CustomEvent(event, {
evt = createCustomEvent(event, {
bubbles: bubbles,
cancelable: true
});
@@ -650,7 +702,7 @@
if (defaultPrevented) {
evt.preventDefault();
if (!Polyfill.defaultPreventedPreservedOnDispatch) {
if (!defaultPreventedPreservedOnDispatch) {
Object.defineProperty(evt, 'defaultPrevented', {
get: function get() {
return true;
@@ -683,14 +735,12 @@
* ------------------------------------------------------------------------
*/
var findFn = Polyfill.find,
_findOne = Polyfill.findOne;
var NODE_TEXT = 3;
var SelectorEngine = {
matches: function matches(element, selector) {
return element.matches(selector);
matches: function matches$1(element, selector) {
return matches.call(element, selector);
},
find: function find(selector, element) {
find: function find$1(selector, element) {
if (element === void 0) {
element = document.documentElement;
}
@@ -699,9 +749,9 @@
return null;
}
return findFn.call(element, selector);
return find.call(element, selector);
},
findOne: function findOne(selector, element) {
findOne: function findOne$1(selector, element) {
if (element === void 0) {
element = document.documentElement;
}
@@ -710,7 +760,7 @@
return null;
}
return _findOne.call(element, selector);
return findOne.call(element, selector);
},
children: function children(element, selector) {
var _this = this;
@@ -742,12 +792,12 @@
return parents;
},
closest: function closest(element, selector) {
closest: function closest$1(element, selector) {
if (typeof selector !== 'string') {
return null;
}
return element.closest(selector);
return closest.call(element, selector);
},
prev: function prev(element, selector) {
if (typeof selector !== 'string') {
@@ -1096,11 +1146,17 @@
});
EventHandler.on(document, Event$2.FOCUS_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
var button = SelectorEngine.closest(event.target, Selector$1.BUTTON);
button.classList.add(ClassName$1.FOCUS);
if (button) {
button.classList.add(ClassName$1.FOCUS);
}
});
EventHandler.on(document, Event$2.BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
var button = SelectorEngine.closest(event.target, Selector$1.BUTTON);
button.classList.remove(ClassName$1.FOCUS);
if (button) {
button.classList.remove(ClassName$1.FOCUS);
}
});
/**
* ------------------------------------------------------------------------
@@ -1419,7 +1475,8 @@
return;
}
var direction = absDeltax / this.touchDeltaX; // swipe left
var direction = absDeltax / this.touchDeltaX;
this.touchDeltaX = 0; // swipe left
if (direction > 0) {
this.prev();
@@ -2246,7 +2303,7 @@
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.14.7
* @version 1.15.0
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
@@ -3071,7 +3128,7 @@
* @argument value
* @returns index or -1
*/
function find(arr, check) {
function find$1(arr, check) {
// use native find if supported
if (Array.prototype.find) {
return arr.find(check);
@@ -3099,7 +3156,7 @@
}
// use `find` + `indexOf` if `findIndex` isn't supported
var match = find(arr, function (obj) {
var match = find$1(arr, function (obj) {
return obj[prop] === value;
});
return arr.indexOf(match);
@@ -3516,7 +3573,7 @@
// Remove this legacy support in Popper.js v2
var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
var legacyGpuAccelerationOption = find$1(data.instance.modifiers, function (modifier) {
return modifier.name === 'applyStyle';
}).gpuAcceleration;
if (legacyGpuAccelerationOption !== undefined) {
@@ -3611,7 +3668,7 @@
* @returns {Boolean}
*/
function isModifierRequired(modifiers, requestingName, requestedName) {
var requesting = find(modifiers, function (_ref) {
var requesting = find$1(modifiers, function (_ref) {
var name = _ref.name;
return name === requestingName;
});
@@ -3850,7 +3907,14 @@
// flip the variation if required
var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
// flips variation if reference element overflows boundaries
var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
// flips variation if popper content overflows boundaries
var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
var flippedVariation = flippedVariationByRef || flippedVariationByContent;
if (overlapsRef || overflowsBoundaries || flippedVariation) {
// this boolean to detect any flip loop
@@ -3985,7 +4049,7 @@
// Detect if the offset string contains a pair of values or a single one
// they could be separated by comma or space
var divider = fragments.indexOf(find(fragments, function (frag) {
var divider = fragments.indexOf(find$1(fragments, function (frag) {
return frag.search(/,|\s/) !== -1;
}));
@@ -4196,7 +4260,7 @@
}
var refRect = data.offsets.reference;
var bound = find(data.instance.modifiers, function (modifier) {
var bound = find$1(data.instance.modifiers, function (modifier) {
return modifier.name === 'preventOverflow';
}).boundaries;
@@ -4457,7 +4521,23 @@
* The popper will never be placed outside of the defined boundaries
* (except if `keepTogether` is enabled)
*/
boundariesElement: 'viewport'
boundariesElement: 'viewport',
/**
* @prop {Boolean} flipVariations=false
* The popper will switch placement variation between `-start` and `-end` when
* the reference element overlaps its boundaries.
*
* The original placement should have a set variation.
*/
flipVariations: false,
/**
* @prop {Boolean} flipVariationsByContent=false
* The popper will switch placement variation between `-start` and `-end` when
* the popper element overlaps its reference boundaries.
*
* The original placement should have a set variation.
*/
flipVariationsByContent: false
},
/**
@@ -4674,8 +4754,8 @@
/**
* Creates a new Popper.js instance.
* @class Popper
* @param {HTMLElement|referenceObject} reference - The reference element used to position the popper
* @param {HTMLElement} popper - The HTML element used as the popper
* @param {Element|referenceObject} reference - The reference element used to position the popper
* @param {Element} popper - The HTML / XML element used as the popper
* @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
* @return {Object} instance - The generated Popper.js instance
*/
@@ -7665,7 +7745,9 @@
EventHandler.trigger(_this._element, Event$b.SHOWN);
if (_this._config.autohide) {
_this.hide();
_this._timeout = setTimeout(function () {
_this.hide();
}, _this._config.delay);
}
};
@@ -7682,7 +7764,7 @@
}
};
_proto.hide = function hide(withoutTimeout) {
_proto.hide = function hide() {
var _this2 = this;
if (!this._element.classList.contains(ClassName$a.SHOW)) {
@@ -7691,12 +7773,20 @@
EventHandler.trigger(this._element, Event$b.HIDE);
if (withoutTimeout) {
this._close();
var complete = function complete() {
_this2._element.classList.add(ClassName$a.HIDE);
EventHandler.trigger(_this2._element, Event$b.HIDDEN);
};
this._element.classList.remove(ClassName$a.SHOW);
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
this._timeout = setTimeout(function () {
_this2._close();
}, this._config.delay);
complete();
}
};
@@ -7725,28 +7815,8 @@
var _this3 = this;
EventHandler.on(this._element, Event$b.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
return _this3.hide(true);
return _this3.hide();
});
};
_proto._close = function _close() {
var _this4 = this;
var complete = function complete() {
_this4._element.classList.add(ClassName$a.HIDE);
EventHandler.trigger(_this4._element, Event$b.HIDDEN);
};
this._element.classList.remove(ClassName$a.SHOW);
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
}
} // Static
;