diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-12-03 17:18:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 17:18:59 +0300 |
commit | cfe31592d7b487a769fd8d14ddf7898c07425280 (patch) | |
tree | 79d9dc546df2099295a948a26ca2f9ae71a3a733 /js/dist/dropdown.js | |
parent | cfd00b5eeb7b7440afb3f115a66ea3c58e2e2d5d (diff) |
Dist (#32323)
Diffstat (limited to 'js/dist/dropdown.js')
-rw-r--r-- | js/dist/dropdown.js | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/js/dist/dropdown.js b/js/dist/dropdown.js index 679bea9f5e..9b5387b5bd 100644 --- a/js/dist/dropdown.js +++ b/js/dist/dropdown.js @@ -5,7 +5,7 @@ */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('popper.js'), require('./dom/selector-engine.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', 'popper.js', './dom/selector-engine.js'], factory) : + typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/manipulator', 'popper.js', './dom/selector-engine'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Data, global.EventHandler, global.Manipulator, global.Popper, global.SelectorEngine)); }(this, (function (Data, EventHandler, Manipulator, Popper, SelectorEngine) { 'use strict'; @@ -101,8 +101,6 @@ } }; - function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } @@ -112,8 +110,55 @@ * ------------------------------------------------------------------------ */ - var NAME = 'dropdown'; var VERSION = '5.0.0-alpha3'; + + var BaseComponent = /*#__PURE__*/function () { + function BaseComponent(element) { + if (!element) { + return; + } + + this._element = element; + Data__default['default'].setData(element, this.constructor.DATA_KEY, this); + } + + var _proto = BaseComponent.prototype; + + _proto.dispose = function dispose() { + Data__default['default'].removeData(this._element, this.constructor.DATA_KEY); + this._element = null; + } + /** Static */ + ; + + BaseComponent.getInstance = function getInstance(element) { + return Data__default['default'].getData(element, this.DATA_KEY); + }; + + _createClass(BaseComponent, null, [{ + key: "VERSION", + get: function get() { + return VERSION; + } + }]); + + return BaseComponent; + }(); + + function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } + + function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'dropdown'; var DATA_KEY = 'bs.dropdown'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -174,17 +219,21 @@ * ------------------------------------------------------------------------ */ - var Dropdown = /*#__PURE__*/function () { + var Dropdown = /*#__PURE__*/function (_BaseComponent) { + _inheritsLoose(Dropdown, _BaseComponent); + function Dropdown(element, config) { - this._element = element; - this._popper = null; - this._config = this._getConfig(config); - this._menu = this._getMenuElement(); - this._inNavbar = this._detectNavbar(); + var _this; + + _this = _BaseComponent.call(this, element) || this; + _this._popper = null; + _this._config = _this._getConfig(config); + _this._menu = _this._getMenuElement(); + _this._inNavbar = _this._detectNavbar(); - this._addEventListeners(); + _this._addEventListeners(); - Data__default['default'].setData(element, DATA_KEY, this); + return _this; } // Getters @@ -300,9 +349,9 @@ }; _proto.dispose = function dispose() { - Data__default['default'].removeData(this._element, DATA_KEY); + _BaseComponent.prototype.dispose.call(this); + EventHandler__default['default'].off(this._element, EVENT_KEY); - this._element = null; this._menu = null; if (this._popper) { @@ -322,13 +371,13 @@ ; _proto._addEventListeners = function _addEventListeners() { - var _this = this; + var _this2 = this; EventHandler__default['default'].on(this._element, EVENT_CLICK, function (event) { event.preventDefault(); event.stopPropagation(); - _this.toggle(); + _this2.toggle(); }); }; @@ -364,13 +413,13 @@ }; _proto._getOffset = function _getOffset() { - var _this2 = this; + var _this3 = this; var offset = {}; if (typeof this._config.offset === 'function') { offset.fn = function (data) { - data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); + data.offsets = _extends({}, data.offsets, _this3._config.offset(data.offsets, _this3._element) || {}); return data; }; } else { @@ -532,15 +581,14 @@ return; } - var index = items.indexOf(event.target); + var index = items.indexOf(event.target); // Up if (event.key === ARROW_UP_KEY && index > 0) { - // Up index--; - } + } // Down + if (event.key === ARROW_DOWN_KEY && index < items.length - 1) { - // Down index++; } // index is -1 if the first keydown is an ArrowUp @@ -549,16 +597,7 @@ items[index].focus(); }; - Dropdown.getInstance = function getInstance(element) { - return Data__default['default'].getData(element, DATA_KEY); - }; - - _createClass(Dropdown, null, [{ - key: "VERSION", - get: function get() { - return VERSION; - } - }, { + _createClass$1(Dropdown, null, [{ key: "Default", get: function get() { return Default; @@ -568,10 +607,15 @@ get: function get() { return DefaultType; } + }, { + key: "DATA_KEY", + get: function get() { + return DATA_KEY; + } }]); return Dropdown; - }(); + }(BaseComponent); /** * ------------------------------------------------------------------------ * Data Api implementation |