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/dropdown.js.map
2015-05-10 19:45:38 -07:00

1 line
No EOL
13 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"sources":["js/src/dropdown.js"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,IAAM,QAAQ,GAAG,CAAC,UAAC,CAAC,EAAK;;;;;;;;AASvB,MAAM,IAAI,GAAkB,UAAU,CAAA;AACtC,MAAM,OAAO,GAAe,OAAO,CAAA;AACnC,MAAM,QAAQ,GAAc,aAAa,CAAA;AACzC,MAAM,kBAAkB,GAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;;AAEtC,MAAM,KAAK,GAAG;AACZ,QAAI,EAAS,kBAAkB;AAC/B,UAAM,EAAO,oBAAoB;AACjC,QAAI,EAAS,kBAAkB;AAC/B,SAAK,EAAQ,mBAAmB;AAChC,SAAK,EAAQ,mBAAmB;AAChC,WAAO,EAAM,8BAA8B;AAC3C,cAAU,EAAG,4BAA4B;GAC1C,CAAA;;AAED,MAAM,SAAS,GAAG;AAChB,YAAQ,EAAG,mBAAmB;AAC9B,YAAQ,EAAG,UAAU;AACrB,QAAI,EAAO,MAAM;GAClB,CAAA;;AAED,MAAM,QAAQ,GAAG;AACf,YAAQ,EAAQ,oBAAoB;AACpC,eAAW,EAAK,0BAA0B;AAC1C,cAAU,EAAM,gBAAgB;AAChC,aAAS,EAAO,eAAe;AAC/B,gBAAY,EAAI,kBAAkB;AAClC,cAAU,EAAM,aAAa;AAC7B,iBAAa,EAAG,qCAAqC,GACrC,sCAAsC;GACvD,CAAA;;;;;;;;MASK,QAAQ;AAED,aAFP,QAAQ,CAEA,OAAO,EAAE;4BAFjB,QAAQ;;AAGV,OAAC,CAAC,OAAO,CAAC,CAAC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;;AASL,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAe,QAAQ,CAAC,gBAAgB,CAAA;AAClD,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,GAAG,QAAQ,CAAA;AACjC,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,GAAI,YAAY;AACnC,KAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAA;AAC/B,WAAO,QAAQ,CAAC,gBAAgB,CAAA;GACjC,CAAA;;AAED,SAAO,QAAQ,CAAA;CAEhB,CAAA,CAAE,MAAM,CAAC,CAAA","file":"js/src/dropdown.js","sourcesContent":["import Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): dropdown.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Dropdown = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'dropdown'\n const VERSION = '4.0.0'\n const DATA_KEY = 'bs.dropdown'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n\n const Event = {\n HIDE   : 'hide.bs.dropdown',\n HIDDEN   : 'hidden.bs.dropdown',\n SHOW   : 'show.bs.dropdown',\n SHOWN   : 'shown.bs.dropdown',\n CLICK   : 'click.bs.dropdown',\n KEYDOWN   : 'keydown.bs.dropdown.data-api',\n CLICK_DATA : 'click.bs.dropdown.data-api'\n }\n\n const ClassName = {\n BACKDROP : 'dropdown-backdrop',\n DISABLED : 'disabled',\n OPEN : 'open'\n }\n\n const Selector = {\n BACKDROP : '.dropdown-backdrop',\n DATA_TOGGLE : '[data-toggle=\"dropdown\"]',\n FORM_CHILD : '.dropdown form',\n ROLE_MENU : '[role=\"menu\"]',\n ROLE_LISTBOX : '[role=\"listbox\"]',\n NAVBAR_NAV : '.navbar-nav',\n VISIBLE_ITEMS : '[role=\"menu\"] li:not(.disabled) a, '\n + '[role=\"listbox\"] li:not(.disabled) a'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Dropdown {\n\n constructor(element) {\n $(element).on(Event.CLICK, this.toggle)\n }\n\n\n // getters\n\n static get VERSION() {\n return VERSION\n }\n\n\n // public\n\n toggle() {\n if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {\n return\n }\n\n let parent = Dropdown._getParentFromElement(this)\n let isActive = $(parent).hasClass(ClassName.OPEN)\n\n Dropdown._clearMenus()\n\n if (isActive) {\n return false\n }\n\n if ('ontouchstart' in document.documentElement &&\n (!$(parent).closest(Selector.NAVBAR_NAV).length)) {\n\n // if mobile we use a backdrop because click events don't delegate\n let dropdown = document.createElement('div')\n dropdown.className = ClassName.BACKDROP\n $(dropdown).insertBefore(this)\n $(dropdown).on('click', Dropdown._clearMenus)\n }\n\n let relatedTarget = { relatedTarget : this }\n let showEvent = $.Event(Event.SHOW, relatedTarget)\n\n $(parent).trigger(showEvent)\n\n if (showEvent.isDefaultPrevented()) {\n return\n }\n\n this.focus()\n this.setAttribute('aria-expanded', 'true')\n\n $(parent).toggleClass(ClassName.OPEN)\n $(parent).trigger(Event.SHOWN, relatedTarget)\n\n return false\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 $(this).data(DATA_KEY, (data = new Dropdown(this)))\n }\n\n if (typeof config === 'string') {\n data[config].call(this)\n }\n })\n }\n\n static _clearMenus(event) {\n if (event && event.which === 3) {\n return\n }\n\n let backdrop = $(Selector.BACKDROP)[0]\n if (backdrop) {\n backdrop.parentNode.removeChild(backdrop)\n }\n\n let toggles = $.makeArray($(Selector.DATA_TOGGLE))\n\n for (let i = 0; i < toggles.length; i++) {\n let parent = Dropdown._getParentFromElement(toggles[i])\n let relatedTarget = { relatedTarget : toggles[i] }\n\n if (!$(parent).hasClass(ClassName.OPEN)) {\n continue\n }\n\n if (event && event.type === 'click' &&\n (/input|textarea/i.test(event.target.tagName)) &&\n ($.contains(parent, event.target))) {\n continue\n }\n\n let hideEvent = $.Event(Event.HIDE, relatedTarget)\n $(parent).trigger(hideEvent)\n if (hideEvent.isDefaultPrevented()) {\n continue\n }\n\n toggles[i].setAttribute('aria-expanded', 'false')\n\n $(parent)\n .removeClass(ClassName.OPEN)\n .trigger(Event.HIDDEN, relatedTarget)\n }\n }\n\n static _getParentFromElement(element) {\n let parent\n let selector = Util.getSelectorFromElement(element)\n\n if (selector) {\n parent = $(selector)[0]\n }\n\n return parent || element.parentNode\n }\n\n static _dataApiKeydownHandler(event) {\n if (!/(38|40|27|32)/.test(event.which) ||\n /input|textarea/i.test(event.target.tagName)) {\n return\n }\n\n event.preventDefault()\n event.stopPropagation()\n\n if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {\n return\n }\n\n let parent = Dropdown._getParentFromElement(this)\n let isActive = $(parent).hasClass(ClassName.OPEN)\n\n if ((!isActive && event.which !== 27) ||\n (isActive && event.which === 27)) {\n\n if (event.which === 27) {\n let toggle = $(parent).find(Selector.DATA_TOGGLE)[0]\n $(toggle).trigger('focus')\n }\n\n $(this).trigger('click')\n return\n }\n\n let items = $.makeArray($(Selector.VISIBLE_ITEMS))\n\n items = items.filter((item) => {\n return item.offsetWidth || item.offsetHeight\n })\n\n if (!items.length) {\n return\n }\n\n let index = items.indexOf(event.target)\n\n if (event.which === 38 && index > 0) index-- // up\n if (event.which === 40 && index < items.length - 1) index++ // down\n if (!~index) index = 0\n\n items[index].focus()\n }\n\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document)\n .on(Event.KEYDOWN, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler)\n .on(Event.KEYDOWN, Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler)\n .on(Event.KEYDOWN, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler)\n .on(Event.CLICK_DATA, Dropdown._clearMenus)\n .on(Event.CLICK_DATA, Selector.DATA_TOGGLE, Dropdown.prototype.toggle)\n .on(Event.CLICK_DATA, Selector.FORM_CHILD, function (e) {\n e.stopPropagation()\n })\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Dropdown._jQueryInterface\n $.fn[NAME].Constructor = Dropdown\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Dropdown._jQueryInterface\n }\n\n return Dropdown\n\n})(jQuery)\n\nexport default Dropdown\n"]}