16 lines
6.4 KiB
JavaScript
16 lines
6.4 KiB
JavaScript
|
/**
|
||
|
* Copyright 2014 Telerik AD
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e,t){function n(e,t){if(!t)return e;e+"/"===t&&(e=t);var n=RegExp("^"+t,"i");return n.test(e)||(e=t+"/"+e),h.protocol+"//"+(h.host+"/"+e).replace(/\/\/+/g,"/")}function r(e){return e?"#!":"#"}function i(e){var t=h.href;return"#!"===e&&t.indexOf("#")>-1&&t.indexOf("#!")<0?null:t.split(e)[1]||""}function o(e,t){return 0===t.indexOf(e)?t.substr(e.length).replace(/\/\//g,"/"):t}function a(e){return e.replace(/^(#)?/,"#")}function s(e){return e.replace(/^(#(!)?)?/,"#!")}var u=window.kendo,l="change",c="back",d="same",f=u.support,h=window.location,p=window.history,m=50,g=u.support.browser.msie,y=/^#*/,v=window.document,w=u.Class.extend({back:function(){g?setTimeout(function(){p.back()}):p.back()},forward:function(){g?setTimeout(function(){p.forward()}):p.forward()},length:function(){return p.length},replaceLocation:function(e){h.replace(e)}}),b=w.extend({init:function(e){this.root=e},navigate:function(e){p.pushState({},v.title,n(e,this.root))},replace:function(e){p.replaceState({},v.title,n(e,this.root))},normalize:function(e){return o(this.root,e)},current:function(){var e=h.pathname;return h.search&&(e+=h.search),o(this.root,e)},change:function(t){e(window).bind("popstate.kendo",t)},stop:function(){e(window).unbind("popstate.kendo")},normalizeCurrent:function(e){var t,o=e.root,a=h.pathname,s=i(r(e.hashBang));o===a+"/"&&(t=o),o===a&&s&&(t=n(s.replace(y,""),o)),t&&p.pushState({},v.title,t)}}),M=w.extend({init:function(e){this._id=u.guid(),this.prefix=r(e),this.fix=e?s:a},navigate:function(e){h.hash=this.fix(e)},replace:function(e){this.replaceLocation(this.fix(e))},normalize:function(e){return e.indexOf(this.prefix)<0?e:e.split(this.prefix)[1]},change:function(t){f.hashChange?e(window).on("hashchange."+this._id,t):this._interval=setInterval(t,m)},stop:function(){e(window).off("hashchange."+this._id),clearInterval(this._interval)},current:function(){return i(this.prefix)},normalizeCurrent:function(e){var t=h.pathname,n=e.root;return e.pushState&&n!==t?(this.replaceLocation(n+this.prefix+o(n,t)),!0):!1}}),S=u.Observable.extend({start:function(t){if(t=t||{},this.bind([l,c,d],t),!this._started){this._started=!0,t.root=t.root||"/";var n,r=this.createAdapter(t);r.normalizeCurrent(t)||(n=r.current(),e.extend(this,{adapter:r,root:t.root,historyLength:r.length(),current:n,locations:[n]}),r.change(e.proxy(this,"_checkUrl")))}},createAdapter:function(e){return f.pushState&&e.pushState?new b(e.root):new M(e.hashBang)},stop:function(){this._started&&(this.adapter.stop(),this.unbind(l),this._started=!1)},change:function(e){this.bind(l,e)},replace:function(e,t){this._navigate(e,t,function(t){t.replace(e),this.locations[this.locations-1]=this.current})},navigate:function(e,n){return"#:back"===e?(this.backCalled=!0,this.adapter.back(),t):(this._navigate(e,n,function(t){t.navigate(e),this.locations.push(this.current)}),t)},_navigate:function(e,n,r){var i=this.adapter;return e=i.normalize(e),this.current===e||this.current===decodeURIComponent(e)?(this.trigger(d),t):((n||!this.trigger(l,{url:e}))&&(this.current=e,r.call(this,i),this.historyLength=i.length()),t)},_checkUrl:function(){var e=this.adapter,n=e.current(),r=e.length(),i=this.historyLength===r,o=n===this.locations[this.locations.length-2]&&i,a=this.backCalled,s=this.current;return null===n||this.current===n||this.current===decodeURIComponent(n)?!0:(this.historyLength=r,this.backCalled=!1,this.current=n,o&&this.trigger("back",{url:s,to:n})?(e.forward(),this.current=s,t):this.trigger(l,{url:n,backButtonPressed:!a})?(o?e.forward():(e.back(),this.historyLength--),this.current=s,t):(o?this.locations.pop():this.locations.push(n),t))}});u.History=S,u.History.HistoryAdapter=w,u.History.HashAdapter=M,u.History.PushStateAdapter=b,u.absoluteURL=n,u.history=new S}(window.kendo.jQuery),function(){function e(e,t){return t?e:"([^/]+)"}function t(t){return RegExp("^"+t.replace(p,"\\$&").replace(d,"(?:$1)?").replace(f,e).replace(h,"(.*?)")+"$")}function n(e){return e.replace(/(\?.*)|(#.*)/g,"")}var r=window.kendo,i=r.history,
|