MediaWiki:Vector.js

!function(t,e,n){var o=!(!e||!e.pushState),r={ANCHOR_REGEX:/^#[^ ]+$/,OFFSET_HEIGHT_PX:150,init:function{this.scrollToCurrent,$(window).on("hashchange",$.proxy(this,"scrollToCurrent")),$("body").on("click","a",$.proxy(this,"delegateAnchors"))},getFixedOffset:function{return this.OFFSET_HEIGHT_PX},scrollIfAnchor:function(r,a){var i,s;return this.ANCHOR_REGEX.test(r)?(i=t.getElementById(r.slice(1)),i&&(s=$(i).offset.top-this.getFixedOffset,$("html, body").animate({scrollTop:s},1e3),o&&a&&e.pushState({},t.title,n.pathname+r)),!!i):!1},scrollToCurrent:function(t){this.scrollIfAnchor(window.location.hash)&&t&&t.preventDefault},delegateAnchors:function(t){var e=t.target;this.scrollIfAnchor(e.getAttribute("href"),!0)&&t.preventDefault}};$(t).ready($.proxy(r,"init"))}(window.document,window.history,window.location);var addStyleSwitcherEle=function{var t=document.createElement("div");t.className="themeswitcher",t.id="darktheme";var e=document.createTextNode("theme");t.appendChild(e);var n=document.getElementById("p-personal");n.insertAdjacentElement("afterend",t)};$(document).ready(addStyleSwitcherEle);var addSmoothStateEle=function{var t=document.createElement("div");t.id="main";var e=document.getElementById("mw-page-base");e.insertAdjacentElement("afterend",t);var n=document.getElementById("content"),o=document.getElementById("mw-navigation"),r=document.getElementById("footer");t.appendChild(n),t.appendChild(o),t.appendChild(r)};$(document).ready(addSmoothStateEle),$(function{$("#content").smoothState}),function(t){"use strict";"object"==typeof module&&"object"==typeof module.exports?t(require("jquery"),window,document):t(jQuery,window,document)}(function(t,e,n,o){"use strict";if(!e.history.pushState)return t.fn.smoothState=function{return this},void(t.fn.smoothState.options={});if(!t.fn.smoothState){var r=t("html, body"),a=e.console,i={debug:!1,anchors:"a",hrefRegex:"",forms:"form",allowFormCaching:!1,repeatDelay:500,blacklist:".no-smoothState",prefetch:!1,prefetchOn:"mouseover touchstart",prefetchBlacklist:".no-prefetch",locationHeader:"X-SmoothState-Location",cacheLength:0,loadingClass:"is-loading",scroll:!0,alterRequest:function(t){return t},alterChangeState:function(t,e,n){return t},onBefore:function(t,e){},onStart:{duration:0,render:function(t){}},onProgress:{duration:0,render:function(t){}},onReady:{duration:0,render:function(t,e){t.html(e)}},onAfter:function(t,e){}},s={isExternal:function(t){var n=t.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);return"string"==typeof n[1]&&n[1].length>0&&n[1].toLowerCase!==e.location.protocol?!0:"string"==typeof n[2]&&n[2].length>0&&n[2].replace(new RegExp(":("+{"http:":80,"https:":443}[e.location.protocol]+")?$"),"")!==e.location.host?!0:!1},stripHash:function(t){return t.replace(/#.*/,"")},isHash:function(t,n){n=n||e.location.href;var o=t.indexOf("#")>-1?!0:!1,r=s.stripHash(t)===s.stripHash(n)?!0:!1;return o&&r},translate:function(e){var n={dataType:"html",type:"GET"};return e="string"==typeof e?t.extend({},n,{url:e}):t.extend({},n,e)},shouldLoadAnchor:function(t,e,n){var r=t.prop("href");return!(s.isExternal(r)||s.isHash(r)||t.is(e)||t.prop("target")||typeof n!==o&&""!==n&&-1===t.prop("href").search(n))},clearIfOverCapacity:function(t,e){return Object.keys||(Object.keys=function(t){var e,n=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.push(e);return n}),Object.keys(t).length>e&&(t={}),t},storePageIn:function(e,n,o,r,a,i){var s=t(" ").append(t(o));return"undefined"==typeof a&&(a={}),"undefined"==typeof i&&(i=n),e[n]={status:"loaded",title:s.find("title").first.text,html:s.find("#"+r),doc:o,state:a,destUrl:i},e},triggerAllAnimationEndEvent:function(e,n){n=" "+n||"";var o=0,r="animationstart webkitAnimationStart oanimationstart MSAnimationStart",a="animationend webkitAnimationEnd oanimationend MSAnimationEnd",i="allanimationend",l=function(n){t(n.delegateTarget).is(e)&&(n.stopPropagation,o++)},c=function(n){t(n.delegateTarget).is(e)&&(n.stopPropagation,o--,0===o&&e.trigger(i))};e.on(r,l),e.on(a,c),e.on("allanimationend"+n,function{o=0,s.redraw(e)})},redraw:function(t){t.height}},l=function(n){if(null!==n.state){var o=e.location.href,r=t("#"+n.state.id),a=r.data("smoothState"),i=a.href!==o&&!s.isHash(o,a.href),l=n.state!==a.cache[a.href].state;(i||l)&&(l&&a.clear(a.href),a.load(o,!1))}},c=function(i,l){var c=t(i),d=c.prop("id"),u=null,h=!1,f={},p={},m=e.location.href,g=function(t){t=t||!1,t&&f.hasOwnProperty(t)?delete f[t]:f={},c.data("smoothState").cache=f},y=function(e,n){n=n||t.noop;var o=s.translate(e);if(f=s.clearIfOverCapacity(f,l.cacheLength),!f.hasOwnProperty(o.url)||"undefined"!=typeof o.data){f[o.url]={status:"fetching"};var r=t.ajax(o);r.done(function(t){s.storePageIn(f,o.url,t,d),c.data("smoothState").cache=f}),r.fail(function{f[o.url].status="error"}),l.locationHeader&&r.always(function(t,e,n){var r=t.statusCode?t:n,a=r.getResponseHeader(l.locationHeader);a&&(f[o.url].destUrl=a)}),n&&r.always(n)}},v=function{if(u){var e=t(u,c);if(e.length){var n=e.offset.top;r.scrollTop(n)}u=null}},S=function(o){var i="#"+d,s=f[o]?t(f[o].html.html):null;s.length?(n.title=f[o].title,c.data("smoothState").href=o,l.loadingClass&&r.removeClass(l.loadingClass),l.onReady.render(c,s),c.one("ss.onReadyEnd",function{h=!1,l.onAfter(c,s),l.scroll&&v,O(c)}),e.setTimeout(function{c.trigger("ss.onReadyEnd")},l.onReady.duration)):!s&&l.debug&&a?a.warn("No element with an id of "+i+" in response from "+o+" in "+f):e.location=o},w=function(t,n,o){var i=s.translate(t);"undefined"==typeof n&&(n=!0),"undefined"==typeof o&&(o=!0);var u=!1,h=!1,m={loaded:function{var t=u?"ss.onProgressEnd":"ss.onStartEnd";if(h&&u?h&&S(i.url):c.one(t,function{S(i.url),o||g(i.url)}),n){var r=f[i.url].destUrl;p=l.alterChangeState({id:d},f[i.url].title,r),f[i.url].state=p,e.history.pushState(p,f[i.url].title,r)}h&&!o&&g(i.url)},fetching:function{u||(u=!0,c.one("ss.onStartEnd",function{l.loadingClass&&r.addClass(l.loadingClass),l.onProgress.render(c),e.setTimeout(function{c.trigger("ss.onProgressEnd"),h=!0},l.onProgress.duration)})),e.setTimeout(function{f.hasOwnProperty(i.url)&&m[f[i.url].status]},10)},error:function{l.debug&&a?a.log("There was an error loading: "+i.url):e.location=i.url}};f.hasOwnProperty(i.url)||y(i),l.onStart.render(c),e.setTimeout(function{l.scroll&&r.scrollTop(0),c.trigger("ss.onStartEnd")},l.onStart.duration),m[f[i.url].status]},E=function(e){var n,o=t(e.currentTarget);s.shouldLoadAnchor(o,l.blacklist,l.hrefRegex)&&!h&&(e.stopPropagation,n=s.translate(o.prop("href")),n=l.alterRequest(n),y(n))},C=function(e){var n=t(e.currentTarget);if(!e.metaKey&&!e.ctrlKey&&s.shouldLoadAnchor(n,l.blacklist,l.hrefRegex)&&(e.stopPropagation,e.preventDefault,!A)){P;var o=s.translate(n.prop("href"));h=!0,u=n.prop("hash"),o=l.alterRequest(o),l.onBefore(n,c),w(o)}},b=function(e){var n=t(e.currentTarget);if(!n.is(l.blacklist)&&(e.preventDefault,e.stopPropagation,!A)){P;var r={url:n.prop("action"),data:n.serialize,type:n.prop("method")};h=!0,r=l.alterRequest(r),"get"===r.type.toLowerCase&&(r.url=r.url+"?"+r.data),l.onBefore(n,c),w(r,o,l.allowFormCaching)}},T=0,A=function{var t=null===l.repeatDelay,e=parseInt(Date.now)>T;return!(t||e)},P=function{T=parseInt(Date.now)+parseInt(l.repeatDelay)},O=function(t){l.anchors&&l.prefetch&&t.find(l.anchors).not(l.prefetchBlacklist).on(l.prefetchOn,null,E)},x=function(t){l.anchors&&(t.on("click",l.anchors,C),O(t)),l.forms&&t.on("submit",l.forms,b)},I=function{var t=c.prop("class");c.removeClass(t),s.redraw(c),c.addClass(t)};return l=t.extend({},t.fn.smoothState.options,l),null===e.history.state?(p=l.alterChangeState({id:d},n.title,m),e.history.replaceState(p,n.title,m)):p={},s.storePageIn(f,m,n.documentElement.outerHTML,d,p),s.triggerAllAnimationEndEvent(c,"ss.onStartEnd ss.onProgressEnd ss.onEndEnd"),x(c),{href:m,cache:f,clear:g,load:w,fetch:y,restartCSSAnimations:I}},d=function(e){return this.each(function{var n=this.tagName.toLowerCase;this.id&&"body"!==n&&"html"!==n&&!t.data(this,"smoothState")?t.data(this,"smoothState",new c(this,e)):!this.id&&a?a.warn("Every smoothState container needs an id but the following one does not have one:",this):"body"!==n&&"html"!==n||!a||a.warn("The smoothstate container cannot be the "+this.tagName+" tag")})};e.onpopstate=l,t.smoothStateUtility=s,t.fn.smoothState=d,t.fn.smoothState.options=i}});