|
|
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 = $(\"<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?");
|