diff options
author | Mark Otto <markdotto@gmail.com> | 2018-06-22 08:55:23 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2018-06-22 08:55:23 +0300 |
commit | eadeab9d1cf6a1d8315a5aab35f247034931ea6e (patch) | |
tree | 660e3dd5d924afcf3cd595ac7dd41fb86842cdc9 /dist/js/bootstrap.js | |
parent | e59265c42db4c9fec397fd92e9646def0b2b4200 (diff) |
dist
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r-- | dist/js/bootstrap.js | 154 |
1 files changed, 88 insertions, 66 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 67647fb714..c5af727849 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -147,8 +147,7 @@ } try { - var $selector = $$$1(document).find(selector); - return $selector.length > 0 ? selector : null; + return document.querySelector(selector) ? selector : null; } catch (err) { return null; } @@ -278,7 +277,7 @@ var parent = false; if (selector) { - parent = $$$1(selector)[0]; + parent = document.querySelector(selector); } if (!parent) { @@ -435,14 +434,14 @@ var rootElement = $$$1(this._element).closest(Selector.DATA_TOGGLE)[0]; if (rootElement) { - var input = $$$1(this._element).find(Selector.INPUT)[0]; + var input = this._element.querySelector(Selector.INPUT); if (input) { if (input.type === 'radio') { - if (input.checked && $$$1(this._element).hasClass(ClassName.ACTIVE)) { + if (input.checked && this._element.classList.contains(ClassName.ACTIVE)) { triggerChangeEvent = false; } else { - var activeElement = $$$1(rootElement).find(Selector.ACTIVE)[0]; + var activeElement = rootElement.querySelector(Selector.ACTIVE); if (activeElement) { $$$1(activeElement).removeClass(ClassName.ACTIVE); @@ -455,7 +454,7 @@ return; } - input.checked = !$$$1(this._element).hasClass(ClassName.ACTIVE); + input.checked = !this._element.classList.contains(ClassName.ACTIVE); $$$1(input).trigger('change'); } @@ -465,7 +464,7 @@ } if (addAriaPressed) { - this._element.setAttribute('aria-pressed', !$$$1(this._element).hasClass(ClassName.ACTIVE)); + this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName.ACTIVE)); } if (triggerChangeEvent) { @@ -633,7 +632,7 @@ this.touchTimeout = null; this._config = this._getConfig(config); this._element = $$$1(element)[0]; - this._indicatorsElement = $$$1(this._element).find(Selector.INDICATORS)[0]; + this._indicatorsElement = this._element.querySelector(Selector.INDICATORS); this._addEventListeners(); } // Getters @@ -667,7 +666,7 @@ this._isPaused = true; } - if ($$$1(this._element).find(Selector.NEXT_PREV)[0]) { + if (this._element.querySelector(Selector.NEXT_PREV)) { Util.triggerTransitionEnd(this._element); this.cycle(true); } @@ -694,7 +693,7 @@ _proto.to = function to(index) { var _this = this; - this._activeElement = $$$1(this._element).find(Selector.ACTIVE_ITEM)[0]; + this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM); var activeIndex = this._getItemIndex(this._activeElement); @@ -800,7 +799,7 @@ }; _proto._getItemIndex = function _getItemIndex(element) { - this._items = $$$1.makeArray($$$1(element).parent().find(Selector.ITEM)); + this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : []; return this._items.indexOf(element); }; @@ -825,7 +824,7 @@ _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { var targetIndex = this._getItemIndex(relatedTarget); - var fromIndex = this._getItemIndex($$$1(this._element).find(Selector.ACTIVE_ITEM)[0]); + var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM)); var slideEvent = $$$1.Event(Event.SLIDE, { relatedTarget: relatedTarget, @@ -839,7 +838,8 @@ _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { if (this._indicatorsElement) { - $$$1(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE)); + $$$1(indicators).removeClass(ClassName.ACTIVE); var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; @@ -852,7 +852,7 @@ _proto._slide = function _slide(direction, element) { var _this3 = this; - var activeElement = $$$1(this._element).find(Selector.ACTIVE_ITEM)[0]; + var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM); var activeElementIndex = this._getItemIndex(activeElement); @@ -1018,11 +1018,13 @@ $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); $$$1(window).on(Event.LOAD_DATA_API, function () { - $$$1(Selector.DATA_RIDE).each(function () { - var $carousel = $$$1(this); + var carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE)); + + for (var i = 0, len = carousels.length; i < len; i++) { + var $carousel = $$$1(carousels[i]); Carousel._jQueryInterface.call($carousel, $carousel.data()); - }); + } }); /** * ------------------------------------------------------------------------ @@ -1103,14 +1105,17 @@ this._isTransitioning = false; this._element = element; this._config = this._getConfig(config); - this._triggerArray = $$$1.makeArray($$$1("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); - var tabToggles = $$$1(Selector.DATA_TOGGLE); + this._triggerArray = $$$1.makeArray(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); + var toggleList = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)); - for (var i = 0; i < tabToggles.length; i++) { - var elem = tabToggles[i]; + for (var i = 0, len = toggleList.length; i < len; i++) { + var elem = toggleList[i]; var selector = Util.getSelectorFromElement(elem); + var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) { + return foundElem === element; + }); - if (selector !== null && $$$1(selector).filter(element).length > 0) { + if (selector !== null && filterElement.length > 0) { this._selector = selector; this._triggerArray.push(elem); @@ -1151,7 +1156,9 @@ var activesData; if (this._parent) { - actives = $$$1.makeArray($$$1(this._parent).find(Selector.ACTIVES).filter("[data-parent=\"" + this._config.parent + "\"]")); + actives = [].slice.call(this._parent.querySelectorAll(Selector.ACTIVES)).filter(function (elem) { + return elem.getAttribute('data-parent') === _this._config.parent; + }); if (actives.length === 0) { actives = null; @@ -1186,7 +1193,7 @@ $$$1(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); this._element.style[dimension] = 0; - if (this._triggerArray.length > 0) { + if (this._triggerArray.length) { $$$1(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); } @@ -1227,14 +1234,15 @@ this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; Util.reflow(this._element); $$$1(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW); + var triggerArrayLength = this._triggerArray.length; - if (this._triggerArray.length > 0) { - for (var i = 0; i < this._triggerArray.length; i++) { + if (triggerArrayLength > 0) { + for (var i = 0; i < triggerArrayLength; i++) { var trigger = this._triggerArray[i]; var selector = Util.getSelectorFromElement(trigger); if (selector !== null) { - var $elem = $$$1(selector); + var $elem = $$$1([].slice.call(document.querySelectorAll(selector))); if (!$elem.hasClass(ClassName.SHOW)) { $$$1(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); @@ -1295,11 +1303,12 @@ parent = this._config.parent[0]; } } else { - parent = $$$1(this._config.parent)[0]; + parent = document.querySelector(this._config.parent); } var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]"; - $$$1(parent).find(selector).each(function (i, element) { + var children = [].slice.call(parent.querySelectorAll(selector)); + $$$1(children).each(function (i, element) { _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); }); return parent; @@ -1309,7 +1318,7 @@ if (element) { var isOpen = $$$1(element).hasClass(ClassName.SHOW); - if (triggerArray.length > 0) { + if (triggerArray.length) { $$$1(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); } } @@ -1318,7 +1327,7 @@ Collapse._getTargetFromElement = function _getTargetFromElement(element) { var selector = Util.getSelectorFromElement(element); - return selector ? $$$1(selector)[0] : null; + return selector ? document.querySelector(selector) : null; }; Collapse._jQueryInterface = function _jQueryInterface(config) { @@ -1376,7 +1385,8 @@ var $trigger = $$$1(this); var selector = Util.getSelectorFromElement(this); - $$$1(selector).each(function () { + var selectors = [].slice.call(document.querySelectorAll(selector)); + $$$1(selectors).each(function () { var $target = $$$1(this); var data = $target.data(DATA_KEY); var config = data ? 'toggle' : $trigger.data(); @@ -1624,14 +1634,16 @@ if (!this._menu) { var parent = Dropdown._getParentFromElement(this._element); - this._menu = $$$1(parent).find(Selector.MENU)[0]; + if (parent) { + this._menu = parent.querySelector(Selector.MENU); + } } return this._menu; }; _proto._getPlacement = function _getPlacement() { - var $parentDropdown = $$$1(this._element).parent(); + var $parentDropdown = $$$1(this._element.parentNode); var placement = AttachmentMap.BOTTOM; // Handle dropup if ($parentDropdown.hasClass(ClassName.DROPUP)) { @@ -1719,9 +1731,9 @@ return; } - var toggles = $$$1.makeArray($$$1(Selector.DATA_TOGGLE)); + var toggles = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)); - for (var i = 0; i < toggles.length; i++) { + for (var i = 0, len = toggles.length; i < len; i++) { var parent = Dropdown._getParentFromElement(toggles[i]); var context = $$$1(toggles[i]).data(DATA_KEY); @@ -1767,7 +1779,7 @@ var selector = Util.getSelectorFromElement(element); if (selector) { - parent = $$$1(selector)[0]; + parent = document.querySelector(selector); } return parent || element.parentNode; @@ -1799,7 +1811,7 @@ if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { if (event.which === ESCAPE_KEYCODE) { - var toggle = $$$1(parent).find(Selector.DATA_TOGGLE)[0]; + var toggle = parent.querySelector(Selector.DATA_TOGGLE); $$$1(toggle).trigger('focus'); } @@ -1807,7 +1819,7 @@ return; } - var items = $$$1(parent).find(Selector.VISIBLE_ITEMS).get(); + var items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS)); if (items.length === 0) { return; @@ -1957,7 +1969,7 @@ function Modal(element, config) { this._config = this._getConfig(config); this._element = element; - this._dialog = $$$1(element).find(Selector.DIALOG)[0]; + this._dialog = element.querySelector(Selector.DIALOG); this._backdrop = null; this._isShown = false; this._isBodyOverflowing = false; @@ -2214,7 +2226,7 @@ this._backdrop.className = ClassName.BACKDROP; if (animate) { - $$$1(this._backdrop).addClass(animate); + this._backdrop.classList.add(animate); } $$$1(this._backdrop).appendTo(document.body); @@ -2308,21 +2320,24 @@ if (this._isBodyOverflowing) { // Note: DOMNode.style.paddingRight returns the actual value or '' if not set // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set - // Adjust fixed content padding - $$$1(Selector.FIXED_CONTENT).each(function (index, element) { - var actualPadding = $$$1(element)[0].style.paddingRight; + var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT)); + var stickyContent = [].slice.call(document.querySelectorAll(Selector.STICKY_CONTENT)); + var navbarToggler = [].slice.call(document.querySelectorAll(Selector.NAVBAR_TOGGLER)); // Adjust fixed content padding + + $$$1(fixedContent).each(function (index, element) { + var actualPadding = element.style.paddingRight; var calculatedPadding = $$$1(element).css('padding-right'); $$$1(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px"); }); // Adjust sticky content margin - $$$1(Selector.STICKY_CONTENT).each(function (index, element) { - var actualMargin = $$$1(element)[0].style.marginRight; + $$$1(stickyContent).each(function (index, element) { + var actualMargin = element.style.marginRight; var calculatedMargin = $$$1(element).css('margin-right'); $$$1(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px"); }); // Adjust navbar-toggler margin - $$$1(Selector.NAVBAR_TOGGLER).each(function (index, element) { - var actualMargin = $$$1(element)[0].style.marginRight; + $$$1(navbarToggler).each(function (index, element) { + var actualMargin = element.style.marginRight; var calculatedMargin = $$$1(element).css('margin-right'); $$$1(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this9._scrollbarWidth + "px"); }); // Adjust body padding @@ -2335,7 +2350,8 @@ _proto._resetScrollbar = function _resetScrollbar() { // Restore fixed content padding - $$$1(Selector.FIXED_CONTENT).each(function (index, element) { + var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT)); + $$$1(fixedContent).each(function (index, element) { var padding = $$$1(element).data('padding-right'); if (typeof padding !== 'undefined') { @@ -2343,7 +2359,8 @@ } }); // Restore sticky content and navbar-toggler margin - $$$1(Selector.STICKY_CONTENT + ", " + Selector.NAVBAR_TOGGLER).each(function (index, element) { + var elements = [].slice.call(document.querySelectorAll(Selector.STICKY_CONTENT + ", " + Selector.NAVBAR_TOGGLER)); + $$$1(elements).each(function (index, element) { var margin = $$$1(element).data('margin-right'); if (typeof margin !== 'undefined') { @@ -2420,7 +2437,7 @@ var selector = Util.getSelectorFromElement(this); if (selector) { - target = $$$1(selector)[0]; + target = document.querySelector(selector); } var config = $$$1(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $$$1(target).data(), $$$1(this).data()); @@ -2685,7 +2702,7 @@ var attachment = this._getAttachment(placement); this.addAttachmentClass(attachment); - var container = this.config.container === false ? document.body : $$$1(this.config.container); + var container = this.config.container === false ? document.body : $$$1(document).find(this.config.container); $$$1(tip).data(this.constructor.DATA_KEY, this); if (!$$$1.contains(this.element.ownerDocument.documentElement, this.tip)) { @@ -2824,9 +2841,9 @@ }; _proto.setContent = function setContent() { - var $tip = $$$1(this.getTipElement()); - this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()); - $tip.removeClass(ClassName.FADE + " " + ClassName.SHOW); + var tip = this.getTipElement(); + this.setElementContent($$$1(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle()); + $$$1(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW); }; _proto.setElementContent = function setElementContent($element, content) { @@ -3019,7 +3036,7 @@ var $tip = $$$1(this.getTipElement()); var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); - if (tabClass !== null && tabClass.length > 0) { + if (tabClass !== null && tabClass.length) { $tip.removeClass(tabClass.join('')); } }; @@ -3421,13 +3438,13 @@ this._offsets = []; this._targets = []; this._scrollHeight = this._getScrollHeight(); - var targets = $$$1.makeArray($$$1(this._selector)); + var targets = [].slice.call(document.querySelectorAll(this._selector)); targets.map(function (element) { var target; var targetSelector = Util.getSelectorFromElement(element); if (targetSelector) { - target = $$$1(targetSelector)[0]; + target = document.querySelector(targetSelector); } if (target) { @@ -3524,7 +3541,9 @@ return; } - for (var i = this._offsets.length; i--;) { + var offsetLength = this._offsets.length; + + for (var i = offsetLength; i--;) { var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); if (isActiveTarget) { @@ -3544,7 +3563,7 @@ queries = queries.map(function (selector) { return selector + "[data-target=\"" + target + "\"]," + (selector + "[href=\"" + target + "\"]"); }); - var $link = $$$1(queries.join(',')); + var $link = $$$1([].slice.call(document.querySelectorAll(queries.join(',')))); if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); @@ -3565,7 +3584,8 @@ }; _proto._clear = function _clear() { - $$$1(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + var nodes = [].slice.call(document.querySelectorAll(this._selector)); + $$$1(nodes).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE); }; // Static @@ -3612,9 +3632,10 @@ $$$1(window).on(Event.LOAD_DATA_API, function () { - var scrollSpys = $$$1.makeArray($$$1(Selector.DATA_SPY)); + var scrollSpys = [].slice.call(document.querySelectorAll(Selector.DATA_SPY)); + var scrollSpysLength = scrollSpys.length; - for (var i = scrollSpys.length; i--;) { + for (var i = scrollSpysLength; i--;) { var $spy = $$$1(scrollSpys[i]); ScrollSpy._jQueryInterface.call($spy, $spy.data()); @@ -3733,7 +3754,7 @@ } if (selector) { - target = $$$1(selector)[0]; + target = document.querySelector(selector); } this._activate(this._element, listElement); @@ -3815,7 +3836,8 @@ var dropdownElement = $$$1(element).closest(Selector.DROPDOWN)[0]; if (dropdownElement) { - $$$1(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); + var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector.DROPDOWN_TOGGLE)); + $$$1(dropdownToggleList).addClass(ClassName.ACTIVE); } element.setAttribute('aria-expanded', true); |