-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathnavigate.min.js
2 lines (2 loc) · 28 KB
/
navigate.min.js
1
2
// navigate.min.js from https://github.com/gebeer/jquery-navigate
window.JSON||(window.JSON={}),function(){function f(e){return 10>e?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var r,a,n,i,o,s=gap,u=t[e];switch(u&&"object"==typeof u&&"function"==typeof u.toJSON&&(u=u.toJSON(e)),"function"==typeof rep&&(u=rep.call(t,e,u)),typeof u){case"string":return quote(u);case"number":return isFinite(u)?String(u):"null";case"boolean":case"null":return String(u);case"object":if(!u)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(u)){for(i=u.length,r=0;i>r;r+=1)o[r]=str(r,u)||"null";return n=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+s+"]":"["+o.join(",")+"]",gap=s,n}if(rep&&"object"==typeof rep)for(i=rep.length,r=0;i>r;r+=1)a=rep[r],"string"==typeof a&&(n=str(a,u),n&&o.push(quote(a)+(gap?": ":":")+n));else for(a in u)Object.hasOwnProperty.call(u,a)&&(n=str(a,u),n&&o.push(quote(a)+(gap?": ":":")+n));return n=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+s+"}":"{"+o.join(",")+"}",gap=s,n}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(e,t,r){var a;if(gap="",indent="","number"==typeof r)for(a=0;r>a;a+=1)indent+=" ";else"string"==typeof r&&(indent=r);if(rep=t,!t||"function"==typeof t||"object"==typeof t&&"number"==typeof t.length)return str("",{"":e});throw new Error("JSON.stringify")}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var r,a,n=e[t];if(n&&"object"==typeof n)for(r in n)Object.hasOwnProperty.call(n,r)&&(a=walk(n,r),void 0!==a?n[r]=a:delete n[r]);return reviver.call(e,t,n)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(e,t){"use strict";var r=e.History=e.History||{},a=e.jQuery;if("undefined"!=typeof r.Adapter)throw new Error("History.js Adapter has already been loaded...");r.Adapter={bind:function(e,t,r){a(e).bind(t,r)},trigger:function(e,t,r){a(e).trigger(t,r)},extractEventData:function(e,r,a){var n=r&&r.originalEvent&&r.originalEvent[e]||a&&a[e]||t;return n},onDomLoad:function(e){a(e)}},"undefined"!=typeof r.init&&r.init()}(window),function(e){"use strict";var t=e.document,r=e.setTimeout||r,a=e.clearTimeout||a,n=e.setInterval||n,i=e.History=e.History||{};if("undefined"!=typeof i.initHtml4)throw new Error("History.js HTML4 Support has already been loaded...");i.initHtml4=function(){return"undefined"!=typeof i.initHtml4.initialized?!1:(i.initHtml4.initialized=!0,i.enabled=!0,i.savedHashes=[],i.isLastHash=function(e){var t,r=i.getHashByIndex();return t=e===r},i.saveHash=function(e){return i.isLastHash(e)?!1:(i.savedHashes.push(e),!0)},i.getHashByIndex=function(e){var t=null;return t="undefined"==typeof e?i.savedHashes[i.savedHashes.length-1]:0>e?i.savedHashes[i.savedHashes.length+e]:i.savedHashes[e]},i.discardedHashes={},i.discardedStates={},i.discardState=function(e,t,r){var a,n=i.getHashByState(e);return a={discardedState:e,backState:r,forwardState:t},i.discardedStates[n]=a,!0},i.discardHash=function(e,t,r){var a={discardedHash:e,backState:r,forwardState:t};return i.discardedHashes[e]=a,!0},i.discardedState=function(e){var t,r=i.getHashByState(e);return t=i.discardedStates[r]||!1},i.discardedHash=function(e){var t=i.discardedHashes[e]||!1;return t},i.recycleState=function(e){var t=i.getHashByState(e);return i.discardedState(e)&&delete i.discardedStates[t],!0},i.emulated.hashChange&&(i.hashChangeInit=function(){i.checkerFunction=null;var r,a,o,s,u="";return i.isInternetExplorer()?(r="historyjs-iframe",a=t.createElement("iframe"),a.setAttribute("id",r),a.style.display="none",t.body.appendChild(a),a.contentWindow.document.open(),a.contentWindow.document.close(),o="",s=!1,i.checkerFunction=function(){if(s)return!1;s=!0;var t=i.getHash()||"",r=i.unescapeHash(a.contentWindow.document.location.hash)||"";return t!==u?(u=t,r!==t&&(o=r=t,a.contentWindow.document.open(),a.contentWindow.document.close(),a.contentWindow.document.location.hash=i.escapeHash(t)),i.Adapter.trigger(e,"hashchange")):r!==o&&(o=r,i.setHash(r,!1)),s=!1,!0}):i.checkerFunction=function(){var t=i.getHash();return t!==u&&(u=t,i.Adapter.trigger(e,"hashchange")),!0},i.intervalList.push(n(i.checkerFunction,i.options.hashChangeInterval)),!0},i.Adapter.onDomLoad(i.hashChangeInit)),i.emulated.pushState&&(i.onHashChange=function(r){var a,n=r&&r.newURL||t.location.href,o=i.getHashByUrl(n),s=null,u=null;return i.isLastHash(o)?(i.busy(!1),!1):(i.doubleCheckComplete(),i.saveHash(o),o&&i.isTraditionalAnchor(o)?(i.Adapter.trigger(e,"anchorchange"),i.busy(!1),!1):(s=i.extractState(i.getFullUrl(o||t.location.href,!1),!0),i.isLastSavedState(s)?(i.busy(!1),!1):(u=i.getHashByState(s),a=i.discardedState(s),a?(i.getHashByIndex(-2)===i.getHashByState(a.forwardState)?i.back(!1):i.forward(!1),!1):(i.pushState(s.data,s.title,s.url,!1),!0))))},i.Adapter.bind(e,"hashchange",i.onHashChange),i.pushState=function(r,a,n,o){if(i.getHashByUrl(n))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(o!==!1&&i.busy())return i.pushQueue({scope:i,callback:i.pushState,args:arguments,queue:o}),!1;i.busy(!0);var s=i.createStateObject(r,a,n),u=i.getHashByState(s),l=i.getState(!1),c=i.getHashByState(l),d=i.getHash();return i.storeState(s),i.expectedStateId=s.id,i.recycleState(s),i.setTitle(s),u===c?(i.busy(!1),!1):u!==d&&u!==i.getShortUrl(t.location.href)?(i.setHash(u,!1),!1):(i.saveState(s),i.Adapter.trigger(e,"statechange"),i.busy(!1),!0)},i.replaceState=function(e,t,r,a){if(i.getHashByUrl(r))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(a!==!1&&i.busy())return i.pushQueue({scope:i,callback:i.replaceState,args:arguments,queue:a}),!1;i.busy(!0);var n=i.createStateObject(e,t,r),o=i.getState(!1),s=i.getStateByIndex(-2);return i.discardState(o,n,s),i.pushState(n.data,n.title,n.url,!1),!0}),i.emulated.pushState&&i.getHash()&&!i.emulated.hashChange&&i.Adapter.onDomLoad(function(){i.Adapter.trigger(e,"hashchange")}),void 0)},"undefined"!=typeof i.init&&i.init()}(window),function(e,t){"use strict";var r=e.console||t,a=e.document,n=e.navigator,i=e.sessionStorage||!1,o=e.setTimeout,s=e.clearTimeout,u=e.setInterval,l=e.clearInterval,c=e.JSON,d=e.alert,f=e.History=e.History||{},h=e.history;if(c.stringify=c.stringify||c.encode,c.parse=c.parse||c.decode,"undefined"!=typeof f.init)throw new Error("History.js Core has already been loaded...");f.init=function(){return"undefined"==typeof f.Adapter?!1:("undefined"!=typeof f.initCore&&f.initCore(),"undefined"!=typeof f.initHtml4&&f.initHtml4(),!0)},f.initCore=function(){if("undefined"!=typeof f.initCore.initialized)return!1;if(f.initCore.initialized=!0,f.options=f.options||{},f.options.hashChangeInterval=f.options.hashChangeInterval||100,f.options.safariPollInterval=f.options.safariPollInterval||500,f.options.doubleCheckInterval=f.options.doubleCheckInterval||500,f.options.storeInterval=f.options.storeInterval||1e3,f.options.busyDelay=f.options.busyDelay||250,f.options.debug=f.options.debug||!1,f.options.initialTitle=f.options.initialTitle||a.title,f.intervalList=[],f.clearAllIntervals=function(){var e,t=f.intervalList;if("undefined"!=typeof t&&null!==t){for(e=0;e<t.length;e++)l(t[e]);f.intervalList=null}},f.debug=function(){(f.options.debug||!1)&&f.log.apply(f,arguments)},f.log=function(){var e,t,n,i,o,s="undefined"!=typeof r&&"undefined"!=typeof r.log&&"undefined"!=typeof r.log.apply,u=a.getElementById("log");for(s?(i=Array.prototype.slice.call(arguments),e=i.shift(),"undefined"!=typeof r.debug?r.debug.apply(r,[e,i]):r.log.apply(r,[e,i])):e="\n"+arguments[0]+"\n",t=1,n=arguments.length;n>t;++t){if(o=arguments[t],"object"==typeof o&&"undefined"!=typeof c)try{o=c.stringify(o)}catch(l){}e+="\n"+o+"\n"}return u?(u.value+=e+"\n-----\n",u.scrollTop=u.scrollHeight-u.clientHeight):s||d(e),!0},f.getInternetExplorerMajorVersion=function(){var e=f.getInternetExplorerMajorVersion.cached="undefined"!=typeof f.getInternetExplorerMajorVersion.cached?f.getInternetExplorerMajorVersion.cached:function(){for(var e=3,t=a.createElement("div"),r=t.getElementsByTagName("i");(t.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->")&&r[0];);return e>4?e:!1}();return e},f.isInternetExplorer=function(){var e=f.isInternetExplorer.cached="undefined"!=typeof f.isInternetExplorer.cached?f.isInternetExplorer.cached:Boolean(f.getInternetExplorerMajorVersion());return e},f.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(n.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(n.userAgent)),hashChange:Boolean(!("onhashchange"in e||"onhashchange"in a)||f.isInternetExplorer()&&f.getInternetExplorerMajorVersion()<8)},f.enabled=!f.emulated.pushState,f.bugs={setHash:Boolean(!f.emulated.pushState&&"Apple Computer, Inc."===n.vendor&&/AppleWebKit\/5([0-2]|3[0-3])/.test(n.userAgent)),safariPoll:Boolean(!f.emulated.pushState&&"Apple Computer, Inc."===n.vendor&&/AppleWebKit\/5([0-2]|3[0-3])/.test(n.userAgent)),ieDoubleCheck:Boolean(f.isInternetExplorer()&&f.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(f.isInternetExplorer()&&f.getInternetExplorerMajorVersion()<7)},f.isEmptyObject=function(e){for(var t in e)return!1;return!0},f.cloneObject=function(e){var t,r;return e?(t=c.stringify(e),r=c.parse(t)):r={},r},f.getRootUrl=function(){var e=a.location.protocol+"//"+(a.location.hostname||a.location.host);return a.location.port&&(e+=":"+a.location.port),e+="/"},f.getBaseHref=function(){var e=a.getElementsByTagName("base"),t=null,r="";return 1===e.length&&(t=e[0],r=t.href.replace(/[^\/]+$/,"")),r=r.replace(/\/+$/,""),r&&(r+="/"),r},f.getBaseUrl=function(){var e=f.getBaseHref()||f.getBasePageUrl()||f.getRootUrl();return e},f.getPageUrl=function(){var e,t=f.getState(!1,!1),r=(t||{}).url||a.location.href;return e=r.replace(/\/+$/,"").replace(/[^\/]+$/,function(e){return/\./.test(e)?e:e+"/"})},f.getBasePageUrl=function(){var e=a.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(e){return/[^\/]$/.test(e)?"":e}).replace(/\/+$/,"")+"/";return e},f.getFullUrl=function(e,t){var r=e,a=e.substring(0,1);return t="undefined"==typeof t?!0:t,/[a-z]+\:\/\//.test(e)||(r="/"===a?f.getRootUrl()+e.replace(/^\/+/,""):"#"===a?f.getPageUrl().replace(/#.*/,"")+e:"?"===a?f.getPageUrl().replace(/[\?#].*/,"")+e:t?f.getBaseUrl()+e.replace(/^(\.\/)+/,""):f.getBasePageUrl()+e.replace(/^(\.\/)+/,"")),r.replace(/\#$/,"")},f.getShortUrl=function(e){var t=e,r=f.getBaseUrl(),a=f.getRootUrl();return f.emulated.pushState&&(t=t.replace(r,"")),t=t.replace(a,"/"),f.isTraditionalAnchor(t)&&(t="./"+t),t=t.replace(/^(\.\/)+/g,"./").replace(/\#$/,"")},f.store={},f.idToState=f.idToState||{},f.stateToId=f.stateToId||{},f.urlToId=f.urlToId||{},f.storedStates=f.storedStates||[],f.savedStates=f.savedStates||[],f.normalizeStore=function(){f.store.idToState=f.store.idToState||{},f.store.urlToId=f.store.urlToId||{},f.store.stateToId=f.store.stateToId||{}},f.getState=function(e,t){"undefined"==typeof e&&(e=!0),"undefined"==typeof t&&(t=!0);var r=f.getLastSavedState();return!r&&t&&(r=f.createStateObject()),e&&(r=f.cloneObject(r),r.url=r.cleanUrl||r.url),r},f.getIdByState=function(e){var t,r=f.extractId(e.url);if(!r)if(t=f.getStateString(e),"undefined"!=typeof f.stateToId[t])r=f.stateToId[t];else if("undefined"!=typeof f.store.stateToId[t])r=f.store.stateToId[t];else{for(;r=(new Date).getTime()+String(Math.random()).replace(/\D/g,""),"undefined"!=typeof f.idToState[r]||"undefined"!=typeof f.store.idToState[r];);f.stateToId[t]=r,f.idToState[r]=e}return r},f.normalizeState=function(e){var t,r;return e&&"object"==typeof e||(e={}),"undefined"!=typeof e.normalized?e:(e.data&&"object"==typeof e.data||(e.data={}),t={},t.normalized=!0,t.title=e.title||"",t.url=f.getFullUrl(f.unescapeString(e.url||a.location.href)),t.hash=f.getShortUrl(t.url),t.data=f.cloneObject(e.data),t.id=f.getIdByState(t),t.cleanUrl=t.url.replace(/\??\&_suid.*/,""),t.url=t.cleanUrl,r=!f.isEmptyObject(t.data),(t.title||r)&&(t.hash=f.getShortUrl(t.url).replace(/\??\&_suid.*/,""),/\?/.test(t.hash)||(t.hash+="?"),t.hash+="&_suid="+t.id),t.hashedUrl=f.getFullUrl(t.hash),(f.emulated.pushState||f.bugs.safariPoll)&&f.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t)},f.createStateObject=function(e,t,r){var a={data:e,title:t,url:r};return a=f.normalizeState(a)},f.getStateById=function(e){e=String(e);var r=f.idToState[e]||f.store.idToState[e]||t;return r},f.getStateString=function(e){var t,r,a;return t=f.normalizeState(e),r={data:t.data,title:e.title,url:e.url},a=c.stringify(r)},f.getStateId=function(e){var t,r;return t=f.normalizeState(e),r=t.id},f.getHashByState=function(e){var t,r;return t=f.normalizeState(e),r=t.hash},f.extractId=function(e){var t,r,a;return r=/(.*)\&_suid=([0-9]+)$/.exec(e),a=r?r[1]||e:e,t=r?String(r[2]||""):"",t||!1},f.isTraditionalAnchor=function(e){var t=!/[\/\?\.]/.test(e);return t},f.extractState=function(e,t){var r,a,n=null;return t=t||!1,r=f.extractId(e),r&&(n=f.getStateById(r)),n||(a=f.getFullUrl(e),r=f.getIdByUrl(a)||!1,r&&(n=f.getStateById(r)),!n&&t&&!f.isTraditionalAnchor(e)&&(n=f.createStateObject(null,null,a))),n},f.getIdByUrl=function(e){var r=f.urlToId[e]||f.store.urlToId[e]||t;return r},f.getLastSavedState=function(){return f.savedStates[f.savedStates.length-1]||t},f.getLastStoredState=function(){return f.storedStates[f.storedStates.length-1]||t},f.hasUrlDuplicate=function(e){var t,r=!1;return t=f.extractState(e.url),r=t&&t.id!==e.id},f.storeState=function(e){return f.urlToId[e.url]=e.id,f.storedStates.push(f.cloneObject(e)),e},f.isLastSavedState=function(e){var t,r,a,n=!1;return f.savedStates.length&&(t=e.id,r=f.getLastSavedState(),a=r.id,n=t===a),n},f.saveState=function(e){return f.isLastSavedState(e)?!1:(f.savedStates.push(f.cloneObject(e)),!0)},f.getStateByIndex=function(e){var t=null;return t="undefined"==typeof e?f.savedStates[f.savedStates.length-1]:0>e?f.savedStates[f.savedStates.length+e]:f.savedStates[e]},f.getHash=function(){var e=f.unescapeHash(a.location.hash);return e},f.unescapeString=function(t){for(var r,a=t;r=e.unescape(a),r!==a;)a=r;return a},f.unescapeHash=function(e){var t=f.normalizeHash(e);return t=f.unescapeString(t)},f.normalizeHash=function(e){var t=e.replace(/[^#]*#/,"").replace(/#.*/,"");return t},f.setHash=function(e,t){var r,n,i;return t!==!1&&f.busy()?(f.pushQueue({scope:f,callback:f.setHash,args:arguments,queue:t}),!1):(r=f.escapeHash(e),f.busy(!0),n=f.extractState(e,!0),n&&!f.emulated.pushState?f.pushState(n.data,n.title,n.url,!1):a.location.hash!==r&&(f.bugs.setHash?(i=f.getPageUrl(),f.pushState(null,null,i+"#"+r,!1)):a.location.hash=r),f)},f.escapeHash=function(t){var r=f.normalizeHash(t);return r=e.escape(r),f.bugs.hashEscape||(r=r.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),r},f.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return t=f.unescapeHash(t)},f.setTitle=function(e){var t,r=e.title;r||(t=f.getStateByIndex(0),t&&t.url===e.url&&(r=t.title||f.options.initialTitle));try{a.getElementsByTagName("title")[0].innerHTML=r.replace("<","<").replace(">",">").replace(" & "," & ")}catch(n){}return a.title=r,f},f.queues=[],f.busy=function(e){if("undefined"!=typeof e?f.busy.flag=e:"undefined"==typeof f.busy.flag&&(f.busy.flag=!1),!f.busy.flag){s(f.busy.timeout);var t=function(){var e,r,a;if(!f.busy.flag)for(e=f.queues.length-1;e>=0;--e)r=f.queues[e],0!==r.length&&(a=r.shift(),f.fireQueueItem(a),f.busy.timeout=o(t,f.options.busyDelay))};f.busy.timeout=o(t,f.options.busyDelay)}return f.busy.flag},f.busy.flag=!1,f.fireQueueItem=function(e){return e.callback.apply(e.scope||f,e.args||[])},f.pushQueue=function(e){return f.queues[e.queue||0]=f.queues[e.queue||0]||[],f.queues[e.queue||0].push(e),f},f.queue=function(e,t){return"function"==typeof e&&(e={callback:e}),"undefined"!=typeof t&&(e.queue=t),f.busy()?f.pushQueue(e):f.fireQueueItem(e),f},f.clearQueue=function(){return f.busy.flag=!1,f.queues=[],f},f.stateChanged=!1,f.doubleChecker=!1,f.doubleCheckComplete=function(){return f.stateChanged=!0,f.doubleCheckClear(),f},f.doubleCheckClear=function(){return f.doubleChecker&&(s(f.doubleChecker),f.doubleChecker=!1),f},f.doubleCheck=function(e){return f.stateChanged=!1,f.doubleCheckClear(),f.bugs.ieDoubleCheck&&(f.doubleChecker=o(function(){return f.doubleCheckClear(),f.stateChanged||e(),!0},f.options.doubleCheckInterval)),f},f.safariStatePoll=function(){var t,r=f.extractState(a.location.href);if(!f.isLastSavedState(r))return t=r,t||(t=f.createStateObject()),f.Adapter.trigger(e,"popstate"),f},f.back=function(e){return e!==!1&&f.busy()?(f.pushQueue({scope:f,callback:f.back,args:arguments,queue:e}),!1):(f.busy(!0),f.doubleCheck(function(){f.back(!1)}),h.go(-1),!0)},f.forward=function(e){return e!==!1&&f.busy()?(f.pushQueue({scope:f,callback:f.forward,args:arguments,queue:e}),!1):(f.busy(!0),f.doubleCheck(function(){f.forward(!1)}),h.go(1),!0)},f.go=function(e,t){var r;if(e>0)for(r=1;e>=r;++r)f.forward(t);else{if(!(0>e))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(r=-1;r>=e;--r)f.back(t)}return f},f.emulated.pushState){var p=function(){};f.pushState=f.pushState||p,f.replaceState=f.replaceState||p}else f.onPopState=function(t,r){var n,i,o=!1,s=!1;return f.doubleCheckComplete(),n=f.getHash(),n?(i=f.extractState(n||a.location.href,!0),i?f.replaceState(i.data,i.title,i.url,!1):(f.Adapter.trigger(e,"anchorchange"),f.busy(!1)),f.expectedStateId=!1,!1):(o=f.Adapter.extractEventData("state",t,r)||!1,s=o?f.getStateById(o):f.expectedStateId?f.getStateById(f.expectedStateId):f.extractState(a.location.href),s||(s=f.createStateObject(null,null,a.location.href)),f.expectedStateId=!1,f.isLastSavedState(s)?(f.busy(!1),!1):(f.storeState(s),f.saveState(s),f.setTitle(s),f.Adapter.trigger(e,"statechange"),f.busy(!1),!0))},f.Adapter.bind(e,"popstate",f.onPopState),f.pushState=function(t,r,a,n){if(f.getHashByUrl(a)&&f.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(n!==!1&&f.busy())return f.pushQueue({scope:f,callback:f.pushState,args:arguments,queue:n}),!1;f.busy(!0);var i=f.createStateObject(t,r,a);return f.isLastSavedState(i)?f.busy(!1):(f.storeState(i),f.expectedStateId=i.id,h.pushState(i.id,i.title,i.url),f.Adapter.trigger(e,"popstate")),!0},f.replaceState=function(t,r,a,n){if(f.getHashByUrl(a)&&f.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(n!==!1&&f.busy())return f.pushQueue({scope:f,callback:f.replaceState,args:arguments,queue:n}),!1;f.busy(!0);var i=f.createStateObject(t,r,a);return f.isLastSavedState(i)?f.busy(!1):(f.storeState(i),f.expectedStateId=i.id,h.replaceState(i.id,i.title,i.url),f.Adapter.trigger(e,"popstate")),!0};if(i){try{f.store=c.parse(i.getItem("History.store"))||{}}catch(g){f.store={}}f.normalizeStore()}else f.store={},f.normalizeStore();f.Adapter.bind(e,"beforeunload",f.clearAllIntervals),f.Adapter.bind(e,"unload",f.clearAllIntervals),f.saveState(f.storeState(f.extractState(a.location.href,!0))),i&&(f.onUnload=function(){var e,t;try{e=c.parse(i.getItem("History.store"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in f.idToState)f.idToState.hasOwnProperty(t)&&(e.idToState[t]=f.idToState[t]);for(t in f.urlToId)f.urlToId.hasOwnProperty(t)&&(e.urlToId[t]=f.urlToId[t]);for(t in f.stateToId)f.stateToId.hasOwnProperty(t)&&(e.stateToId[t]=f.stateToId[t]);f.store=e,f.normalizeStore(),i.setItem("History.store",c.stringify(e))},f.intervalList.push(u(f.onUnload,f.options.storeInterval)),f.Adapter.bind(e,"beforeunload",f.onUnload),f.Adapter.bind(e,"unload",f.onUnload)),f.emulated.pushState||(f.bugs.safariPoll&&f.intervalList.push(u(f.safariStatePoll,f.options.safariPollInterval)),("Apple Computer, Inc."===n.vendor||"Mozilla"===(n.appCodeName||""))&&(f.Adapter.bind(e,"hashchange",function(){f.Adapter.trigger(e,"popstate")}),f.getHash()&&f.Adapter.onDomLoad(function(){f.Adapter.trigger(e,"hashchange")})))},f.init()}(window),jQuery.refresh={ajaxCalls:new Array,refreshTimers:new Array,defaultCache:!1},function(e){e.fn.getSelector=function(){var t=e(this);if(t.is("body"))return"body";if(e.isWindow(t[0]))return t=null,window;var r=t.attr("id");return r||(r="me-"+Math.floor(1e6*Math.random()),t.attr("id",r)),t=null,"#"+r},e.fn.stopRefresh=function(){var t=e(this);t.trigger("stoprefresh");var r=t.getSelector(),a=e.refresh.refreshTimers[r];a&&(clearInterval(a),delete a);var n=e.refresh.ajaxCalls[r];n&&(n.abort(),delete n)},e.fn.defaultRefreshInsert=function(t){e(this).html(t.html),e(this).trigger({type:"finishrefreshinsert"})},e.fn.refresh=function(t){var r=e(this),a=r.getSelector();"boolean"==typeof t&&(t={refresh:t}),t=e.extend({html:null,refresh:r,resetInterval:!0,url:null,content:a,clickedSelector:e(this).getSelector(),callback:function(){},cache:e.refresh.defaultCache,insertFunction:e.navigate.defaultInsertFunction,customData:null,timeout:8e3},t);var n=r.attr("data-refresh-function");if("undefined"!=typeof n)r[n]?r[n]():n();else if(t.refresh){var i=e.refresh.ajaxCalls[a];i&&(r.trigger("stoprefresh"),i.abort());var o=t.url;if(!o){var s=r.attr("data-refresh-url");o=s?s:window.location.href}var u=r.attr("data-refresh-id");r.trigger({type:"startrefresh",clickedSelector:t.clickedSelector});var l=function(a){i=null;var n=/<body[\s\S]*\/body>/,o=a.match(n);o&&o.length>0?(o=o[0].replace(/^<body/,"<div"),o=o.replace(/body>$/,"div>")):o=a;var n=/<head[\s\S]*\/head>/,s=a.match(n);s&&s.length>0?(s=s[0].replace(/^<head/,"<div"),s=s.replace(/head>$/,"div>"),s=e(s).html()):s="";var l=o.match(/<noscript\b[^>]*>([\s\S]*?)<\/noscript>/gm);o=o.replace(new RegExp("<noscript","g"),'<div class="temp-script"'),o=o.replace(new RegExp("noscript>","g"),"div>");var c=o.match(/<script\b[^>]*>([\s\S]*?)<\/script>/gm);if(o=o.replace(new RegExp("<script","g"),'<div class="temp-script"'),o=o.replace(new RegExp("script>","g"),"div>"),"body"!=t.content)var d=e(t.content,"<div>"+o+"</div>");else var d=e(o);var f=d.attr("data-refresh-id");if(u&&f&&u==f)return void r.trigger({type:"cancelrefresh",clickedSelector:t.clickedSelector});var h="",p=d.find(".temp-script").remove();if(d.each(function(){h+=e(this).html()}),myScriptsHtml="",c)for(var g=0;g<c.length;g++)myScriptsHtml+=c[g];if(l)for(var g=0;g<l.length;g++)myScriptsHtml+=l[g];if(h+=myScriptsHtml,!h)return void r.trigger({type:"failrefresh",clickedSelector:t.clickedSelector,status:"error"});var S=r.attr("data-refresh-insert-function");S||(S=r.attr("data-insert-function")),S||(S=t.insertFunction),r.off("finishrefreshinsert").one("finishrefreshinsert",function(){var e=d.attr("data-refresh-status"),a=r.attr("data-refresh-status");e&&a!=e&&r.trigger({type:"refreshstatuschanged",clickedSelector:t.clickedSelector,oldStatus:a,newStatus:e}),r.trigger({type:"donerefresh",clickedSelector:t.clickedSelector}),t.callback({clickedSelector:t.clickedSelector})}),r[S]?"append"==S||"prepend"==S||"html"==S?(r[S](h),r.trigger({type:"finishrefreshinsert"})):"appendTo"==S||"prependTo"==S?(e("<div>"+h+"</div>").children().each(function(){e(this)[S](r)}),r.trigger({type:"finishrefreshinsert"})):r[S]({html:h,head:s,scripts:myScriptsHtml,customData:t.customData,"class":d.attr("class")}):window[S]&&window[S]({html:h,head:s,scripts:p,customData:t.customData,"class":d.attr("class")})};t.html?l(t.html):i=e.ajax({type:"GET",cache:t.cache,context:r,url:o,timeout:t.timeout,dataType:"html"}).done(l).fail(function(r,a){i.abort(),i=null,e(this).trigger({type:"failrefresh",clickedSelector:t.clickedSelector,status:a})})}else r.trigger({type:"donerefresh",clickedSelector:t.clickedSelector});var c=e.refresh.refreshTimers[a];t.resetInterval&&c&&(clearInterval(c),delete c);var d=r.attr("data-refresh-interval");d&&(d=parseInt(d),t.resetInterval&&d>0&&(e.refresh.refreshTimers[a]=setInterval(function(){r.refresh({refresh:!0,resetInterval:!1})},d)))}}(jQuery),jQuery.navigate={active:!1,historyStates:new Array,defaultCache:!0,ajaxLinks:'a:not(.noAjax)[rel!="external"][target!="_blank"], .ajaxLink',discreteLinks:'a:not(.noAjax)[rel!="external"][target!="_blank"], .ajaxLink',defaultInsertFunction:"defaultRefreshInsert",stateChanged:function(){var e=History.getState(!1,!1),t=(0==History.getState().internal,$(e.data.target?e.data.target:"body")),r=(e.data.content?" "+e.data.content:"",null);if(History.savedStates.length>1&&(r=History.getStateByIndex(-2)),null==r)return("undefined"==typeof Modernizr||Modernizr.touch)&&$("body").find($.navigate.discreteLinks).each(function(){$(this).discreteClick()}),void $("body").refresh({refresh:!1});var a=$(r.data.target?r.data.target:"body");a.stopRefresh();var n={refresh:!0,url:e.url,content:e.data.content,status:e.data.status,html:e.data.html,clickedSelector:e.data.clickedSelector,callback:function(){("undefined"==typeof Modernizr||Modernizr.touch)&&t.find($.navigate.discreteLinks).each(function(){$(this).discreteClick()})},cache:$.navigate.defaultCache,customData:e.data.customData,timeout:$.navigate.timeout};return e.data.insertFunction&&(n.insertFunction=e.data.insertFunction),t.refresh(n),!1},init:function(e){if(e=$.extend({ajaxLinks:this.ajaxLinks,discreteLinks:this.discreteLinks,defaultInsertFunction:$.navigate.defaultInsertFunction,timeout:8e3},e),this.active=e.active,this.defaultInsertFunction=e.defaultInsertFunction,this.ajaxLinks=e.ajaxLinks,this.discreteLinks=e.discreteLinks,this.timeout=e.timeout,"undefined"==typeof e.active&&("undefined"==typeof Modernizr?(console.log('if not specified any other "active" parameter, navigate tests Modernizr.history to get active, Modernizr undefined => navigate will not get active'),this.active=!1):this.active=Modernizr.history),!this.active)return void $("body").trigger("donerefresh");var t=window.History;return t.enabled?($("html").on("click",$.navigate.ajaxLinks,function(){var e=$(this);return e.navigate()}),t.Adapter.bind(window,"statechange",$.navigate.stateChanged),void $.navigate.stateChanged()):!1}},function(e){e.fn.getSelector=function(){var t=e(this);if(t.is("body"))return"body";if(e.isWindow(t[0]))return t=null,window;var r=t.attr("id");return r||(r="me-"+Math.floor(1e6*Math.random()),t.attr("id",r)),t=null,"#"+r},e.fn.discreteClick=function(){var t=e(this);"javascript://"!=t.attr("href")&&(t.attr("data-ajax-href",t.attr("href")),t.attr("href","javascript://"))},e.fn.navigate=function(t){var r=e(this),a={html:null},n=r.attr("data-ajax-href");if(n||(n=r.attr("href")),"javascript://"==n)return!0;n||(n=document.location.href);var i=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1);n=n.replace(i,""),a.url=n;var o=r.attr("data-ajax-content");o||(o="body"),a.content=o;var s=r.attr("data-ajax-target");s||(s=r.attr("data-target")),s||(s="body"),a.target=s;var u=r.attr("title");u||(u=document.title),a.title=u;var l=e(s).attr("data-refresh-status");l||(l=null),a.status=l;var c=r.attr("data-refresh-insert-function");return c||(c=r.attr("data-ajax-insert")),c||(c=r.attr("data-insert-function")),c||(c=null),a.insertFunction=c,t=e.extend(a,t),History.pushState({target:t.target,content:t.content,insertFunction:t.insertFunction,status:t.status,clickedSelector:e(this).getSelector(),html:t.html,customData:t.customData},t.title,t.url),!1}}(jQuery);