You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
12 KiB
1 lines
12 KiB
{"version":3,"sources":["../../src/bootstrap/button.js"],"names":["DATA_KEY","EVENT_KEY","DATA_API_KEY","JQUERY_NO_CONFLICT","$","fn","CLASS_NAME_ACTIVE","SELECTOR_DATA_TOGGLE_CARROT","SELECTOR_INPUT","SELECTOR_BUTTON","EVENT_CLICK_DATA_API","EVENT_FOCUS_BLUR_DATA_API","EVENT_LOAD_DATA_API","Button","element","_element","shouldAvoidTriggerChange","triggerChangeEvent","addAriaPressed","rootElement","closest","input","querySelector","type","checked","classList","contains","activeElement","removeClass","trigger","focus","hasAttribute","setAttribute","toggleClass","removeData","config","avoidTriggerChange","each","$element","data","document","on","event","button","target","initialButton","hasClass","preventDefault","inputBtn","tagName","_jQueryInterface","call","test","window","buttons","slice","querySelectorAll","i","len","length","add","remove","getAttribute","Constructor","noConflict"],"mappings":"yJAOA,uD,oUAUMA,CAAAA,CAAQ,CAAG,W,CACXC,CAAS,YAAOD,CAAP,C,CACTE,CAAY,CAAG,W,CACfC,CAAkB,CAAGC,UAAEC,EAAF,O,CAErBC,CAAiB,CAAG,Q,CAIpBC,CAA2B,CAAG,2B,CAI9BC,CAAc,CAAG,8B,CAEjBC,CAAe,CAAG,M,CAElBC,CAAoB,gBAAWT,CAAX,SAAuBC,CAAvB,C,CACpBS,CAAyB,CAAG,eAAQV,CAAR,SAAoBC,CAApB,oBACDD,CADC,SACWC,CADX,C,CAE5BU,CAAmB,eAAUX,CAAV,SAAsBC,CAAtB,C,CAQnBW,C,YACJ,WAAYC,CAAZ,CAAqB,WACnB,KAAKC,QAAL,CAAgBD,CAAhB,CACA,KAAKE,wBAAL,GACD,C,0CAUQ,IACHC,CAAAA,CAAkB,GADf,CAEHC,CAAc,GAFX,CAGDC,CAAW,CAAG,cAAE,KAAKJ,QAAP,EAAiBK,OAAjB,CAnCM,2BAmCN,EAAgD,CAAhD,CAHb,CAKP,GAA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M,CAAClB,SAAP,CAAiBmC,GAAjB,CAAqBtD,CAArB,CACD,CAFD,IAEO,CACLqC,CAAM,CAAClB,SAAP,CAAiBoC,MAAjB,CAAwBvD,CAAxB,CACD,CACF,CAGDgD,CAAO,CAAG,GAAGC,KAAH,CAASJ,IAAT,CAAcX,QAAQ,CAACgB,gBAAT,CA5JG,0BA4JH,CAAd,CAAV,CACA,IAAK,GAAIC,CAAAA,CAAC,CAAG,CAAR,CAAWC,CAAG,CAAGJ,CAAO,CAACK,MAAzB,CACGhB,CADR,CAAsCc,CAAC,CAAGC,CAA1C,CAA+CD,CAAC,EAAhD,CAAoD,CAC5Cd,CAD4C,CACnCW,CAAO,CAACG,CAAD,CAD4B,CAElD,GAA4C,MAAxC,GAAAd,CAAM,CAACmB,YAAP,CAAoB,cAApB,CAAJ,CAAoD,CAClDnB,CAAM,CAAClB,SAAP,CAAiBmC,GAAjB,CAAqBtD,CAArB,CACD,CAFD,IAEO,CACLqC,CAAM,CAAClB,SAAP,CAAiBoC,MAAjB,CAAwBvD,CAAxB,CACD,CACF,CACF,CAzBD,EAiCAF,UAAEC,EAAF,QAAaQ,CAAM,CAACqC,gBAApB,CACA9C,UAAEC,EAAF,QAAW0D,WAAX,CAAyBlD,CAAzB,CACAT,UAAEC,EAAF,QAAW2D,UAAX,CAAwB,UAAM,CAC5B5D,UAAEC,EAAF,QAAaF,CAAb,CACA,MAAOU,CAAAA,CAAM,CAACqC,gBACf,CAHD,C,UAKerC,C","sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.6.0): button.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport $ from 'jquery'\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst NAME = 'button'\nconst VERSION = '4.6.0'\nconst DATA_KEY = 'bs.button'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\nconst JQUERY_NO_CONFLICT = $.fn[NAME]\n\nconst CLASS_NAME_ACTIVE = 'active'\nconst CLASS_NAME_BUTTON = 'btn'\nconst CLASS_NAME_FOCUS = 'focus'\n\nconst SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^=\"button\"]'\nconst SELECTOR_DATA_TOGGLES = '[data-toggle=\"buttons\"]'\nconst SELECTOR_DATA_TOGGLE = '[data-toggle=\"button\"]'\nconst SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle=\"buttons\"] .btn'\nconst SELECTOR_INPUT = 'input:not([type=\"hidden\"])'\nconst SELECTOR_ACTIVE = '.active'\nconst SELECTOR_BUTTON = '.btn'\n\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_FOCUS_BLUR_DATA_API = `focus${EVENT_KEY}${DATA_API_KEY} ` +\n `blur${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`\n\n/**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\nclass Button {\n constructor(element) {\n this._element = element\n this.shouldAvoidTriggerChange = false\n }\n\n // Getters\n\n static get VERSION() {\n return VERSION\n }\n\n // Public\n\n toggle() {\n let triggerChangeEvent = true\n let addAriaPressed = true\n const rootElement = $(this._element).closest(SELECTOR_DATA_TOGGLES)[0]\n\n if (rootElement) {\n const input = this._element.querySelector(SELECTOR_INPUT)\n\n if (input) {\n if (input.type === 'radio') {\n if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) {\n triggerChangeEvent = false\n } else {\n const activeElement = rootElement.querySelector(SELECTOR_ACTIVE)\n\n if (activeElement) {\n $(activeElement).removeClass(CLASS_NAME_ACTIVE)\n }\n }\n }\n\n if (triggerChangeEvent) {\n // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input\n if (input.type === 'checkbox' || input.type === 'radio') {\n input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE)\n }\n\n if (!this.shouldAvoidTriggerChange) {\n $(input).trigger('change')\n }\n }\n\n input.focus()\n addAriaPressed = false\n }\n }\n\n if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {\n if (addAriaPressed) {\n this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE))\n }\n\n if (triggerChangeEvent) {\n $(this._element).toggleClass(CLASS_NAME_ACTIVE)\n }\n }\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n this._element = null\n }\n\n // Static\n\n static _jQueryInterface(config, avoidTriggerChange) {\n return this.each(function () {\n const $element = $(this)\n let data = $element.data(DATA_KEY)\n\n if (!data) {\n data = new Button(this)\n $element.data(DATA_KEY, data)\n }\n\n data.shouldAvoidTriggerChange = avoidTriggerChange\n\n if (config === 'toggle') {\n data[config]()\n }\n })\n }\n}\n\n/**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n$(document)\n .on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {\n let button = event.target\n const initialButton = button\n\n if (!$(button).hasClass(CLASS_NAME_BUTTON)) {\n button = $(button).closest(SELECTOR_BUTTON)[0]\n }\n\n if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {\n event.preventDefault() // work around Firefox bug #1540995\n } else {\n const inputBtn = button.querySelector(SELECTOR_INPUT)\n\n if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {\n event.preventDefault() // work around Firefox bug #1540995\n return\n }\n\n if (initialButton.tagName === 'INPUT' || button.tagName !== 'LABEL') {\n Button._jQueryInterface.call($(button), 'toggle', initialButton.tagName === 'INPUT')\n }\n }\n })\n .on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, event => {\n const button = $(event.target).closest(SELECTOR_BUTTON)[0]\n $(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type))\n })\n\n$(window).on(EVENT_LOAD_DATA_API, () => {\n // ensure correct active class is set to match the controls' actual values/states\n\n // find all checkboxes/readio buttons inside data-toggle groups\n let buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS))\n for (let i = 0, len = buttons.length; i < len; i++) {\n const button = buttons[i]\n const input = button.querySelector(SELECTOR_INPUT)\n if (input.checked || input.hasAttribute('checked')) {\n button.classList.add(CLASS_NAME_ACTIVE)\n } else {\n button.classList.remove(CLASS_NAME_ACTIVE)\n }\n }\n\n // find all button toggles\n buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE))\n for (let i = 0, len = buttons.length; i < len; i++) {\n const button = buttons[i]\n if (button.getAttribute('aria-pressed') === 'true') {\n button.classList.add(CLASS_NAME_ACTIVE)\n } else {\n button.classList.remove(CLASS_NAME_ACTIVE)\n }\n }\n})\n\n/**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n$.fn[NAME] = Button._jQueryInterface\n$.fn[NAME].Constructor = Button\n$.fn[NAME].noConflict = () => {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Button._jQueryInterface\n}\n\nexport default Button\n"],"file":"button.min.js"}
|