MediaWiki:Vector.js

$(function{function t{$("body").addClass("dark")}if($("#p-personal ul").append($("").append($("").attr("id","styleswitcher").append("Switch theme"))),"true"==mw.cookie.get("dark")&&t,$("#styleswitcher").click(function{"true"!=mw.cookie.get("dark")?(t,mw.cookie.set("dark","true")):($("body").removeClass("dark"),mw.cookie.set("dark","false"))}),$("a[href*=#]:not([href=#])").click(function{if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var t=$(this.hash);if(t=t.length?t:$("[name="+this.hash.slice(1)+"]"),t.length)return $("html,body").animate({scrollTop:t.offset.top-150},1e3),!1}}),$(location.href.split("#")[1])){var e=$("#"+location.href.split("#")[1]);if(e.length)return $("html,body").animate({scrollTop:e.offset.top-125},1e3),!1}Waves.attach("#mw-navigation li"),Waves.attach(".editButtons input"),Waves.attach(".editButtons span"),Waves.attach(".vectorMenu li"),Waves.attach(".toctoggle"),Waves.attach(".toc li"),Waves.attach(".thumb",["waves-image"]),Waves.attach(".thumbinner",["waves-image"]),Waves.attach(".infobox-table-img",["waves-image"]),Waves.attach(".mw-editsection a",["waves-circle"]),Waves.attach(".oo-ui-buttonElement-button",["waves-light"]),Waves.attach(".suggestions"),Waves.attach(".mw-ui-button",["waves-light"]),Waves.init}),$(window).load(function{$("body").removeClass("fade-out"),$("body").hasClass("page-Star_Citizen_Wiki")&&$("#homegrid").addClass("hq")}),function(t,e){"use strict";"function"==typeof define&&define.amd?define([],function{return e.apply(t)}):"object"==typeof exports?module.exports=e.call(t):t.Waves=e.call(t)}("object"==typeof global?global:this,function{"use strict";function t(t){return null!==t&&t===t.window}function e(e){return t(e)?e:9===e.nodeType&&e.defaultView}function n(t){var e=typeof t;return"function"===e||"object"===e&&!!t}function a(t){return n(t)&&t.nodeType>0}function o(t){var e=f.call(t);return"[object String]"===e?d(t):n(t)&&/^\[object (Array|HTMLCollection|NodeList|Object)\]$/.test(e)&&t.hasOwnProperty("length")?t:a(t)?[t]:[]}function i(t){var n,a,o={top:0,left:0},i=t&&t.ownerDocument;return n=i.documentElement,"undefined"!=typeof t.getBoundingClientRect&&(o=t.getBoundingClientRect),a=e(i),{top:o.top+a.pageYOffset-n.clientTop,left:o.left+a.pageXOffset-n.clientLeft}}function r(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+t[n]+";");return e}function s(t,e,n){if(n){n.classList.remove("waves-rippling");var a=n.getAttribute("data-x"),o=n.getAttribute("data-y"),i=n.getAttribute("data-scale"),s=n.getAttribute("data-translate"),c=Date.now-Number(n.getAttribute("data-hold")),u=350-c;0>u&&(u=0),"mousemove"===t.type&&(u=150);var l="mousemove"===t.type?2500:v.duration;setTimeout(function{var t={top:o+"px",left:a+"px",opacity:"0","-webkit-transition-duration":l+"ms","-moz-transition-duration":l+"ms","-o-transition-duration":l+"ms","transition-duration":l+"ms","-webkit-transform":i+" "+s,"-moz-transform":i+" "+s,"-ms-transform":i+" "+s,"-o-transform":i+" "+s,transform:i+" "+s};n.setAttribute("style",r(t)),setTimeout(function{try{e.removeChild(n)}catch(t){return!1}},l)},u)}}function c(t){if(p.allowEvent(t)===!1)return null;for(var e=null,n=t.target||t.srcElement;n.parentElement;){if(!(n instanceof SVGElement)&&n.classList.contains("waves-effect")){e=n;break}n=n.parentElement}return e}function u(t){var e=c(t);if(null!==e){if(e.disabled||e.getAttribute("disabled")||e.classList.contains("disabled"))return;if(p.registerEvent(t),"touchstart"===t.type&&v.delay){var n=!1,a=setTimeout(function{a=null,v.show(t,e)},v.delay),o=function(o){a&&(clearTimeout(a),a=null,v.show(t,e)),n||(n=!0,v.hide(o,e)),r},i=function(t){a&&(clearTimeout(a),a=null),o(t),r};e.addEventListener("touchmove",i,!1),e.addEventListener("touchend",o,!1),e.addEventListener("touchcancel",o,!1);var r=function{e.removeEventListener("touchmove",i),e.removeEventListener("touchend",o),e.removeEventListener("touchcancel",o)}}else v.show(t,e),m&&(e.addEventListener("touchend",v.hide,!1),e.addEventListener("touchcancel",v.hide,!1)),e.addEventListener("mouseup",v.hide,!1),e.addEventListener("mouseleave",v.hide,!1)}}var l=l||{},d=document.querySelectorAll.bind(document),f=Object.prototype.toString,m="ontouchstart"in window,v={duration:750,delay:200,show:function(t,e,n){if(2===t.button)return!1;e=e||this;var a=document.createElement("div");a.className="waves-ripple waves-rippling",e.appendChild(a);var o=i(e),s=0,c=0;"touches"in t&&t.touches.length?(s=t.touches[0].pageY-o.top,c=t.touches[0].pageX-o.left):(s=t.pageY-o.top,c=t.pageX-o.left),c=c>=0?c:0,s=s>=0?s:0;var u="scale("+e.clientWidth/100*3+")",l="translate(0,0)";n&&(l="translate("+n.x+"px, "+n.y+"px)"),a.setAttribute("data-hold",Date.now),a.setAttribute("data-x",c),a.setAttribute("data-y",s),a.setAttribute("data-scale",u),a.setAttribute("data-translate",l);var d={top:s+"px",left:c+"px"};a.classList.add("waves-notransition"),a.setAttribute("style",r(d)),a.classList.remove("waves-notransition"),d["-webkit-transform"]=u+" "+l,d["-moz-transform"]=u+" "+l,d["-ms-transform"]=u+" "+l,d["-o-transform"]=u+" "+l,d.transform=u+" "+l,d.opacity="1";var f="mousemove"===t.type?2500:v.duration;d["-webkit-transition-duration"]=f+"ms",d["-moz-transition-duration"]=f+"ms",d["-o-transition-duration"]=f+"ms",d["transition-duration"]=f+"ms",a.setAttribute("style",r(d))},hide:function(t,e){e=e||this;for(var n=e.getElementsByClassName("waves-rippling"),a=0,o=n.length;o>a;a++)s(t,e,n[a]);m&&(e.removeEventListener("touchend",v.hide),e.removeEventListener("touchcancel",v.hide)),e.removeEventListener("mouseup",v.hide),e.removeEventListener("mouseleave",v.hide)}},h={input:function(t){var e=t.parentNode;if("i"!==e.tagName.toLowerCase||!e.classList.contains("waves-effect")){var n=document.createElement("i");n.className=t.className+" waves-input-wrapper",t.className="waves-button-input",e.replaceChild(n,t),n.appendChild(t);var a=window.getComputedStyle(t,null),o=a.color,i=a.backgroundColor;n.setAttribute("style","color:"+o+";background:"+i),t.setAttribute("style","background-color:rgba(0,0,0,0);")}},img:function(t){var e=t.parentNode;if("i"!==e.tagName.toLowerCase||!e.classList.contains("waves-effect")){var n=document.createElement("i");e.replaceChild(n,t),n.appendChild(t)}}},p={touches:0,allowEvent:function(t){var e=!0;return/^(mousedown|mousemove)$/.test(t.type)&&p.touches&&(e=!1),e},registerEvent:function(t){var e=t.type;"touchstart"===e?p.touches+=1:/^(touchend|touchcancel)$/.test(e)&&setTimeout(function{p.touches&&(p.touches-=1)},500)}};return l.init=function(t){var e=document.body;t=t||{},"duration"in t&&(v.duration=t.duration),"delay"in t&&(v.delay=t.delay),m&&(e.addEventListener("touchstart",u,!1),e.addEventListener("touchcancel",p.registerEvent,!1),e.addEventListener("touchend",p.registerEvent,!1)),e.addEventListener("mousedown",u,!1)},l.attach=function(t,e){t=o(t),"[object Array]"===f.call(e)&&(e=e.join(" ")),e=e?" "+e:"";for(var n,a,i=0,r=t.length;r>i;i++)n=t[i],a=n.tagName.toLowerCase,-1!==["input","img"].indexOf(a)&&(h[a](n),n=n.parentElement),-1===n.className.indexOf("waves-effect")&&(n.className+=" waves-effect"+e)},l.ripple=function(t,e){t=o(t);var n=t.length;if(e=e||{},e.wait=e.wait||0,e.position=e.position||null,n)for(var a,r,s,c={},u=0,l={type:"mousedown",button:1},d=function(t,e){return function{v.hide(t,e)}};n>u;u++)if(a=t[u],r=e.position||{x:a.clientWidth/2,y:a.clientHeight/2},s=i(a),c.x=s.left+r.x,c.y=s.top+r.y,l.pageX=c.x,l.pageY=c.y,v.show(l,a),e.wait>=0&&null!==e.wait){var f={type:"mouseup",button:1};setTimeout(d(f,a),e.wait)}},l.calm=function(t){t=o(t);for(var e={type:"mouseup",button:1},n=0,a=t.length;a>n;n++)v.hide(e,t[n])},l.displayEffect=function(t){console.error("Waves.displayEffect has been deprecated and will be removed in future version. Please use Waves.init to initialize Waves effect"),l.init(t)},l});