diff options
author | XhmikosR <xhmikosr@gmail.com> | 2019-08-27 16:03:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-27 16:03:21 +0300 |
commit | bf57274fb51fd59f8d680590ead92cb631cf8ea1 (patch) | |
tree | 63aec9b1415470f399e1cbab0ae0d404d1389923 /js/dist/tab.js | |
parent | cad3d1098a2340299e88d05d7da190aac08ca319 (diff) |
Dist (#29263)
Diffstat (limited to 'js/dist/tab.js')
-rw-r--r-- | js/dist/tab.js | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/js/dist/tab.js b/js/dist/tab.js index 65b7fdba7b..1919fc861b 100644 --- a/js/dist/tab.js +++ b/js/dist/tab.js @@ -36,23 +36,22 @@ * -------------------------------------------------------------------------- */ var MILLISECONDS_MULTIPLIER = 1000; - var TRANSITION_END = 'transitionend'; - var _window = window, - jQuery = _window.jQuery; // Shoutout AngusCroll (https://goo.gl/pxwQGp) + var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) - var getSelectorFromElement = function getSelectorFromElement(element) { + var getSelector = function getSelector(element) { var selector = element.getAttribute('data-target'); if (!selector || selector === '#') { var hrefAttr = element.getAttribute('href'); - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''; + selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; } - try { - return document.querySelector(selector) ? selector : null; - } catch (error) { - return null; - } + return selector; + }; + + var getElementFromSelector = function getElementFromSelector(element) { + var selector = getSelector(element); + return selector ? document.querySelector(selector) : null; }; var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) { @@ -114,6 +113,17 @@ return element.offsetHeight; }; + var getjQuery = function getjQuery() { + var _window = window, + jQuery = _window.jQuery; + + if (jQuery && !document.body.hasAttribute('data-no-jquery')) { + return jQuery; + } + + return null; + }; + /** * ------------------------------------------------------------------------ * Constants @@ -174,10 +184,9 @@ return; } - var target; var previous; + var target = getElementFromSelector(this._element); var listElement = SelectorEngine.closest(this._element, Selector.NAV_LIST_GROUP); - var selector = getSelectorFromElement(this._element); if (listElement) { var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector.ACTIVE_UL : Selector.ACTIVE; @@ -201,10 +210,6 @@ return; } - if (selector) { - target = SelectorEngine.findOne(selector); - } - this._activate(this._element, listElement); var complete = function complete() { @@ -294,7 +299,7 @@ } // Static ; - Tab._jQueryInterface = function _jQueryInterface(config) { + Tab.jQueryInterface = function jQueryInterface(config) { return this.each(function () { var data = Data.getData(this, DATA_KEY) || new Tab(this); @@ -308,7 +313,7 @@ }); }; - Tab._getInstance = function _getInstance(element) { + Tab.getInstance = function getInstance(element) { return Data.getData(element, DATA_KEY); }; @@ -333,6 +338,7 @@ var data = Data.getData(this, DATA_KEY) || new Tab(this); data.show(); }); + var $ = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery @@ -342,14 +348,14 @@ /* istanbul ignore if */ - if (typeof jQuery !== 'undefined') { - var JQUERY_NO_CONFLICT = jQuery.fn[NAME]; - jQuery.fn[NAME] = Tab._jQueryInterface; - jQuery.fn[NAME].Constructor = Tab; + if ($) { + var JQUERY_NO_CONFLICT = $.fn[NAME]; + $.fn[NAME] = Tab.jQueryInterface; + $.fn[NAME].Constructor = Tab; - jQuery.fn[NAME].noConflict = function () { - jQuery.fn[NAME] = JQUERY_NO_CONFLICT; - return Tab._jQueryInterface; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tab.jQueryInterface; }; } |