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
7.1 KiB

define(["exports","jquery","core/popper","./util"],function(a,b,c,d){"use strict";function e(a){return a&&a.__esModule?a:{"default":a}}function f(a){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function g(){return g=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},g.apply(this,arguments)}function h(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function i(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}function j(a,b,c){return b&&i(a.prototype,b),c&&i(a,c),a}Object.defineProperty(a,"__esModule",{value:!0});var k=e(b),l=e(c),m=e(d),n=function(a){var b="dropdown",c="4.0.0",d="bs.dropdown",e=".".concat(d),i=".data-api",k=a.fn[b],n=27,o=32,p=9,q=38,r=40,s=3,t=new RegExp("".concat(q,"|").concat(r,"|").concat(n)),u={HIDE:"hide".concat(e),HIDDEN:"hidden".concat(e),SHOW:"show".concat(e),SHOWN:"shown".concat(e),CLICK:"click".concat(e),CLICK_DATA_API:"click".concat(e).concat(i),KEYDOWN_DATA_API:"keydown".concat(e).concat(i),KEYUP_DATA_API:"keyup".concat(e).concat(i)},v={DISABLED:"disabled",SHOW:"show",DROPUP:"dropup",DROPRIGHT:"dropright",DROPLEFT:"dropleft",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",POSITION_STATIC:"position-static"},w={DATA_TOGGLE:'[data-toggle="dropdown"]',FORM_CHILD:".dropdown form",MENU:".dropdown-menu",NAVBAR_NAV:".navbar-nav",VISIBLE_ITEMS:".dropdown-menu .dropdown-item:not(.disabled)"},x={TOP:"top-start",TOPEND:"top-end",BOTTOM:"bottom-start",BOTTOMEND:"bottom-end",RIGHT:"right-start",RIGHTEND:"right-end",LEFT:"left-start",LEFTEND:"left-end"},y={offset:0,flip:!1,boundary:"scrollParent"},z={offset:"(number|string|function)",flip:"boolean",boundary:"(string|element)"},A=function(){function i(a,b){h(this,i),this._element=a,this._popper=null,this._config=this._getConfig(b),this._menu=this._getMenuElement(),this._inNavbar=this._detectNavbar(),this._addEventListeners()}return j(i,[{key:"toggle",value:function(){if(!this._element.disabled&&!a(this._element).hasClass(v.DISABLED)){var b=i._getParentFromElement(this._element),c=a(this._menu).hasClass(v.SHOW);if(i._clearMenus(),!c){var d={relatedTarget:this._element},e=a.Event(u.SHOW,d);if(a(b).trigger(e),!e.isDefaultPrevented()){if(!this._inNavbar){if("undefined"==typeof l["default"])throw new TypeError("Bootstrap dropdown require Popper.js (https://popper.js.org)");var f=this._element;a(b).hasClass(v.DROPUP)&&(a(this._menu).hasClass(v.MENULEFT)||a(this._menu).hasClass(v.MENURIGHT))&&(f=b),"scrollParent"!==this._config.boundary&&a(b).addClass(v.POSITION_STATIC),this._popper=new l["default"](f,this._menu,this._getPopperConfig())}"ontouchstart"in document.documentElement&&0===a(b).closest(w.NAVBAR_NAV).length&&a("body").children().on("mouseover",null,a.noop),this._element.focus(),this._element.setAttribute("aria-expanded",!0),a(this._menu).toggleClass(v.SHOW),a(b).toggleClass(v.SHOW).trigger(a.Event(u.SHOWN,d))}}}}},{key:"dispose",value:function(){a.removeData(this._element,d),a(this._element).off(e),this._element=null,this._menu=null,null!==this._popper&&(this._popper.destroy(),this._popper=null)}},{key:"update",value:function(){this._inNavbar=this._detectNavbar(),null!==this._popper&&this._popper.scheduleUpdate()}},{key:"_addEventListeners",value:function(){var b=this;a(this._element).on(u.CLICK,function(a){a.preventDefault(),a.stopPropagation(),b.toggle()})}},{key:"_getConfig",value:function(c){return c=g({},this.constructor.Default,a(this._element).data(),c),m["default"].typeCheckConfig(b,c,this.constructor.DefaultType),c}},{key:"_getMenuElement",value:function(){if(!this._menu){var b=i._getParentFromElement(this._element);this._menu=a(b).find(w.MENU)[0]}return this._menu}},{key:"_getPlacement",value:function(){var b=a(this._element).parent(),c=x.BOTTOM;return b.hasClass(v.DROPUP)?(c=x.TOP,a(this._menu).hasClass(v.MENURIGHT)&&(c=x.TOPEND)):b.hasClass(v.DROPRIGHT)?c=x.RIGHT:b.hasClass(v.DROPLEFT)?c=x.LEFT:a(this._menu).hasClass(v.MENURIGHT)&&(c=x.BOTTOMEND),c}},{key:"_detectNavbar",value:function(){return a(this._element).closest(".navbar").length>0}},{key:"_getPopperConfig",value:function(){var a=this,b={};"function"==typeof this._config.offset?b.fn=function(b){return b.offsets=g({},b.offsets,a._config.offset(b.offsets)||{}),b}:b.offset=this._config.offset;var c={placement:this._getPlacement(),modifiers:{offset:b,flip:{enabled:this._config.flip},preventOverflow:{boundariesElement:this._config.boundary}}};return c}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this).data(d),e="object"===f(b)?b:null;if(c||(c=new i(this,e),a(this).data(d,c)),"string"==typeof b){if("undefined"==typeof c[b])throw new TypeError('No method named "'.concat(b,'"'));c[b]()}})}},{key:"_clearMenus",value:function(b){if(!b||b.which!==s&&("keyup"!==b.type||b.which===p))for(var c=a.makeArray(a(w.DATA_TOGGLE)),e=0;e<c.length;e++){var f=i._getParentFromElement(c[e]),g=a(c[e]).data(d),h={relatedTarget:c[e]};if(g){var j=g._menu;if(a(f).hasClass(v.SHOW)&&!(b&&("click"===b.type&&/input|textarea/i.test(b.target.tagName)||"keyup"===b.type&&b.which===p)&&a.contains(f,b.target))){var k=a.Event(u.HIDE,h);a(f).trigger(k),k.isDefaultPrevented()||("ontouchstart"in document.documentElement&&a("body").children().off("mouseover",null,a.noop),c[e].setAttribute("aria-expanded","false"),a(j).removeClass(v.SHOW),a(f).removeClass(v.SHOW).trigger(a.Event(u.HIDDEN,h)))}}}}},{key:"_getParentFromElement",value:function(b){var c,d=m["default"].getSelectorFromElement(b);return d&&(c=a(d)[0]),c||b.parentNode}},{key:"_dataApiKeydownHandler",value:function(b){if((/input|textarea/i.test(b.target.tagName)?!(b.which===o||b.which!==n&&(b.which!==r&&b.which!==q||a(b.target).closest(w.MENU).length)):t.test(b.which))&&(b.preventDefault(),b.stopPropagation(),!this.disabled&&!a(this).hasClass(v.DISABLED))){var c=i._getParentFromElement(this),d=a(c).hasClass(v.SHOW);if(!d&&(b.which!==n||b.which!==o)||d&&(b.which===n||b.which===o)){if(b.which===n){var e=a(c).find(w.DATA_TOGGLE)[0];a(e).trigger("focus")}return void a(this).trigger("click")}var f=a(c).find(w.VISIBLE_ITEMS).get();if(0!==f.length){var g=f.indexOf(b.target);b.which===q&&g>0&&g--,b.which===r&&g<f.length-1&&g++,g<0&&(g=0),f[g].focus()}}}},{key:"VERSION",get:function(){return c}},{key:"Default",get:function(){return y}},{key:"DefaultType",get:function(){return z}}]),i}();return a(document).on(u.KEYDOWN_DATA_API,w.DATA_TOGGLE,A._dataApiKeydownHandler).on(u.KEYDOWN_DATA_API,w.MENU,A._dataApiKeydownHandler).on("".concat(u.CLICK_DATA_API," ").concat(u.KEYUP_DATA_API),A._clearMenus).on(u.CLICK_DATA_API,w.DATA_TOGGLE,function(b){b.preventDefault(),b.stopPropagation(),A._jQueryInterface.call(a(this),"toggle")}).on(u.CLICK_DATA_API,w.FORM_CHILD,function(a){a.stopPropagation()}),a.fn[b]=A._jQueryInterface,a.fn[b].Constructor=A,a.fn[b].noConflict=function(){return a.fn[b]=k,A._jQueryInterface},A}(k["default"],l["default"]);a["default"]=n});