MediaWiki:Common.js
Vai alla navigazione
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
//logo cliccabile $('.tbbox-logo').wrap('<a href="/wiki/Pagina principale"></a>'); $(document).mousemove(function(e){ if ($('.popup_window:visible').length!==0){ var width; var height; var parent_left = $('.item_container:hover').offset().left; var parent_top = $('.item_container:hover').offset().top; var w = e.pageX; if (e.clientX < ($(window).width())/2){ width = w + 20 - parent_left; } else { width = w - 20 - $('.popup_window:visible').outerWidth() - parent_left; } var h = e.pageY; var h2 = $('.popup_window:visible').outerHeight(); var h3 =$(window).height(); if (e.clientY < (h3/2)){ height = h + 20 - parent_top; if (e.clientY + h2 +10 > h3) height = h - e.clientY - parent_top + h3 - h2 + 10; } else { height = h - h2 - parent_top; if (e.clientY - h2 < 10) height = h - e.clientY - parent_top + 10; } $('.popup_window:visible').css({top: height, left: width}); } }); //Input level if ($("#input_level").length == 1) { $("#input_level").append('Livello pg: '); var input_level = $('<input type="number" class="west" placeholder="Livello" min="0" max="150">').bind("propertychange keyup input paste", function() { if (this.value > 150) { this.value = 150; } else if (this.value < 0) { this.value = 0; } $(".calc").each(function() { if (input_level.val() == 0) { $(this).html(this.id); $('.per_level_off').addClass('per_level').removeClass('per_level_off'); } else { $(this).html(Math.ceil(Number(this.id) * input_level.val())); $('.per_level').addClass('per_level_off').removeClass('per_level'); } }); }).appendTo($("#input_level")); } //Switch weapons if ($("#switch").length == 1) { $("#fuoco").hide(); $("#switch").on("click", function() { $('#contusione, #fuoco').toggle() }); } //Switch prodotti if ($("#scambio").length == 1) { $("#sella").hide(); $("#scambio").on("click", function() { $('#prodotto, #sella').toggle() }); } //Switch maps if ($("#switch1" || "#switch2").length == 1) { $("#mandante1, #mandante2").hide(); $("#switch1").on("click", function() { $("#mandante1").show(); $("#mandante2").hide(); $("#vuota").hide(); }); $("#switch2").on("click", function() { $("#mandante2").show(); $("#mandante1").hide(); $("#vuota").hide(); }); } //Search if ($("#input_search").length == 1) { //Add :containsCI selector (contains case insensitive) $.extend($.expr[":"], { "containsCI": function(elem, i, match, array) { return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; } }); var input_search = $('<input type="search" class="west" placeholder="Cerca">').bind("propertychange keyup input paste", function() { if (this.value == '') { $('.item_container').show(); } else { $('.item_container').hide(); $('.item_container:containsCI("' + this.value + '")').show(); } }).appendTo($("#input_search")); } $(document).ready(function() { // Nascondo l'icona al caricamento della pagina $("#back_to_top").hide(); // Intercetto lo scroll di pagina $(window).scroll(function() { // Se l'evento scroll si verifica, mostro l'icona (invisibile) con effetto dissolvenza if ($("#back_to_top").is(":hidden")) { $("#back_to_top").fadeIn(500); } // Se si verifica il ritorno ad inizio pagina, nascondo l'icona con effetto dissolvenza if ((window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0) == 0 && !$("#back_to_top").is(":hidden")) { $("#back_to_top").fadeOut(500); } }); // Al click sull'icona, torno ad inizio pagina con movenza fluida $("#back_to_top").click(function() { $("html,body").animate({scrollTop: 0}, 500, function(){}); }); }); //slide var slideIndex = 0; showSlides(); function showSlides() { var i; var slides = document.getElementsByClassName("mySlides"); for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } slideIndex++; if (slideIndex > slides.length) {slideIndex = 1} slides[slideIndex-1].style.display = "block"; setTimeout(showSlides, 3000); // Change image every 3 seconds } /* Any JavaScript here will be loaded for all users on every page load. */ $('.tbbox-logo').wrap('<a href="/wiki/Main_Page"></a>'); if ($('.item_container').length!==0) { $('.item_container').each(function() { $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + '">'); }); $.getScript("https://wiki.the-west.net/wiki/Popup.js?action=raw"); } $(window).scroll(function() { if ($(this).scrollTop() > 100) { $('#back-top').fadeIn(); } else { $('#back-top').fadeOut(); } }); // Scroll body to top on click $('#back-top a').click(function() { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); // Embed youtube videos if ($('.youtube_video').length !== 0) { $('.youtube_video').each(function() { $(this).html('<iframe width="100%" height="100%" src="https://www.youtube.com/embed/' + $(this).attr('data-id') + '?cc_load_policy=1&cc_lang_pref=' + $(this).attr('data-subtitles') + '" frameborder="0" allowfullscreen></iframe>'); }); } /** stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills @version v3.4.1 @link https://github.com/dollarshaveclub/stickybits#readme @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) @license MIT **/ !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s():"function"==typeof define&&define.amd?define(s):s()}(0,function(){"use strict";var s=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.4.1",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var l=this.els[r],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getOffsetTop=function(t){for(var s=0;s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,l=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,a=s.stickyChange,r=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=r<=v&&"sticky"===n;o<v&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),l.position=f,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(l.position="")})):w&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var S=a<=v&&v<=r;return v<a||r<v?m(function(){g(e,h)}):S&&m(function(){g(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.stickybits=function(t){return new s(this,t)})}}); $('#right_menu').stickybits({stickyBitStickyOffset: 25});