diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-06-16 21:50:01 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-06-16 22:02:03 +0300 |
commit | ebb0b8c68c8dabc9ba7065a07f280335d12d42bd (patch) | |
tree | 76c054bfec94b22a6e6af60704829ebf2767ad73 /js/dist/button.js | |
parent | 723cd8d12bdd48f389234b5fc40c3b1789807b4d (diff) |
Run dist.
Diffstat (limited to 'js/dist/button.js')
-rw-r--r-- | js/dist/button.js | 83 |
1 files changed, 11 insertions, 72 deletions
diff --git a/js/dist/button.js b/js/dist/button.js index 1921bfef50..eb6e88cd22 100644 --- a/js/dist/button.js +++ b/js/dist/button.js @@ -1,22 +1,21 @@ /*! * Bootstrap button.js v5.0.0-alpha1 (https://getbootstrap.com/) * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/selector-engine.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/selector-engine.js'], factory) : - (global = global || self, global.Button = factory(global.Data, global.EventHandler, global.SelectorEngine)); -}(this, (function (Data, EventHandler, SelectorEngine) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')) : + typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js'], factory) : + (global = global || self, global.Button = factory(global.Data, global.EventHandler)); +}(this, (function (Data, EventHandler) { 'use strict'; Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data; EventHandler = EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default') ? EventHandler['default'] : EventHandler; - SelectorEngine = SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default') ? SelectorEngine['default'] : SelectorEngine; /** * -------------------------------------------------------------------------- * Bootstrap (v5.0.0-alpha1): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -46,16 +45,8 @@ var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; var CLASS_NAME_ACTIVE = 'active'; - var CLASS_NAME_DISABLED = 'disabled'; - var CLASS_NAME_FOCUS = 'focus'; - var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'; - var SELECTOR_DATA_TOGGLE = '[data-toggle="buttons"]'; - var SELECTOR_INPUT = 'input:not([type="hidden"])'; - var SELECTOR_ACTIVE = '.active'; - var SELECTOR_BUTTON = '.btn'; + var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'; var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; - var EVENT_FOCUS_DATA_API = "focus" + EVENT_KEY + DATA_API_KEY; - var EVENT_BLUR_DATA_API = "blur" + EVENT_KEY + DATA_API_KEY; /** * ------------------------------------------------------------------------ * Class Definition @@ -73,46 +64,8 @@ // Public _proto.toggle = function toggle() { - var triggerChangeEvent = true; - var addAriaPressed = true; - - var rootElement = this._element.closest(SELECTOR_DATA_TOGGLE); - - if (rootElement) { - var input = SelectorEngine.findOne(SELECTOR_INPUT, this._element); - - if (input && input.type === 'radio') { - if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) { - triggerChangeEvent = false; - } else { - var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE, rootElement); - - if (activeElement) { - activeElement.classList.remove(CLASS_NAME_ACTIVE); - } - } - - if (triggerChangeEvent) { - if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains(CLASS_NAME_DISABLED) || rootElement.classList.contains(CLASS_NAME_DISABLED)) { - return; - } - - input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE); - EventHandler.trigger(input, 'change'); - } - - input.focus(); - addAriaPressed = false; - } - } - - if (addAriaPressed) { - this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE)); - } - - if (triggerChangeEvent) { - this._element.classList.toggle(CLASS_NAME_ACTIVE); - } + // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method + this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE)); }; _proto.dispose = function dispose() { @@ -155,9 +108,9 @@ */ - EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) { + EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { event.preventDefault(); - var button = event.target.closest(SELECTOR_BUTTON); + var button = event.target.closest(SELECTOR_DATA_TOGGLE); var data = Data.getData(button, DATA_KEY); if (!data) { @@ -166,20 +119,6 @@ data.toggle(); }); - EventHandler.on(document, EVENT_FOCUS_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) { - var button = event.target.closest(SELECTOR_BUTTON); - - if (button) { - button.classList.add(CLASS_NAME_FOCUS); - } - }); - EventHandler.on(document, EVENT_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) { - var button = event.target.closest(SELECTOR_BUTTON); - - if (button) { - button.classList.remove(CLASS_NAME_FOCUS); - } - }); var $ = getjQuery(); /** * ------------------------------------------------------------------------ |