You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
33 KiB
JavaScript
126 lines
33 KiB
JavaScript
/*
|
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
* This devtool is neither made for production nor for readable output files.
|
|
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
* or disable the default devtool with "devtool: false".
|
|
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
*/
|
|
/******/ (() => { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./src/baseWidgets/bottomNav.js":
|
|
/*!**************************************!*\
|
|
!*** ./src/baseWidgets/bottomNav.js ***!
|
|
\**************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"BottomNavWidget\": () => (/* binding */ BottomNavWidget)\n/* harmony export */ });\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar BottomNavWidget = /*#__PURE__*/function () {\n function BottomNavWidget() {\n _classCallCheck(this, BottomNavWidget);\n this.domCreated = false;\n this.btnList = [];\n }\n _createClass(BottomNavWidget, [{\n key: \"initDom\",\n value: function initDom() {\n if (!this.domCreated) {\n var bottomNavContainer = document.querySelector('#isekai-bottom-nav');\n if (bottomNavContainer) {\n this.bottomNavContainer = bottomNavContainer;\n this.bottomNavElem = bottomNavContainer.querySelector('.isekai-bottom-nav');\n } else {\n bottomNavContainer = document.createElement('nav');\n bottomNavContainer.id = 'isekai-bottom-nav';\n bottomNavContainer.className = 'isekai-bottom-nav-container';\n this.bottomNavContainer = bottomNavContainer;\n var bottomNavElem = document.createElement('div');\n bottomNavElem.className = 'isekai-bottom-nav';\n this.bottomNavElem = bottomNavElem;\n var bottomNavPlaceholder = document.createElement('div');\n bottomNavPlaceholder.id = 'isekai-bottom-nav-placeholder';\n bottomNavPlaceholder.className = 'isekai-bottom-nav-placeholder';\n bottomNavContainer.appendChild(bottomNavElem);\n document.body.appendChild(bottomNavContainer);\n document.body.appendChild(bottomNavPlaceholder);\n document.body.classList.add('use-isekai-bottom-nav');\n }\n }\n }\n }, {\n key: \"addButton\",\n value: function addButton(btnInfo) {\n var _btnInfo$priority;\n if (!this.domCreated) {\n this.initDom();\n }\n var btnElem = document.createElement('a');\n btnElem.role = 'button';\n btnElem.href = 'javascript:void(0);';\n btnElem.classList.add('isekai-bottom-nav-btn');\n btnElem.dataset.id = btnInfo.id;\n if (btnInfo.className) {\n var _btnElem$classList;\n (_btnElem$classList = btnElem.classList).add.apply(_btnElem$classList, _toConsumableArray(btnInfo.className.split(' ')));\n }\n if (btnInfo.icon) {\n var iconElem = document.createElement('span');\n iconElem.className = 'isekai-bottom-nav-btn-icon';\n if (typeof btnInfo.icon === 'string') {\n iconElem.innerHTML = btnInfo.icon;\n } else if (_typeof(btnInfo.icon) === 'object') {\n iconElem.appendChild(btnInfo.icon);\n }\n btnElem.appendChild(iconElem);\n }\n if (btnInfo.label) {\n btnElem.title = btnInfo.label;\n btnElem.setAttribute('aria-label', btnInfo.label);\n }\n if (btnInfo.expand) {\n var _btnInfo$label;\n btnElem.classList.add('isekai-bottom-nav-btn-expand');\n var labelElem = document.createElement('span');\n labelElem.className = 'isekai-bottom-nav-btn-label';\n labelElem.innerText = (_btnInfo$label = btnInfo.label) !== null && _btnInfo$label !== void 0 ? _btnInfo$label : '';\n btnElem.appendChild(labelElem);\n }\n if (btnInfo.onClick) {\n btnElem.addEventListener('click', btnInfo.onClick);\n }\n var newBtnInfo = _objectSpread(_objectSpread({}, btnInfo), {}, {\n element: btnElem,\n proiorty: (_btnInfo$priority = btnInfo.priority) !== null && _btnInfo$priority !== void 0 ? _btnInfo$priority : 0\n });\n var insertAfter = null;\n var insertAfterIndex = 0;\n this.btnList.forEach(function (one, index) {\n if (newBtnInfo.priority > one.priority) {\n insertAfter = one.element;\n insertAfterIndex = index;\n }\n });\n if (insertAfter) {\n this.bottomNavElem.insertAfter(btnElem, insertAfter);\n this.btnList = [].concat(_toConsumableArray(this.btnList.slice(0, insertAfterIndex + 1)), [newBtnInfo], _toConsumableArray(this.btnList.slice(insertAfterIndex + 1)));\n } else {\n this.bottomNavElem.prepend(btnElem);\n this.btnList.unshift(newBtnInfo);\n }\n return btnElem;\n }\n }, {\n key: \"removeButton\",\n value: function removeButton(btnInfo) {\n var btnId = '';\n if (typeof btnInfo === 'string') {\n btnId = btnInfo;\n } else if (_typeof(btnInfo) === 'object') {\n btnId = btnInfo.id;\n }\n var btnElem = this.bottomNavElem.querySelector(\".isekai-bottom-nav-btn[data-id=\\\"\".concat(btnId, \"\\\"]\"));\n if (btnElem) {\n btnElem.remove();\n }\n }\n }]);\n return BottomNavWidget;\n}();\n\n//# sourceURL=webpack://isekai-widgets/./src/baseWidgets/bottomNav.js?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/baseWidgets/contextMenu.js":
|
|
/*!****************************************!*\
|
|
!*** ./src/baseWidgets/contextMenu.js ***!
|
|
\****************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ContextMenuWidget\": () => (/* binding */ ContextMenuWidget)\n/* harmony export */ });\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if (\"number\" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (\"string\" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return \"$\" + (Array.isArray(group) ? group.join(\"$\") : group); })); } if (\"function\" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return \"object\" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nvar isMobileSafari = function () {\n var v = navigator.userAgent.match( /*#__PURE__*/_wrapRegExp(/Version\\/(\\S+) Mobile\\/\\S+/, {\n version: 1\n }));\n if (v && v.groups.version) {\n // Safari\n return true;\n }\n return false;\n}();\nvar ContextMenuWidget = /*#__PURE__*/function () {\n function ContextMenuWidget() {\n _classCallCheck(this, ContextMenuWidget);\n this.menuItems = [];\n this.menuItemsUpdated = true;\n this.initDom();\n }\n _createClass(ContextMenuWidget, [{\n key: \"initDom\",\n value: function initDom() {\n var _this2 = this;\n var menuContainer = document.createElement('div');\n menuContainer.id = 'iseai-contextmenu';\n menuContainer.className = 'oo-ui-toolGroup-tools oo-ui-popupToolGroup-tools oo-ui-listToolGroup-tools oo-ui-toolGroup-enabled-tools oo-ui-popupToolGroup-active-tools';\n menuContainer.style.minWidth = 'unset';\n menuContainer.style.display = 'none';\n this.menuContainer = menuContainer;\n var menuCover = document.createElement('div');\n menuCover.className = 'isekai-contextmenu-cover';\n menuCover.style.display = 'none';\n menuCover.addEventListener('click', function () {\n _this2.hide();\n });\n this.menuCover = menuCover;\n document.body.appendChild(menuContainer);\n document.body.appendChild(menuCover);\n }\n }, {\n key: \"setMenuItem\",\n value: function setMenuItem(menuItems) {\n this.menuItems = menuItems;\n this.menuItemsUpdated = true;\n }\n }, {\n key: \"updateMenuItemDom\",\n value: function updateMenuItemDom() {\n var _this3 = this;\n if (this.menuItemsUpdated) {\n this.menuContainer.innerHTML = '';\n this.menuItems.sort(function (a, b) {\n var _b$priority, _a$priority;\n return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);\n }).forEach(function (menuItem) {\n var menuElem = document.createElement('span');\n menuElem.className = 'oo-ui-widget oo-ui-widget-enabled oo-ui-tool';\n var menuLink = document.createElement('a');\n menuLink.className = 'oo-ui-tool-link';\n menuLink.tabIndex = 0;\n menuLink.role = 'button';\n menuLink.addEventListener('click', function (e) {\n var _menuItem$onClick;\n e.preventDefault();\n (_menuItem$onClick = menuItem.onClick) === null || _menuItem$onClick === void 0 ? void 0 : _menuItem$onClick.call(menuItem);\n _this3.hide();\n });\n var menuLabel = document.createElement('span');\n menuLabel.className = 'oo-ui-tool-title';\n menuLabel.innerText = menuItem.label;\n menuLink.appendChild(menuLabel);\n menuElem.appendChild(menuLink);\n _this3.menuContainer.appendChild(menuElem);\n });\n this.menuItemsUpdated = false;\n }\n }\n }, {\n key: \"show\",\n value: function show() {\n var x = 0;\n var y = 0;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (args[0] instanceof MouseEvent) {\n x = args[0].clientX;\n y = args[0].clientY;\n } else if (args[0] instanceof Element) {\n var rect = args[0].getBoundingClientRect();\n x = rect.left;\n y = rect.top;\n } else if (args.length === 2 && typeof args[0] === 'number' && typeof args[1] === 'number') {\n x = args[0];\n y = args[1];\n }\n if (this.menuItemsUpdated) {\n this.updateMenuItemDom();\n }\n this.menuContainer.style.display = 'block';\n this.menuCover.style.display = 'block';\n var menuWidth = this.menuContainer.clientWidth;\n var menuHeight = this.menuContainer.clientHeight;\n if (x + menuWidth > window.innerWidth) {\n x -= menuWidth;\n }\n if (y + menuHeight > window.innerHeight) {\n y -= menuHeight;\n }\n this.menuContainer.style.left = x + 'px';\n this.menuContainer.style.top = y + 'px';\n }\n }, {\n key: \"hide\",\n value: function hide() {\n this.menuContainer.style.display = 'none';\n this.menuCover.style.display = 'none';\n }\n }, {\n key: \"bindToDom\",\n value: function bindToDom(dom) {\n var _this4 = this;\n dom.addEventListener('contextmenu', function (e) {\n e.preventDefault();\n _this4.show(e);\n });\n if (isMobileSafari) {\n // Safari下对长按的特殊处理\n var longPressTimer;\n dom.addEventListener('touchstart', function (e) {\n document.body.classList.add('isekai-contextmenu-ios-longpress');\n longPressTimer = setTimeout(function () {\n e.preventDefault();\n _this4.show({\n x: e.pageX - window.scrollX,\n y: e.pageY - window.scrollY\n });\n }, 200);\n });\n dom.addEventListener('touchend', function (e) {\n document.body.classList.remove('isekai-contextmenu-ios-longpress');\n if (longPressTimer) {\n clearInterval(longPressTimer);\n }\n });\n }\n }\n }]);\n return ContextMenuWidget;\n}();\n\n//# sourceURL=webpack://isekai-widgets/./src/baseWidgets/contextMenu.js?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/baseWidgets/ext.isekai.baseWidgets.js":
|
|
/*!***************************************************!*\
|
|
!*** ./src/baseWidgets/ext.isekai.baseWidgets.js ***!
|
|
\***************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _moduleRegister__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../moduleRegister */ \"./src/moduleRegister.js\");\n/* harmony import */ var _contextMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contextMenu */ \"./src/baseWidgets/contextMenu.js\");\n/* harmony import */ var _fab__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fab */ \"./src/baseWidgets/fab.js\");\n/* harmony import */ var _bottomNav__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bottomNav */ \"./src/baseWidgets/bottomNav.js\");\n\n\n\n\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('ui.ContextMenuWidget', _contextMenu__WEBPACK_IMPORTED_MODULE_1__.ContextMenuWidget);\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('ui.FabWidget', _fab__WEBPACK_IMPORTED_MODULE_2__.FabWidget);\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('ui.BottomNavWidget', _bottomNav__WEBPACK_IMPORTED_MODULE_3__.BottomNavWidget);\nvar fabInstance = new _fab__WEBPACK_IMPORTED_MODULE_2__.FabWidget();\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('fab', fabInstance);\nvar bottomNavInstance = new _bottomNav__WEBPACK_IMPORTED_MODULE_3__.BottomNavWidget();\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('bottomNav', bottomNavInstance);\n\n//# sourceURL=webpack://isekai-widgets/./src/baseWidgets/ext.isekai.baseWidgets.js?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/baseWidgets/fab.js":
|
|
/*!********************************!*\
|
|
!*** ./src/baseWidgets/fab.js ***!
|
|
\********************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"FabWidget\": () => (/* binding */ FabWidget)\n/* harmony export */ });\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar FabWidget = /*#__PURE__*/function () {\n function FabWidget() {\n var _this = this;\n _classCallCheck(this, FabWidget);\n _defineProperty(this, \"_onContextMenu\", function (e) {\n e.preventDefault();\n document.body.removeEventListener('contextmenu', _this._onContextMenu);\n _this.show();\n });\n this.domCreated = false;\n this.btnList = [];\n this.hidden = false;\n }\n _createClass(FabWidget, [{\n key: \"initDom\",\n value: function initDom() {\n var _this2 = this;\n if (!this.domCreated) {\n var fabContainer = document.querySelector('#isekai-fab-container');\n if (fabContainer) {\n this.fabContainer = fabContainer;\n } else {\n fabContainer = document.createElement('div');\n fabContainer.id = 'isekai-fab-container';\n fabContainer.className = 'isekai-fab-group';\n this.fabContainer = fabContainer;\n document.body.appendChild(fabContainer);\n\n // 右键隐藏\n var menuItems = [{\n label: mw.msg('isekai-fab-hide-fab-button'),\n onClick: function onClick() {\n _this2.hide();\n mw.notify(mw.msg('isekai-fab-hide-fab-button-success'));\n }\n }];\n var contextMenu = new isekai.ui.ContextMenuWidget();\n contextMenu.setMenuItem(menuItems);\n contextMenu.bindToDom(fabContainer);\n this.contextMenu = contextMenu;\n }\n this.domCreated = true;\n }\n }\n }, {\n key: \"addButton\",\n value: function addButton(btnInfo) {\n var _btnInfo$priority;\n if (!this.domCreated) {\n this.initDom();\n }\n var btnElem = document.createElement('a');\n btnElem.role = 'button';\n btnElem.href = 'javascript:void(0);';\n btnElem.className = 'isekai-fab-btn';\n btnElem.dataset.id = btnInfo.id;\n if (btnInfo.icon) {\n var iconElem = document.createElement('span');\n iconElem.className = 'isekai-fab-btn-icon';\n if (typeof btnInfo.icon === 'string') {\n iconElem.innerHTML = btnInfo.icon;\n } else if (_typeof(btnInfo.icon) === 'object') {\n iconElem.appendChild(btnInfo.icon);\n }\n btnElem.appendChild(iconElem);\n }\n if (btnInfo.label) {\n btnElem.title = btnInfo.label;\n btnElem.setAttribute('aria-label', btnInfo.label);\n }\n if (btnInfo.onClick) {\n btnElem.addEventListener('click', btnInfo.onClick);\n }\n var newBtnInfo = _objectSpread(_objectSpread({}, btnInfo), {}, {\n element: btnElem,\n proiorty: (_btnInfo$priority = btnInfo.priority) !== null && _btnInfo$priority !== void 0 ? _btnInfo$priority : 0\n });\n var insertBefore = null;\n var insertBeforeIndex = 0;\n this.btnList.forEach(function (one, index) {\n if (one.priority < newBtnInfo.priority) {\n insertBefore = one.element;\n insertBeforeIndex = index;\n }\n });\n if (insertBefore) {\n this.fabContainer.insertBefore(btnElem, insertBefore);\n this.btnList = [].concat(_toConsumableArray(this.btnList.slice(0, insertBeforeIndex)), [newBtnInfo], _toConsumableArray(this.btnList.slice(insertBeforeIndex)));\n } else {\n this.fabContainer.appendChild(btnElem);\n this.btnList.push(newBtnInfo);\n }\n return btnElem;\n }\n }, {\n key: \"removeButton\",\n value: function removeButton(btnInfo) {\n var btnId = '';\n if (typeof btnInfo === 'string') {\n btnId = btnInfo;\n } else if (_typeof(btnInfo) === 'object') {\n btnId = btnInfo.id;\n }\n var fabBtn = this.fabContainer.querySelector(\".isekai-fab-btn[data-id=\\\"\".concat(btnId, \"\\\"]\"));\n if (fabBtn) {\n fabBtn.remove();\n }\n }\n }, {\n key: \"hide\",\n value: function hide() {\n this.fabContainer.classList.add('isekai-fab-hidden');\n this.hidden = true;\n document.body.addEventListener('contextmenu', this._onContextMenu);\n }\n }, {\n key: \"show\",\n value: function show() {\n this.fabContainer.classList.remove('isekai-fab-hidden');\n this.hidden = false;\n }\n }]);\n return FabWidget;\n}();\n\n//# sourceURL=webpack://isekai-widgets/./src/baseWidgets/fab.js?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/moduleRegister.js":
|
|
/*!*******************************!*\
|
|
!*** ./src/moduleRegister.js ***!
|
|
\*******************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"registerModule\": () => (/* binding */ registerModule)\n/* harmony export */ });\nfunction registerModule(namespace, func) {\n var nsList = namespace.split('.');\n if (!('isekai' in window)) {\n window.isekai = {};\n }\n var obj = window.isekai;\n for (var i = 0; i < nsList.length - 1; i++) {\n var ns = nsList[i];\n if (!(ns in obj)) {\n obj[ns] = {};\n }\n obj = obj[ns];\n }\n obj[nsList[i]] = func;\n}\n\n//# sourceURL=webpack://isekai-widgets/./src/moduleRegister.js?");
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ (() => {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ (() => {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/************************************************************************/
|
|
/******/
|
|
/******/ // startup
|
|
/******/ // Load entry module and return exports
|
|
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
/******/ var __webpack_exports__ = __webpack_require__("./src/baseWidgets/ext.isekai.baseWidgets.js");
|
|
/******/
|
|
/******/ })()
|
|
; |