diff options
Diffstat (limited to 'js/dist/button.js')
| -rw-r--r-- | js/dist/button.js | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/js/dist/button.js b/js/dist/button.js index c12da2691..e67f088c8 100644 --- a/js/dist/button.js +++ b/js/dist/button.js @@ -35,8 +35,17 @@ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ - var _window = window, - jQuery = _window.jQuery; // Shoutout AngusCroll (https://goo.gl/pxwQGp) + + var getjQuery = function getjQuery() { + var _window = window, + jQuery = _window.jQuery; + + if (jQuery && !document.body.hasAttribute('data-no-jquery')) { + return jQuery; + } + + return null; + }; /** * ------------------------------------------------------------------------ @@ -93,16 +102,14 @@ if (rootElement) { var input = SelectorEngine.findOne(Selector.INPUT, this._element); - if (input) { - if (input.type === 'radio') { - if (input.checked && this._element.classList.contains(ClassName.ACTIVE)) { - triggerChangeEvent = false; - } else { - var activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement); + if (input && input.type === 'radio') { + if (input.checked && this._element.classList.contains(ClassName.ACTIVE)) { + triggerChangeEvent = false; + } else { + var activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement); - if (activeElement) { - activeElement.classList.remove(ClassName.ACTIVE); - } + if (activeElement) { + activeElement.classList.remove(ClassName.ACTIVE); } } @@ -135,7 +142,7 @@ } // Static ; - Button._jQueryInterface = function _jQueryInterface(config) { + Button.jQueryInterface = function jQueryInterface(config) { return this.each(function () { var data = Data.getData(this, DATA_KEY); @@ -149,7 +156,7 @@ }); }; - Button._getInstance = function _getInstance(element) { + Button.getInstance = function getInstance(element) { return Data.getData(element, DATA_KEY); }; @@ -199,6 +206,7 @@ button.classList.remove(ClassName.FOCUS); } }); + var $ = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery @@ -208,14 +216,14 @@ /* istanbul ignore if */ - if (typeof jQuery !== 'undefined') { - var JQUERY_NO_CONFLICT = jQuery.fn[NAME]; - jQuery.fn[NAME] = Button._jQueryInterface; - jQuery.fn[NAME].Constructor = Button; + if ($) { + var JQUERY_NO_CONFLICT = $.fn[NAME]; + $.fn[NAME] = Button.jQueryInterface; + $.fn[NAME].Constructor = Button; - jQuery.fn[NAME].noConflict = function () { - jQuery.fn[NAME] = JQUERY_NO_CONFLICT; - return Button._jQueryInterface; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Button.jQueryInterface; }; } |
