0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00
Bootstrap/js/dist/button.js.map
Mark Otto d8a5147c38 dist
2017-09-09 16:59:37 -07:00

1 line
8.8 KiB
Plaintext

{"version":3,"sources":["../src/button.js"],"names":["Button","NAME","VERSION","DATA_KEY","EVENT_KEY","DATA_API_KEY","JQUERY_NO_CONFLICT","$","fn","ClassName","ACTIVE","BUTTON","FOCUS","Selector","DATA_TOGGLE_CARROT","DATA_TOGGLE","INPUT","Event","CLICK_DATA_API","FOCUS_BLUR_DATA_API","element","_element","triggerChangeEvent","addAriaPressed","rootElement","closest","input","find","type","checked","hasClass","activeElement","removeClass","hasAttribute","classList","contains","trigger","focus","setAttribute","toggleClass","removeData","config","each","data","document","on","event","preventDefault","button","target","_jQueryInterface","call","test","Constructor","noConflict","jQuery"],"mappings":";;;;;;AACA;;;;;;;AAOA,IAAMA,SAAU,YAAM;;AAGpB;;;;;;AAMA,MAAMC,OAAsB,QAA5B;AACA,MAAMC,UAAsB,YAA5B;AACA,MAAMC,WAAsB,WAA5B;AACA,MAAMC,kBAA0BD,QAAhC;AACA,MAAME,eAAsB,WAA5B;AACA,MAAMC,qBAAsBC,EAAEC,EAAF,CAAKP,IAAL,CAA5B;;AAEA,MAAMQ,YAAY;AAChBC,YAAS,QADO;AAEhBC,YAAS,KAFO;AAGhBC,WAAS;AAHO,GAAlB;;AAMA,MAAMC,WAAW;AACfC,wBAAqB,yBADN;AAEfC,iBAAqB,yBAFN;AAGfC,WAAqB,OAHN;AAIfN,YAAqB,SAJN;AAKfC,YAAqB;AALN,GAAjB;;AAQA,MAAMM,QAAQ;AACZC,8BAA8Bd,SAA9B,GAA0CC,YAD9B;AAEZc,yBAAsB,UAAQf,SAAR,GAAoBC,YAApB,mBACOD,SADP,GACmBC,YADnB;AAFV,GAAd;;AAOA;;;;;;AArCoB,MA2CdL,MA3Cc;AA6ClB,oBAAYoB,OAAZ,EAAqB;AAAA;;AACnB,WAAKC,QAAL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,EAAEyC,MAAF,CAA7B,EAAwC,QAAxC;AACD,GAXH,EAYGH,EAZH,CAYM5B,MAAME,mBAZZ,EAYiCN,SAASC,kBAZ1C,EAY8D,UAACgC,KAAD,EAAW;AACrE,QAAME,SAASzC,EAAEuC,MAAMG,MAAR,EAAgBxB,OAAhB,CAAwBZ,SAASF,MAAjC,EAAyC,CAAzC,CAAf;AACAJ,MAAEyC,MAAF,EAAUT,WAAV,CAAsB9B,UAAUG,KAAhC,EAAuC,eAAewC,IAAf,CAAoBN,MAAMlB,IAA1B,CAAvC;AACD,GAfH;;AAkBA;;;;;;AAMArB,IAAEC,EAAF,CAAKP,IAAL,IAAyBD,OAAOkD,gBAAhC;AACA3C,IAAEC,EAAF,CAAKP,IAAL,EAAWoD,WAAX,GAAyBrD,MAAzB;AACAO,IAAEC,EAAF,CAAKP,IAAL,EAAWqD,UAAX,GAAyB,YAAY;AACnC/C,MAAEC,EAAF,CAAKP,IAAL,IAAaK,kBAAb;AACA,WAAON,OAAOkD,gBAAd;AACD,GAHD;;AAKA,SAAOlD,MAAP;AAED,CAhLc,CAgLZuD,MAhLY,CAAf","file":"button.js","sourcesContent":["import $ from 'jquery'\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0-beta): button.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Button = (() => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'button'\n const VERSION = '4.0.0-beta'\n const DATA_KEY = 'bs.button'\n const EVENT_KEY = `.${DATA_KEY}`\n const DATA_API_KEY = '.data-api'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n\n const ClassName = {\n ACTIVE : 'active',\n BUTTON : 'btn',\n FOCUS : 'focus'\n }\n\n const Selector = {\n DATA_TOGGLE_CARROT : '[data-toggle^=\"button\"]',\n DATA_TOGGLE : '[data-toggle=\"buttons\"]',\n INPUT : 'input',\n ACTIVE : '.active',\n BUTTON : '.btn'\n }\n\n const Event = {\n CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`,\n FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} `\n + `blur${EVENT_KEY}${DATA_API_KEY}`\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Button {\n\n constructor(element) {\n this._element = element\n }\n\n\n // getters\n\n static get VERSION() {\n return VERSION\n }\n\n\n // public\n\n toggle() {\n let triggerChangeEvent = true\n let addAriaPressed = true\n const rootElement = $(this._element).closest(\n Selector.DATA_TOGGLE\n )[0]\n\n if (rootElement) {\n const input = $(this._element).find(Selector.INPUT)[0]\n\n if (input) {\n if (input.type === 'radio') {\n if (input.checked &&\n $(this._element).hasClass(ClassName.ACTIVE)) {\n triggerChangeEvent = false\n\n } else {\n const activeElement = $(rootElement).find(Selector.ACTIVE)[0]\n\n if (activeElement) {\n $(activeElement).removeClass(ClassName.ACTIVE)\n }\n }\n }\n\n if (triggerChangeEvent) {\n if (input.hasAttribute('disabled') ||\n rootElement.hasAttribute('disabled') ||\n input.classList.contains('disabled') ||\n rootElement.classList.contains('disabled')) {\n return\n }\n input.checked = !$(this._element).hasClass(ClassName.ACTIVE)\n $(input).trigger('change')\n }\n\n input.focus()\n addAriaPressed = false\n }\n\n }\n\n if (addAriaPressed) {\n this._element.setAttribute('aria-pressed',\n !$(this._element).hasClass(ClassName.ACTIVE))\n }\n\n if (triggerChangeEvent) {\n $(this._element).toggleClass(ClassName.ACTIVE)\n }\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n this._element = null\n }\n\n\n // static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let data = $(this).data(DATA_KEY)\n\n if (!data) {\n data = new Button(this)\n $(this).data(DATA_KEY, data)\n }\n\n if (config === 'toggle') {\n data[config]()\n }\n })\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 event.preventDefault()\n\n let button = event.target\n\n if (!$(button).hasClass(ClassName.BUTTON)) {\n button = $(button).closest(Selector.BUTTON)\n }\n\n Button._jQueryInterface.call($(button), 'toggle')\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(ClassName.FOCUS, /^focus(in)?$/.test(event.type))\n })\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Button._jQueryInterface\n $.fn[NAME].Constructor = Button\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Button._jQueryInterface\n }\n\n return Button\n\n})(jQuery)\n\nexport default Button\n"]}