1/*! 2 * Bootstrap dropdown.js v4.3.1 (https://getbootstrap.com/) 3 * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 */ 6(function (global, factory) { 7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) : 8 typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) : 9 (global = global || self, global.Dropdown = factory(global.jQuery, global.Popper, global.Util)); 10}(this, function ($, Popper, Util) { 'use strict'; 11 12 $ = $ && $.hasOwnProperty('default') ? $['default'] : $; 13 Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper; 14 Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util; 15 16 function _defineProperties(target, props) { 17 for (var i = 0; i < props.length; i++) { 18 var descriptor = props[i]; 19 descriptor.enumerable = descriptor.enumerable || false; 20 descriptor.configurable = true; 21 if ("value" in descriptor) descriptor.writable = true; 22 Object.defineProperty(target, descriptor.key, descriptor); 23 } 24 } 25 26 function _createClass(Constructor, protoProps, staticProps) { 27 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 28 if (staticProps) _defineProperties(Constructor, staticProps); 29 return Constructor; 30 } 31 32 function _defineProperty(obj, key, value) { 33 if (key in obj) { 34 Object.defineProperty(obj, key, { 35 value: value, 36 enumerable: true, 37 configurable: true, 38 writable: true 39 }); 40 } else { 41 obj[key] = value; 42 } 43 44 return obj; 45 } 46 47 function _objectSpread(target) { 48 for (var i = 1; i < arguments.length; i++) { 49 var source = arguments[i] != null ? arguments[i] : {}; 50 var ownKeys = Object.keys(source); 51 52 if (typeof Object.getOwnPropertySymbols === 'function') { 53 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 54 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 55 })); 56 } 57 58 ownKeys.forEach(function (key) { 59 _defineProperty(target, key, source[key]); 60 }); 61 } 62 63 return target; 64 } 65 66 /** 67 * ------------------------------------------------------------------------ 68 * Constants 69 * ------------------------------------------------------------------------ 70 */ 71 72 var NAME = 'dropdown'; 73 var VERSION = '4.3.1'; 74 var DATA_KEY = 'bs.dropdown'; 75 var EVENT_KEY = "." + DATA_KEY; 76 var DATA_API_KEY = '.data-api'; 77 var JQUERY_NO_CONFLICT = $.fn[NAME]; 78 var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key 79 80 var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key 81 82 var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key 83 84 var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key 85 86 var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key 87 88 var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) 89 90 var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); 91 var Event = { 92 HIDE: "hide" + EVENT_KEY, 93 HIDDEN: "hidden" + EVENT_KEY, 94 SHOW: "show" + EVENT_KEY, 95 SHOWN: "shown" + EVENT_KEY, 96 CLICK: "click" + EVENT_KEY, 97 CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY, 98 KEYDOWN_DATA_API: "keydown" + EVENT_KEY + DATA_API_KEY, 99 KEYUP_DATA_API: "keyup" + EVENT_KEY + DATA_API_KEY 100 }; 101 var ClassName = { 102 DISABLED: 'disabled', 103 SHOW: 'show', 104 DROPUP: 'dropup', 105 DROPRIGHT: 'dropright', 106 DROPLEFT: 'dropleft', 107 MENURIGHT: 'dropdown-menu-right', 108 MENULEFT: 'dropdown-menu-left', 109 POSITION_STATIC: 'position-static' 110 }; 111 var Selector = { 112 DATA_TOGGLE: '[data-toggle="dropdown"]', 113 FORM_CHILD: '.dropdown form', 114 MENU: '.dropdown-menu', 115 NAVBAR_NAV: '.navbar-nav', 116 VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)' 117 }; 118 var AttachmentMap = { 119 TOP: 'top-start', 120 TOPEND: 'top-end', 121 BOTTOM: 'bottom-start', 122 BOTTOMEND: 'bottom-end', 123 RIGHT: 'right-start', 124 RIGHTEND: 'right-end', 125 LEFT: 'left-start', 126 LEFTEND: 'left-end' 127 }; 128 var Default = { 129 offset: 0, 130 flip: true, 131 boundary: 'scrollParent', 132 reference: 'toggle', 133 display: 'dynamic' 134 }; 135 var DefaultType = { 136 offset: '(number|string|function)', 137 flip: 'boolean', 138 boundary: '(string|element)', 139 reference: '(string|element)', 140 display: 'string' 141 /** 142 * ------------------------------------------------------------------------ 143 * Class Definition 144 * ------------------------------------------------------------------------ 145 */ 146 147 }; 148 149 var Dropdown = 150 /*#__PURE__*/ 151 function () { 152 function Dropdown(element, config) { 153 this._element = element; 154 this._popper = null; 155 this._config = this._getConfig(config); 156 this._menu = this._getMenuElement(); 157 this._inNavbar = this._detectNavbar(); 158 159 this._addEventListeners(); 160 } // Getters 161 162 163 var _proto = Dropdown.prototype; 164 165 // Public
166 _proto.toggle = function toggle() { 167 if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) { 168 return; 169 } 170 171 var parent = Dropdown._getParentFromElement(this._element); 172 173 var isActive = $(this._menu).hasClass(ClassName.SHOW); 174 175 Dropdown._clearMenus(); 176 177 if (isActive) { 178 return; 179 } 180 181 var relatedTarget = { 182 relatedTarget: this._element 183 }; 184 var showEvent = $.Event(Event.SHOW, relatedTarget); 185 $(parent).trigger(showEvent); 186 187 if (showEvent.isDefaultPrevented()) { 188 return; 189 } // Disable totally Popper.js for Dropdown in Navbar 190 191 192 if (!this._inNavbar) { 193 /** 194 * Check for Popper dependency 195 * Popper - https://popper.js.org 196 */ 197 if (typeof Popper === 'undefined') { 198 throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)'); 199 } 200 201 var referenceElement = this._element; 202 203 if (this._config.reference === 'parent') { 204 referenceElement = parent; 205 } else if (Util.isElement(this._config.reference)) { 206 referenceElement = this._config.reference; // Check if it's jQuery element 207 208 if (typeof this._config.reference.jquery !== 'undefined') { 209 referenceElement = this._config.reference[0]; 210 } 211 } // If boundary is not `scrollParent`, then set position to `static` 212 // to allow the menu to "escape" the scroll parent's boundaries 213 // https://github.com/twbs/bootstrap/issues/24251 214 215 216 if (this._config.boundary !== 'scrollParent') { 217 $(parent).addClass(ClassName.POSITION_STATIC); 218 } 219 220 this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); 221 } // If this is a touch-enabled device we add extra 222 // empty mouseover listeners to the body's immediate children; 223 // only needed because of broken event delegation on iOS 224 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html 225 226 227 if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) { 228 $(document.body).children().on('mouseover', null, $.noop); 229 } 230 231 this._element.focus(); 232 233 this._element.setAttribute('aria-expanded', true); 234 235 $(this._menu).toggleClass(ClassName.SHOW); 236 $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget)); 237 }; 238 239 _proto.show = function show() { 240 if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) { 241 return; 242 } 243 244 var relatedTarget = { 245 relatedTarget: this._element 246 }; 247 var showEvent = $.Event(Event.SHOW, relatedTarget); 248 249 var parent = Dropdown._getParentFromElement(this._element); 250 251 $(parent).trigger(showEvent); 252 253 if (showEvent.isDefaultPrevented()) { 254 return; 255 } 256 257 $(this._menu).toggleClass(ClassName.SHOW); 258 $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget)); 259 }; 260 261 _proto.hide = function hide() { 262 if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || !$(this._menu).hasClass(ClassName.SHOW)) { 263 return; 264 } 265 266 var relatedTarget = { 267 relatedTarget: this._element 268 }; 269 var hideEvent = $.Event(Event.HIDE, relatedTarget); 270 271 var parent = Dropdown._getParentFromElement(this._element); 272 273 $(parent).trigger(hideEvent); 274 275 if (hideEvent.isDefaultPrevented()) { 276 return; 277 } 278 279 $(this._menu).toggleClass(ClassName.SHOW); 280 $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget)); 281 }; 282 283 _proto.dispose = function dispose() { 284 $.removeData(this._element, DATA_KEY); 285 $(this._element).off(EVENT_KEY); 286 this._element = null; 287 this._menu = null; 288 289 if (this._popper !== null) { 290 this._popper.destroy(); 291 292 this._popper = null; 293 } 294 }; 295 296 _proto.update = function update() { 297 this._inNavbar = this._detectNavbar(); 298 299 if (this._popper !== null) { 300 this._popper.scheduleUpdate(); 301 } 302 } // Private 303 ; 304 305 _proto._addEventListeners = function _addEventListeners() { 306 var _this = this; 307 308 $(this._element).on(Event.CLICK, function (event) { 309 event.preventDefault(); 310 event.stopPropagation(); 311 312 _this.toggle(); 313 }); 314 }; 315 316 _proto._getConfig = function _getConfig(config) { 317 config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config); 318 Util.typeCheckConfig(NAME, config, this.constructor.DefaultType); 319 return config; 320 }; 321 322 _proto._getMenuElement = function _getMenuElement() { 323 if (!this._menu) { 324 var parent = Dropdown._getParentFromElement(this._element); 325 326 if (parent) { 327 this._menu = parent.querySelector(Selector.MENU); 328 } 329 } 330 331 return this._menu; 332 }; 333 334 _proto._getPlacement = function _getPlacement() { 335 var $parentDropdown = $(this._element.parentNode); 336 var placement = AttachmentMap.BOTTOM; // Handle dropup 337 338 if ($parentDropdown.hasClass(ClassName.DROPUP)) { 339 placement = AttachmentMap.TOP; 340 341 if ($(this._menu).hasClass(ClassName.MENURIGHT)) { 342 placement = AttachmentMap.TOPEND; 343 } 344 } else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) { 345 placement = AttachmentMap.RIGHT; 346 } else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) { 347 placement = AttachmentMap.LEFT; 348 } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) { 349 placement = AttachmentMap.BOTTOMEND; 350 } 351 352 return placement; 353 }; 354 355 _proto._detectNavbar = function _detectNavbar() { 356 return $(this._element).closest('.navbar').length > 0; 357 }; 358 359 _proto._getOffset = function _getOffset() { 360 var _this2 = this; 361 362 var offset = {}; 363 364 if (typeof this._config.offset === 'function') { 365 offset.fn = function (data) { 366 data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); 367 return data; 368 }; 369 } else { 370 offset.offset = this._config.offset; 371 } 372 373 return offset; 374 }; 375 376 _proto._getPopperConfig = function _getPopperConfig() { 377 var popperConfig = { 378 placement: this._getPlacement(), 379 modifiers: { 380 offset: this._getOffset(), 381 flip: { 382 enabled: this._config.flip 383 }, 384 preventOverflow: {
385 boundariesElement: this._config.boundary 386 } 387 } // Disable Popper.js if we have a static display 388 389 }; 390 391 if (this._config.display === 'static') { 392 popperConfig.modifiers.applyStyle = { 393 enabled: false 394 }; 395 } 396 397 return popperConfig; 398 } // Static 399 ; 400 401 Dropdown._jQueryInterface = function _jQueryInterface(config) { 402 return this.each(function () { 403 var data = $(this).data(DATA_KEY); 404 405 var _config = typeof config === 'object' ? config : null; 406 407 if (!data) { 408 data = new Dropdown(this, _config); 409 $(this).data(DATA_KEY, data); 410 } 411 412 if (typeof config === 'string') { 413 if (typeof data[config] === 'undefined') { 414 throw new TypeError("No method named \"" + config + "\""); 415 } 416 417 data[config](); 418 } 419 }); 420 }; 421 422 Dropdown._clearMenus = function _clearMenus(event) { 423 if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { 424 return; 425 } 426 427 var toggles = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)); 428 429 for (var i = 0, len = toggles.length; i < len; i++) { 430 var parent = Dropdown._getParentFromElement(toggles[i]); 431 432 var context = $(toggles[i]).data(DATA_KEY); 433 var relatedTarget = { 434 relatedTarget: toggles[i] 435 }; 436 437 if (event && event.type === 'click') { 438 relatedTarget.clickEvent = event; 439 } 440 441 if (!context) { 442 continue; 443 } 444 445 var dropdownMenu = context._menu; 446 447 if (!$(parent).hasClass(ClassName.SHOW)) { 448 continue; 449 } 450 451 if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) { 452 continue; 453 } 454 455 var hideEvent = $.Event(Event.HIDE, relatedTarget); 456 $(parent).trigger(hideEvent); 457 458 if (hideEvent.isDefaultPrevented()) { 459 continue; 460 } // If this is a touch-enabled device we remove the extra 461 // empty mouseover listeners we added for iOS support 462 463 464 if ('ontouchstart' in document.documentElement) { 465 $(document.body).children().off('mouseover', null, $.noop); 466 } 467 468 toggles[i].setAttribute('aria-expanded', 'false'); 469 $(dropdownMenu).removeClass(ClassName.SHOW); 470 $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget)); 471 } 472 }; 473 474 Dropdown._getParentFromElement = function _getParentFromElement(element) { 475 var parent; 476 var selector = Util.getSelectorFromElement(element); 477 478 if (selector) { 479 parent = document.querySelector(selector); 480 } 481 482 return parent || element.parentNode; 483 } // eslint-disable-next-line complexity 484 ; 485 486 Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { 487 // If not input/textarea: 488 // - And not a key in REGEXP_KEYDOWN => not a dropdown command 489 // If input/textarea: 490 // - If space key => not a dropdown command 491 // - If key is other than escape 492 // - If key is not up or down => not a dropdown command 493 // - If trigger inside the menu => not a dropdown command 494 if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { 495 return; 496 } 497 498 event.preventDefault(); 499 event.stopPropagation(); 500 501 if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { 502 return; 503 } 504 505 var parent = Dropdown._getParentFromElement(this); 506 507 var isActive = $(parent).hasClass(ClassName.SHOW); 508 509 if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { 510 if (event.which === ESCAPE_KEYCODE) { 511 var toggle = parent.querySelector(Selector.DATA_TOGGLE); 512 $(toggle).trigger('focus'); 513 } 514 515 $(this).trigger('click'); 516 return; 517 } 518 519 var items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS)); 520 521 if (items.length === 0) { 522 return; 523 } 524 525 var index = items.indexOf(event.target); 526 527 if (event.which === ARROW_UP_KEYCODE && index > 0) { 528 // Up 529 index--; 530 } 531 532 if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { 533 // Down 534 index++; 535 } 536 537 if (index < 0) { 538 index = 0; 539 } 540 541 items[index].focus(); 542 }; 543 544 _createClass(Dropdown, null, [{ 545 key: "VERSION", 546 get: function get() { 547 return VERSION; 548 } 549 }, {
vendor: 1,385 bytes, lines 550-595
550 key: "Default", 551 get: function get() { 552 return Default; 553 } 554 }, { 555 key: "DefaultType", 556 get: function get() { 557 return DefaultType; 558 } 559 }]); 560 561 return Dropdown; 562 }(); 563 /** 564 * ------------------------------------------------------------------------ 565 * Data Api implementation 566 * ------------------------------------------------------------------------ 567 */ 568 569 570 $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + " " + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { 571 event.preventDefault(); 572 event.stopPropagation(); 573 574 Dropdown._jQueryInterface.call($(this), 'toggle'); 575 }).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) { 576 e.stopPropagation(); 577 }); 578 /** 579 * ------------------------------------------------------------------------ 580 * jQuery 581 * ------------------------------------------------------------------------ 582 */ 583 584 $.fn[NAME] = Dropdown._jQueryInterface; 585 $.fn[NAME].Constructor = Dropdown; 586 587 $.fn[NAME].noConflict = function () { 588 $.fn[NAME] = JQUERY_NO_CONFLICT; 589 return Dropdown._jQueryInterface; 590 }; 591 592 return Dropdown; 593 594})); 595//# sourceMappingURL=dropdown.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.