1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00
twbs--bootstrap/js/dist/tab.js.map
Mark Otto 8c587d4280 dist
2017-10-25 12:31:55 -07:00

1 line
No EOL
14 KiB
Text

{"version":3,"sources":["../src/tab.js"],"names":["Tab","$","NAME","VERSION","DATA_KEY","EVENT_KEY","DATA_API_KEY","JQUERY_NO_CONFLICT","fn","TRANSITION_DURATION","Event","HIDE","HIDDEN","SHOW","SHOWN","CLICK_DATA_API","ClassName","DROPDOWN_MENU","ACTIVE","DISABLED","FADE","Selector","DROPDOWN","NAV_LIST_GROUP","ACTIVE_UL","DATA_TOGGLE","DROPDOWN_TOGGLE","DROPDOWN_ACTIVE_CHILD","element","_element","show","parentNode","nodeType","Node","ELEMENT_NODE","hasClass","target","previous","listElement","closest","selector","Util","getSelectorFromElement","itemSelector","nodeName","makeArray","find","length","hideEvent","relatedTarget","showEvent","trigger","isDefaultPrevented","_activate","complete","hiddenEvent","shownEvent","dispose","removeData","container","callback","activeElements","children","active","isTransitioning","supportsTransitionEnd","_transitionComplete","one","TRANSITION_END","emulateTransitionEnd","removeClass","dropdownChild","getAttribute","setAttribute","addClass","reflow","dropdownElement","_jQueryInterface","config","each","$this","data","Error","document","on","event","preventDefault","call","Constructor","noConflict"],"mappings":";;;;AAIA;;;;;;AAOA,IAAMA,MAAO,UAACC,CAAD,EAAO;AAGlB;;;;;AAMA,MAAMC,OAAsB,KAA5B;AACA,MAAMC,UAAsB,cAA5B;AACA,MAAMC,WAAsB,QAA5B;AACA,MAAMC,kBAA0BD,QAAhC;AACA,MAAME,eAAsB,WAA5B;AACA,MAAMC,qBAAsBN,EAAEO,EAAF,CAAKN,IAAL,CAA5B;AACA,MAAMO,sBAAsB,GAA5B;AAEA,MAAMC,QAAQ;AACZC,mBAAwBN,SADZ;AAEZO,uBAA0BP,SAFd;AAGZQ,mBAAwBR,SAHZ;AAIZS,qBAAyBT,SAJb;AAKZU,8BAAyBV,SAAzB,G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AUD,MAAMC,IAAN,CAAW7E,QAAX,CAAd;;AAEA,YAAI,CAAC6E,IAAL,EAAW;AACTA,iBAAO,IAAIjF,GAAJ,CAAQ,IAAR,CAAP;AACAgF,gBAAMC,IAAN,CAAW7E,QAAX,EAAqB6E,IAArB;AACD;;AAED,YAAI,OAAOH,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,cAAI,OAAOG,KAAKH,MAAL,CAAP,KAAwB,WAA5B,EAAyC;AACvC,kBAAM,IAAII,KAAJ,wBAA8BJ,MAA9B,QAAN;AACD;;AACDG,eAAKH,MAAL;AACD;AACF,OAfM,CAAP;AAgBD,KAhPe;;AAAA;AAAA;AAAA,0BA2DK;AACnB,eAAO3E,OAAP;AACD;AA7De;;AAAA;AAAA;AAqPlB;;;;;;;AAMAF,IAAEkF,QAAF,EACGC,EADH,CACM1E,MAAMK,cADZ,EAC4BM,SAASI,WADrC,EACkD,UAAU4D,KAAV,EAAiB;AAC/DA,UAAMC,cAAN;;AACAtF,QAAI6E,gBAAJ,CAAqBU,IAArB,CAA0BtF,EAAE,IAAF,CAA1B,EAAmC,MAAnC;AACD,GAJH;AAOA;;;;;;AAMAA,IAAEO,EAAF,CAAKN,IAAL,IAAyBF,IAAI6E,gBAA7B;AACA5E,IAAEO,EAAF,CAAKN,IAAL,EAAWsF,WAAX,GAAyBxF,GAAzB;;AACAC,IAAEO,EAAF,CAAKN,IAAL,EAAWuF,UAAX,GAAyB,YAAY;AACnCxF,MAAEO,EAAF,CAAKN,IAAL,IAAaK,kBAAb;AACA,WAAOP,IAAI6E,gBAAX;AACD,GAHD;;AAKA,SAAO7E,GAAP;AAED,CAjRW,CAiRTC,CAjRS,CAAZ","file":"tab.js","sourcesContent":["import $ from 'jquery'\nimport Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0-beta.2): tab.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Tab = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'tab'\n const VERSION = '4.0.0-beta.2'\n const DATA_KEY = 'bs.tab'\n const EVENT_KEY = `.${DATA_KEY}`\n const DATA_API_KEY = '.data-api'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const TRANSITION_DURATION = 150\n\n const Event = {\n HIDE : `hide${EVENT_KEY}`,\n HIDDEN : `hidden${EVENT_KEY}`,\n SHOW : `show${EVENT_KEY}`,\n SHOWN : `shown${EVENT_KEY}`,\n CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`\n }\n\n const ClassName = {\n DROPDOWN_MENU : 'dropdown-menu',\n ACTIVE : 'active',\n DISABLED : 'disabled',\n FADE : 'fade',\n SHOW : 'show'\n }\n\n const Selector = {\n DROPDOWN : '.dropdown',\n NAV_LIST_GROUP : '.nav, .list-group',\n ACTIVE : '.active',\n ACTIVE_UL : '> li > .active',\n DATA_TOGGLE : '[data-toggle=\"tab\"], [data-toggle=\"pill\"], [data-toggle=\"list\"]',\n DROPDOWN_TOGGLE : '.dropdown-toggle',\n DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Tab {\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 show() {\n if (this._element.parentNode &&\n this._element.parentNode.nodeType === Node.ELEMENT_NODE &&\n $(this._element).hasClass(ClassName.ACTIVE) ||\n $(this._element).hasClass(ClassName.DISABLED)) {\n return\n }\n\n let target\n let previous\n const listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0]\n const selector = Util.getSelectorFromElement(this._element)\n\n if (listElement) {\n const itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE\n previous = $.makeArray($(listElement).find(itemSelector))\n previous = previous[previous.length - 1]\n }\n\n const hideEvent = $.Event(Event.HIDE, {\n relatedTarget: this._element\n })\n\n const showEvent = $.Event(Event.SHOW, {\n relatedTarget: previous\n })\n\n if (previous) {\n $(previous).trigger(hideEvent)\n }\n\n $(this._element).trigger(showEvent)\n\n if (showEvent.isDefaultPrevented() ||\n hideEvent.isDefaultPrevented()) {\n return\n }\n\n if (selector) {\n target = $(selector)[0]\n }\n\n this._activate(\n this._element,\n listElement\n )\n\n const complete = () => {\n const hiddenEvent = $.Event(Event.HIDDEN, {\n relatedTarget: this._element\n })\n\n const shownEvent = $.Event(Event.SHOWN, {\n relatedTarget: previous\n })\n\n $(previous).trigger(hiddenEvent)\n $(this._element).trigger(shownEvent)\n }\n\n if (target) {\n this._activate(target, target.parentNode, complete)\n } else {\n complete()\n }\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n this._element = null\n }\n\n\n // private\n\n _activate(element, container, callback) {\n let activeElements\n if (container.nodeName === 'UL') {\n activeElements = $(container).find(Selector.ACTIVE_UL)\n } else {\n activeElements = $(container).children(Selector.ACTIVE)\n }\n\n const active = activeElements[0]\n const isTransitioning = callback\n && Util.supportsTransitionEnd()\n && (active && $(active).hasClass(ClassName.FADE))\n\n const complete = () => this._transitionComplete(\n element,\n active,\n isTransitioning,\n callback\n )\n\n if (active && isTransitioning) {\n $(active)\n .one(Util.TRANSITION_END, complete)\n .emulateTransitionEnd(TRANSITION_DURATION)\n\n } else {\n complete()\n }\n\n if (active) {\n $(active).removeClass(ClassName.SHOW)\n }\n }\n\n _transitionComplete(element, active, isTransitioning, callback) {\n if (active) {\n $(active).removeClass(ClassName.ACTIVE)\n\n const dropdownChild = $(active.parentNode).find(\n Selector.DROPDOWN_ACTIVE_CHILD\n )[0]\n\n if (dropdownChild) {\n $(dropdownChild).removeClass(ClassName.ACTIVE)\n }\n\n if (active.getAttribute('role') === 'tab') {\n active.setAttribute('aria-selected', false)\n }\n }\n\n $(element).addClass(ClassName.ACTIVE)\n if (element.getAttribute('role') === 'tab') {\n element.setAttribute('aria-selected', true)\n }\n\n if (isTransitioning) {\n Util.reflow(element)\n $(element).addClass(ClassName.SHOW)\n } else {\n $(element).removeClass(ClassName.FADE)\n }\n\n if (element.parentNode &&\n $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {\n\n const dropdownElement = $(element).closest(Selector.DROPDOWN)[0]\n if (dropdownElement) {\n $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE)\n }\n\n element.setAttribute('aria-expanded', true)\n }\n\n if (callback) {\n callback()\n }\n }\n\n\n // static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n const $this = $(this)\n let data = $this.data(DATA_KEY)\n\n if (!data) {\n data = new Tab(this)\n $this.data(DATA_KEY, data)\n }\n\n if (typeof config === 'string') {\n if (typeof data[config] === 'undefined') {\n throw new Error(`No method named \"${config}\"`)\n }\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, function (event) {\n event.preventDefault()\n Tab._jQueryInterface.call($(this), 'show')\n })\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Tab._jQueryInterface\n $.fn[NAME].Constructor = Tab\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Tab._jQueryInterface\n }\n\n return Tab\n\n})($)\n\nexport default Tab\n"]}