diff --git a/modules/baseWidgets/ext.isekai.baseWidgets.js b/modules/baseWidgets/ext.isekai.baseWidgets.js index 87621a6..ba44746 100644 --- a/modules/baseWidgets/ext.isekai.baseWidgets.js +++ b/modules/baseWidgets/ext.isekai.baseWidgets.js @@ -1,126 +1 @@ -/* - * 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"); -/******/ -/******/ })() -; \ No newline at end of file +(()=>{"use strict";function t(t,e){var n=t.split(".");"isekai"in window||(window.isekai={});for(var o=window.isekai,i=0;i]+)>/g,(function(t,e){var n=r[e];return"$"+(Array.isArray(n)?n.join("$"):n)})))}if("function"==typeof i){var l=this;return t[Symbol.replace].call(this,o,(function(){var t=arguments;return"object"!=e(t[t.length-1])&&(t=[].slice.call(t)).push(a(t,l)),i.apply(this,t)}))}return t[Symbol.replace].call(this,o,i)},o.apply(this,arguments)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var r,a=!(!(r=navigator.userAgent.match(o(/Version\/(\S+) Mobile\/\S+/,{version:1})))||!r.groups.version),l=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.menuItems=[],this.menuItemsUpdated=!0,this.initDom()}var e,o;return e=t,o=[{key:"initDom",value:function(){var t=this,e=document.createElement("div");e.id="iseai-contextmenu",e.className="oo-ui-toolGroup-tools oo-ui-popupToolGroup-tools oo-ui-listToolGroup-tools oo-ui-toolGroup-enabled-tools oo-ui-popupToolGroup-active-tools",e.style.minWidth="unset",e.style.display="none",this.menuContainer=e;var n=document.createElement("div");n.className="isekai-contextmenu-cover",n.style.display="none",n.addEventListener("click",(function(){t.hide()})),this.menuCover=n,document.body.appendChild(e),document.body.appendChild(n)}},{key:"setMenuItem",value:function(t){this.menuItems=t,this.menuItemsUpdated=!0}},{key:"updateMenuItemDom",value:function(){var t=this;this.menuItemsUpdated&&(this.menuContainer.innerHTML="",this.menuItems.sort((function(t,e){var n,o;return(null!==(n=e.priority)&&void 0!==n?n:0)-(null!==(o=t.priority)&&void 0!==o?o:0)})).forEach((function(e){var n=document.createElement("span");n.className="oo-ui-widget oo-ui-widget-enabled oo-ui-tool";var o=document.createElement("a");o.className="oo-ui-tool-link",o.tabIndex=0,o.role="button",o.addEventListener("click",(function(n){var o;n.preventDefault(),null===(o=e.onClick)||void 0===o||o.call(e),t.hide()}));var i=document.createElement("span");i.className="oo-ui-tool-title",i.innerText=e.label,o.appendChild(i),n.appendChild(o),t.menuContainer.appendChild(n)})),this.menuItemsUpdated=!1)}},{key:"show",value:function(){for(var t=0,e=0,n=arguments.length,o=new Array(n),i=0;iwindow.innerWidth&&(t-=a),e+l>window.innerHeight&&(e-=l),this.menuContainer.style.left=t+"px",this.menuContainer.style.top=e+"px"}},{key:"hide",value:function(){this.menuContainer.style.display="none",this.menuCover.style.display="none"}},{key:"bindToDom",value:function(t){var e,n=this;t.addEventListener("contextmenu",(function(t){t.preventDefault(),n.show(t)})),a&&(t.addEventListener("touchstart",(function(t){document.body.classList.add("isekai-contextmenu-ios-longpress"),e=setTimeout((function(){t.preventDefault(),n.show({x:t.pageX-window.scrollX,y:t.pageY-window.scrollY})}),200)})),t.addEventListener("touchend",(function(t){document.body.classList.remove("isekai-contextmenu-ios-longpress"),e&&clearInterval(e)})))}}],o&&n(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),t}();function s(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);nt.length)&&(e=t.length);for(var n=0,o=new Array(e);n=0&&l.priority { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/createPage/ext.isekai.createPage.js": -/*!*************************************************!*\ - !*** ./src/createPage/ext.isekai.createPage.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\");\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); }\n\nvar CreatePageWidget = /*#__PURE__*/function () {\n function CreatePageWidget(dom) {\n _classCallCheck(this, CreatePageWidget);\n this.baseDom = dom;\n this.pageUrl = null;\n this.api = new mw.Api();\n this.hasError = false;\n this.initDom();\n }\n _createClass(CreatePageWidget, [{\n key: \"initDom\",\n value: function initDom() {\n this.pageNameInput = new OO.ui.TextInputWidget({\n placeholder: mw.message('isekai-createpage-page-title').parse()\n });\n this.pageNameInput.on('enter', this.createPage.bind(this));\n this.pageNameInput.on('change', this.onPageNameChange.bind(this));\n this.createButton = new OO.ui.ButtonWidget({\n label: mw.message('isekai-createpage-create-page-button').parse(),\n flags: ['primary', 'progressive']\n });\n this.createButton.on('click', this.createPage.bind(this));\n this.formGroup = new OO.ui.ActionFieldLayout(this.pageNameInput, this.createButton, {\n align: 'top'\n });\n this.baseDom.find('.card-body .card-content').append(this.formGroup.$element);\n }\n }, {\n key: \"createPage\",\n value: function createPage() {\n var _this = this;\n var title = this.pageNameInput.getValue();\n if (this.hasError) {\n this.clearError(); //清除errors\n }\n\n if (title.trim().length > 0) {\n this.createButton.setDisabled(true);\n this.pageExists(title).then(function (exists) {\n if (exists) {\n _this.createButton.setDisabled(false);\n _this.setError(mw.message('isekai-createpage-page-exists').parse()); //提示页面已经存在\n } else {\n var targetUrl = mw.util.getUrl(title, {\n veaction: 'edit'\n });\n _this.formGroup.setSuccess([mw.message('isekai-createpage-redirecting').parse()]); //提示正在跳转\n location.href = targetUrl;\n }\n });\n } else {\n this.setError(mw.message('isekai-createpage-title-empty').parse());\n }\n }\n }, {\n key: \"onPageNameChange\",\n value: function onPageNameChange() {\n if (this.hasError) {\n this.clearError();\n }\n var value = this.pageNameInput.getValue();\n if (value.indexOf(':') !== -1 || value.indexOf('`') !== -1) {\n var range = this.pageNameInput.getRange();\n value = value.replace(/:/g, ':').replace(/`/g, '·');\n this.pageNameInput.setValue(value);\n this.pageNameInput.selectRange(range.from, range.to);\n }\n }\n }, {\n key: \"setError\",\n value: function setError(msg) {\n this.formGroup.setErrors([msg]); //提示页面已经存在\n this.hasError = true;\n }\n }, {\n key: \"clearError\",\n value: function clearError() {\n this.formGroup.setErrors([]);\n this.hasError = false;\n }\n }, {\n key: \"pageExists\",\n value: function pageExists(title) {\n var _this2 = this;\n return new Promise(function (resolve, reject) {\n _this2.api.get({\n action: 'query',\n titles: title\n }).done(function (data) {\n if (data.query && data.query.pages) {\n if (data.query.pages[\"-1\"]) {\n resolve(false);\n } else {\n resolve(true);\n }\n } else {\n resolve(false);\n }\n }).fail(reject);\n });\n }\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.text(title);\n }\n }]);\n return CreatePageWidget;\n}();\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('ui.CreatePageWidget', CreatePageWidget);\n\n//# sourceURL=webpack://isekai-widgets/./src/createPage/ext.isekai.createPage.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/createPage/ext.isekai.createPage.js"); -/******/ -/******/ })() -; \ No newline at end of file +(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,i){for(var r=0;r0?(this.createButton.setDisabled(!0),this.pageExists(t).then((function(i){if(i)e.createButton.setDisabled(!1),e.setError(mw.message("isekai-createpage-page-exists").parse());else{var r=mw.util.getUrl(t,{veaction:"edit"});e.formGroup.setSuccess([mw.message("isekai-createpage-redirecting").parse()]),location.href=r}}))):this.setError(mw.message("isekai-createpage-title-empty").parse())}},{key:"onPageNameChange",value:function(){this.hasError&&this.clearError();var e=this.pageNameInput.getValue();if(-1!==e.indexOf(":")||-1!==e.indexOf("`")){var t=this.pageNameInput.getRange();e=e.replace(/:/g,":").replace(/`/g,"·"),this.pageNameInput.setValue(e),this.pageNameInput.selectRange(t.from,t.to)}}},{key:"setError",value:function(e){this.formGroup.setErrors([e]),this.hasError=!0}},{key:"clearError",value:function(){this.formGroup.setErrors([]),this.hasError=!1}},{key:"pageExists",value:function(e){var t=this;return new Promise((function(i,r){t.api.get({action:"query",titles:e}).done((function(e){e.query&&e.query.pages?e.query.pages[-1]?i(!1):i(!0):i(!1)})).fail(r)}))}},{key:"setTitle",value:function(e){this.title.text(e)}}])&&t(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),e}())})(); \ No newline at end of file diff --git a/modules/discover/ext.isekai.discover.js b/modules/discover/ext.isekai.discover.js index e8a8acd..91d1a39 100644 --- a/modules/discover/ext.isekai.discover.js +++ b/modules/discover/ext.isekai.discover.js @@ -1,96 +1 @@ -/* - * 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/discover/ext.isekai.discover.js": -/*!*********************************************!*\ - !*** ./src/discover/ext.isekai.discover.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\");\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); }\n\nvar DiscoverWidget = /*#__PURE__*/function () {\n function DiscoverWidget(dom) {\n _classCallCheck(this, DiscoverWidget);\n this.baseDom = dom;\n this.pageUrl = null;\n this.api = new mw.Api();\n this.initDom();\n this.refreshPage();\n }\n _createClass(DiscoverWidget, [{\n key: \"initDom\",\n value: function initDom() {\n this.reloadButton = new OO.ui.ButtonWidget({\n icon: 'reload',\n label: mw.message('isekai-discover-change-btn').parse()\n });\n this.reloadButton.on('click', this.refreshPage.bind(this));\n this.readMoreButton = new OO.ui.ButtonWidget({\n icon: 'ellipsis',\n label: mw.message('isekai-discover-readmore-btn').parse(),\n flags: ['primary', 'progressive']\n });\n this.readMoreButton.on('click', this.showMore.bind(this));\n this.loadingBar = new OO.ui.ProgressBarWidget({\n progress: false\n });\n this.baseDom.find('.card-body .loading .spinner').append(this.loadingBar.$element);\n this.buttonGroup = new OO.ui.ButtonGroupWidget({\n items: [this.reloadButton, this.readMoreButton]\n });\n this.baseDom.find('.card-header .card-header-buttons').append(this.buttonGroup.$element);\n this.loading = this.baseDom.find('.card-body .loading');\n this.title = this.baseDom.find('.card-body .card-title');\n this.contentContainer = this.baseDom.find('.card-body .card-content');\n }\n }, {\n key: \"showMore\",\n value: function showMore() {\n if (this.pageUrl) {\n //页面存在就跳转\n window.open(this.pageUrl);\n }\n }\n }, {\n key: \"refreshPage\",\n value: function refreshPage() {\n var _this = this;\n this.pageUrl = null;\n this.clearContent();\n this.showLoading();\n this.getRandomPage().then(function (title) {\n _this.loadPage(title);\n });\n }\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.text(title);\n }\n }, {\n key: \"showLoading\",\n value: function showLoading() {\n this.loading.show();\n this.contentContainer.hide();\n }\n }, {\n key: \"hideLoading\",\n value: function hideLoading() {\n this.loading.hide();\n this.contentContainer.show();\n }\n }, {\n key: \"clearContent\",\n value: function clearContent() {\n this.contentContainer.children().remove();\n }\n }, {\n key: \"setContent\",\n value: function setContent(dom) {\n this.hideLoading();\n this.clearContent();\n this.contentContainer.append(dom);\n }\n }, {\n key: \"showError\",\n value: function showError(msg) {\n var errorMsg = new OO.ui.MessageWidget({\n type: 'error',\n label: msg\n });\n this.setContent(errorMsg.$element);\n }\n }, {\n key: \"getRandomPage\",\n value: function getRandomPage() {\n var _this2 = this;\n return new Promise(function (resolve, reject) {\n _this2.api.get({\n action: 'query',\n list: 'random',\n rnlimit: 1,\n rnnamespace: 0\n }).done(function (data) {\n if (data.query && data.query.random && data.query.random.length > 0) {\n var title = data.query.random[0].title;\n _this2.setTitle(title);\n resolve(title);\n } else if (data.error) {\n _this2.showError(data.error.info);\n } else {\n _this2.showError(mw.message('isekai-discover-error-cannotload').parse());\n }\n });\n });\n }\n }, {\n key: \"parseHTMLString\",\n value: function parseHTMLString(txt) {\n try {\n var parser = new DOMParser();\n var xmlDoc = parser.parseFromString(txt, \"text/html\");\n return xmlDoc;\n } catch (e) {\n console.error(e.message);\n }\n return null;\n }\n }, {\n key: \"loadPage\",\n value: function loadPage(title) {\n var _this3 = this;\n var url = mw.util.getUrl(title);\n this.pageUrl = url;\n if (url.indexOf('?') >= 0) {\n url += '&';\n } else {\n url += '?';\n }\n url += 'action=render';\n $.get(url, function (str) {\n var dom = $(_this3.parseHTMLString(str));\n var content = dom.find('.mw-parser-output');\n if (content.length > 0) {\n //删除目录\n content.find('.toc').remove();\n _this3.setContent(content);\n }\n }, 'html');\n }\n }]);\n return DiscoverWidget;\n}();\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_0__.registerModule)('ui.DiscoverWidget', DiscoverWidget);\n\n//# sourceURL=webpack://isekai-widgets/./src/discover/ext.isekai.discover.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/discover/ext.isekai.discover.js"); -/******/ -/******/ })() -; \ No newline at end of file +(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n){for(var i=0;i0){var i=n.query.random[0].title;e.setTitle(i),t(i)}else n.error?e.showError(n.error.info):e.showError(mw.message("isekai-discover-error-cannotload").parse())}))}))}},{key:"parseHTMLString",value:function(e){try{return(new DOMParser).parseFromString(e,"text/html")}catch(e){console.error(e.message)}return null}},{key:"loadPage",value:function(e){var t=this,n=mw.util.getUrl(e);this.pageUrl=n,n.indexOf("?")>=0?n+="&":n+="?",n+="action=render",$.get(n,(function(e){var n=$(t.parseHTMLString(e)).find(".mw-parser-output");n.length>0&&(n.find(".toc").remove(),t.setContent(n))}),"html")}}])&&t(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}())})(); \ No newline at end of file diff --git a/modules/tile/ext.isekai.tile.css b/modules/tile/ext.isekai.tile.css index c086ce3..f3da602 100644 --- a/modules/tile/ext.isekai.tile.css +++ b/modules/tile/ext.isekai.tile.css @@ -1,6 +1,3 @@ -/*!************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/.pnpm/css-loader@6.7.3_webpack@5.82.0/node_modules/css-loader/dist/cjs.js!./node_modules/.pnpm/postcss-loader@7.3.0_postcss@8.4.23_webpack@5.82.0/node_modules/postcss-loader/dist/cjs.js!./node_modules/.pnpm/less-loader@11.1.0_less@4.1.3_webpack@5.82.0/node_modules/less-loader/dist/cjs.js!./src/tile/tile.less ***! - \************************************************************************************************************************************************************************************************************************************************************************************************************************************************/ .tile-small, .tile-medium, .tile-wide, diff --git a/modules/tile/ext.isekai.tile.js b/modules/tile/ext.isekai.tile.js index c301af1..d59d415 100644 --- a/modules/tile/ext.isekai.tile.js +++ b/modules/tile/ext.isekai.tile.js @@ -1,106 +1 @@ -/* - * 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/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?"); - -/***/ }), - -/***/ "./src/tile/ext.isekai.tile.js": -/*!*************************************!*\ - !*** ./src/tile/ext.isekai.tile.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _tile_less__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile.less */ \"./src/tile/tile.less\");\n/* harmony import */ var _moduleRegister__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../moduleRegister */ \"./src/moduleRegister.js\");\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); }\n/* global Colors */\n\n\nvar TileDefaultConfig = {\n tileDeferred: 0,\n size: \"medium\",\n cover: \"\",\n coverPosition: \"center\",\n effect: \"\",\n effectInterval: 3000,\n effectDuration: 500,\n target: null,\n canTransform: true,\n onClick: function onClick() {},\n onTileCreate: function onTileCreate() {}\n};\nvar METRO_THROWS = true;\nvar GRID_GAP = 10;\nvar IsekaiTile = /*#__PURE__*/function () {\n function IsekaiTile() {\n _classCallCheck(this, IsekaiTile);\n }\n _createClass(IsekaiTile, null, [{\n key: \"setup\",\n value: function setup(options) {\n TileDefaultConfig = jQuery.extend({}, TileDefaultConfig, options);\n }\n }, {\n key: \"init\",\n value: function init() {}\n }]);\n return IsekaiTile;\n}();\n(0,_moduleRegister__WEBPACK_IMPORTED_MODULE_1__.registerModule)('ui.tile', IsekaiTile);\n(function ($) {\n function rand(min, max) {\n // min and max included \n return Math.floor(Math.random() * (max - min + 1) + min);\n }\n var Utils = {\n isValue: function isValue(val) {\n return val !== undefined && val !== null && val !== \"\";\n },\n isUrl: function isUrl(val) {\n /* eslint-disable-next-line */\n return /^(\\.\\/|\\.\\.\\/|ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@\\-\\/]))?/.test(val);\n },\n isTag: function isTag(val) {\n /* eslint-disable-next-line */\n return /^<\\/?[\\w\\s=\"/.':;#-\\/\\?]+>/gi.test(val);\n },\n isType: function isType(o, t) {\n if (!Utils.isValue(o)) {\n return false;\n }\n if (_typeof(o) === t) {\n return o;\n }\n if (Utils.isTag(o) || Utils.isUrl(o)) {\n return false;\n }\n if (_typeof(window[o]) === t) {\n return window[o];\n }\n if (typeof o === 'string' && o.indexOf(\".\") === -1) {\n return false;\n }\n if (typeof o === 'string' && o.indexOf(\"/\") !== -1) {\n return false;\n }\n if (typeof o === 'string' && o.indexOf(\" \") !== -1) {\n return false;\n }\n if (typeof o === 'string' && o.indexOf(\"(\") !== -1) {\n return false;\n }\n if (typeof o === 'string' && o.indexOf(\"[\") !== -1) {\n return false;\n }\n if (typeof o === \"number\" && t.toLowerCase() !== \"number\") {\n return false;\n }\n var ns = o.split(\".\");\n var i,\n context = window;\n for (i = 0; i < ns.length; i++) {\n context = context[ns[i]];\n }\n return _typeof(context) === t ? context : false;\n },\n isFunc: function isFunc(f) {\n return Utils.isType(f, 'function');\n },\n /**\r\n *\r\n * @param {TouchEvent|Event|MouseEvent} e\r\n * @returns {{x: (*), y: (*)}}\r\n */\n pageXY: function pageXY(e) {\n return {\n x: e.changedTouches ? e.changedTouches[0].pageX : e.pageX,\n y: e.changedTouches ? e.changedTouches[0].pageY : e.pageY\n };\n },\n isRightMouse: function isRightMouse(e) {\n return \"which\" in e ? e.which === 3 : \"button\" in e ? e.button === 2 : undefined;\n },\n func: function func(f) {\n /* jshint -W054 */\n return new Function(\"a\", f);\n },\n exec: function exec(f, args, context) {\n var result;\n if (f === undefined || f === null) {\n return false;\n }\n var func = Utils.isFunc(f);\n if (func === false) {\n func = Utils.func(f);\n }\n try {\n result = func.apply(context, args);\n } catch (err) {\n result = null;\n if (METRO_THROWS === true) {\n throw err;\n }\n }\n return result;\n }\n };\n var FrameAnimation = {\n duration: 100,\n func: \"linear\",\n \"switch\": function _switch(current, next) {\n current.hide();\n next.css({\n top: 0,\n left: 0\n }).show();\n },\n slideUp: function slideUp(current, next, duration, func) {\n var h = current.parent().outerHeight(true);\n if (duration === undefined) {\n duration = this.duration;\n }\n if (func === undefined) {\n func = this.func;\n }\n current.css(\"z-index\", 1).animate({\n draw: {\n top: -h,\n opacity: 0\n },\n dur: duration,\n ease: func\n });\n next.css({\n top: h,\n left: 0,\n zIndex: 2\n }).animate({\n draw: {\n top: 0,\n opacity: 1\n },\n dur: duration,\n ease: func\n });\n },\n slideDown: function slideDown(current, next, duration, func) {\n var h = current.parent().outerHeight(true);\n if (duration === undefined) {\n duration = this.duration;\n }\n if (func === undefined) {\n func = this.func;\n }\n current.css(\"z-index\", 1).animate({\n draw: {\n top: h,\n opacity: 0\n },\n dur: duration,\n ease: func\n });\n next.css({\n left: 0,\n top: -h,\n zIndex: 2\n }).animate({\n draw: {\n top: 0,\n opacity: 1\n },\n dur: duration,\n ease: func\n });\n },\n slideLeft: function slideLeft(current, next, duration, func) {\n var w = current.parent().outerWidth(true);\n if (duration === undefined) {\n duration = this.duration;\n }\n if (func === undefined) {\n func = this.func;\n }\n current.css(\"z-index\", 1).animate({\n draw: {\n left: -w,\n opacity: 0\n },\n dur: duration,\n ease: func\n });\n next.css({\n left: w,\n zIndex: 2\n }).animate({\n draw: {\n left: 0,\n opacity: 1\n },\n dur: duration,\n ease: func\n });\n },\n slideRight: function slideRight(current, next, duration, func) {\n var w = current.parent().outerWidth(true);\n if (duration === undefined) {\n duration = this.duration;\n }\n if (func === undefined) {\n func = this.func;\n }\n current.css(\"z-index\", 1).animate({\n draw: {\n left: w,\n opacity: 0\n },\n dur: duration,\n ease: func\n });\n next.css({\n left: -w,\n zIndex: 2\n }).animate({\n draw: {\n left: 0,\n opacity: 1\n },\n dur: duration,\n ease: func\n });\n },\n fade: function fade(current, next, duration) {\n if (duration === undefined) {\n duration = this.duration;\n }\n current.animate({\n draw: {\n opacity: 0\n },\n dur: duration\n });\n next.css({\n top: 0,\n left: 0,\n opacity: 0\n }).animate({\n draw: {\n opacity: 1\n },\n dur: duration\n });\n }\n };\n var Colors = {\n PALETTES: {\n ALL: \"colorList\",\n METRO: \"colorListMetro\",\n STANDARD: \"colorListStandard\"\n },\n colorListMetro: {\n lime: '#a4c400',\n green: '#60a917',\n emerald: '#008a00',\n blue: '#00AFF0',\n teal: '#00aba9',\n cyan: '#1ba1e2',\n cobalt: '#0050ef',\n indigo: '#6a00ff',\n violet: '#aa00ff',\n pink: '#dc4fad',\n magenta: '#d80073',\n crimson: '#a20025',\n red: '#CE352C',\n orange: '#fa6800',\n amber: '#f0a30a',\n yellow: '#fff000',\n brown: '#825a2c',\n olive: '#6d8764',\n steel: '#647687',\n mauve: '#76608a',\n taupe: '#87794e'\n },\n colorListStandard: {\n aliceBlue: \"#f0f8ff\",\n antiqueWhite: \"#faebd7\",\n aqua: \"#00ffff\",\n aquamarine: \"#7fffd4\",\n azure: \"#f0ffff\",\n beige: \"#f5f5dc\",\n bisque: \"#ffe4c4\",\n black: \"#000000\",\n blanchedAlmond: \"#ffebcd\",\n blue: \"#0000ff\",\n blueViolet: \"#8a2be2\",\n brown: \"#a52a2a\",\n burlyWood: \"#deb887\",\n cadetBlue: \"#5f9ea0\",\n chartreuse: \"#7fff00\",\n chocolate: \"#d2691e\",\n coral: \"#ff7f50\",\n cornflowerBlue: \"#6495ed\",\n cornsilk: \"#fff8dc\",\n crimson: \"#dc143c\",\n cyan: \"#00ffff\",\n darkBlue: \"#00008b\",\n darkCyan: \"#008b8b\",\n darkGoldenRod: \"#b8860b\",\n darkGray: \"#a9a9a9\",\n darkGreen: \"#006400\",\n darkKhaki: \"#bdb76b\",\n darkMagenta: \"#8b008b\",\n darkOliveGreen: \"#556b2f\",\n darkOrange: \"#ff8c00\",\n darkOrchid: \"#9932cc\",\n darkRed: \"#8b0000\",\n darkSalmon: \"#e9967a\",\n darkSeaGreen: \"#8fbc8f\",\n darkSlateBlue: \"#483d8b\",\n darkSlateGray: \"#2f4f4f\",\n darkTurquoise: \"#00ced1\",\n darkViolet: \"#9400d3\",\n deepPink: \"#ff1493\",\n deepSkyBlue: \"#00bfff\",\n dimGray: \"#696969\",\n dodgerBlue: \"#1e90ff\",\n fireBrick: \"#b22222\",\n floralWhite: \"#fffaf0\",\n forestGreen: \"#228b22\",\n fuchsia: \"#ff00ff\",\n gainsboro: \"#DCDCDC\",\n ghostWhite: \"#F8F8FF\",\n gold: \"#ffd700\",\n goldenRod: \"#daa520\",\n gray: \"#808080\",\n green: \"#008000\",\n greenYellow: \"#adff2f\",\n honeyDew: \"#f0fff0\",\n hotPink: \"#ff69b4\",\n indianRed: \"#cd5c5c\",\n indigo: \"#4b0082\",\n ivory: \"#fffff0\",\n khaki: \"#f0e68c\",\n lavender: \"#e6e6fa\",\n lavenderBlush: \"#fff0f5\",\n lawnGreen: \"#7cfc00\",\n lemonChiffon: \"#fffacd\",\n lightBlue: \"#add8e6\",\n lightCoral: \"#f08080\",\n lightCyan: \"#e0ffff\",\n lightGoldenRodYellow: \"#fafad2\",\n lightGray: \"#d3d3d3\",\n lightGreen: \"#90ee90\",\n lightPink: \"#ffb6c1\",\n lightSalmon: \"#ffa07a\",\n lightSeaGreen: \"#20b2aa\",\n lightSkyBlue: \"#87cefa\",\n lightSlateGray: \"#778899\",\n lightSteelBlue: \"#b0c4de\",\n lightYellow: \"#ffffe0\",\n lime: \"#00ff00\",\n limeGreen: \"#32dc32\",\n linen: \"#faf0e6\",\n magenta: \"#ff00ff\",\n maroon: \"#800000\",\n mediumAquaMarine: \"#66cdaa\",\n mediumBlue: \"#0000cd\",\n mediumOrchid: \"#ba55d3\",\n mediumPurple: \"#9370db\",\n mediumSeaGreen: \"#3cb371\",\n mediumSlateBlue: \"#7b68ee\",\n mediumSpringGreen: \"#00fa9a\",\n mediumTurquoise: \"#48d1cc\",\n mediumVioletRed: \"#c71585\",\n midnightBlue: \"#191970\",\n mintCream: \"#f5fffa\",\n mistyRose: \"#ffe4e1\",\n moccasin: \"#ffe4b5\",\n navajoWhite: \"#ffdead\",\n navy: \"#000080\",\n oldLace: \"#fdd5e6\",\n olive: \"#808000\",\n oliveDrab: \"#6b8e23\",\n orange: \"#ffa500\",\n orangeRed: \"#ff4500\",\n orchid: \"#da70d6\",\n paleGoldenRod: \"#eee8aa\",\n paleGreen: \"#98fb98\",\n paleTurquoise: \"#afeeee\",\n paleVioletRed: \"#db7093\",\n papayaWhip: \"#ffefd5\",\n peachPuff: \"#ffdab9\",\n peru: \"#cd853f\",\n pink: \"#ffc0cb\",\n plum: \"#dda0dd\",\n powderBlue: \"#b0e0e6\",\n purple: \"#800080\",\n rebeccaPurple: \"#663399\",\n red: \"#ff0000\",\n rosyBrown: \"#bc8f8f\",\n royalBlue: \"#4169e1\",\n saddleBrown: \"#8b4513\",\n salmon: \"#fa8072\",\n sandyBrown: \"#f4a460\",\n seaGreen: \"#2e8b57\",\n seaShell: \"#fff5ee\",\n sienna: \"#a0522d\",\n silver: \"#c0c0c0\",\n slyBlue: \"#87ceeb\",\n slateBlue: \"#6a5acd\",\n slateGray: \"#708090\",\n snow: \"#fffafa\",\n springGreen: \"#00ff7f\",\n steelBlue: \"#4682b4\",\n tan: \"#d2b48c\",\n teal: \"#008080\",\n thistle: \"#d8bfd8\",\n tomato: \"#ff6347\",\n turquoise: \"#40e0d0\",\n violet: \"#ee82ee\",\n wheat: \"#f5deb3\",\n white: \"#ffffff\",\n whiteSmoke: \"#f5f5f5\",\n yellow: \"#ffff00\",\n yellowGreen: \"#9acd32\"\n },\n colorList: {},\n colors: function colors(palette) {\n var c = [];\n palette = palette || this.PALETTES.ALL;\n $.each(this[palette], function () {\n c.push(this);\n });\n return c;\n }\n };\n function Tile(options, element) {\n this.init = function (options, element) {\n this.effectInterval = false;\n this.images = [];\n this.slides = [];\n this.currentSlide = -1;\n this.options = $.extend({}, TileDefaultConfig, options);\n this.element = element;\n this.hasIcon = false;\n this.hasBranding = false;\n this._fixSizeCallback = this.resize.bind(this);\n this._create();\n };\n this._create = function () {\n this._createTile();\n this._createEvents();\n this.element.trigger(\"tilecreate\");\n };\n this._createTile = function () {\n function switchImage(el, img_src, i) {\n setTimeout(function () {\n el.fadeOut(500, function () {\n el.css(\"background-image\", \"url(\" + img_src + \")\");\n el.fadeIn();\n });\n }, i * 300);\n }\n var that = this,\n element = this.element,\n o = this.options;\n var slides = element.find(\".slide\");\n var slides2 = element.find(\".slide-front, .slide-back\");\n element.addClass(\"tile-\" + o.size);\n if (element.find('.icon').length > 0) {\n this.hasIcon = true;\n }\n if (element.find('.branding-bar')) {\n this.hasBranding = true;\n }\n if (o.effect.indexOf(\"hover-\") > -1) {\n element.addClass(\"effect-\" + o.effect);\n $.each(slides2, function () {\n var slide = $(this);\n if (slide.data(\"cover\") !== undefined) {\n that._setCover(slide, slide.data(\"cover\"), slide.data(\"cover-position\"));\n }\n });\n }\n if (o.effect.indexOf(\"animate-\") > -1 && slides.length > 1) {\n $.each(slides, function (i) {\n var slide = $(this);\n that.slides.push(this);\n if (slide.data(\"cover\") !== undefined) {\n this._setCover(slide, slide.data(\"cover\"), slide.data(\"cover-position\"));\n }\n if (i > 0) {\n if ([\"animate-slide-up\", \"animate-slide-down\"].indexOf(o.effect) > -1) slide.css(\"top\", \"100%\");\n if ([\"animate-slide-left\", \"animate-slide-right\"].indexOf(o.effect) > -1) slide.css(\"left\", \"100%\");\n if ([\"animate-fade\"].indexOf(o.effect) > -1) slide.css(\"opacity\", 0);\n }\n });\n this.currentSlide = 0;\n this._runEffects();\n }\n if (o.cover !== \"\") {\n this._setCover(element, o.cover);\n }\n if (o.effect === \"image-set\") {\n element.addClass(\"image-set\");\n $.each(element.children(\"img\"), function () {\n var imgElem = document.createElement('img');\n imgElem.src = this.src;\n imgElem.srcset = this.srcset;\n imgElem.alt = this.alt;\n that.images.push(imgElem);\n $(this).remove();\n });\n var temp = this.images.slice();\n for (var i = 0; i < 5; i++) {\n var rnd_index = rand(0, temp.length - 1);\n var div = $(\"
\").addClass(\"img -js-img-\" + i).css(\"background-image\", \"url(\" + temp[rnd_index].src + \")\");\n element.prepend(div);\n if (temp.length > 1) {\n temp.splice(rnd_index, 1);\n }\n }\n var a = [0, 1, 4, 3, 2];\n setInterval(function () {\n var temp = that.images.slice();\n var colors = Colors.colors(Colors.PALETTES.ALL),\n bg;\n bg = colors[rand(0, colors.length - 1)];\n element.css(\"background-color\", bg);\n for (var i = 0; i < a.length; i++) {\n var rnd_index = rand(0, temp.length - 1);\n var div = element.find(\".-js-img-\" + a[i]);\n switchImage(div, temp[rnd_index].src, i);\n if (temp.length > 1) {\n temp.splice(rnd_index, 1);\n }\n }\n a = a.reverse();\n }, 5000);\n }\n };\n this._runEffects = function () {\n var o = this.options;\n if (this.effectInterval === false) this.effectInterval = setInterval(function () {\n var current, next;\n current = $(this.slides[this.currentSlide]);\n this.currentSlide++;\n if (this.currentSlide === this.slides.length) {\n this.currentSlide = 0;\n }\n next = this.slides[this.currentSlide];\n if (o.effect === \"animate-slide-up\") FrameAnimation.slideUp($(current), $(next), o.effectDuration);\n if (o.effect === \"animate-slide-down\") FrameAnimation.slideDown($(current), $(next), o.effectDuration);\n if (o.effect === \"animate-slide-left\") FrameAnimation.slideLeft($(current), $(next), o.effectDuration);\n if (o.effect === \"animate-slide-right\") FrameAnimation.slideRight($(current), $(next), o.effectDuration);\n if (o.effect === \"animate-fade\") FrameAnimation.fade($(current), $(next), o.effectDuration);\n }, o.effectInterval);\n };\n this._stopEffects = function () {\n clearInterval(this.effectInterval);\n this.effectInterval = false;\n };\n this.resize = function () {\n var ratio = 1;\n var padding = 0;\n var grid = this.element.parent('.tiles-grid');\n var gridWidth = 0;\n if (grid.length > 0) {\n gridWidth = grid.width();\n }\n if (this.options.size == 'wide') {\n ratio = 0.5;\n }\n\n //修正长宽比\n var height = this.element.width() * ratio - padding;\n //this.element.height(height);\n\n if (this.hasIcon) {\n var fontSize = height * 0.33;\n var iconDom = this.element.find('.icon');\n iconDom.css('font-size', fontSize + 'px');\n if (this.hasBranding) {\n //计算与标签的重叠\n var iconBottom = (height + fontSize) / 2;\n var brandingTop = height - this.element.find('.branding-bar').outerHeight();\n var overlap = iconBottom - brandingTop + height * 0.1;\n if (overlap > 0) {\n iconDom.css('padding-bottom', overlap + 'px');\n }\n }\n }\n };\n this._setCover = function (to, src, pos) {\n if (!Utils.isValue(pos)) {\n pos = this.options.coverPosition;\n }\n to.css({\n backgroundImage: \"url(\" + src + \")\",\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: pos\n });\n };\n this._createEvents = function () {\n var element = this.element,\n o = this.options;\n element.on('mousedown touchstart', function (e) {\n var tile = $(this);\n var dim = {\n w: element.width(),\n h: element.height()\n };\n var X = Utils.pageXY(e).x - tile.offset().left,\n Y = Utils.pageXY(e).y - tile.offset().top;\n var side;\n if (Utils.isRightMouse(e) === false) {\n if (X < dim.w * 1 / 3 && (Y < dim.h * 1 / 2 || Y > dim.h * 1 / 2)) {\n side = 'left';\n } else if (X > dim.w * 2 / 3 && (Y < dim.h * 1 / 2 || Y > dim.h * 1 / 2)) {\n side = 'right';\n } else if (X > dim.w * 1 / 3 && X < dim.w * 2 / 3 && Y > dim.h / 2) {\n side = 'bottom';\n } else {\n side = \"top\";\n }\n if (o.canTransform === true) tile.addClass(\"transform-\" + side);\n if (o.target !== null) {\n setTimeout(function () {\n document.location.href = o.target;\n }, 100);\n }\n Utils.exec(o.onClick, [side], element[0]);\n element.trigger(\"click\", {\n side: side\n });\n }\n });\n element.on('mouseup touchend mouseleave', function () {\n $(this).removeClass(\"transform-left\").removeClass(\"transform-right\").removeClass(\"transform-top\").removeClass(\"transform-bottom\");\n });\n $(window).on('resize', this._fixSizeCallback);\n $(this._fixSizeCallback);\n };\n this.destroy = function () {\n var element = this.element;\n element.off('mousedown touchstart');\n element.off('mouseup touchend mouseleave');\n $(window).off('resize', this._fixSizeCallback);\n this._stopEffects();\n };\n this.init(options, element);\n }\n ;\n function getElementOptions(element) {\n var options = {};\n $.each(element[0].attributes, function (index, attribute) {\n if (attribute.name.startsWith('data-')) {\n options[attribute.name.substr(5)] = attribute.value;\n }\n });\n return options;\n }\n $.fn.extend({\n tile: function tile(action) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n var result;\n this.each(function () {\n var element = $(this);\n if (element.attr('data-role') !== 'tile') {\n throw new Error('This element isn\\'t a tile element');\n }\n var tileObj = element.data('tile');\n if (action == 'init') {\n if (tileObj) {\n throw new Error('Tile already inited.');\n }\n var options = args[0] || {};\n options = $.extend({}, options, getElementOptions(element));\n tileObj = new Tile(options, element);\n element.data('tile', tileObj);\n } else {\n var _tileObj$action;\n if (!tileObj) {\n throw new Error('Tile not inited.');\n }\n if (!tileObj[action]) {\n throw new Error('Method: ' + action + ' not exists.');\n }\n result = (_tileObj$action = tileObj[action]).apply.apply(_tileObj$action, [tileObj].concat(args));\n }\n });\n if (result == undefined) {\n return this;\n } else {\n return result;\n }\n }\n });\n function resizeGrid() {\n $('.tiles-grid').each(function () {\n var dom = $(this);\n var width = dom.width();\n var gridSize = width / 4 - GRID_GAP;\n dom.css({\n gridTemplateColumns: 'repeat(4, ' + gridSize + 'px)',\n gridAutoRows: gridSize + 'px'\n });\n });\n }\n $('*[data-role=\"tile\"]').tile('init');\n $(window).on('resize', resizeGrid);\n $(resizeGrid);\n function onCollapseDivChange(mutationsList) {\n mutationsList.forEach(function (item) {\n if (item.type == 'attributes' && item.attributeName == 'class') {\n $('*[data-role=\"tile\"]').tile('resize');\n resizeGrid();\n }\n });\n }\n if ($('body').hasClass('skin-minerva')) {\n $('#mw-content-text .collapsible-block').each(function () {\n var dom = $(this);\n if (dom.find('*[data-role=\"tile\"]').length > 0) {\n //存在tile,监听这个dom\n var observer = new MutationObserver(onCollapseDivChange);\n observer.observe(dom[0], {\n attributes: true\n });\n }\n });\n }\n})(jQuery);\n\n//# sourceURL=webpack://isekai-widgets/./src/tile/ext.isekai.tile.js?"); - -/***/ }), - -/***/ "./src/tile/tile.less": -/*!****************************!*\ - !*** ./src/tile/tile.less ***! - \****************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://isekai-widgets/./src/tile/tile.less?"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // 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/tile/ext.isekai.tile.js"); -/******/ -/******/ })() -; \ No newline at end of file +(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,i){for(var n=0;n/gi.test(e)},isType:function(t,i){if(!a.isValue(t))return!1;if(e(t)===i)return t;if(a.isTag(t)||a.isUrl(t))return!1;if(e(window[t])===i)return window[t];if("string"==typeof t&&-1===t.indexOf("."))return!1;if("string"==typeof t&&-1!==t.indexOf("/"))return!1;if("string"==typeof t&&-1!==t.indexOf(" "))return!1;if("string"==typeof t&&-1!==t.indexOf("("))return!1;if("string"==typeof t&&-1!==t.indexOf("["))return!1;if("number"==typeof t&&"number"!==i.toLowerCase())return!1;var n,r=t.split("."),f=window;for(n=0;n0&&(this.hasIcon=!0),a.find(".branding-bar")&&(this.hasBranding=!0),r.effect.indexOf("hover-")>-1&&(a.addClass("effect-"+r.effect),t.each(s,(function(){var e=t(this);void 0!==e.data("cover")&&i._setCover(e,e.data("cover"),e.data("cover-position"))}))),r.effect.indexOf("animate-")>-1&&o.length>1&&(t.each(o,(function(e){var n=t(this);i.slides.push(this),void 0!==n.data("cover")&&this._setCover(n,n.data("cover"),n.data("cover-position")),e>0&&(["animate-slide-up","animate-slide-down"].indexOf(r.effect)>-1&&n.css("top","100%"),["animate-slide-left","animate-slide-right"].indexOf(r.effect)>-1&&n.css("left","100%"),["animate-fade"].indexOf(r.effect)>-1&&n.css("opacity",0))})),this.currentSlide=0,this._runEffects()),""!==r.cover&&this._setCover(a,r.cover),"image-set"===r.effect){a.addClass("image-set"),t.each(a.children("img"),(function(){var e=document.createElement("img");e.src=this.src,e.srcset=this.srcset,e.alt=this.alt,i.images.push(e),t(this).remove()}));for(var l=this.images.slice(),c=0;c<5;c++){var d=n(0,l.length-1),u=t("
").addClass("img -js-img-"+c).css("background-image","url("+l[d].src+")");a.prepend(u),l.length>1&&l.splice(d,1)}var h=[0,1,4,3,2];setInterval((function(){var t,r=i.images.slice(),o=f.colors(f.PALETTES.ALL);t=o[n(0,o.length-1)],a.css("background-color",t);for(var s=0;s1&&r.splice(l,1)}h=h.reverse()}),5e3)}},this._runEffects=function(){var e=this.options;!1===this.effectInterval&&(this.effectInterval=setInterval((function(){var i,n;i=t(this.slides[this.currentSlide]),this.currentSlide++,this.currentSlide===this.slides.length&&(this.currentSlide=0),n=this.slides[this.currentSlide],"animate-slide-up"===e.effect&&r.slideUp(t(i),t(n),e.effectDuration),"animate-slide-down"===e.effect&&r.slideDown(t(i),t(n),e.effectDuration),"animate-slide-left"===e.effect&&r.slideLeft(t(i),t(n),e.effectDuration),"animate-slide-right"===e.effect&&r.slideRight(t(i),t(n),e.effectDuration),"animate-fade"===e.effect&&r.fade(t(i),t(n),e.effectDuration)}),e.effectInterval))},this._stopEffects=function(){clearInterval(this.effectInterval),this.effectInterval=!1},this.resize=function(){var e=1,t=this.element.parent(".tiles-grid");t.length>0&&t.width(),"wide"==this.options.size&&(e=.5);var i=this.element.width()*e-0;if(this.hasIcon){var n=.33*i,a=this.element.find(".icon");if(a.css("font-size",n+"px"),this.hasBranding){var r=(i+n)/2-(i-this.element.find(".branding-bar").outerHeight())+.1*i;r>0&&a.css("padding-bottom",r+"px")}}},this._setCover=function(e,t,i){a.isValue(i)||(i=this.options.coverPosition),e.css({backgroundImage:"url("+t+")",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:i})},this._createEvents=function(){var e=this.element,i=this.options;e.on("mousedown touchstart",(function(n){var r,f=t(this),o=e.width(),s=e.height(),l=a.pageXY(n).x-f.offset().left,c=a.pageXY(n).y-f.offset().top;!1===a.isRightMouse(n)&&(r=l<1*o/3&&(c<1*s/2||c>1*s/2)?"left":l>2*o/3&&(c<1*s/2||c>1*s/2)?"right":l>1*o/3&&l<2*o/3&&c>s/2?"bottom":"top",!0===i.canTransform&&f.addClass("transform-"+r),null!==i.target&&setTimeout((function(){document.location.href=i.target}),100),a.exec(i.onClick,[r],e[0]),e.trigger("click",{side:r}))})),e.on("mouseup touchend mouseleave",(function(){t(this).removeClass("transform-left").removeClass("transform-right").removeClass("transform-top").removeClass("transform-bottom")})),t(window).on("resize",this._fixSizeCallback),t(this._fixSizeCallback)},this.destroy=function(){var e=this.element;e.off("mousedown touchstart"),e.off("mouseup touchend mouseleave"),t(window).off("resize",this._fixSizeCallback),this._stopEffects()},this.init(e,o)}function s(){t(".tiles-grid").each((function(){var e=t(this),i=e.width()/4-10;e.css({gridTemplateColumns:"repeat(4, "+i+"px)",gridAutoRows:i+"px"})}))}function l(e){e.forEach((function(e){"attributes"==e.type&&"class"==e.attributeName&&(t('*[data-role="tile"]').tile("resize"),s())}))}t.fn.extend({tile:function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),a=1;a0&&new MutationObserver(l).observe(e[0],{attributes:!0})}))}(jQuery)})(); \ No newline at end of file diff --git a/src/baseWidgets/bottomNav.js b/src/baseWidgets/bottomNav.js index 3a84ea6..92c0f71 100644 --- a/src/baseWidgets/bottomNav.js +++ b/src/baseWidgets/bottomNav.js @@ -74,23 +74,28 @@ export class BottomNavWidget { let newBtnInfo = {...btnInfo, element: btnElem, proiorty: btnInfo.priority ?? 0}; - let insertAfter = null; - let insertAfterIndex = 0; - this.btnList.forEach((one, index) => { - if (newBtnInfo.priority > one.priority) { - insertAfter = one.element; - insertAfterIndex = index; + let insertBefore = null; + let insertBeforeIndex = 0; + // asc (left to right) + for (let i = this.btnList.length - 1; i >= 0; i--) { + if (newBtnInfo.priority < this.btnList[i].priority) { + insertBefore = this.btnList[i].element; + insertBeforeIndex = i; + } else { + break; } - }); + } - if (insertAfter) { - this.bottomNavElem.insertAfter(btnElem, insertAfter); - this.btnList = [...this.btnList.slice(0, insertAfterIndex + 1), newBtnInfo, ...this.btnList.slice(insertAfterIndex + 1)]; + if (insertBefore) { + this.bottomNavElem.insertBefore(btnElem, insertBefore); + this.btnList = [...this.btnList.slice(0, insertBeforeIndex), newBtnInfo, ...this.btnList.slice(insertBeforeIndex)]; } else { - this.bottomNavElem.prepend(btnElem); - this.btnList.unshift(newBtnInfo); + this.bottomNavElem.append(btnElem); + this.btnList.push(newBtnInfo); } + console.log(this.btnList); + return btnElem; }