You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
13 KiB
JavaScript

(()=>{"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<i.length;n++){var a=i[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,(void 0,r=function(t,i){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,"string");if("object"!==e(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(a.key),"symbol"===e(r)?r:String(r)),a)}var r}var i={tileDeferred:0,size:"medium",cover:"",coverPosition:"center",effect:"",effectInterval:3e3,effectDuration:500,target:null,canTransform:!0,onClick:function(){},onTileCreate:function(){}};!function(e,t){var i="ui.tile".split(".");"isekai"in window||(window.isekai={});for(var n=window.isekai,a=0;a<i.length-1;a++){var r=i[a];r in n||(n[r]={}),n=n[r]}n[i[a]]=t}(0,function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var n,a;return n=e,a=[{key:"setup",value:function(e){i=jQuery.extend({},i,e)}},{key:"init",value:function(){}}],null&&t(n.prototype,null),a&&t(n,a),Object.defineProperty(n,"prototype",{writable:!1}),e}()),function(t){function n(e,t){return Math.floor(Math.random()*(t-e+1)+e)}var a={isValue:function(e){return null!=e&&""!==e},isUrl:function(e){return/^(\.\/|\.\.\/|ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@\-\/]))?/.test(e)},isTag:function(e){return/^<\/?[\w\s="/.':;#-\/\?]+>/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;n<r.length;n++)f=f[r[n]];return e(f)===i&&f},isFunc:function(e){return a.isType(e,"function")},pageXY:function(e){return{x:e.changedTouches?e.changedTouches[0].pageX:e.pageX,y:e.changedTouches?e.changedTouches[0].pageY:e.pageY}},isRightMouse:function(e){return"which"in e?3===e.which:"button"in e?2===e.button:void 0},func:function(e){return new Function("a",e)},exec:function(e,t,i){var n;if(null==e)return!1;var r=a.isFunc(e);!1===r&&(r=a.func(e));try{n=r.apply(i,t)}catch(e){throw n=null,e}return n}},r={duration:100,func:"linear",switch:function(e,t){e.hide(),t.css({top:0,left:0}).show()},slideUp:function(e,t,i,n){var a=e.parent().outerHeight(!0);void 0===i&&(i=this.duration),void 0===n&&(n=this.func),e.css("z-index",1).animate({draw:{top:-a,opacity:0},dur:i,ease:n}),t.css({top:a,left:0,zIndex:2}).animate({draw:{top:0,opacity:1},dur:i,ease:n})},slideDown:function(e,t,i,n){var a=e.parent().outerHeight(!0);void 0===i&&(i=this.duration),void 0===n&&(n=this.func),e.css("z-index",1).animate({draw:{top:a,opacity:0},dur:i,ease:n}),t.css({left:0,top:-a,zIndex:2}).animate({draw:{top:0,opacity:1},dur:i,ease:n})},slideLeft:function(e,t,i,n){var a=e.parent().outerWidth(!0);void 0===i&&(i=this.duration),void 0===n&&(n=this.func),e.css("z-index",1).animate({draw:{left:-a,opacity:0},dur:i,ease:n}),t.css({left:a,zIndex:2}).animate({draw:{left:0,opacity:1},dur:i,ease:n})},slideRight:function(e,t,i,n){var a=e.parent().outerWidth(!0);void 0===i&&(i=this.duration),void 0===n&&(n=this.func),e.css("z-index",1).animate({draw:{left:a,opacity:0},dur:i,ease:n}),t.css({left:-a,zIndex:2}).animate({draw:{left:0,opacity:1},dur:i,ease:n})},fade:function(e,t,i){void 0===i&&(i=this.duration),e.animate({draw:{opacity:0},dur:i}),t.css({top:0,left:0,opacity:0}).animate({draw:{opacity:1},dur:i})}},f={PALETTES:{ALL:"colorList",METRO:"colorListMetro",STANDARD:"colorListStandard"},colorListMetro:{lime:"#a4c400",green:"#60a917",emerald:"#008a00",blue:"#00AFF0",teal:"#00aba9",cyan:"#1ba1e2",cobalt:"#0050ef",indigo:"#6a00ff",violet:"#aa00ff",pink:"#dc4fad",magenta:"#d80073",crimson:"#a20025",red:"#CE352C",orange:"#fa6800",amber:"#f0a30a",yellow:"#fff000",brown:"#825a2c",olive:"#6d8764",steel:"#647687",mauve:"#76608a",taupe:"#87794e"},colorListStandard:{aliceBlue:"#f0f8ff",antiqueWhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedAlmond:"#ffebcd",blue:"#0000ff",blueViolet:"#8a2be2",brown:"#a52a2a",burlyWood:"#deb887",cadetBlue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerBlue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkBlue:"#00008b",darkCyan:"#008b8b",darkGoldenRod:"#b8860b",darkGray:"#a9a9a9",darkGreen:"#006400",darkKhaki:"#bdb76b",darkMagenta:"#8b008b",darkOliveGreen:"#556b2f",darkOrange:"#ff8c00",darkOrchid:"#9932cc",darkRed:"#8b0000",darkSalmon:"#e9967a",darkSeaGreen:"#8fbc8f",darkSlateBlue:"#483d8b",darkSlateGray:"#2f4f4f",darkTurquoise:"#00ced1",darkViolet:"#9400d3",deepPink:"#ff1493",deepSkyBlue:"#00bfff",dimGray:"#696969",dodgerBlue:"#1e90ff",fireBrick:"#b22222",floralWhite:"#fffaf0",forestGreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#DCDCDC",ghostWhite:"#F8F8FF",gold:"#ffd700",goldenRod:"#daa520",gray:"#808080",green:"#008000",greenYellow:"#adff2f",honeyDew:"#f0fff0",hotPink:"#ff69b4",indianRed:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderBlush:"#fff0f5",lawnGreen:"#7cfc00",lemonChiffon:"#fffacd",lightBlue:"#add8e6",lightCoral:"#f08080",lightCyan:"#e0ffff",lightGoldenRodYellow:"#fafad2",lightGray:"#d3d3d3",lightGreen:"#90ee90",lightPink:"#ffb6c1",lightSalmon:"#ffa07a",lightSeaGreen:"#20b2aa",lightSkyBlue:"#87cefa",lightSlateGray:"#778899",lightSteelBlue:"#b0c4de",lightYellow:"#ffffe0",lime:"#00ff00",limeGreen:"#32dc32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumAquaMarine:"#66cdaa",mediumBlue:"#0000cd",mediumOrchid:"#ba55d3",mediumPurple:"#9370db",mediumSeaGreen:"#3cb371",mediumSlateBlue:"#7b68ee",mediumSpringGreen:"#00fa9a",mediumTurquoise:"#48d1cc",mediumVioletRed:"#c71585",midnightBlue:"#191970",mintCream:"#f5fffa",mistyRose:"#ffe4e1",moccasin:"#ffe4b5",navajoWhite:"#ffdead",navy:"#000080",oldLace:"#fdd5e6",olive:"#808000",oliveDrab:"#6b8e23",orange:"#ffa500",orangeRed:"#ff4500",orchid:"#da70d6",paleGoldenRod:"#eee8aa",paleGreen:"#98fb98",paleTurquoise:"#afeeee",paleVioletRed:"#db7093",papayaWhip:"#ffefd5",peachPuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderBlue:"#b0e0e6",purple:"#800080",rebeccaPurple:"#663399",red:"#ff0000",rosyBrown:"#bc8f8f",royalBlue:"#4169e1",saddleBrown:"#8b4513",salmon:"#fa8072",sandyBrown:"#f4a460",seaGreen:"#2e8b57",seaShell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",slyBlue:"#87ceeb",slateBlue:"#6a5acd",slateGray:"#708090",snow:"#fffafa",springGreen:"#00ff7f",steelBlue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whiteSmoke:"#f5f5f5",yellow:"#ffff00",yellowGreen:"#9acd32"},colorList:{},colors:function(e){var i=[];return e=e||this.PALETTES.ALL,t.each(this[e],(function(){i.push(this)})),i}};function o(e,o){this.init=function(e,n){this.effectInterval=!1,this.images=[],this.slides=[],this.currentSlide=-1,this.options=t.extend({},i,e),this.element=n,this.hasIcon=!1,this.hasBranding=!1,this._fixSizeCallback=this.resize.bind(this),this._create()},this._create=function(){this._createTile(),this._createEvents(),this.element.trigger("tilecreate")},this._createTile=function(){function e(e,t,i){setTimeout((function(){e.fadeOut(500,(function(){e.css("background-image","url("+t+")"),e.fadeIn()}))}),300*i)}var i=this,a=this.element,r=this.options,o=a.find(".slide"),s=a.find(".slide-front, .slide-back");if(a.addClass("tile-"+r.size),a.find(".icon").length>0&&(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("<div>").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;s<h.length;s++){var l=n(0,r.length-1);e(a.find(".-js-img-"+h[s]),r[l].src,s),r.length>1&&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;a<i;a++)n[a-1]=arguments[a];var r;return this.each((function(){var i=t(this);if("tile"!==i.attr("data-role"))throw new Error("This element isn't a tile element");var a=i.data("tile");if("init"==e){if(a)throw new Error("Tile already inited.");var f=n[0]||{};f=t.extend({},f,function(e){var i={};return t.each(e[0].attributes,(function(e,t){t.name.startsWith("data-")&&(i[t.name.substr(5)]=t.value)})),i}(i)),a=new o(f,i),i.data("tile",a)}else{var s;if(!a)throw new Error("Tile not inited.");if(!a[e])throw new Error("Method: "+e+" not exists.");r=(s=a[e]).apply.apply(s,[a].concat(n))}})),null==r?this:r}}),t('*[data-role="tile"]').tile("init"),t(window).on("resize",s),t(s),t("body").hasClass("skin-minerva")&&t("#mw-content-text .collapsible-block").each((function(){var e=t(this);e.find('*[data-role="tile"]').length>0&&new MutationObserver(l).observe(e[0],{attributes:!0})}))}(jQuery)})();