From e90fc24f167fbf817c13c3eb7b43b2fc1d330c24 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Tue, 8 Oct 2013 12:51:16 +0400 Subject: [PATCH 01/81] update documetation --- README.md | 160 +++++++++++++++++++++++++------------------------- readme.en.txt | 147 +++++++++++++++++++++++----------------------- readme.ru.txt | 89 ++++++++++++++-------------- 3 files changed, 200 insertions(+), 196 deletions(-) diff --git a/README.md b/README.md index d4eb55e..4319376 100644 --- a/README.md +++ b/README.md @@ -13,42 +13,43 @@ Example of using the library in the pure JS context: - My Link - Other Link + My Link + Other Link ``` @@ -80,9 +81,9 @@ Example of using the library along with JQuery: $(function() { // looking for all the links and hang on the event, all references in this document - $("a").click(function() { + $(document).on('click', 'a.ajax', function() { // keep the link in the browser history - history.pushState( null, null, this.href ); + history.pushState(null, null, this.href); // here can cause data loading, etc. @@ -93,7 +94,7 @@ Example of using the library along with JQuery: }); // hang on popstate event triggered by pressing back/forward in browser - $( window ).bind( "popstate", function( e ) { + $(window).on('popstate', function(e) { // we get a normal Location object @@ -112,14 +113,14 @@ Example of using the library along with JQuery: // just post - alert( "We returned to the page with a link: " + returnLocation.href ); + alert("We returned to the page with a link: " + returnLocation.href); }); }); - My Link - Other Link + My Link + Other Link ``` @@ -127,12 +128,12 @@ Example of using the library along with JQuery: Example of using popstate (pure JS): ```javascript -window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstate', function( event ) { +window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // receiving location from the window.history object var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }, false); ``` @@ -140,12 +141,12 @@ window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstat Example of using popstate with JQuery: ```javascript -$( window ).bind( 'popstate', function( event ) { +$(window).on('popstate', function(event) { // receiving location from the window.history object var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }); ``` @@ -161,7 +162,7 @@ You can also combine options: Or execute special method in JavaScript: - history.redirect( /* type = */ '/', /* basepath = */ '/pathtosite/' ); + history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); Demo Site: http://history.spb-piksel.ru/ @@ -191,32 +192,33 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov - My Link - Other Link + My Link + Other Link ``` @@ -258,9 +260,9 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov $(function() { // ищем все ссылки и вешаем события на все ссылки в нашем документе - $("a").click(function() { + $(document).on('click', 'a.ajax', function() { // заносим ссылку в историю - history.pushState( null, null, this.href ); + history.pushState(null, null, this.href); // тут можете вызвать подгрузку данных и т.п. @@ -271,7 +273,7 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov }); // вешаем событие на popstate которое срабатывает при нажатии back/forward в браузере - $( window ).bind( "popstate", function( e ) { + $(window).on('popstate', function(e) { // получаем нормальный объект Location @@ -290,14 +292,14 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov // просто сообщение - alert( "Мы вернулись на страницу со ссылкой: " + returnLocation.href ); + alert("Мы вернулись на страницу со ссылкой: " + returnLocation.href); }); }); - My Link - Other Link + My Link + Other Link ``` @@ -305,12 +307,12 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov Использование события popstate при обычном чистом JS: ```javascript -window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstate', function( event ) { +window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // получение location из объекта window.history var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }, false); ``` @@ -318,12 +320,12 @@ window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstat Использование события popstate в связке jQuery: ```javascript -$( window ).bind( 'popstate', function( event ) { +$(window).on('popstate', function(e) { // получение location из объекта window.history var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }); ``` @@ -339,7 +341,7 @@ $( window ).bind( 'popstate', function( event ) { Или выполнить специальный метод в JavaScript: - history.redirect( /* type = */ '/', /* basepath = */ '/pathtosite/' ); + history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); Демо-сайт: http://history.spb-piksel.ru/ diff --git a/readme.en.txt b/readme.en.txt index f6e5f40..4de96be 100644 --- a/readme.en.txt +++ b/readme.en.txt @@ -15,57 +15,58 @@ on pure JS: - My Link - Other Link + My Link + Other Link @@ -78,84 +79,84 @@ And now show an example in conjunction with jQuery: - My Link - Other Link + My Link + Other Link Using the event popstate the usual pure JS: - window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstate', function( event ) { + window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // receiving location from the window.history object var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }, false); Using the popstate event in conjunction jQuery: - $( window ).bind( 'popstate', function( event ) { + $(window).on('popstate', function(e) { // receiving location from the window.history object - var loc = history.location || document.location; + var loc = history.location || document.location; - alert( "return to: " + loc ); - }); + alert("return to: " + loc); + }); You can use the advanced configuration library: - history.min.js?basepath=/pathtosite/ - the base path to the site defaults to the root "/". - history.min.js?redirect=true - enable link translation. - history.min.js?type=/ - substitute the string after the anchor, by default, nothing substitutes. + history.min.js?basepath=/pathtosite/ - the base path to the site defaults to the root "/". + history.min.js?redirect=true - enable link translation. + history.min.js?type=/ - substitute the string after the anchor, by default, nothing substitutes. You can also combine options: - history.min.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter. + history.min.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter. Or execute special method in JavaScript: - history.redirect( /* type = */ '/', /* basepath = */ '/pathtosite/' ); + history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); Demo Site: http://history.spb-piksel.ru/ diff --git a/readme.ru.txt b/readme.ru.txt index b0351a8..aefc127 100644 --- a/readme.ru.txt +++ b/readme.ru.txt @@ -15,32 +15,33 @@ - My Link - Other Link + My Link + Other Link @@ -80,12 +81,12 @@ $(function() { // ищем все ссылки и вешаем события на все ссылки в нашем документе - $("a").click(function() { + $(document).on('click', 'a.ajax', function() { // заносим ссылку в историю - history.pushState( null, null, this.href ); + history.pushState(null, null, this.href); - // тут можете вызвать подгруздку данных и т.п. + // тут можете вызвать подгрузку данных и т.п. // не даем выполнить действие по умолчанию @@ -93,7 +94,7 @@ }); // вешаем событие на popstate которое срабатывает при нажатии back/forward в браузере - $( window ).bind( "popstate", function( e ) { + $(window).on('popstate', function(e) { // получаем нормальный объект Location @@ -108,54 +109,54 @@ var returnLocation = history.location || document.location; - // тут можете вызвать подгруздку данных и т.п. + // тут можете вызвать подгрузку данных и т.п. // просто сообщение - alert( "Мы вернулись на страницу со ссылкой: " + returnLocation.href ); + alert("Мы вернулись на страницу со ссылкой: " + returnLocation.href); }); }); - My Link - Other Link + My Link + Other Link Использование события popstate при обычном чистом JS: - window[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( 'popstate', function( event ) { + window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // получение location из объекта window.history var loc = history.location || document.location; - alert( "return to: " + loc ); + alert("return to: " + loc); }, false); Использование события popstate в связке jQuery: - $( window ).bind( 'popstate', function( event ) { + $(window).on('popstate', function(e) { // получение location из объекта window.history var loc = history.location || document.location; - alert( "return to: " + loc ); - }); + alert("return to: " + loc); + }); Вы можете использовать дополнительные параметры конфигурации библиотеки: - history.min.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". - history.min.js?redirect=true - включить преобразование ссылок. - history.min.js?type=/ - подставлять подстроку после якоря, по умолчанию ничего не подставляет. + history.min.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". + history.min.js?redirect=true - включить преобразование ссылок. + history.min.js?type=/ - подставлять подстроку после якоря, по умолчанию ничего не подставляет. Также вы можете комбинировать опции: - history.min.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение. + history.min.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение. Или выполнить специальный метод в JavaScript: - history.redirect( /* type = */ '/', /* basepath = */ '/pathtosite/' ); + history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); Демо-сайт: http://history.spb-piksel.ru/ From 4ec2a6808178702b75ba782a7a2085083d085ada Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Wed, 9 Oct 2013 17:49:46 +0400 Subject: [PATCH 02/81] update documetation --- README.md | 4 ++-- readme.en.txt | 2 +- readme.ru.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4319376..dc22cdf 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Advanced library configuration: history.js?basepath=/pathtosite/ - the base path to the site; defaults to the root "/". history.js?redirect=true - enable link translation. - history.js?type=/ - substitute the string after the anchor; by default, nothing is substituted. + history.js?type=/ - substitute the string after the anchor; by default "/". You can also combine options: @@ -333,7 +333,7 @@ $(window).on('popstate', function(e) { history.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". history.js?redirect=true - включить преобразование ссылок. - history.js?type=/ - подставлять подстроку после якоря, по умолчанию ничего не подставляет. + history.js?type=/ - подставлять подстроку после якоря, по умолчанию имеет символ "/". Также вы можете комбинировать опции: diff --git a/readme.en.txt b/readme.en.txt index 4de96be..41501d2 100644 --- a/readme.en.txt +++ b/readme.en.txt @@ -150,7 +150,7 @@ Using the popstate event in conjunction jQuery: You can use the advanced configuration library: history.min.js?basepath=/pathtosite/ - the base path to the site defaults to the root "/". history.min.js?redirect=true - enable link translation. - history.min.js?type=/ - substitute the string after the anchor, by default, nothing substitutes. + history.min.js?type=/ - substitute the string after the anchor, by default "/". You can also combine options: history.min.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter. diff --git a/readme.ru.txt b/readme.ru.txt index aefc127..765e8d7 100644 --- a/readme.ru.txt +++ b/readme.ru.txt @@ -150,7 +150,7 @@ Вы можете использовать дополнительные параметры конфигурации библиотеки: history.min.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". history.min.js?redirect=true - включить преобразование ссылок. - history.min.js?type=/ - подставлять подстроку после якоря, по умолчанию ничего не подставляет. + history.min.js?type=/ - подставлять подстроку после якоря, по умолчанию имеет символ "/". Также вы можете комбинировать опции: history.min.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение. From 27d79fb08833fe376fcdced3f9e7789a23e9415e Mon Sep 17 00:00:00 2001 From: John Babak Date: Thu, 10 Oct 2013 17:27:33 +0400 Subject: [PATCH 03/81] Fix handling anchors with nested elements If an anchor contains nested elements (e.g. a span), onAnchorClick did not handle the events that start on the nested elements. --- history.iegte8.js | 21 +++++++++++++++++---- history.js | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index d82fa25..73d825b 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 20.08.13 21:16 + * Update: 2013-10-10 17:16 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -764,13 +764,26 @@ } /** - * handler url with anchor for non-HTML5 browsers + * Finds the closest ancestor anchor element (including the target itself). * - * @param e + * @param {HTMLElement} target The element to start scanning from. + * @return {HTMLElement} An element which is the closest ancestor anchor. + */ + function anchorTarget(target) { + while (target) { + if (target.nodeName === 'A') return target; + target = target.parentNode; + } + } + + /** + * Handles anchor elements with a hash fragment for non-HTML5 browsers + * + * @param {Event} e */ function onAnchorClick(e) { var event = e || window.event; - var target = event.target || event.srcElement; + var target = anchorTarget(event.target || event.srcElement); var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; if (target && target.nodeName === "A" && !defaultPrevented) { var current = parseURL(); diff --git a/history.js b/history.js index 653d9df..c25a9dc 100644 --- a/history.js +++ b/history.js @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 20.08.13 21:16 + * Update: 2013-10-10 17:16 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -764,13 +764,26 @@ } /** - * handler url with anchor for non-HTML5 browsers + * Finds the closest ancestor anchor element (including the target itself). * - * @param e + * @param {HTMLElement} target The element to start scanning from. + * @return {HTMLElement} An element which is the closest ancestor anchor. + */ + function anchorTarget(target) { + while (target) { + if (target.nodeName === 'A') return target; + target = target.parentNode; + } + } + + /** + * Handles anchor elements with a hash fragment for non-HTML5 browsers + * + * @param {Event} e */ function onAnchorClick(e) { var event = e || window.event; - var target = event.target || event.srcElement; + var target = anchorTarget(event.target || event.srcElement); var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; if (target && target.nodeName === "A" && !defaultPrevented) { var current = parseURL(); From f911dd4b831682dd67306841a7768ce18406ef8c Mon Sep 17 00:00:00 2001 From: John Babak Date: Thu, 10 Oct 2013 17:47:41 +0400 Subject: [PATCH 04/81] Update min-files, bump version to 4.0.6 Minified from previous commit 27d79fb08833fe376fcdced3f9e7789a23e9415e --- bower.json | 2 +- history.iegte8.js | 4 ++-- history.iegte8.min.js | 31 ++++++++++++++++--------------- history.js | 4 ++-- history.min.js | 42 +++++++++++++++++++++--------------------- package.json | 2 +- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/bower.json b/bower.json index 9fda30d..0ff3ecf 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.0.5", + "version": "4.0.6", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 73d825b..1b20930 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ -/* - * History API JavaScript Library v4.0.5 +/*! + * History API JavaScript Library v4.0.6 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 81b80e1..621bef7 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ -/* - * History API JavaScript Library v4.0.5 +/*! + * History API JavaScript Library v4.0.6 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,17 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 20.08.13 21:16 + * Update: 2013-10-10 17:16 */ -(function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a&&!b)var b=k(),c=b.d,f=b.h,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?f+a:a:f+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:d.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol+"//"+d.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",f=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+f+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+f;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:f,a:e,c:g,j:h,f:h+e}}function W(){var a="";if(t)a+=t.getItem(x);else{var b=g.cookie.split(x+"=");1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(q[e.href]=a)}};x=function(b,c,e,h){d.apply(this,arguments)||(b===t?t[c]=e:b===g?(g[c]=e,"state"===c&&(t=a(t),f.history=g=a(g))):b[c]=e.get&&e.get());return b};setInterval(function(){var a=h().a;if(a!=B){var b=l.createEventObject(); -b.oldURL=B;b.newURL=B=a;b.type="hashchange";M(b)}},100);f.JSON=r}}if(f.history){var l=f.document,J=l.documentElement,C=j,G=f.Object,r=f.JSON,e=f.location,n=f.history,g=n,N=n.pushState,U=n.replaceState,p=!!N,I="state"in n,D=G.defineProperty,t=x({},"t")?{}:l.createElement("a"),w="",O=f.addEventListener?"addEventListener":(w="on")&&"attachEvent",V=f.removeEventListener?"removeEventListener":"detachEvent",W=f.dispatchEvent?"dispatchEvent":"fireEvent",v=f[O],X=f[V],ca=f[W],m={basepath:"/",redirect:0,type:"/"}, -F="__historyAPI__",P=l.createElement("a"),A=e.href,R="",E=o,q={},z={},fa={onhashchange:j,onpopstate:j},Y=function(a,b){var c=f.history!==n;c&&(f.history=n);a.apply(n,b);c&&(f.history=g)},Z={redirect:function(a,b){m.basepath=b=b==j?m.basepath:b;m.type=a=a==j?m.type:a;if(f.top==f.self){var c=h(j,o,i).c,d=e.pathname+e.search;p?(d=d.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&e.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&e.replace(b+"#"+d.replace(RegExp("^"+ -b,"i"),a)+e.hash))}},pushState:function(a,b,c){N&&Y(N,arguments);s(a,c)},replaceState:function(a,b,c){delete q[e.href];U&&Y(U,arguments);s(a,c,i)},location:{set:function(a){f.location=a},get:function(){return p?e:t}},state:{get:function(){return q[e.href]||j}}},L={assign:function(a){0===(""+a).indexOf("#")?s(j,a):e.assign(a)},reload:function(){e.reload()},replace:function(a){0===(""+a).indexOf("#")?s(j,a,i):e.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j, -host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){s(j,(""+a).replace(/^(#|)/,"#"),o,A)},get:function(){return h().b}}};(function(){var a=l.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){m[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});try{C=f.sessionStorage}catch(b){}ea();v(w+"hashchange",M,o);var c=[L,t,fa, -f,Z,g];I&&delete Z.state;for(var d=0;dlfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";\x3c/script>'),g.close();!f&&a&&(s[d.href]=a)}else a&&(s[d.href]=a)};z=function(b,c,d,h){f.apply(this,arguments)||(b===v?v[c]=d:b===g?(g[c]=d,"state"===c&&(v=a(v),e.history=g=a(g))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=m.createEventObject(); +b.oldURL=k;b.newURL=k=a;b.type="hashchange";N(b)}},100);e.JSON=t}}if(e.history){var m=e.document,K=m.documentElement,D=null,H=e.Object,t=e.JSON,d=e.location,q=e.history,g=q,P=q.pushState,X=q.replaceState,r=!!P,J="state"in q,E=H.defineProperty,v=z({},"t")?{}:m.createElement("a"),y="",O=e.addEventListener?"addEventListener":(y="on")&&"attachEvent",Y=e.removeEventListener?"removeEventListener":"detachEvent",Z=e.dispatchEvent?"dispatchEvent":"fireEvent",x=e[O],R=e[Y],fa=e[Z],n={basepath:"/",redirect:0, +type:"/"},G="__historyAPI__",Q=m.createElement("a"),C=d.href,T="",F=!1,s={},B={},ja={onhashchange:null,onpopstate:null},$=function(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=g)},W={redirect:function(a,b){n.basepath=b=null==b?n.basepath:b;n.type=a=null==a?n.type:a;if(e.top==e.self){var c=h(null,!1,!0).c,f=d.pathname+d.search;r?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&& +d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){P&&$(P,arguments);u(a,c)},replaceState:function(a,b,c){delete s[d.href];X&&$(X,arguments);u(a,c,!0)},location:{set:function(a){e.location=a},get:function(){return r?d:v}},state:{get:function(){return s[d.href]||null}}},M={assign:function(a){0===(""+a).indexOf("#")?u(null,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?u(null,a,!0):d.replace(a)},toString:function(){return this.href}, +href:{get:function(){return h().a}},protocol:null,host:null,hostname:null,port:null,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){u(null,(""+a).replace(/^(#|)/,"#"),!1,C)},get:function(){return h().b}}};ha()&&(g.emulate=!r,e[O]=da,e[Y]=ea,e[Z]=I)}})(window); diff --git a/package.json b/package.json index 3f12b38..5add8df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.0.5", + "version": "4.0.6", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From a1be5e658e6755e6c6c8a47888485f9a810cc678 Mon Sep 17 00:00:00 2001 From: amid2887 Date: Tue, 15 Oct 2013 12:26:29 +0700 Subject: [PATCH 05/81] Update README.md Grammatic mistype --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc22cdf..021a047 100644 --- a/README.md +++ b/README.md @@ -248,7 +248,7 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov ``` -А тепер показываю пример в связке с jQuery: +А теперь показываю пример в связке с jQuery: ```html From 66db77a5bc354cb4c4011f41a02ec199e39d2fea Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 30 Oct 2013 12:06:00 +0300 Subject: [PATCH 06/81] Update README.md Small punctuation errors --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 021a047..89ea6d4 100644 --- a/README.md +++ b/README.md @@ -176,13 +176,13 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov Библиотека эмулирует HTML5 History API в старых браузерах. -Библиотека которая не добавляет ненужные методы заставляя их изучать, а оперирует по спецификации w3c, по интерфейсу History. +Библиотека, которая не добавляет ненужные методы, заставляя их изучать, а оперирует по спецификации w3c, по интерфейсу History. Для примера могу привести короткий код как с ней работать. -По принципу мы работаем с HTML5 History API так как описано например тут http://htmlbook.ru/html5/history или по спецификации http://www.w3.org/TR/html5/history.html#the-history-interface +По принципу мы работаем с HTML5 History API так как описано, например, тут http://htmlbook.ru/html5/history или по спецификации http://www.w3.org/TR/html5/history.html#the-history-interface -То-есть коротенький пример: +То есть коротенький пример: на чистом JS: From 28464c2f83a9eb7d6add5affeb5131a186564421 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Wed, 30 Oct 2013 18:43:41 +0400 Subject: [PATCH 07/81] Added ability to update title in history when using pushState/replaceState --- history.iegte8.js | 14 ++++++++++++-- history.iegte8.min.js | 30 +++++++++++++++--------------- history.js | 14 ++++++++++++-- history.min.js | 40 ++++++++++++++++++++-------------------- 4 files changed, 59 insertions(+), 39 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index 1b20930..c689db9 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.6 + * History API JavaScript Library v4.0.7 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-10 17:16 + * Update: 2013-10-30 18:29 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -142,8 +142,13 @@ * @param {string} [url] */ pushState: function(state, title, url) { + var t = document.title; + if (title != null) { + document.title = title; + } historyPushState && fastFixChrome(historyPushState, arguments); changeState(state, url); + document.title = t; }, /** * The method updates the state object, @@ -156,9 +161,14 @@ * @param {string} [url] */ replaceState: function(state, title, url) { + var t = document.title; + if (title != null) { + document.title = title; + } delete stateStorage[windowLocation.href]; historyReplaceState && fastFixChrome(historyReplaceState, arguments); changeState(state, url, true); + document.title = t; }, /** * Object 'history.location' is similar to the diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 621bef7..71b9b3a 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.6 + * History API JavaScript Library v4.0.7 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,18 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-10 17:16 + * Update: 2013-10-30 18:29 */ -(function(f){function D(){}function k(a,b,c){if(a&&!b){b=k();c=b.d;var e=b.h;a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol+"//"+d.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href); -b=a[2]+(a[3]?":"+a[3]:"");c=a[4]||"/";var e=a[5]||"",f="#"===a[6]?"":a[6]||"",g=c+e+f,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+e;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:e,a:f,c:g,j:h,f:h+f}}function W(){var a="";if(t)a+=t.getItem(x);else{var b=g.cookie.split(x+"=");1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";\x3c/script>'),g.close();!f&&a&&(s[d.href]=a)}else a&&(s[d.href]=a)};z=function(b,c,d,h){f.apply(this,arguments)||(b===v?v[c]=d:b===g?(g[c]=d,"state"===c&&(v=a(v),e.history=g=a(g))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=m.createEventObject(); -b.oldURL=k;b.newURL=k=a;b.type="hashchange";N(b)}},100);e.JSON=t}}if(e.history){var m=e.document,K=m.documentElement,D=null,H=e.Object,t=e.JSON,d=e.location,q=e.history,g=q,P=q.pushState,X=q.replaceState,r=!!P,J="state"in q,E=H.defineProperty,v=z({},"t")?{}:m.createElement("a"),y="",O=e.addEventListener?"addEventListener":(y="on")&&"attachEvent",Y=e.removeEventListener?"removeEventListener":"detachEvent",Z=e.dispatchEvent?"dispatchEvent":"fireEvent",x=e[O],R=e[Y],fa=e[Z],n={basepath:"/",redirect:0, -type:"/"},G="__historyAPI__",Q=m.createElement("a"),C=d.href,T="",F=!1,s={},B={},ja={onhashchange:null,onpopstate:null},$=function(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=g)},W={redirect:function(a,b){n.basepath=b=null==b?n.basepath:b;n.type=a=null==a?n.type:a;if(e.top==e.self){var c=h(null,!1,!0).c,f=d.pathname+d.search;r?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&& -d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){P&&$(P,arguments);u(a,c)},replaceState:function(a,b,c){delete s[d.href];X&&$(X,arguments);u(a,c,!0)},location:{set:function(a){e.location=a},get:function(){return r?d:v}},state:{get:function(){return s[d.href]||null}}},M={assign:function(a){0===(""+a).indexOf("#")?u(null,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?u(null,a,!0):d.replace(a)},toString:function(){return this.href}, -href:{get:function(){return h().a}},protocol:null,host:null,hostname:null,port:null,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){u(null,(""+a).replace(/^(#|)/,"#"),!1,C)},get:function(){return h().b}}};ha()&&(g.emulate=!r,e[O]=da,e[Y]=ea,e[Z]=I)}})(window); +(function(f){var i=!0,k=null,n=!1;function J(){}function l(a,b,c){if(a&&!b)var b=l(),c=b.e,e=b.h,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:d.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol+"//"+d.host+j.basepath+a.replace(RegExp("^#[/]?(?:"+j.type+")?"),"");O.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(O.href),b= +a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",f="#"===a[6]?"":a[6]||"",g=c+e+f,t=c.replace(RegExp("^"+j.basepath,"i"),j.type)+e;return{a:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:f,c:g,j:t,d:t+f}}function Z(){var a="";if(B)a+=B.getItem(E);else{var b=g.cookie.split(E+"=");1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,g){e.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"===c&&(s=a(s),f.history=h=a(h))):b[c]=d.get&&d.get()); +return b};setInterval(function(){var a=l().a;if(a!=A){var b=g.createEventObject();b.oldURL=A;b.newURL=A=a;b.type="hashchange";L(b)}},100);f.JSON=q}}if(f.history){var g=f.document,I=g.documentElement,B=k,F=f.Object,q=f.JSON,d=f.location,m=f.history,h=m,M=m.pushState,T=m.replaceState,o=!!M,H="state"in m,C=F.defineProperty,s=w({},"t")?{}:g.createElement("a"),v="",N=f.addEventListener?"addEventListener":(v="on")&&"attachEvent",U=f.removeEventListener?"removeEventListener":"detachEvent",V=f.dispatchEvent? +"dispatchEvent":"fireEvent",u=f[N],W=f[U],ba=f[V],j={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",O=g.createElement("a"),z=d.href,Q="",D=n,p={},y={},ea={onhashchange:k,onpopstate:k},X=function(a,b){var c=f.history!==m;c&&(f.history=m);a.apply(m,b);c&&(f.history=h)},Y={redirect:function(a,b){j.basepath=b=b==k?j.basepath:b;j.type=a=a==k?j.type:a;if(f.top==f.self){var c=l(k,n,i).c,e=d.pathname+d.search;o?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&d.replace(c)):e!=b&& +(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&d.replace(b+"#"+e.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var e=g.title;b!=k&&(g.title=b);M&&X(M,arguments);r(a,c);g.title=e},replaceState:function(a,b,c){var e=g.title;b!=k&&(g.title=b);delete p[d.href];T&&X(T,arguments);r(a,c,i);g.title=e},location:{set:function(a){f.location=a},get:function(){return o?d:s}},state:{get:function(){return p[d.href]||k}}},K={assign:function(a){0===(""+a).indexOf("#")?r(k,a):d.assign(a)}, +reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(k,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return l().e}},search:{get:function(){return l().f}},hash:{set:function(a){r(k,(""+a).replace(/^(#|)/,"#"),n,z)},get:function(){return l().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g, +function(a,b,c){j[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});try{B=f.sessionStorage}catch(b){}da();u(v+"hashchange",L,n);var c=[K,s,ea,f,Y,h];H&&delete Y.state;for(var e=0;e Date: Wed, 30 Oct 2013 18:45:35 +0400 Subject: [PATCH 08/81] bump version to 4.0.7 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 0ff3ecf..5a1efcc 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.0.6", + "version": "4.0.7", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/package.json b/package.json index 5add8df..fc78d5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.0.6", + "version": "4.0.7", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 9406cf2b9bc4fe1727b7b814c151a9bbe2383995 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Wed, 30 Oct 2013 19:00:42 +0400 Subject: [PATCH 09/81] fix --- history.iegte8.js | 12 ++++++++---- history.iegte8.min.js | 26 +++++++++++++------------- history.js | 12 ++++++++---- history.min.js | 32 ++++++++++++++++---------------- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index c689db9..c91f596 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -72,6 +72,8 @@ var stateStorage = {}; // in this object will be stored custom handlers var eventsList = {}; + // stored last title + var lastTitle = document.title; /** * Properties that will be replaced in the global @@ -143,12 +145,13 @@ */ pushState: function(state, title, url) { var t = document.title; - if (title != null) { - document.title = title; + if (lastTitle != null) { + document.title = lastTitle; } historyPushState && fastFixChrome(historyPushState, arguments); changeState(state, url); document.title = t; + lastTitle = title; }, /** * The method updates the state object, @@ -162,13 +165,14 @@ */ replaceState: function(state, title, url) { var t = document.title; - if (title != null) { - document.title = title; + if (lastTitle != null) { + document.title = lastTitle; } delete stateStorage[windowLocation.href]; historyReplaceState && fastFixChrome(historyReplaceState, arguments); changeState(state, url, true); document.title = t; + lastTitle = title; }, /** * Object 'history.location' is similar to the diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 71b9b3a..35bdbba 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -13,16 +13,16 @@ * * Update: 2013-10-30 18:29 */ -(function(f){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a&&!b)var b=k(),c=b.d,d=b.h,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:e.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=e.protocol+"//"+e.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",f="#"===a[6]?"":a[6]||"",g=c+d+f,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:f,c:g,j:h,f:h+f}}function W(){var a="";if(t)a+=t.getItem(x);else{var b=g.cookie.split(x+"=");1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,g){e.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"===c&&(s=a(s),f.history=h=a(h))):b[c]=d.get&&d.get()); -return b};setInterval(function(){var a=l().a;if(a!=A){var b=g.createEventObject();b.oldURL=A;b.newURL=A=a;b.type="hashchange";L(b)}},100);f.JSON=q}}if(f.history){var g=f.document,I=g.documentElement,B=k,F=f.Object,q=f.JSON,d=f.location,m=f.history,h=m,M=m.pushState,T=m.replaceState,o=!!M,H="state"in m,C=F.defineProperty,s=w({},"t")?{}:g.createElement("a"),v="",N=f.addEventListener?"addEventListener":(v="on")&&"attachEvent",U=f.removeEventListener?"removeEventListener":"detachEvent",V=f.dispatchEvent? -"dispatchEvent":"fireEvent",u=f[N],W=f[U],ba=f[V],j={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",O=g.createElement("a"),z=d.href,Q="",D=n,p={},y={},ea={onhashchange:k,onpopstate:k},X=function(a,b){var c=f.history!==m;c&&(f.history=m);a.apply(m,b);c&&(f.history=h)},Y={redirect:function(a,b){j.basepath=b=b==k?j.basepath:b;j.type=a=a==k?j.type:a;if(f.top==f.self){var c=l(k,n,i).c,e=d.pathname+d.search;o?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&d.replace(c)):e!=b&& -(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&d.replace(b+"#"+e.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var e=g.title;b!=k&&(g.title=b);M&&X(M,arguments);r(a,c);g.title=e},replaceState:function(a,b,c){var e=g.title;b!=k&&(g.title=b);delete p[d.href];T&&X(T,arguments);r(a,c,i);g.title=e},location:{set:function(a){f.location=a},get:function(){return o?d:s}},state:{get:function(){return p[d.href]||k}}},K={assign:function(a){0===(""+a).indexOf("#")?r(k,a):d.assign(a)}, -reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(k,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return l().e}},search:{get:function(){return l().f}},hash:{set:function(a){r(k,(""+a).replace(/^(#|)/,"#"),n,z)},get:function(){return l().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g, -function(a,b,c){j[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});try{B=f.sessionStorage}catch(b){}da();u(v+"hashchange",L,n);var c=[K,s,ea,f,Y,h];H&&delete Y.state;for(var e=0;elfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,g){e.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"===c&&(s=a(s),f.history=h=a(h))):b[c]=d.get&&d.get()); +return b};setInterval(function(){var a=l().a;if(a!=B){var b=g.createEventObject();b.oldURL=B;b.newURL=B=a;b.type="hashchange";M(b)}},100);f.JSON=q}}if(f.history){var g=f.document,J=g.documentElement,C=k,G=f.Object,q=f.JSON,d=f.location,m=f.history,h=m,N=m.pushState,U=m.replaceState,o=!!N,I="state"in m,D=G.defineProperty,s=w({},"t")?{}:g.createElement("a"),v="",O=f.addEventListener?"addEventListener":(v="on")&&"attachEvent",V=f.removeEventListener?"removeEventListener":"detachEvent",W=f.dispatchEvent? +"dispatchEvent":"fireEvent",u=f[O],X=f[V],ca=f[W],j={basepath:"/",redirect:0,type:"/"},F="__historyAPI__",P=g.createElement("a"),z=d.href,R="",E=n,p={},y={},A=g.title,fa={onhashchange:k,onpopstate:k},Y=function(a,b){var c=f.history!==m;c&&(f.history=m);a.apply(m,b);c&&(f.history=h)},Z={redirect:function(a,b){j.basepath=b=b==k?j.basepath:b;j.type=a=a==k?j.type:a;if(f.top==f.self){var c=l(k,n,i).c,e=d.pathname+d.search;o?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&d.replace(c)): +e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&d.replace(b+"#"+e.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var e=g.title;A!=k&&(g.title=A);N&&Y(N,arguments);r(a,c);g.title=e;A=b},replaceState:function(a,b,c){var e=g.title;A!=k&&(g.title=A);delete p[d.href];U&&Y(U,arguments);r(a,c,i);g.title=e;A=b},location:{set:function(a){f.location=a},get:function(){return o?d:s}},state:{get:function(){return p[d.href]||k}}},L={assign:function(a){0===(""+a).indexOf("#")? +r(k,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(k,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return l().e}},search:{get:function(){return l().f}},hash:{set:function(a){r(k,(""+a).replace(/^(#|)/,"#"),n,z)},get:function(){return l().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop(): +"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){j[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});try{C=f.sessionStorage}catch(b){}ea();u(v+"hashchange",M,n);var c=[L,s,fa,f,Z,h];I&&delete Z.state;for(var e=0;e Date: Thu, 31 Oct 2013 16:18:01 +0400 Subject: [PATCH 10/81] Fixed bug when using variable type of number as a URL. Bump version to 4.0.8 --- bower.json | 2 +- history.iegte8.js | 8 +++++--- history.iegte8.min.js | 24 ++++++++++++------------ history.js | 8 +++++--- history.min.js | 6 +++--- package.json | 2 +- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/bower.json b/bower.json index 5a1efcc..2731f2d 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.0.7", + "version": "4.0.8", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index c91f596..47cc4e2 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.7 + * History API JavaScript Library v4.0.8 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-30 18:29 + * Update: 2013-10-31 16:06 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -346,8 +346,10 @@ */ function parseURL(href, isWindowLocation, isNotAPI) { var re = /(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; - if (href && !isWindowLocation) { + if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), _pathname = current._pathname, _protocol = current._protocol; + // convert to type of string + href = '' + href; // convert relative link to the absolute href = /^(?:[\w0-9]+\:)?\/\//.test(href) ? href.indexOf("/") === 0 ? _protocol + href : href : _protocol + "//" + current._host + ( diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 35bdbba..4764d27 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.7 + * History API JavaScript Library v4.0.8 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,18 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-30 18:29 + * Update: 2013-10-31 16:06 */ -(function(f){var i=!0,j=null,n=!1;function E(){}function k(a,b,c){if(a&&!b)var b=k(),c=b.d,d=b.h,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:e.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=e.protocol+"//"+e.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");J.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(J.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",f="#"===a[6]?"":a[6]||"",g=c+d+f,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:f,c:g,j:h,f:h+f}}function X(){var a="";if(u)a+=u.getItem(y);else{var b=g.cookie.split(y+"=");1 Date: Wed, 20 Nov 2013 13:16:32 +0400 Subject: [PATCH 11/81] #34 changes code associated with sessionStorage --- bower.json | 2 +- history.iegte8.js | 64 +++++++++++++++++++++---------------------- history.iegte8.min.js | 30 ++++++++++---------- history.js | 64 +++++++++++++++++++++---------------------- history.min.js | 40 +++++++++++++-------------- package.json | 2 +- 6 files changed, 101 insertions(+), 101 deletions(-) diff --git a/bower.json b/bower.json index 2731f2d..89ab7fd 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.0.8", + "version": "4.0.9", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 47cc4e2..52be61a 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.8 + * History API JavaScript Library v4.0.9 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-31 16:06 + * Update: 2013-11-20 13:03 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -20,8 +20,6 @@ var document = window.document; // HTML element var documentElement = document.documentElement; - // symlink to sessionStorage - var sessionStorage = null; // symlink to constructor of Object var Object = window['Object']; // symlink to JSON Object @@ -404,33 +402,44 @@ * Initializing storage for the custom state's object */ function storageInitialize() { - var storage = ''; - if (sessionStorage) { - // get cache from the storage in browser - storage += sessionStorage.getItem(sessionStorageKey); - } else { - var cookie = document.cookie.split(sessionStorageKey + "="); - if (cookie.length > 1) { - storage += (cookie.pop().split(";").shift() || 'null'); + var sessionStorage; + /** + * sessionStorage throws error when cookies are disabled + * Chrome content settings when running the site in a Facebook IFrame. + * see: https://github.com/devote/HTML5-History-API/issues/34 + * and: http://stackoverflow.com/a/12976988/669360 + */ + try { + sessionStorage = window['sessionStorage']; + sessionStorage.setItem(sessionStorageKey + 't', '1'); + sessionStorage.removeItem(sessionStorageKey + 't'); + } catch(_e_) { + sessionStorage = { + getItem: function(key) { + var cookie = document.cookie.split(key + "="); + return cookie.length > 1 && cookie.pop().split(";").shift() || 'null'; + }, + setItem: function(key, value) { + var state = {}; + // insert one current element to cookie + if (state[windowLocation.href] = historyObject.state) { + document.cookie = key + '=' + JSON.stringify(state); + } + } } } + try { - stateStorage = JSON.parse(storage) || {}; + // get cache from the storage in browser + stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {}; } catch(_e_) { stateStorage = {}; } + // hang up the event handler to event unload page addEvent(eventNamePrefix + 'unload', function() { - if (sessionStorage) { - // save current state's object - sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); - } else { - // save the current 'state' in the cookie - var state = {}; - if (state[windowLocation.href] = historyObject.state) { - document.cookie = sessionStorageKey + '=' + JSON.stringify(state); - } - } + // save current state's object + sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); }, false); } @@ -849,15 +858,6 @@ settings[key] = (value || (key === 'basepath' ? '/' : '')).replace(/^(0|false)$/, ''); }); - /** - * sessionStorage throws error when cookies are disabled - * Chrome content settings when running the site in a Facebook IFrame. - * see: https://github.com/devote/HTML5-History-API/issues/34 - */ - try { - sessionStorage = window['sessionStorage']; - } catch(_e_) {} - /** * hang up the event handler to listen to the events hashchange */ diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 4764d27..3d46217 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.8 + * History API JavaScript Library v4.0.9 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,18 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-10-31 16:06 + * Update: 2013-11-20 13:03 */ -(function(f){var h=!0,j=null,n=!1;function E(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:e.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=e.protocol+"//"+e.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");J.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(J.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",f="#"===a[6]?"":a[6]||"",g=c+d+f,i=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:f,c:g,j:i,f:i+f}}function X(){var a="";if(u)a+=u.getItem(y);else{var b=g.cookie.split(y+"=");1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,g){e.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"===c&&(s=a(s),f.history=h=a(h))):b[c]=d.get&&d.get()); -return b};setInterval(function(){var a=l().a;if(a!=B){var b=g.createEventObject();b.oldURL=B;b.newURL=B=a;b.type="hashchange";M(b)}},100);f.JSON=q}}if(f.history){var g=f.document,J=g.documentElement,C=k,G=f.Object,q=f.JSON,d=f.location,m=f.history,h=m,N=m.pushState,U=m.replaceState,o=!!N,I="state"in m,D=G.defineProperty,s=w({},"t")?{}:g.createElement("a"),v="",O=f.addEventListener?"addEventListener":(v="on")&&"attachEvent",V=f.removeEventListener?"removeEventListener":"detachEvent",W=f.dispatchEvent? -"dispatchEvent":"fireEvent",u=f[O],X=f[V],ca=f[W],j={basepath:"/",redirect:0,type:"/"},F="__historyAPI__",P=g.createElement("a"),z=d.href,R="",E=n,p={},y={},A=g.title,fa={onhashchange:k,onpopstate:k},Y=function(a,b){var c=f.history!==m;c&&(f.history=m);a.apply(m,b);c&&(f.history=h)},Z={redirect:function(a,b){j.basepath=b=b==k?j.basepath:b;j.type=a=a==k?j.type:a;if(f.top==f.self){var c=l(k,n,i).c,e=d.pathname+d.search;o?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&d.replace(c)): -e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&d.replace(b+"#"+e.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var e=g.title;A!=k&&(g.title=A);N&&Y(N,arguments);r(a,c);g.title=e;A=b},replaceState:function(a,b,c){var e=g.title;A!=k&&(g.title=A);delete p[d.href];U&&Y(U,arguments);r(a,c,i);g.title=e;A=b},location:{set:function(a){f.location=a},get:function(){return o?d:s}},state:{get:function(){return p[d.href]||k}}},L={assign:function(a){0===(""+a).indexOf("#")? -r(k,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(k,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return l().e}},search:{get:function(){return l().f}},hash:{set:function(a){r(k,(""+a).replace(/^(#|)/,"#"),n,z)},get:function(){return l().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop(): -"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){j[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});try{C=f.sessionStorage}catch(b){}ea();u(v+"hashchange",M,n);var c=[L,s,fa,f,Z,h];I&&delete Z.state;for(var e=0;elfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};x=function(b,c,f,g){d.apply(this,arguments)||(b===t?t[c]=f:b=== +l?(l[c]=f,"state"===c&&(t=a(t),e.history=l=a(l))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=g.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";L(b)}},100);e.JSON=q}}if(e.history){var g=e.document,I=g.documentElement,F=e.Object,q=e.JSON,f=e.location,n=e.history,l=n,M=n.pushState,T=n.replaceState,p=!!M,H="state"in n,C=F.defineProperty,t=x({},"t")?{}:g.createElement("a"),w="",N=e.addEventListener?"addEventListener":(w="on")&&"attachEvent",U=e.removeEventListener? +"removeEventListener":"detachEvent",V=e.dispatchEvent?"dispatchEvent":"fireEvent",v=e[N],W=e[U],ba=e[V],k={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",O=g.createElement("a"),A=f.href,Q="",D=o,r={},z={},B=g.title,ea={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},Y={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,o,i).c,d=f.pathname+f.search;p?(d=d.replace(/([^\/])$/, +"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&f.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&f.replace(b+"#"+d.replace(RegExp("^"+b,"i"),a)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=j&&(g.title=B);M&&X(M,arguments);s(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=j&&(g.title=B);delete r[f.href];T&&X(T,arguments);s(a,c,i);g.title=d;B=b},location:{set:function(a){e.location=a},get:function(){return p?f:t}},state:{get:function(){return r[f.href]|| +j}}},K={assign:function(a){0===(""+a).indexOf("#")?s(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?s(j,a,i):f.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){s(j,(""+a).replace(/^(#|)/,"#"),o,A)},get:function(){return h().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length- +1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){k[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});da();v(w+"hashchange",L,o);var b=[K,t,ea,e,Y,l];H&&delete Y.state;for(var c=0;c Date: Wed, 20 Nov 2013 17:06:53 +0400 Subject: [PATCH 12/81] update package.json --- package.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec84adc..726d488 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,17 @@ "url": "git://github.com/devote/HTML5-History-API.git" }, "keywords": [ + "javascript", + "html5 history api", + "hashchange", + "popstate", + "pushstate", + "replacestate", + "hashes", + "hashbang", "history", "html5", - "pushState", - "replaceState" + "devote" ], "author": "Dmitrii Pakhtinov", "license": "GPL/MIT", From 764464255be35c8649e0cbf72ca25d65bdd47ec3 Mon Sep 17 00:00:00 2001 From: szegheo Date: Wed, 29 Jan 2014 10:48:45 +0100 Subject: [PATCH 13/81] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89ea6d4..ec30883 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ENGLISH This Javascript library provides an emulation of HTML5 History API for older browsers. -The library operates according to W3C specification, adding no new or incompatible methods. The library can be used exactly as described, for example, in Dive Into HTML5 book (http://diveintohtml5.info/history.html) or in the History API Specification (http://www.w3.org/TR/html5/history.html#the-history-interface). +The library operates according to W3C specification, adding no new or incompatible methods. The library can be used exactly as described, for example, in Dive Into HTML5 book (http://diveintohtml5.info/history.html) or in the History API Specification (http://www.w3.org/TR/html5/browsers.html#the-history-interface). Example of using the library in the pure JS context: From eda868eb1750e81ce3ed028e6c36dea975e1c099 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Mon, 24 Mar 2014 12:05:34 +0400 Subject: [PATCH 14/81] added thank you for my job --- README.md | 21 +++++++++++++++++++++ readme.en.txt | 11 +++++++++++ readme.ru.txt | 11 +++++++++++ 3 files changed, 43 insertions(+) diff --git a/README.md b/README.md index ec30883..8311c04 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,16 @@ Demo Site: http://history.spb-piksel.ru/ Follow me on Twitter: https://twitter.com/DimaPakhtinov +----------------------------- +Want to thank you for my job? + +WebMoney: +WMR: R258217300226 +WMZ: Z314183434448 + +Yandex.Money: 41001414127851 + +Alfa-Bank Card # 5486732005875430 - 11/15 ------------------------------------------------------------------------------------------------------------- @@ -346,3 +356,14 @@ $(window).on('popstate', function(e) { Демо-сайт: http://history.spb-piksel.ru/ Я в Twitter: https://twitter.com/DimaPakhtinov + +----------------------------------- +Хочешь поблагодарить за мою работу? + +WebMoney: +WMR: R258217300226 +WMZ: Z314183434448 + +Yandex.Money: 41001414127851 + +Alfa-Bank Card # 5486732005875430 - 11/15 diff --git a/readme.en.txt b/readme.en.txt index 41501d2..f5c72f1 100644 --- a/readme.en.txt +++ b/readme.en.txt @@ -163,3 +163,14 @@ Demo Site: http://history.spb-piksel.ru/ GitHub Project: https://github.com/devote/HTML5-History-API I'm on Twitter: https://twitter.com/DimaPakhtinov + +----------------------------- +Want to thank you for my job? + +WebMoney: +WMR: R258217300226 +WMZ: Z314183434448 + +Yandex.Money: 41001414127851 + +Alfa-Bank Card # 5486732005875430 - 11/15 diff --git a/readme.ru.txt b/readme.ru.txt index 765e8d7..46c95e8 100644 --- a/readme.ru.txt +++ b/readme.ru.txt @@ -163,3 +163,14 @@ GitHub Проект: https://github.com/devote/HTML5-History-API Я в Twitter: https://twitter.com/DimaPakhtinov + +----------------------------------- +Хочешь поблагодарить за мою работу? + +WebMoney: +WMR: R258217300226 +WMZ: Z314183434448 + +Yandex.Money: 41001414127851 + +Alfa-Bank Card # 5486732005875430 - 11/15 From 75d248bb884f33ce97d092afd6fe3ec71afd1a34 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Mon, 24 Mar 2014 13:18:50 +0400 Subject: [PATCH 15/81] fixed issue #46 and #50 --- bower.json | 2 +- history.iegte8.js | 17 ++++++++++------- history.iegte8.min.js | 26 +++++++++++++------------- history.js | 17 ++++++++++------- history.min.js | 40 ++++++++++++++++++++-------------------- package.json | 2 +- 6 files changed, 55 insertions(+), 49 deletions(-) diff --git a/bower.json b/bower.json index 89ab7fd..ce46b9d 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.0.9", + "version": "4.1.0", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 52be61a..c0a115f 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.9 + * History API JavaScript Library v4.1.0 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-11-20 13:03 + * Update: 2014-03-24 13:14 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -362,7 +362,8 @@ // get hash fragment href = href.replace(/^[^#]*/, '') || "#"; // form the absolute link from the hash - href = windowLocation.protocol + '//' + windowLocation.host + settings['basepath'] + // https://github.com/devote/HTML5-History-API/issues/50 + href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath'] + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), ""); } } @@ -728,8 +729,12 @@ * @return void */ function onHashChange(event) { - // if not empty lastURL, otherwise skipped the current handler event - if (lastURL) { + // https://github.com/devote/HTML5-History-API/issues/46 + var fireNow = lastURL; + // new value to lastURL + lastURL = windowLocation.href; + // if not empty fireNow, otherwise skipped the current handler event + if (fireNow) { // if checkUrlForPopState equal current url, this means that the event was raised popstate browser if (checkUrlForPopState !== windowLocation.href) { // otherwise, @@ -751,8 +756,6 @@ dispatchEvent(event); } } - // new value to lastURL - lastURL = windowLocation.href; } /** diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 3d46217..108df00 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.0.9 + * History API JavaScript Library v4.1.0 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,18 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2013-11-20 13:03 + * Update: 2014-03-24 13:14 */ -(function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= +(function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};x=function(b,c,f,g){d.apply(this,arguments)||(b===t?t[c]=f:b=== -l?(l[c]=f,"state"===c&&(t=a(t),e.history=l=a(l))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=g.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";L(b)}},100);e.JSON=q}}if(e.history){var g=e.document,I=g.documentElement,F=e.Object,q=e.JSON,f=e.location,n=e.history,l=n,M=n.pushState,T=n.replaceState,p=!!M,H="state"in n,C=F.defineProperty,t=x({},"t")?{}:g.createElement("a"),w="",N=e.addEventListener?"addEventListener":(w="on")&&"attachEvent",U=e.removeEventListener? -"removeEventListener":"detachEvent",V=e.dispatchEvent?"dispatchEvent":"fireEvent",v=e[N],W=e[U],ba=e[V],k={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",O=g.createElement("a"),A=f.href,Q="",D=o,r={},z={},B=g.title,ea={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},Y={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,o,i).c,d=f.pathname+f.search;p?(d=d.replace(/([^\/])$/, -"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&f.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&f.replace(b+"#"+d.replace(RegExp("^"+b,"i"),a)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=j&&(g.title=B);M&&X(M,arguments);s(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=j&&(g.title=B);delete r[f.href];T&&X(T,arguments);s(a,c,i);g.title=d;B=b},location:{set:function(a){e.location=a},get:function(){return p?f:t}},state:{get:function(){return r[f.href]|| -j}}},K={assign:function(a){0===(""+a).indexOf("#")?s(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?s(j,a,i):f.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){s(j,(""+a).replace(/^(#|)/,"#"),o,A)},get:function(){return h().b}}};(function(){var a=g.getElementsByTagName("script"),a=(a[a.length- -1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){k[b]=(c||("basepath"===b?"/":"")).replace(/^(0|false)$/,"")});da();v(w+"hashchange",L,o);var b=[K,t,ea,e,Y,l];H&&delete Y.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(s[d.href]=a)}};y=function(b,c,d,g){f.apply(this,arguments)||(b===u?u[c]=d:b===l?(l[c]=d,"state"===c&&(u=a(u),e.history=l=a(l))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a; +if(a!=k){var b=g.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";M(b)}},100);e.JSON=r}}if(e.history){var g=e.document,J=g.documentElement,G=e.Object,r=e.JSON,d=e.location,o=e.history,l=o,O=o.pushState,W=o.replaceState,q=!!O,I="state"in o,D=G.defineProperty,u=y({},"t")?{}:g.createElement("a"),x="",N=e.addEventListener?"addEventListener":(x="on")&&"attachEvent",X=e.removeEventListener?"removeEventListener":"detachEvent",Y=e.dispatchEvent?"dispatchEvent":"fireEvent",w=e[N],Q=e[X],ea= +e[Y],k={basepath:"/",redirect:0,type:"/"},F="__historyAPI__",P=g.createElement("a"),B=d.href,S="",E=p,s={},A={},C=g.title,ia={onhashchange:j,onpopstate:j},Z=function(a,b){var c=e.history!==o;c&&(e.history=o);a.apply(o,b);c&&(e.history=l)},V={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,p,i).c,f=d.pathname+d.search;q?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+ +b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=g.title;C!=j&&(g.title=C);O&&Z(O,arguments);t(a,c);g.title=d;C=b},replaceState:function(a,b,c){var e=g.title;C!=j&&(g.title=C);delete s[d.href];W&&Z(W,arguments);t(a,c,i);g.title=e;C=b},location:{set:function(a){e.location=a},get:function(){return q?d:u}},state:{get:function(){return s[d.href]||j}}},L={assign:function(a){0===(""+a).indexOf("#")?t(j,a):d.assign(a)},reload:function(){d.reload()}, +replace:function(a){0===(""+a).indexOf("#")?t(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){t(j,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return h().b}}};ga()&&(l.emulate=!q,e[N]=ca,e[X]=da,e[Y]=H)}})(window); diff --git a/package.json b/package.json index 726d488..a72f9fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.0.9", + "version": "4.1.0", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 1e6b0de7ab83c3e39ac8a9ad0fd503e0d0ba1da6 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Fri, 28 Mar 2014 13:31:25 +0400 Subject: [PATCH 16/81] add pay method --- README.md | 4 ++++ readme.en.txt | 2 ++ readme.ru.txt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 8311c04..9c024bb 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov ----------------------------- Want to thank you for my job? +PayPal: spb.piksel@gmail.com + WebMoney: WMR: R258217300226 WMZ: Z314183434448 @@ -360,6 +362,8 @@ $(window).on('popstate', function(e) { ----------------------------------- Хочешь поблагодарить за мою работу? +PayPal: spb.piksel@gmail.com + WebMoney: WMR: R258217300226 WMZ: Z314183434448 diff --git a/readme.en.txt b/readme.en.txt index f5c72f1..f645dbe 100644 --- a/readme.en.txt +++ b/readme.en.txt @@ -167,6 +167,8 @@ I'm on Twitter: https://twitter.com/DimaPakhtinov ----------------------------- Want to thank you for my job? +PayPal: spb.piksel@gmail.com + WebMoney: WMR: R258217300226 WMZ: Z314183434448 diff --git a/readme.ru.txt b/readme.ru.txt index 46c95e8..4b80a84 100644 --- a/readme.ru.txt +++ b/readme.ru.txt @@ -167,6 +167,8 @@ GitHub Проект: https://github.com/devote/HTML5-History-API ----------------------------------- Хочешь поблагодарить за мою работу? +PayPal: spb.piksel@gmail.com + WebMoney: WMR: R258217300226 WMZ: Z314183434448 From f01541054a823ef8b6e81ac4387001f7da703ac5 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Tue, 29 Apr 2014 15:43:19 +0400 Subject: [PATCH 17/81] Fixed IE browser compatibles mode --- LICENSE-MIT | 2 +- bower.json | 2 +- history.iegte8.js | 7 ++++--- history.iegte8.min.js | 16 ++++++++-------- history.js | 9 ++++++--- history.min.js | 41 +++++++++++++++++++++-------------------- package.json | 2 +- 7 files changed, 42 insertions(+), 37 deletions(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index 737e952..e59748e 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License (MIT) -Copyright (c) 2010-2013 Dmitrii Pakhtinov +Copyright (c) 2010-2014 Dmitrii Pakhtinov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bower.json b/bower.json index ce46b9d..570ca8f 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.0", + "version": "4.1.1", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index c0a115f..be0a23d 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,9 +1,9 @@ /*! - * History API JavaScript Library v4.1.0 + * History API JavaScript Library v4.1.1 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2013, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-03-24 13:14 + * Update: 2014-04-29 15:22 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -511,6 +511,7 @@ * the same names. */ window['execScript']('Public ' + prop, 'VBScript'); + window['execScript']('var ' + prop + ';', 'JavaScript'); } else { try { /** diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 108df00..d916e79 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,9 +1,9 @@ /*! - * History API JavaScript Library v4.1.0 + * History API JavaScript Library v4.1.1 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2013, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * @@ -11,15 +11,15 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-03-24 13:14 + * Update: 2014-04-29 15:22 */ (function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1 7) { + if (!msie || (document.documentMode && document.documentMode > 7)) { // If it is not IE or a version greater than seven return; } @@ -1175,6 +1176,8 @@ if (prop === 'state') { locationObject = createVBObjects(locationObject); window.history = historyObject = createVBObjects(historyObject); + // hack for IE7 + window['execScript']('var history = window.history;', 'JavaScript'); } } else { object[prop] = descriptor.get && descriptor.get(); diff --git a/history.min.js b/history.min.js index e232ad0..7c240c1 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.0 + * History API JavaScript Library v4.1.1 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,23 +11,24 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-03-24 13:14 + * Update: 2014-04-29 15:22 */ -(function(e){var i=!0,j=null,p=!1;function K(){}function h(a,b,c){if(a!=j&&""!==a&&!b)var b=h(),c=b.e,f=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?f+a:a:f+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:d.href,!q||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+k.basepath+a.replace(RegExp("^#[/]?(?:"+k.type+")?"),"");P.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(P.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",f=a[5]||"",e="#"===a[6]?"":a[6]||"",m=c+f+e,v=c.replace(RegExp("^"+k.basepath,"i"),k.type)+f;return{a:a[1]+"//"+b+m,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:f,b:e,c:m,j:v,d:v+e}}function $(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(s[d.href]=a)}};y=function(b,c,d,g){f.apply(this,arguments)||(b===u?u[c]=d:b===l?(l[c]=d,"state"===c&&(u=a(u),e.history=l=a(l))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a; -if(a!=k){var b=g.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";M(b)}},100);e.JSON=r}}if(e.history){var g=e.document,J=g.documentElement,G=e.Object,r=e.JSON,d=e.location,o=e.history,l=o,O=o.pushState,W=o.replaceState,q=!!O,I="state"in o,D=G.defineProperty,u=y({},"t")?{}:g.createElement("a"),x="",N=e.addEventListener?"addEventListener":(x="on")&&"attachEvent",X=e.removeEventListener?"removeEventListener":"detachEvent",Y=e.dispatchEvent?"dispatchEvent":"fireEvent",w=e[N],Q=e[X],ea= -e[Y],k={basepath:"/",redirect:0,type:"/"},F="__historyAPI__",P=g.createElement("a"),B=d.href,S="",E=p,s={},A={},C=g.title,ia={onhashchange:j,onpopstate:j},Z=function(a,b){var c=e.history!==o;c&&(e.history=o);a.apply(o,b);c&&(e.history=l)},V={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,p,i).c,f=d.pathname+d.search;q?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+ -b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=g.title;C!=j&&(g.title=C);O&&Z(O,arguments);t(a,c);g.title=d;C=b},replaceState:function(a,b,c){var e=g.title;C!=j&&(g.title=C);delete s[d.href];W&&Z(W,arguments);t(a,c,i);g.title=e;C=b},location:{set:function(a){e.location=a},get:function(){return q?d:u}},state:{get:function(){return s[d.href]||j}}},L={assign:function(a){0===(""+a).indexOf("#")?t(j,a):d.assign(a)},reload:function(){d.reload()}, -replace:function(a){0===(""+a).indexOf("#")?t(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){t(j,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return h().b}}};ga()&&(l.emulate=!q,e[N]=ca,e[X]=da,e[Y]=H)}})(window); +(function(e){var i=!0,j=null,o=!1;function I(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.e,g=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:d.href,!m||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");N.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(N.href),b= +a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",f=c+g+e,t=c.replace(RegExp("^"+l.basepath,"i"),l.type)+g;return{a:a[1]+"//"+b+f,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:f,j:t,d:t+e}}function Y(){var a;try{a=e.sessionStorage,a.setItem(D+"t","1"),a.removeItem(D+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(q[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"=== +c&&(s=a(s),e.history=h=a(h),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=k().a;if(a!=l){var b=f.createEventObject();b.oldURL=l;b.newURL=l=a;b.type="hashchange";K(b)}},100);e.JSON=p}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,p=e.JSON,d=e.location,n=e.history,h=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"),v="",L=e.addEventListener?"addEventListener": +(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],l={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,q={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=h)},T={redirect:function(a,b){l.basepath=b=b==j?l.basepath:b;l.type=a=a==j?l.type:a;if(e.top==e.self){var c=k(j,o,i).c, +f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete q[d.href];U&&X(U,arguments);r(a,c,i);f.title=e;A=b},location:{set:function(a){e.location=a},get:function(){return m? +d:s}},state:{get:function(){return q[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){r(j,(""+a).replace(/^(#|)/,"#"),o,z)},get:function(){return k().b}}};ea()&&(h.emulate= +!m,e[L]=aa,e[V]=ba,e[W]=F)}})(window); diff --git a/package.json b/package.json index a72f9fb..4b2561e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.0", + "version": "4.1.1", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 99642408f0ba1f2b7e5b47316462b777a518ebb9 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Tue, 29 Apr 2014 16:46:21 +0400 Subject: [PATCH 18/81] Fix for IE7 --- bower.json | 2 +- history.iegte8.js | 4 ++-- history.iegte8.min.js | 4 ++-- history.js | 7 +++++-- history.min.js | 34 +++++++++++++++++----------------- package.json | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/bower.json b/bower.json index 570ca8f..e5bffc9 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.1", + "version": "4.1.2", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index be0a23d..9b872f8 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.1 + * History API JavaScript Library v4.1.2 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-04-29 15:22 + * Update: 2014-04-29 15:30 */ (function(window) { // Prevent the code from running if there is no window.history object diff --git a/history.iegte8.min.js b/history.iegte8.min.js index d916e79..d6a13f7 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.1 + * History API JavaScript Library v4.1.2 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-04-29 15:22 + * Update: 2014-04-29 15:30 */ (function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(q[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)||(b===s?s[c]=d:b===h?(h[c]=d,"state"=== -c&&(s=a(s),e.history=h=a(h),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=k().a;if(a!=l){var b=f.createEventObject();b.oldURL=l;b.newURL=l=a;b.type="hashchange";K(b)}},100);e.JSON=p}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,p=e.JSON,d=e.location,n=e.history,h=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"),v="",L=e.addEventListener?"addEventListener": -(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],l={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,q={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=h)},T={redirect:function(a,b){l.basepath=b=b==j?l.basepath:b;l.type=a=a==j?l.type:a;if(e.top==e.self){var c=k(j,o,i).c, -f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete q[d.href];U&&X(U,arguments);r(a,c,i);f.title=e;A=b},location:{set:function(a){e.location=a},get:function(){return m? -d:s}},state:{get:function(){return q[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){r(j,(""+a).replace(/^(#|)/,"#"),o,z)},get:function(){return k().b}}};ea()&&(h.emulate= +'"'+a.replace(b,function(a){return a in c?c[a]:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}var c=e.eval&&eval("/*@cc_on 1;@*/");if(c&&!(f.documentMode&&7lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)||(b===s?s[c]=d: +b===l?(l[c]=d,"state"===c&&(s=a(s),e.history=l=a(l),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=f.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";K(b)}},100);e.JSON=q}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,q=e.JSON,d=e.location,n=e.history,l=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"),v="",L=e.addEventListener? +"addEventListener":(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],k={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,p={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},T={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c= +h(j,o,i).c,f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete p[d.href];U&&X(U,arguments);r(a,c,i);f.title=e;A=b},location:{set:function(a){e.location=a},get:function(){return m? +d:s}},state:{get:function(){return p[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){r(j,(""+a).replace(/^(#|)/,"#"),o,z)},get:function(){return h().b}}};ea()&&(l.emulate= !m,e[L]=aa,e[V]=ba,e[W]=F)}})(window); diff --git a/package.json b/package.json index 4b2561e..76e9177 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.1", + "version": "4.1.2", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 808784f092b1db262cfdaa52d17d09392710ed9f Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Wed, 14 May 2014 14:22:52 +0400 Subject: [PATCH 19/81] Incorrect format basepath --- bower.json | 2 +- history.iegte8.js | 10 ++++++---- history.iegte8.min.js | 16 ++++++++-------- history.js | 12 +++++++----- history.min.js | 30 +++++++++++++++--------------- package.json | 2 +- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/bower.json b/bower.json index e5bffc9..21bcdba 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.2", + "version": "4.1.3", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 9b872f8..cf67249 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.2 + * History API JavaScript Library v4.1.3 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-04-29 15:30 + * Update: 2014-05-14 14:06 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -113,7 +113,8 @@ * @param {String} [basepath] */ "redirect": function(type, basepath) { - settings["basepath"] = basepath = basepath == null ? settings["basepath"] : basepath; + settings["basepath"] = ('' + (basepath = basepath == null ? + settings["basepath"] : basepath)).replace(/(?:^|\/)[^\/]*$/, '/'); settings["type"] = type = type == null ? settings["type"] : type; if (window.top == window.self) { var relative = parseURL(null, false, true)._relative; @@ -859,7 +860,8 @@ var src = (scripts[scripts.length - 1] || {}).src || ''; var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : ''; arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) { - settings[key] = (value || (key === 'basepath' ? '/' : '')).replace(/^(0|false)$/, ''); + value = (value || '').replace(/^(0|false)$/, ''); + settings[key] = key === 'basepath' ? value.replace(/(?:^|\/)[^\/]*$/, '/') : value; }); /** diff --git a/history.iegte8.min.js b/history.iegte8.min.js index d6a13f7..a432720 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.2 + * History API JavaScript Library v4.1.3 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-04-29 15:30 + * Update: 2014-05-14 14:06 */ (function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)||(b===s?s[c]=d: -b===l?(l[c]=d,"state"===c&&(s=a(s),e.history=l=a(l),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=f.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";K(b)}},100);e.JSON=q}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,q=e.JSON,d=e.location,n=e.history,l=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"),v="",L=e.addEventListener? -"addEventListener":(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],k={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,p={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},T={redirect:function(a,b){k.basepath=b=b==j?k.basepath:b;k.type=a=a==j?k.type:a;if(e.top==e.self){var c= -h(j,o,i).c,f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete p[d.href];U&&X(U,arguments);r(a,c,i);f.title=e;A=b},location:{set:function(a){e.location=a},get:function(){return m? -d:s}},state:{get:function(){return p[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){r(j,(""+a).replace(/^(#|)/,"#"),o,z)},get:function(){return h().b}}};ea()&&(l.emulate= -!m,e[L]=aa,e[V]=ba,e[W]=F)}})(window); +a.returnValue=o))}function S(a){var b=f.getElementById(a=(a||"").replace(/^#/,""));b&&(b.id===a&&"A"===b.nodeName)&&(a=b.getBoundingClientRect(),e.scrollTo(H.scrollLeft||0,a.top+(H.scrollTop||0)-(H.clientTop||0)))}function ea(){var a=f.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){c=(c||"").replace(/^(0|false)$/,"");k[b]="basepath"===b?c.replace(/(?:^|\/)[^\/]*$/,"/"):c});fa();u(v+"hashchange", +K,o);var b=[J,s,ga,e,T,l];G&&delete T.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)|| +(b===s?s[c]=d:b===l?(l[c]=d,"state"===c&&(s=a(s),e.history=l=a(l),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=f.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";K(b)}},100);e.JSON=q}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,q=e.JSON,d=e.location,n=e.history,l=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"), +v="",L=e.addEventListener?"addEventListener":(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],k={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,p={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},T={redirect:function(a,b){k.basepath=b=(""+(b==j?k.basepath:b)).replace(/(?:^|\/)[^\/]*$/, +"/");k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,o,i).c,f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete p[d.href];U&&X(U,arguments);r(a,c,i);f.title= +e;A=b},location:{set:function(a){e.location=a},get:function(){return m?d:s}},state:{get:function(){return p[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){r(j,(""+ +a).replace(/^(#|)/,"#"),o,z)},get:function(){return h().b}}};ea()&&(l.emulate=!m,e[L]=aa,e[V]=ba,e[W]=F)}})(window); diff --git a/package.json b/package.json index 76e9177..f4e555a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.2", + "version": "4.1.3", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From ec9da3ea270a3a367215dec7db527cb8ec5d9284 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Wed, 14 May 2014 14:28:47 +0400 Subject: [PATCH 20/81] my bug --- bower.json | 2 +- history.iegte8.js | 6 +++--- history.iegte8.min.js | 6 +++--- history.js | 4 ++-- history.min.js | 4 ++-- package.json | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bower.json b/bower.json index 21bcdba..15e5edf 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.3", + "version": "4.1.4", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index cf67249..106e72e 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.3 + * History API JavaScript Library v4.1.4 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-05-14 14:06 + * Update: 2014-05-14 14:27 */ (function(window) { // Prevent the code from running if there is no window.history object @@ -113,7 +113,7 @@ * @param {String} [basepath] */ "redirect": function(type, basepath) { - settings["basepath"] = ('' + (basepath = basepath == null ? + settings["basepath"] = basepath = ('' + (basepath == null ? settings["basepath"] : basepath)).replace(/(?:^|\/)[^\/]*$/, '/'); settings["type"] = type = type == null ? settings["type"] : type; if (window.top == window.self) { diff --git a/history.iegte8.min.js b/history.iegte8.min.js index a432720..446d853 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.3 + * History API JavaScript Library v4.1.4 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-05-14 14:06 + * Update: 2014-05-14 14:27 */ (function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1 Date: Wed, 14 May 2014 23:09:44 +0400 Subject: [PATCH 21/81] #56 AMD Support --- README.md | 43 +++++++++++++++++++++++++++++++++++-------- bower.json | 2 +- history.iegte8.js | 17 +++++++++++++---- history.iegte8.min.js | 30 +++++++++++++++--------------- history.js | 19 +++++++++++++------ history.min.js | 42 +++++++++++++++++++++--------------------- package.json | 2 +- 7 files changed, 99 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 9c024bb..3023d58 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,38 @@ This Javascript library provides an emulation of HTML5 History API for older bro The library operates according to W3C specification, adding no new or incompatible methods. The library can be used exactly as described, for example, in Dive Into HTML5 book (http://diveintohtml5.info/history.html) or in the History API Specification (http://www.w3.org/TR/html5/browsers.html#the-history-interface). -Example of using the library in the pure JS context: +### You may install this plugin with this command: +```shell +nmp install html5-history-api +``` + +### AMD Support: +```html + + + + + + + + + +``` +### Example of using the library in the pure JS context: ```html @@ -69,8 +99,7 @@ Example of using the library in the pure JS context: ``` -Example of using the library along with JQuery: - +### Example of using the library along with JQuery: ```html @@ -125,8 +154,7 @@ Example of using the library along with JQuery: ``` -Example of using popstate (pure JS): - +### Example of using popstate (pure JS): ```javascript window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { @@ -138,8 +166,7 @@ window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', }, false); ``` -Example of using popstate with JQuery: - +### Example of using popstate with JQuery: ```javascript $(window).on('popstate', function(event) { @@ -150,7 +177,7 @@ $(window).on('popstate', function(event) { }); ``` -Advanced library configuration: +### Advanced library configuration: history.js?basepath=/pathtosite/ - the base path to the site; defaults to the root "/". history.js?redirect=true - enable link translation. diff --git a/bower.json b/bower.json index 15e5edf..dd61bec 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.4", + "version": "4.1.5", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 106e72e..af57687 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.4 + * History API JavaScript Library v4.1.5 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,9 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-05-14 14:27 + * Update: 2014-05-14 22:01 */ -(function(window) { +(function(factory) { + if (typeof self === 'object' && self.history) { + factory(self); + if (typeof define === 'function' && define['amd']) { + define("html5-history-api", function() { + return self.history; + }); + } + } +})(function(window) { // Prevent the code from running if there is no window.history object if (!window.history) return; // symlink to document @@ -977,4 +986,4 @@ window[removeEventListenerName] = removeEventListener; window[dispatchEventName] = dispatchEvent; -})(window); \ No newline at end of file +}); \ No newline at end of file diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 446d853..8a118c5 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.4 + * History API JavaScript Library v4.1.5 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,18 +11,18 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-05-14 14:27 + * Update: 2014-05-14 22:01 */ -(function(e){var i=!0,j=null,n=!1;function D(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.d,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a);else if(a=b?a:f.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");I.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(I.href),b= -a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",g=c+d+e,h=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{b:a[1]+"//"+b+g,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:g,j:h,f:h+e}}function W(){var a;try{a=e.sessionStorage,a.setItem(x+"t","1"),a.removeItem(x+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!f&&a&&(p[d.href]=a)}};w=function(b,c,d,f){g.apply(this,arguments)|| -(b===s?s[c]=d:b===l?(l[c]=d,"state"===c&&(s=a(s),e.history=l=a(l),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=h().a;if(a!=k){var b=f.createEventObject();b.oldURL=k;b.newURL=k=a;b.type="hashchange";K(b)}},100);e.JSON=q}}if(e.history){var f=e.document,H=f.documentElement,E=e.Object,q=e.JSON,d=e.location,n=e.history,l=n,M=n.pushState,U=n.replaceState,m=!!M,G="state"in n,B=E.defineProperty,s=w({},"t")?{}:f.createElement("a"), -v="",L=e.addEventListener?"addEventListener":(v="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent",u=e[L],O=e[V],ca=e[W],k={basepath:"/",redirect:0,type:"/"},D="__historyAPI__",N=f.createElement("a"),z=d.href,Q="",C=o,p={},y={},A=f.title,ga={onhashchange:j,onpopstate:j},X=function(a,b){var c=e.history!==n;c&&(e.history=n);a.apply(n,b);c&&(e.history=l)},T={redirect:function(a,b){k.basepath=b=(""+(b==j?k.basepath:b)).replace(/(?:^|\/)[^\/]*$/, -"/");k.type=a=a==j?k.type:a;if(e.top==e.self){var c=h(j,o,i).c,f=d.pathname+d.search;m?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&d.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&d.replace(b+"#"+f.replace(RegExp("^"+b,"i"),a)+d.hash))}},pushState:function(a,b,c){var d=f.title;A!=j&&(f.title=A);M&&X(M,arguments);r(a,c);f.title=d;A=b},replaceState:function(a,b,c){var e=f.title;A!=j&&(f.title=A);delete p[d.href];U&&X(U,arguments);r(a,c,i);f.title= -e;A=b},location:{set:function(a){e.location=a},get:function(){return m?d:s}},state:{get:function(){return p[d.href]||j}}},J={assign:function(a){0===(""+a).indexOf("#")?r(j,a):d.assign(a)},reload:function(){d.reload()},replace:function(a){0===(""+a).indexOf("#")?r(j,a,i):d.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){r(j,(""+ -a).replace(/^(#|)/,"#"),o,z)},get:function(){return h().b}}};ea()&&(l.emulate=!m,e[L]=aa,e[V]=ba,e[W]=F)}})(window); +(function(e){"object"===typeof self&&self.history&&(e(self),"function"===typeof define&&define.amd&&define("html5-history-api",function(){return self.history}))})(function(e){var i=!0,j=null,n=!1;function O(a,b){var c=e.history!==m;c&&(e.history=m);a.apply(m,b);c&&(e.history=h)}function J(){}function k(a,b,c){if(a!=j&&""!==a&&!b)var b=k(),c=b.e,d=b.h,a=""+a,a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g, +"")+a);else if(a=b?a:g.href,!p||c)a=a.replace(/^[^#]*/,"")||"#",a=g.protocol.replace(/:.*$|$/,":")+"//"+g.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");P.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(P.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",f=c+d+e,u=c.replace(RegExp("^"+l.basepath,"i"),l.type)+d;return{a:a[1]+"//"+b+f,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:d,b:e,c:f,j:u,d:u+ +e}}function Z(){var a;try{a=e.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),f.close();!d&&a&&(o[g.href]=a)}};x=function(b,c,f,g){d.apply(this,arguments)||(b===t?t[c]=f:b===h?(h[c]=f,"state"===c&&(t=a(t),e.history=h=a(h),e.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b}; +setInterval(function(){var a=k().a;if(a!=l){var b=f.createEventObject();b.oldURL=l;b.newURL=l=a;b.type="hashchange";L(b)}},100);e.JSON=q}}var f=e.document,I=f.documentElement,F=e.Object,q=e.JSON,g=e.location,m=e.history,h=m,M=m.pushState,U=m.replaceState,p=!!M,H="state"in m,C=F.defineProperty,t=x({},"t")?{}:f.createElement("a"),w="",N=e.addEventListener?"addEventListener":(w="on")&&"attachEvent",V=e.removeEventListener?"removeEventListener":"detachEvent",W=e.dispatchEvent?"dispatchEvent":"fireEvent", +v=e[N],X=e[V],ba=e[W],l={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",P=f.createElement("a"),A=g.href,R="",D=n,o={},z={},B=f.title,ea={onhashchange:j,onpopstate:j},Y={redirect:function(a,b){l.basepath=b=(""+(b==j?l.basepath:b)).replace(/(?:^|\/)[^\/]*$/,"/");l.type=a=a==j?l.type:a;if(e.top==e.self){var c=k(j,n,i).c,d=g.pathname+g.search;p?(d=d.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&g.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&g.replace(b+ +"#"+d.replace(RegExp("^"+b,"i"),a)+g.hash))}},pushState:function(a,b,c){var d=f.title;B!=j&&(f.title=B);M&&O(M,arguments);r(a,c);f.title=d;B=b},replaceState:function(a,b,c){var d=f.title;B!=j&&(f.title=B);delete o[g.href];U&&O(U,arguments);r(a,c,i);f.title=d;B=b},location:{set:function(a){e.location=a},get:function(){return p?g:t}},state:{get:function(){return o[g.href]||j}}},K={assign:function(a){0===(""+a).indexOf("#")?r(j,a):g.assign(a)},reload:function(){g.reload()},replace:function(a){0===(""+ +a).indexOf("#")?r(j,a,i):g.replace(a)},toString:function(){return this.href},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){r(j,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return k().b}}};(function(){var a=f.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){c=(c||"").replace(/^(0|false)$/, +"");l[b]="basepath"===b?c.replace(/(?:^|\/)[^\/]*$/,"/"):c});da();v(w+"hashchange",L,n);var b=[K,t,ea,e,Y,h];H&&delete Y.state;for(var c=0;c Date: Wed, 14 May 2014 23:14:52 +0400 Subject: [PATCH 22/81] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3023d58..363c7fe 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The library operates according to W3C specification, adding no new or incompatib ### You may install this plugin with this command: ```shell -nmp install html5-history-api +npm install html5-history-api ``` ### AMD Support: From 1a30586dca8d66fbb22ea402efd972855f148ef1 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Thu, 15 May 2014 00:54:29 +0400 Subject: [PATCH 23/81] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 363c7fe..cac8041 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ npm install html5-history-api 'html5-history-api': '/history' } }); - requirejs(['html5-history-api'], function(history) { + requirejs(['html5-history-api'], function() { if (history.emulate) { console.log('In your browser is emulated HTML5-History-API'); } else { From 8f75a8784af58691a25b7b63b63384b7a1c70e0f Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Thu, 15 May 2014 17:31:00 +0400 Subject: [PATCH 24/81] fix error: Mismatched anonymous define() --- README.md | 7 +-- bower.json | 2 +- history.iegte8.js | 119 +++++++++++++++++++++---------------- history.iegte8.min.js | 30 +++++----- history.js | 134 ++++++++++++++++++++++++------------------ history.min.js | 42 ++++++------- package.json | 2 +- 7 files changed, 182 insertions(+), 154 deletions(-) diff --git a/README.md b/README.md index cac8041..c66c844 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,7 @@ npm install html5-history-api - - - - My Link - Other Link - + + + + + + My Link + Other Link + ``` @@ -98,80 +95,52 @@ npm install html5-history-api ```html - - - - - - - My Link - Other Link - + + + + + + + My Link + Other Link + ``` -### Example of using popstate (pure JS): -```javascript -window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { - - // receiving location from the window.history object - var loc = history.location || document.location; - - alert("return to: " + loc); - -}, false); -``` - -### Example of using popstate with JQuery: -```javascript -$(window).on('popstate', function(event) { - - // receiving location from the window.history object - var loc = history.location || document.location; - - alert("return to: " + loc); -}); -``` - ### Advanced library configuration: history.js?basepath=/pathtosite/ - the base path to the site; defaults to the root "/". @@ -227,6 +196,18 @@ Alfa-Bank Card # 5486732005875430 - 11/15 @@ -292,16 +258,25 @@ Alfa-Bank Card # 5486732005875430 - 11/15 @@ -338,31 +299,6 @@ Alfa-Bank Card # 5486732005875430 - 11/15 ``` -Использование события popstate при обычном чистом JS: - -```javascript -window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { - - // получение location из объекта window.history - var loc = history.location || document.location; - - alert("return to: " + loc); - -}, false); -``` - -Использование события popstate в связке jQuery: - -```javascript -$(window).on('popstate', function(e) { - - // получение location из объекта window.history - var loc = history.location || document.location; - - alert("return to: " + loc); -}); -``` - Вы можете использовать дополнительные параметры конфигурации библиотеки: history.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". From 411b6db8b8e9ea0b9d3f59538d5a48a27584a100 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Sat, 28 Jun 2014 23:44:19 +0400 Subject: [PATCH 34/81] update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 41812a7..d842ffb 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,26 @@ The library operates according to W3C specification, adding no new or incompatib npm install html5-history-api ``` +### For library developers: + +To enable support for HTML5-History-API polyfill in your library, you need to add one line of code: +```js +var location = window.history.location || window.location; +``` + +code of library looks like this: +```js +(function(){ + // To enable support for HTML5-History-API polyfill in your library + var location = window.history.location || window.location; + + // you library code here + // .... + // .... + // .... +})(); +``` + ### AMD Support: ```html From 09774c7fc7e344226559771c1548fd056ae06b1d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 3 Jul 2014 17:12:41 +0400 Subject: [PATCH 35/81] Minor bug in example To prevent work on classes like "is-not-ajax" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d842ffb..38a6090 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ code of library looks like this: var target = event.target || event.srcElement; // looking for all the links with 'ajax' class found if (target && target.nodeName === 'A' && - (' ' + target.className + ' ').indexOf('ajax') >= 0) + (' ' + target.className + ' ').indexOf(' ajax ') >= 0) { // keep the link in the browser history history.pushState(null, null, target.href); From 94f2fd723a0b77b02aaf1e31eb2f43fe462dd070 Mon Sep 17 00:00:00 2001 From: Roman Zhak Date: Wed, 9 Jul 2014 12:35:25 +0400 Subject: [PATCH 36/81] Update history.js [\w0-9] equals to [\w] as w\ means [A-Za-z0-9_] --- history.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/history.js b/history.js index f9db6b1..450b441 100644 --- a/history.js +++ b/history.js @@ -369,7 +369,7 @@ * @return {Object} */ function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + var re = /(?:(\w+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; @@ -383,7 +383,7 @@ // convert to type of string href = '' + href; // convert relative link to the absolute - href = /^(?:[\w0-9]+\:)?\/\//.test(href) ? href.indexOf("/") === 0 + href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 ? _protocol + href : href : _protocol + "//" + current._host + ( href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 ? _pathname + href : href.indexOf("#") === 0 @@ -1260,4 +1260,4 @@ global['JSON'] = JSON; } -}); \ No newline at end of file +}); From 2e0b93ab216f3d92ff1605b186b3367b86963627 Mon Sep 17 00:00:00 2001 From: Roman Zhak Date: Wed, 9 Jul 2014 13:55:25 +0400 Subject: [PATCH 37/81] Update history.iegte8.js --- history.iegte8.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index 2863e92..a1b6bf4 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -369,7 +369,7 @@ * @return {Object} */ function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + var re = /(?:(\w+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; @@ -383,7 +383,7 @@ // convert to type of string href = '' + href; // convert relative link to the absolute - href = /^(?:[\w0-9]+\:)?\/\//.test(href) ? href.indexOf("/") === 0 + href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 ? _protocol + href : href : _protocol + "//" + current._host + ( href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 ? _pathname + href : href.indexOf("#") === 0 @@ -1026,4 +1026,4 @@ global[dispatchEventName] = dispatchEvent; return historyObject; -}); \ No newline at end of file +}); From 7ba26e94f30a9c220884cd20ffa13abfc0a02b1f Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Sat, 19 Jul 2014 19:18:03 +0400 Subject: [PATCH 38/81] do not removed first event listener --- history.iegte8.js | 6 +++--- history.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index 2863e92..8afa4bf 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.11 + * History API JavaScript Library v4.1.12 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-28 03:56 + * Update: 2014-06-29 20:56 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -659,7 +659,7 @@ function removeEventListener(event, listener, capture) { var list = eventsList[event]; if (list) { - for(var i = list.length; --i;) { + for(var i = list.length; i--;) { if (list[i] === listener) { list.splice(i, 1); break; diff --git a/history.js b/history.js index f9db6b1..80c7fb9 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.11 + * History API JavaScript Library v4.1.12 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-28 03:56 + * Update: 2014-06-29 20:56 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -659,7 +659,7 @@ function removeEventListener(event, listener, capture) { var list = eventsList[event]; if (list) { - for(var i = list.length; --i;) { + for(var i = list.length; i--;) { if (list[i] === listener) { list.splice(i, 1); break; From 4a12275a6e1d8eab6868726731457ea64883a996 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Sat, 19 Jul 2014 19:34:28 +0400 Subject: [PATCH 39/81] update README.md and bump version to 4.1.12 --- README.md | 192 +++++++++++++++++++++--------------------- bower.json | 2 +- history.iegte8.js | 2 +- history.iegte8.min.js | 14 +-- history.js | 2 +- history.min.js | 24 +++--- package.json | 2 +- 7 files changed, 119 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index 38a6090..1667227 100644 --- a/README.md +++ b/README.md @@ -212,59 +212,59 @@ Alfa-Bank Card # 5486732005875430 - 11/15 ```html - - - - - - My Link - Other Link - + + + + + + My Link + Other Link + ``` @@ -273,49 +273,49 @@ Alfa-Bank Card # 5486732005875430 - 11/15 ```html - - - - - - - My Link - Other Link - + + + + + + + My Link + Other Link + ``` diff --git a/bower.json b/bower.json index 1ae70dc..93da0f3 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.11", + "version": "4.1.12", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index 929bd0f..f0689cd 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -369,7 +369,7 @@ * @return {Object} */ function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:(\w+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 891aa12..a7aeaa3 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.11 + * History API JavaScript Library v4.1.12 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,12 +11,12 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-28 03:56 + * Update: 2014-06-29 20:56 */ -(function(K){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",K):K()})(function(){var h=!0,k=null,n=!1;function L(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=i)}function F(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=l(d.href,k,h));c=b.d;d=b.h;a=""+a;a=/^(?:[\w0-9]+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!o||c)a=a.replace(/^[^#]*/,"")||"#", -a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+j.basepath+a.replace(RegExp("^#[/]?(?:"+j.type+")?"),"");M.href=a;var a=/(?:([\w0-9]+:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(M.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",i=c+d+e,N=c.replace(RegExp("^"+j.basepath,"i"),j.type)+d;return{b:a[1]+"//"+b+i,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:i,j:N,f:N+e}}function Z(){var a;try{a=e.sessionStorage,a.setItem(y+"t", -"1"),a.removeItem(y+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1 Date: Mon, 25 Aug 2014 11:27:59 +0400 Subject: [PATCH 40/81] update readme.md --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1667227..d0e7f04 100644 --- a/README.md +++ b/README.md @@ -172,9 +172,9 @@ You can also combine options: history.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter. Or execute special method in JavaScript: - - history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); - +```js +history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); +``` Demo Site: http://history.spb-piksel.ru/ or http://devote.github.io/demos/history/ Follow me on Twitter: https://twitter.com/DimaPakhtinov @@ -205,10 +205,53 @@ Alfa-Bank Card # 5486732005875430 - 11/15 По принципу мы работаем с HTML5 History API так как описано, например, тут http://htmlbook.ru/html5/history или по спецификации http://www.w3.org/TR/html5/history.html#the-history-interface -То есть коротенький пример: +### Вы можете установить плагин с помощью команды: +```shell +npm install html5-history-api +``` + +### Для разработчиков библиотек: + +Для включения поддержки плагина HTML5-History-API polyfill в своих библиотеках, добавьте строку кода: +```js +var location = window.history.location || window.location; +``` + +код будет выглядеть примерно так: +```js +(function(){ + // Включает поддержку плагина HTML5-History-API polyfill + var location = window.history.location || window.location; -на чистом JS: + // код вашей библиотеки + // .... + // .... + // .... +})(); +``` +### Поддержка AMD: +```html + + + + + + + + + +``` + +### Коротенький пример на чистом JS: ```html @@ -268,7 +311,7 @@ Alfa-Bank Card # 5486732005875430 - 11/15 ``` -А теперь показываю пример в связке с jQuery: +### А теперь показываю пример в связке с jQuery: ```html @@ -319,7 +362,7 @@ Alfa-Bank Card # 5486732005875430 - 11/15 ``` -Вы можете использовать дополнительные параметры конфигурации библиотеки: +### Вы можете использовать дополнительные параметры конфигурации библиотеки: history.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". history.js?redirect=true - включить преобразование ссылок. @@ -330,9 +373,9 @@ Alfa-Bank Card # 5486732005875430 - 11/15 history.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение. Или выполнить специальный метод в JavaScript: - - history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); - +```js +history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); +``` Демо-сайт: http://history.spb-piksel.ru/ или http://devote.github.io/demos/history/ Я в Twitter: https://twitter.com/DimaPakhtinov From 51327f06b17d18998ec47c1cfe561208e1a7ae4e Mon Sep 17 00:00:00 2001 From: James Newell Date: Fri, 5 Sep 2014 15:25:55 +1000 Subject: [PATCH 41/81] added component.json --- component.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 component.json diff --git a/component.json b/component.json new file mode 100644 index 0000000..d35fee1 --- /dev/null +++ b/component.json @@ -0,0 +1,23 @@ +{ + "name": "html5-history-api", + "version": "4.1.12", + "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", + "main": "history.js", + "scripts": ["history.js"], + "repository": "devote/HTML5-History-API", + "keywords": [ + "javascript", + "html5 history api", + "hashchange", + "popstate", + "pushstate", + "replacestate", + "hashes", + "hashbang", + "history", + "html5", + "devote" + ], + "author": "Dmitrii Pakhtinov", + "license": "GPL/MIT" +} From bb0e7ae110c8067e6f61c8024f93684f77f1a6de Mon Sep 17 00:00:00 2001 From: James Newell Date: Fri, 5 Sep 2014 15:29:44 +1000 Subject: [PATCH 42/81] bumped the version --- bower.json | 2 +- component.json | 2 +- history.iegte8.js | 2 +- history.iegte8.min.js | 2 +- history.js | 2 +- history.min.js | 2 +- package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 93da0f3..3ff2758 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.12", + "version": "4.1.13", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index d35fee1..c3fd8ed 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.12", + "version": "4.1.13", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index f0689cd..817ad59 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.12 + * History API JavaScript Library v4.1.13 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * diff --git a/history.iegte8.min.js b/history.iegte8.min.js index a7aeaa3..5f4a76f 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.12 + * History API JavaScript Library v4.1.13 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * diff --git a/history.js b/history.js index a3d7fe7..67ec5a2 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.12 + * History API JavaScript Library v4.1.13 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * diff --git a/history.min.js b/history.min.js index 34e6df8..83b7df2 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.12 + * History API JavaScript Library v4.1.13 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * diff --git a/package.json b/package.json index 9c42269..c74a6cb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "*.js" ] }], - "version": "4.1.12", + "version": "4.1.13", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 07262566e0dc2d9c0e6202c01f0ca2e6e0dba4fb Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Sat, 25 Oct 2014 22:59:08 +0300 Subject: [PATCH 43/81] #67 replaced the document.location to window.location in comments and examples --- README.md | 16 ++++++++-------- readme.en.txt | 16 ++++++++-------- readme.ru.txt | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d0e7f04..1f4bf5d 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,11 @@ code of library looks like this: /* * Note, this is the only difference when using this library, - * because the object document.location cannot be overriden, + * because the object window.location cannot be overriden, * so library the returns generated "location" object within * an object window.history, so get it out of "history.location". * For browsers supporting "history.pushState" get generated - * object "location" with the usual "document.location". + * object "location" with the usual "window.location". */ var location = window.history.location || window.location; @@ -124,11 +124,11 @@ code of library looks like this: /* * Note, this is the only difference when using this library, - * because the object document.location cannot be overriden, + * because the object window.location cannot be overriden, * so library the returns generated "location" object within * an object window.history, so get it out of "history.location". * For browsers supporting "history.pushState" get generated - * object "location" with the usual "document.location". + * object "location" with the usual "window.location". */ var location = window.history.location || window.location; @@ -263,11 +263,11 @@ var location = window.history.location || window.location; /* * заметьте, это единственная разница при работе с данной библиотекой, - * так как объект document.location нельзя перезагрузить, поэтому + * так как объект window.location нельзя перезагрузить, поэтому * библиотека history возвращает сформированный "location" объект внутри * объекта window.history, поэтому получаем его из "history.location". * Для браузеров поддерживающих "history.pushState" получаем - * сформированный объект "location" с обычного "document.location". + * сформированный объект "location" с обычного "window.location". */ var location = window.history.location || window.location; @@ -325,11 +325,11 @@ var location = window.history.location || window.location; /* * заметьте, это единственная разница при работе с данной библиотекой, - * так как объект document.location нельзя перезагрузить, поэтому + * так как объект window.location нельзя перезагрузить, поэтому * библиотека history возвращает сформированный "location" объект внутри * объекта window.history, поэтому получаем его из "history.location". * Для браузеров поддерживающих "history.pushState" получаем - * сформированный объект "location" с обычного "document.location". + * сформированный объект "location" с обычного "window.location". */ var location = window.history.location || window.location; diff --git a/readme.en.txt b/readme.en.txt index f645dbe..0198f10 100644 --- a/readme.en.txt +++ b/readme.en.txt @@ -46,13 +46,13 @@ on pure JS: /* * Note, this is the only difference when using this library, - * because the object document.location cannot be overriden, + * because the object window.location cannot be overriden, * so library the returns generated "location" object within * an object window.history, so get it out of "history.location". * For browsers supporting "history.pushState" get generated - * object "location" with the usual "document.location". + * object "location" with the usual "window.location". */ - var returnLocation = history.location || document.location; + var returnLocation = history.location || window.location; // here can cause data loading, etc. @@ -100,13 +100,13 @@ And now show an example in conjunction with jQuery: /* * Note, this is the only difference when using this library, - * because the object document.location cannot be overriden, + * because the object window.location cannot be overriden, * so library the returns generated "location" object within * an object window.history, so get it out of "history.location". * For browsers supporting "history.pushState" get generated - * object "location" with the usual "document.location". + * object "location" with the usual "window.location". */ - var returnLocation = history.location || document.location; + var returnLocation = history.location || window.location; // here can cause data loading, etc. @@ -129,7 +129,7 @@ Using the event popstate the usual pure JS: window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // receiving location from the window.history object - var loc = history.location || document.location; + var loc = history.location || window.location; alert("return to: " + loc); @@ -141,7 +141,7 @@ Using the popstate event in conjunction jQuery: $(window).on('popstate', function(e) { // receiving location from the window.history object - var loc = history.location || document.location; + var loc = history.location || window.location; alert("return to: " + loc); }); diff --git a/readme.ru.txt b/readme.ru.txt index 4b80a84..35dfb97 100644 --- a/readme.ru.txt +++ b/readme.ru.txt @@ -46,13 +46,13 @@ /* * заметьте, это единственная разница при работе с данной библиотекой, - * так как объект document.location нельзя перезагрузить, поэтому + * так как объект window.location нельзя перезагрузить, поэтому * библиотека history возвращает сформированный "location" объект внутри * объекта window.history, поэтому получаем его из "history.location". * Для браузеров поддерживающих "history.pushState" получаем - * сформированный объект "location" с обычного "document.location". + * сформированный объект "location" с обычного "window.location". */ - var returnLocation = history.location || document.location; + var returnLocation = history.location || window.location; // тут можете вызвать подгрузку данных и т.п. @@ -100,13 +100,13 @@ /* * заметьте, это единственная разница при работе с данной библиотекой, - * так как объект document.location нельзя перезагрузить, поэтому + * так как объект window.location нельзя перезагрузить, поэтому * библиотека history возвращает сформированный "location" объект внутри * объекта window.history, поэтому получаем его из "history.location". * Для браузеров поддерживающих "history.pushState" получаем - * сформированный объект "location" с обычного "document.location". + * сформированный объект "location" с обычного "window.location". */ - var returnLocation = history.location || document.location; + var returnLocation = history.location || window.location; // тут можете вызвать подгрузку данных и т.п. @@ -129,7 +129,7 @@ window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { // получение location из объекта window.history - var loc = history.location || document.location; + var loc = history.location || window.location; alert("return to: " + loc); @@ -141,7 +141,7 @@ $(window).on('popstate', function(e) { // получение location из объекта window.history - var loc = history.location || document.location; + var loc = history.location || window.location; alert("return to: " + loc); }); From 3d97c16cfca3830fe776b4ed4781e3ae02eda423 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Thu, 30 Oct 2014 14:47:51 +0300 Subject: [PATCH 44/81] Added option 'init' --- history.iegte8.js | 8 +++++++- history.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index 817ad59..aea2b8c 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -64,7 +64,7 @@ var removeEvent = global[removeEventListenerName]; var dispatch = global[dispatchEventName]; // default settings - var settings = {"basepath": '/', "redirect": 0, "type": '/'}; + var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; // key for the sessionStorage var sessionStorageKey = '__historyAPI__'; // Anchor Element for parseURL function @@ -968,6 +968,12 @@ historyObject['redirect'](); } + // initialize + if (settings["init"]) { + // You agree that you will use window.history.location instead window.location + isUsedHistoryLocationFlag = 1; + } + // If browser does not support object 'state' in interface 'History' if (!isSupportStateObjectInHistory && JSON) { storageInitialize(); diff --git a/history.js b/history.js index 67ec5a2..45de0ee 100644 --- a/history.js +++ b/history.js @@ -64,7 +64,7 @@ var removeEvent = global[removeEventListenerName]; var dispatch = global[dispatchEventName]; // default settings - var settings = {"basepath": '/', "redirect": 0, "type": '/'}; + var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; // key for the sessionStorage var sessionStorageKey = '__historyAPI__'; // Anchor Element for parseURL function @@ -973,6 +973,12 @@ historyObject['redirect'](); } + // initialize + if (settings["init"]) { + // You agree that you will use window.history.location instead window.location + isUsedHistoryLocationFlag = 1; + } + // If browser does not support object 'state' in interface 'History' if (!isSupportStateObjectInHistory && JSON) { storageInitialize(); From 7ce60cb9c7d0f1697c8ee9287671fd62d73de628 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Thu, 30 Oct 2014 14:57:21 +0300 Subject: [PATCH 45/81] update minified files --- history.iegte8.min.js | 27 +++++++++++++-------------- history.min.js | 38 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 5f4a76f..f310928 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -13,17 +13,16 @@ * * Update: 2014-06-29 20:56 */ -(function(K){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",K):K()})(function(){var h=!0,k=null,n=!1;function L(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=i)}function F(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=l(d.href,k,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, -":")+"//"+f.host+j.basepath+a.replace(RegExp("^#[/]?(?:"+j.type+")?"),"");M.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(M.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",i=c+d+e,N=c.replace(RegExp("^"+j.basepath,"i"),j.type)+d;return{b:a[1]+"//"+b+i,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:i,j:N,f:N+e}}function Z(){var a;try{a=e.sessionStorage,a.setItem(y+"t","1"),a.removeItem(y+"t")}catch(b){a= -{getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(q[f.href]=a)}};y=function(b,c,f,g){d.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),e.history=l=a(l),e.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&& -f.get());return b};setInterval(function(){var a=h().a;if(a!=i){var b=g.createEventObject();b.oldURL=i;b.newURL=i=a;b.type="hashchange";M(b)}},100);e.JSON=t}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var g=e.document,I=g.documentElement,F=e.Object,t=e.JSON,f=e.location,n=e.history,l=n,N=n.pushState,W=n.replaceState,s=!!N,H="state"in n,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",O=e.addEventListener?"addEventListener":(x="on")&& -"attachEvent",X=e.removeEventListener?"removeEventListener":"detachEvent",Y=e.dispatchEvent?"dispatchEvent":"fireEvent",w=e[O],Z=e[X],da=e[Y],i={basepath:"/",redirect:0,type:"/"},E="__historyAPI__",R=g.createElement("a"),A=f.href,T="",D=m,o=0,q={},z={},B=g.title,ga={onhashchange:k,onpopstate:k},$={setup:function(a,b,c){i.basepath=(""+(a==k?i.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");i.type=b==k?i.type:b;i.redirect=c==k?i.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=i.basepath;if(e.top==e.self){var c= -h(k,m,j).c,d=f.pathname+f.search;s?(d=d.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&f.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&f.replace(b+"#"+d.replace(RegExp("^"+b,"i"),i.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);N&&Q(N,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];W&&Q(W,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===o&&(o=1); -e.location=a},get:function(){0===o&&(o=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},L={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href},href:{get:function(){return h().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return h().e}},search:{get:function(){return h().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/, -"#"),m,A)},get:function(){return h().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){i[b]=(c||"").replace(/^(0|false)$/,"")});fa();w(x+"hashchange",M,m);var b=[L,r,ga,e,$,l];H&&delete $.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(q[f.href]=a)}}; +y=function(b,c,f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";M(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON, +f=d.location,o=d.history,l=o,N=o.pushState,X=o.replaceState,s=!!N,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",O=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[O],S=d[Y],fa=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",R=g.createElement("a"),A=f.href,U="",D=n,m=0,q={},z={},B=g.title,ia={onhashchange:k,onpopstate:k},$={setup:function(a, +b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); +N&&Q(N,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];X&&Q(X,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},L={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, +href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ha();w(x+"hashchange",M,n);var b=[L,r,ia,d,$,l]; +H&&delete $.state;for(var c=0;c Date: Thu, 30 Oct 2014 15:00:23 +0300 Subject: [PATCH 46/81] bump version to 4.1.14 --- bower.json | 2 +- component.json | 2 +- history.iegte8.js | 4 ++-- history.iegte8.min.js | 4 ++-- history.js | 4 ++-- history.min.js | 4 ++-- package.json | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index 3ff2758..9c54910 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.13", + "version": "4.1.14", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index c3fd8ed..13cb170 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.13", + "version": "4.1.14", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index aea2b8c..897ae9a 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.13 + * History API JavaScript Library v4.1.14 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-29 20:56 + * Update: 2014-10-30 14:57 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.iegte8.min.js b/history.iegte8.min.js index f310928..10d4a09 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.13 + * History API JavaScript Library v4.1.14 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-29 20:56 + * Update: 2014-10-30 14:57 */ (function(K){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",K):K()})(function(){var h=!0,k=null,o=!1;function L(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=i)}function F(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&(d&&d.getAttribute("href"))&&(d.href=d.href,b=l(d.href,k,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!q||c)a=a.replace(/^[^#]*/,"")||"#",a= f.protocol.replace(/:.*$|$/,":")+"//"+f.host+j.basepath+a.replace(RegExp("^#[/]?(?:"+j.type+")?"),"");M.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(M.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",i=c+d+e,n=c.replace(RegExp("^"+j.basepath,"i"),j.type)+d;return{b:a[1]+"//"+b+i,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:i,j:n,f:n+e}}function Y(){var a;try{a=e.sessionStorage,a.setItem(y+"t","1"),a.removeItem(y+ diff --git a/history.js b/history.js index 45de0ee..76cbd22 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.13 + * History API JavaScript Library v4.1.14 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-29 20:56 + * Update: 2014-10-30 14:57 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.min.js b/history.min.js index 19858d0..013414d 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.13 + * History API JavaScript Library v4.1.14 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-06-29 20:56 + * Update: 2014-10-30 14:57 */ (function(P){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",P):P()})(function(){var j=!0,k=null,n=!1;function Q(a,b){var c=d.history!==o;c&&(d.history=o);a.apply(o,b);c&&(d.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),e=g.getElementsByTagName("base")[0];!c&&(e&&e.getAttribute("href"))&&(e.href=e.href,b=i(e.href,k,j));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a= f.protocol.replace(/:.*$|$/,":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",p=c+e+d,v=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:p,j:v,d:v+d}}function aa(){var a;try{a=d.sessionStorage,a.setItem(E+"t","1"), diff --git a/package.json b/package.json index c74a6cb..82b855f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "*.js" ] }], - "version": "4.1.13", + "version": "4.1.14", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 8e585eef2c2909513efce530cae054e6a531490e Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Thu, 30 Oct 2014 15:01:31 +0300 Subject: [PATCH 47/81] remove readme.en.txt, readme.ru.txt --- readme.en.txt | 178 -------------------------------------------------- readme.ru.txt | 178 -------------------------------------------------- 2 files changed, 356 deletions(-) delete mode 100644 readme.en.txt delete mode 100644 readme.ru.txt diff --git a/readme.en.txt b/readme.en.txt deleted file mode 100644 index 0198f10..0000000 --- a/readme.en.txt +++ /dev/null @@ -1,178 +0,0 @@ -Library emulates the HTML5 History API in older browsers. - -Library that does not add unnecessary methods forcing them to study, and operates under the specification of w3c, the interface History. - -For example I can give a short code to work with her. - -In principle we are working with HTML5 History API as described for example here http://diveintohtml5.info/history.html or on the specification http://www.w3.org/TR/html5/history.html#the-history-interface - -That is a very brief example: - -on pure JS: - - - - - - - - - My Link - Other Link - - - -And now show an example in conjunction with jQuery: - - - - - - - - - - My Link - Other Link - - - -Using the event popstate the usual pure JS: - - window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { - - // receiving location from the window.history object - var loc = history.location || window.location; - - alert("return to: " + loc); - - }, false); - - -Using the popstate event in conjunction jQuery: - - $(window).on('popstate', function(e) { - - // receiving location from the window.history object - var loc = history.location || window.location; - - alert("return to: " + loc); - }); - - -You can use the advanced configuration library: - history.min.js?basepath=/pathtosite/ - the base path to the site defaults to the root "/". - history.min.js?redirect=true - enable link translation. - history.min.js?type=/ - substitute the string after the anchor, by default "/". - -You can also combine options: - history.min.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter. - -Or execute special method in JavaScript: - history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); - -Demo Site: http://history.spb-piksel.ru/ - -GitHub Project: https://github.com/devote/HTML5-History-API - -I'm on Twitter: https://twitter.com/DimaPakhtinov - ------------------------------ -Want to thank you for my job? - -PayPal: spb.piksel@gmail.com - -WebMoney: -WMR: R258217300226 -WMZ: Z314183434448 - -Yandex.Money: 41001414127851 - -Alfa-Bank Card # 5486732005875430 - 11/15 diff --git a/readme.ru.txt b/readme.ru.txt deleted file mode 100644 index 35dfb97..0000000 --- a/readme.ru.txt +++ /dev/null @@ -1,178 +0,0 @@ -Библиотека эмулирует HTML5 History API в старых браузерах. - -Библиотека которая не добавляет ненужные методы заставляя их изучать, а оперирует по спецификации w3c, по интерфейсу History. - -Для примера могу привести короткий код как с ней работать. - -По принципу мы работаем с HTML5 History API так как описано например тут http://htmlbook.ru/html5/history или по спецификации http://www.w3.org/TR/html5/history.html#the-history-interface - -То-есть коротенький пример: - -на чистом JS: - - - - - - - - - My Link - Other Link - - - -А теперь показываю пример в связке с jQuery: - - - - - - - - - - My Link - Other Link - - - -Использование события popstate при обычном чистом JS: - - window[window.addEventListener ? 'addEventListener' : 'attachEvent']('popstate', function(event) { - - // получение location из объекта window.history - var loc = history.location || window.location; - - alert("return to: " + loc); - - }, false); - - -Использование события popstate в связке jQuery: - - $(window).on('popstate', function(e) { - - // получение location из объекта window.history - var loc = history.location || window.location; - - alert("return to: " + loc); - }); - - -Вы можете использовать дополнительные параметры конфигурации библиотеки: - history.min.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/". - history.min.js?redirect=true - включить преобразование ссылок. - history.min.js?type=/ - подставлять подстроку после якоря, по умолчанию имеет символ "/". - -Также вы можете комбинировать опции: - history.min.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение. - -Или выполнить специальный метод в JavaScript: - history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); - -Демо-сайт: http://history.spb-piksel.ru/ - -GitHub Проект: https://github.com/devote/HTML5-History-API - -Я в Twitter: https://twitter.com/DimaPakhtinov - ------------------------------------ -Хочешь поблагодарить за мою работу? - -PayPal: spb.piksel@gmail.com - -WebMoney: -WMR: R258217300226 -WMZ: Z314183434448 - -Yandex.Money: 41001414127851 - -Alfa-Bank Card # 5486732005875430 - 11/15 From 10015c7aef720afcc88fbb1defdd496a5190dfcb Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Fri, 31 Oct 2014 21:58:24 +0300 Subject: [PATCH 48/81] #69 window.onpopstate fires twice in Safari 8.0 --- history.iegte8.js | 29 ++++++++++++++++++++++++++--- history.iegte8.min.js | 27 ++++++++++++++------------- history.js | 29 ++++++++++++++++++++++++++--- history.min.js | 38 +++++++++++++++++++------------------- 4 files changed, 85 insertions(+), 38 deletions(-) diff --git a/history.iegte8.js b/history.iegte8.js index 897ae9a..d2ca331 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -73,6 +73,8 @@ var lastURL = windowLocation.href; // Control URL, need to fix the bug in Opera var checkUrlForPopState = ''; + // for fix on Safari 8 + var triggerEventsInWindowAttributes = 1; // trigger event 'onpopstate' on page load var isFireInitialState = false; // if used history.location of other code @@ -563,6 +565,25 @@ */ defineProperty(object, prop, {value: emptyFunction}); } catch(_e_) { + if (prop === 'onpopstate') { + /** + * window.onpopstate fires twice in Safari 8.0. + * Block initial event on window.onpopstate + * See: https://github.com/devote/HTML5-History-API/issues/69 + */ + addEvent('popstate', descriptor = function() { + removeEvent('popstate', descriptor, false); + var onpopstate = object.onpopstate; + // cancel initial event on attribute handler + object.onpopstate = null; + setTimeout(function() { + // restore attribute value after short time + object.onpopstate = onpopstate; + }, 1); + }, false); + // cancel trigger events on attributes in object the window + triggerEventsInWindowAttributes = 0; + } } } // set old value to new variable @@ -696,9 +717,11 @@ }); } } - // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context - ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) - || emptyFunction).call(global, eventObject); + if (triggerEventsInWindowAttributes) { + // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context + ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) + || emptyFunction).call(global, eventObject); + } // run other functions that are in the list of handlers for(var i = 0, len = list.length; i < len; i++) { list[i].call(global, eventObject); diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 10d4a09..36902e7 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -13,16 +13,17 @@ * * Update: 2014-10-30 14:57 */ -(function(K){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",K):K()})(function(){var h=!0,k=null,o=!1;function L(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=i)}function F(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&(d&&d.getAttribute("href"))&&(d.href=d.href,b=l(d.href,k,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!q||c)a=a.replace(/^[^#]*/,"")||"#",a= -f.protocol.replace(/:.*$|$/,":")+"//"+f.host+j.basepath+a.replace(RegExp("^#[/]?(?:"+j.type+")?"),"");M.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(M.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",i=c+d+e,n=c.replace(RegExp("^"+j.basepath,"i"),j.type)+d;return{b:a[1]+"//"+b+i,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:i,j:n,f:n+e}}function Y(){var a;try{a=e.sessionStorage,a.setItem(y+"t","1"),a.removeItem(y+ -"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(q[f.href]=a)}}; -y=function(b,c,f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";M(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON, -f=d.location,o=d.history,l=o,N=o.pushState,X=o.replaceState,s=!!N,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",O=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[O],S=d[Y],fa=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",R=g.createElement("a"),A=f.href,U="",D=n,m=0,q={},z={},B=g.title,ia={onhashchange:k,onpopstate:k},$={setup:function(a, -b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); -N&&Q(N,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];X&&Q(X,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},L={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, -href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ha();w(x+"hashchange",M,n);var b=[L,r,ia,d,$,l]; -H&&delete $.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(q[f.href]=a)}};y=function(b,c,f,g){d.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),e.history=l=a(l), +e.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);e.JSON=t}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var g=e.document,I=g.documentElement,F=e.Object,t=e.JSON,f=e.location,o=e.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")? +{}:g.createElement("a"),x="",P=e.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=e.removeEventListener?"removeEventListener":"detachEvent",$=e.dispatchEvent?"dispatchEvent":"fireEvent",v=e[P],L=e[Z],ea=e[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect= +c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(e.top==e.self){var c=i(k,n,j).c,d=f.pathname+f.search;s?(d=d.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&f.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&f.replace(b+"#"+d.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href]; +Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);e.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href},href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}}, +hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,e,aa,l];H&&delete aa.state;for(var c=0;c Date: Fri, 31 Oct 2014 22:00:51 +0300 Subject: [PATCH 49/81] bump version to 4.1.15 --- bower.json | 2 +- component.json | 2 +- history.iegte8.js | 4 ++-- history.iegte8.min.js | 4 ++-- history.js | 4 ++-- history.min.js | 4 ++-- package.json | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index 9c54910..cc33fac 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.14", + "version": "4.1.15", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 13cb170..2584a06 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.14", + "version": "4.1.15", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.js b/history.iegte8.js index d2ca331..6226e26 100644 --- a/history.iegte8.js +++ b/history.iegte8.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.14 + * History API JavaScript Library v4.1.15 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-10-30 14:57 + * Update: 2014-10-31 21:58 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.iegte8.min.js b/history.iegte8.min.js index 36902e7..87ab313 100644 --- a/history.iegte8.min.js +++ b/history.iegte8.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.14 + * History API JavaScript Library v4.1.15 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-10-30 14:57 + * Update: 2014-10-31 21:58 */ (function(L){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",L):L()})(function(){var h=!0,i=null,o=!1;function M(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=j)}function F(){}function l(a,b,c){if(a!=i&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=l(d.href,i,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!q||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, ":")+"//"+f.host+k.basepath+a.replace(RegExp("^#[/]?(?:"+k.type+")?"),"");N.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(N.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",j=c+d+e,n=c.replace(RegExp("^"+k.basepath,"i"),k.type)+d;return{b:a[1]+"//"+b+j,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:j,j:n,f:n+e}}function Z(){var a;try{a=e.sessionStorage,a.setItem(y+"t","1"),a.removeItem(y+"t")}catch(b){a= diff --git a/history.js b/history.js index 3c8a205..5bbbef1 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.14 + * History API JavaScript Library v4.1.15 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-10-30 14:57 + * Update: 2014-10-31 21:58 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.min.js b/history.min.js index 649c6ce..17faa00 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.1.14 + * History API JavaScript Library v4.1.15 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-10-30 14:57 + * Update: 2014-10-31 21:58 */ (function(Q){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",Q):Q()})(function(){var j=!0,k=null,n=!1;function R(a,b){var c=e.history!==o;c&&(e.history=o);a.apply(o,b);c&&(e.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=i(d.href,k,j));c=b.e;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, ":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",p=c+d+e,w=c.replace(RegExp("^"+h.basepath,"i"),h.type)+d;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:d,b:e,c:p,j:w,d:w+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a= diff --git a/package.json b/package.json index 82b855f..60e2995 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "*.js" ] }], - "version": "4.1.14", + "version": "4.1.15", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 8db2ed2538af4b2a97b6070b940472a1037a5ae2 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Wed, 5 Nov 2014 22:04:34 +0300 Subject: [PATCH 50/81] #70 MSIE detection uses eval which is blocked by browser Content Security Policy --- history.js | 2 +- history.min.js | 39 ++++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/history.js b/history.js index 5bbbef1..213dd21 100644 --- a/history.js +++ b/history.js @@ -1133,7 +1133,7 @@ } // testing IE browser - var msie = global['eval'] && eval("/*@cc_on 1;@*/"); + var msie = global['execScript'] && (global['execScript']('var documentMsie/*@cc_on =1@*/;', 'JavaScript'), global['documentMsie']); if (!msie || (document.documentMode && document.documentMode > 7)) { // If it is not IE or a version greater than seven return; diff --git a/history.min.js b/history.min.js index 17faa00..dd16c00 100644 --- a/history.min.js +++ b/history.min.js @@ -13,22 +13,23 @@ * * Update: 2014-10-31 21:58 */ -(function(Q){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",Q):Q()})(function(){var j=!0,k=null,n=!1;function R(a,b){var c=e.history!==o;c&&(e.history=o);a.apply(o,b);c&&(e.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=i(d.href,k,j));c=b.e;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, -":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",p=c+d+e,w=c.replace(RegExp("^"+h.basepath,"i"),h.type)+d;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:d,b:e,c:p,j:w,d:w+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a= -{getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(q[f.href]=a)}};y=function(b,c,f,g){d.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),e.history=l=a(l), -e.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);e.JSON=t}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var g=e.document,I=g.documentElement,F=e.Object,t=e.JSON,f=e.location,o=e.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")? -{}:g.createElement("a"),x="",P=e.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=e.removeEventListener?"removeEventListener":"detachEvent",$=e.dispatchEvent?"dispatchEvent":"fireEvent",v=e[P],L=e[Z],ea=e[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect= -c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(e.top==e.self){var c=i(k,n,j).c,d=f.pathname+f.search;s?(d=d.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(d)&&f.replace(c)):d!=b&&(d=d.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(d)&&f.replace(b+"#"+d.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href]; -Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);e.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href},href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}}, -hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,e,aa,l];H&&delete aa.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(q[f.href]=a)}};y=function(b,c, +f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON,f=d.location,o= +d.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",P=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a, +b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); +O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, +href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,d,aa, +l];H&&delete aa.state;for(var c=0;c Date: Thu, 6 Nov 2014 21:42:48 +0300 Subject: [PATCH 51/81] Rename files, reducing the priority of the browser IE6-7, bump version to 4.2.0 --- README.md | 10 ++ bower.json | 2 +- component.json | 2 +- history.iegte8.min.js | 29 --- history.iegte8.js => history.ielte7.js | 240 ++++++++++++++++++++++++- history.ielte7.min.js | 35 ++++ history.js | 240 +------------------------ history.min.js | 40 ++--- package.json | 2 +- 9 files changed, 305 insertions(+), 295 deletions(-) delete mode 100644 history.iegte8.min.js rename history.iegte8.js => history.ielte7.js (80%) create mode 100644 history.ielte7.min.js diff --git a/README.md b/README.md index 1f4bf5d..26418fb 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ The library operates according to W3C specification, adding no new or incompatib npm install html5-history-api ``` +### Browser Support: + +`history.js` - IE8+ and other browsers +`history.ielte7.js` - IE6+ and other browsers + ### For library developers: To enable support for HTML5-History-API polyfill in your library, you need to add one line of code: @@ -210,6 +215,11 @@ Alfa-Bank Card # 5486732005875430 - 11/15 npm install html5-history-api ``` +### Поддержка браузеров: + +`history.js` - IE8+ и другие браузеры +`history.ielte7.js` - IE6+ и другие браузеры + ### Для разработчиков библиотек: Для включения поддержки плагина HTML5-History-API polyfill в своих библиотеках, добавьте строку кода: diff --git a/bower.json b/bower.json index cc33fac..0759b47 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.1.15", + "version": "4.2.0", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 2584a06..6f3995f 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.1.15", + "version": "4.2.0", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.iegte8.min.js b/history.iegte8.min.js deleted file mode 100644 index 87ab313..0000000 --- a/history.iegte8.min.js +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * History API JavaScript Library v4.1.15 - * - * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other - * - * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) - * - * http://spb-piksel.ru/ - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * Update: 2014-10-31 21:58 - */ -(function(L){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",L):L()})(function(){var h=!0,i=null,o=!1;function M(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=j)}function F(){}function l(a,b,c){if(a!=i&&""!==a&&!b){var b=l(),d=g.getElementsByTagName("base")[0];!c&&d&&d.getAttribute("href")&&(d.href=d.href,b=l(d.href,i,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!q||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, -":")+"//"+f.host+k.basepath+a.replace(RegExp("^#[/]?(?:"+k.type+")?"),"");N.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(N.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",d=a[5]||"",e="#"===a[6]?"":a[6]||"",j=c+d+e,n=c.replace(RegExp("^"+k.basepath,"i"),k.type)+d;return{b:a[1]+"//"+b+j,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:d,a:e,c:j,j:n,f:n+e}}function Z(){var a;try{a=e.sessionStorage,a.setItem(y+"t","1"),a.removeItem(y+"t")}catch(b){a= -{getItem:function(a){a=g.cookie.split(a+"=");return 1 7)) { + // If it is not IE or a version greater than seven + return; + } + + // save original links to methods + var originalChangeState = changeState; + var originalRedefineProperty = redefineProperty; + var currentHref = parseURL()._href; + var iFrame = document.createElement('iframe'); + + // insert IFRAME element to DOM + iFrame.src = "javascript:true;"; + iFrame = documentElement.firstChild.appendChild(iFrame).contentWindow; + + // correction value for VB Script + global['execScript']( + 'Public history\nFunction VBCVal(o,r) If IsObject(o) Then Set r=o Else r=o End If End Function', + 'VBScript' + ); + + // renew standard object + locationObject = {"_": {get: locationDescriptors.toString}}; + historyObject = { + // properties to create an object in IE + "back": windowHistory.back, + "forward": windowHistory.forward, + "go": windowHistory.go, + "emulate": null, + "_": {get: function() { + return '[object History]'; + }} + }; + + JSON = { + /** + * Analogue of JSON.parse() + * + * @param value + * @returns {*} + */ + "parse": function(value) { + try { + return new Function('', 'return ' + value)(); + } catch(_e_) { + return null; + } + }, + /** + * Analogue of JSON.stringify() + * + * @param value + * @returns {*} + */ + "stringify": function(value) { + var n = (typeof value).charCodeAt(2); + return n === 114 ? quote(value) : n === 109 ? isFinite(value) ? String(value) : 'null' : n === 111 || n + === 108 ? String(value) : n === 106 ? !value ? 'null' : (function(isArray) { + var out = isArray ? '[' : '{'; + if (isArray) { + for(var i = 0; i < value.length; i++) { + out += (i == 0 ? "" : ",") + JSON.stringify(value[i]); + } + } else { + for(var k in value) { + if (value.hasOwnProperty(k)) { + out += (out.length == 1 ? "" : ",") + quote(k) + ":" + JSON.stringify(value[k]); + } + } + } + return out + (isArray ? ']' : '}'); + })(Object.prototype.toString.call(value) === '[object Array]') : 'void 0'; + } + }; + + /** + * Change the data of the current history for IE6+ + */ + changeState = function(state, url, replace, lastURLValue, lfirst) { + var iFrameDocument = iFrame.document; + // if not used implementation history.location + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; + // normalization url + var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); + isFireInitialState = false; + if (urlObject._relative === parseURL()._relative && !lfirst) { + if (state) { + stateStorage[windowLocation.href] = state; + } + return; + } + lastURL = lastURLValue; + if (replace) { + if (iFrame["lfirst"]) { + history.back(); + changeState(state, urlObject._href, 0, lastURLValue, 1); + } else { + windowLocation.replace("#" + urlObject._special); + } + } else if (urlObject._href != currentHref || lfirst) { + if (!iFrame['lfirst']) { + iFrame["lfirst"] = 1; + changeState(state, currentHref, 0, lastURLValue, 1); + } else if (lfirst) { + lfirst = 0; + state = stateStorage[windowLocation.href]; + } + iFrameDocument.open(); + iFrameDocument.write('\x3Cscript\x3Elfirst=1;parent.location.hash="' + + urlObject._special.replace(/"/g, '\\"') + '";\x3C/script\x3E'); + iFrameDocument.close(); + } + if (!lfirst && state) { + stateStorage[windowLocation.href] = state; + } + }; + + /** + * See original method + */ + redefineProperty = function(object, prop, descriptor, onWrapped) { + if (!originalRedefineProperty.apply(this, arguments)) { + if (object === locationObject) { + locationObject[prop] = descriptor; + } else if (object === historyObject) { + historyObject[prop] = descriptor; + if (prop === 'state') { + locationObject = createVBObjects(locationObject); + global.history = historyObject = createVBObjects(historyObject); + // hack for IE7 + global['execScript']('var history = window.history;', 'JavaScript'); + } + } else { + object[prop] = descriptor.get && descriptor.get(); + } + } + return object; + }; + + /** + * Tracking changes in the hash in the address bar + */ + var interval = setInterval(function() { + var href = parseURL()._href; + if (href != currentHref) { + var e = document.createEventObject(); + e.oldURL = currentHref; + e.newURL = currentHref = href; + e.type = 'hashchange'; + onHashChange(e); + } + }, 100); + + global['JSON'] = JSON; + } }); diff --git a/history.ielte7.min.js b/history.ielte7.min.js new file mode 100644 index 0000000..c971270 --- /dev/null +++ b/history.ielte7.min.js @@ -0,0 +1,35 @@ +/*! + * History API JavaScript Library v4.2.0 + * + * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other + * + * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * + * http://spb-piksel.ru/ + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Update: 2014-11-06 21:35 + */ +(function(Q){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",Q):Q()})(function(){var j=!0,k=null,n=!1;function R(a,b){var c=d.history!==o;c&&(d.history=o);a.apply(o,b);c&&(d.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),e=g.getElementsByTagName("base")[0];!c&&e&&e.getAttribute("href")&&(e.href=e.href,b=i(e.href,k,j));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, +":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",p=c+e+d,w=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:p,j:w,d:w+d}}function ba(){var a;try{a=d.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a= +{getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(q[f.href]=a)}};y=function(b,c, +f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON,f=d.location,o= +d.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",P=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a, +b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); +O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, +href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,d,aa, +l];H&&delete aa.state;for(var c=0;c 7)) { - // If it is not IE or a version greater than seven - return; - } - - // save original links to methods - var originalChangeState = changeState; - var originalRedefineProperty = redefineProperty; - var currentHref = parseURL()._href; - var iFrame = document.createElement('iframe'); - - // insert IFRAME element to DOM - iFrame.src = "javascript:true;"; - iFrame = documentElement.firstChild.appendChild(iFrame).contentWindow; - - // correction value for VB Script - global['execScript']( - 'Public history\nFunction VBCVal(o,r) If IsObject(o) Then Set r=o Else r=o End If End Function', - 'VBScript' - ); - - // renew standard object - locationObject = {"_": {get: locationDescriptors.toString}}; - historyObject = { - // properties to create an object in IE - "back": windowHistory.back, - "forward": windowHistory.forward, - "go": windowHistory.go, - "emulate": null, - "_": {get: function() { - return '[object History]'; - }} - }; - - JSON = { - /** - * Analogue of JSON.parse() - * - * @param value - * @returns {*} - */ - "parse": function(value) { - try { - return new Function('', 'return ' + value)(); - } catch(_e_) { - return null; - } - }, - /** - * Analogue of JSON.stringify() - * - * @param value - * @returns {*} - */ - "stringify": function(value) { - var n = (typeof value).charCodeAt(2); - return n === 114 ? quote(value) : n === 109 ? isFinite(value) ? String(value) : 'null' : n === 111 || n - === 108 ? String(value) : n === 106 ? !value ? 'null' : (function(isArray) { - var out = isArray ? '[' : '{'; - if (isArray) { - for(var i = 0; i < value.length; i++) { - out += (i == 0 ? "" : ",") + JSON.stringify(value[i]); - } - } else { - for(var k in value) { - if (value.hasOwnProperty(k)) { - out += (out.length == 1 ? "" : ",") + quote(k) + ":" + JSON.stringify(value[k]); - } - } - } - return out + (isArray ? ']' : '}'); - })(Object.prototype.toString.call(value) === '[object Array]') : 'void 0'; - } - }; - - /** - * Change the data of the current history for IE6+ - */ - changeState = function(state, url, replace, lastURLValue, lfirst) { - var iFrameDocument = iFrame.document; - // if not used implementation history.location - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; - // normalization url - var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); - isFireInitialState = false; - if (urlObject._relative === parseURL()._relative && !lfirst) { - if (state) { - stateStorage[windowLocation.href] = state; - } - return; - } - lastURL = lastURLValue; - if (replace) { - if (iFrame["lfirst"]) { - history.back(); - changeState(state, urlObject._href, 0, lastURLValue, 1); - } else { - windowLocation.replace("#" + urlObject._special); - } - } else if (urlObject._href != currentHref || lfirst) { - if (!iFrame['lfirst']) { - iFrame["lfirst"] = 1; - changeState(state, currentHref, 0, lastURLValue, 1); - } else if (lfirst) { - lfirst = 0; - state = stateStorage[windowLocation.href]; - } - iFrameDocument.open(); - iFrameDocument.write('\x3Cscript\x3Elfirst=1;parent.location.hash="' - + urlObject._special.replace(/"/g, '\\"') + '";\x3C/script\x3E'); - iFrameDocument.close(); - } - if (!lfirst && state) { - stateStorage[windowLocation.href] = state; - } - }; - - /** - * See original method - */ - redefineProperty = function(object, prop, descriptor, onWrapped) { - if (!originalRedefineProperty.apply(this, arguments)) { - if (object === locationObject) { - locationObject[prop] = descriptor; - } else if (object === historyObject) { - historyObject[prop] = descriptor; - if (prop === 'state') { - locationObject = createVBObjects(locationObject); - global.history = historyObject = createVBObjects(historyObject); - // hack for IE7 - global['execScript']('var history = window.history;', 'JavaScript'); - } - } else { - object[prop] = descriptor.get && descriptor.get(); - } - } - return object; - }; - - /** - * Tracking changes in the hash in the address bar - */ - var interval = setInterval(function() { - var href = parseURL()._href; - if (href != currentHref) { - var e = document.createEventObject(); - e.oldURL = currentHref; - e.newURL = currentHref = href; - e.type = 'hashchange'; - onHashChange(e); - } - }, 100); - - global['JSON'] = JSON; - } }); diff --git a/history.min.js b/history.min.js index dd16c00..4ac636d 100644 --- a/history.min.js +++ b/history.min.js @@ -1,7 +1,7 @@ /*! - * History API JavaScript Library v4.1.15 + * History API JavaScript Library v4.2.0 * - * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other + * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * @@ -11,25 +11,19 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-10-31 21:58 + * Update: 2014-11-06 21:35 */ -(function(Q){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",Q):Q()})(function(){var j=!0,k=null,n=!1;function R(a,b){var c=d.history!==o;c&&(d.history=o);a.apply(o,b);c&&(d.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),e=g.getElementsByTagName("base")[0];!c&&e&&e.getAttribute("href")&&(e.href=e.href,b=i(e.href,k,j));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, -":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",p=c+e+d,w=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:p,j:w,d:w+d}}function ba(){var a;try{a=d.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a= -{getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(q[f.href]=a)}};y=function(b,c, -f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON,f=d.location,o= -d.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",P=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a, -b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); -O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, -href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,d,aa, -l];H&&delete aa.state;for(var c=0;c Date: Fri, 22 May 2015 13:44:23 +0300 Subject: [PATCH 52/81] #73 Mismatched anonymous define() module because of #57 --- README.md | 2 ++ bower.json | 2 +- component.json | 2 +- history.ielte7.js | 24 +++++++++++++++++------- history.ielte7.min.js | 42 +++++++++++++++++++++--------------------- history.js | 24 +++++++++++++++++------- history.min.js | 34 +++++++++++++++++----------------- package.json | 2 +- 8 files changed, 77 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 26418fb..29341f6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ npm install html5-history-api ### Browser Support: `history.js` - IE8+ and other browsers + `history.ielte7.js` - IE6+ and other browsers ### For library developers: @@ -218,6 +219,7 @@ npm install html5-history-api ### Поддержка браузеров: `history.js` - IE8+ и другие браузеры + `history.ielte7.js` - IE6+ и другие браузеры ### Для разработчиков библиотек: diff --git a/bower.json b/bower.json index 0759b47..56edb55 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.0", + "version": "4.2.1", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 6f3995f..310d48f 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.0", + "version": "4.2.1", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index aad33a3..436c0d8 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,9 +1,9 @@ /*! - * History API JavaScript Library v4.2.0 + * History API JavaScript Library v4.2.1 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2015, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * @@ -11,15 +11,25 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-11-06 21:35 + * Update: 2015-05-22 13:02 */ (function(factory) { if (typeof define === 'function' && define['amd']) { - // https://github.com/devote/HTML5-History-API/issues/57#issuecomment-43133600 - define(typeof document !== "object" || document.readyState !== "loading" ? [] : "html5-history-api", factory); - } else { - factory(); + // https://github.com/devote/HTML5-History-API/issues/73 + var rndKey = '[history' + (new Date()).getTime() + ']'; + var onError = requirejs['onError']; + factory.toString = function() { + return rndKey; + }; + requirejs['onError'] = function(err) { + if (err.message.indexOf(rndKey) === -1) { + onError.call(requirejs, err); + } + }; + define([], factory); } + // execute anyway + factory(); })(function() { // Define global variable var global = (typeof window === 'object' ? window : this) || {}; diff --git a/history.ielte7.min.js b/history.ielte7.min.js index c971270..175fca6 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,9 +1,9 @@ /*! - * History API JavaScript Library v4.2.0 + * History API JavaScript Library v4.2.1 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2014, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2015, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * @@ -11,25 +11,25 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2014-11-06 21:35 + * Update: 2015-05-22 13:02 */ -(function(Q){"function"===typeof define&&define.amd?define("object"!==typeof document||"loading"!==document.readyState?[]:"html5-history-api",Q):Q()})(function(){var j=!0,k=null,n=!1;function R(a,b){var c=d.history!==o;c&&(d.history=o);a.apply(o,b);c&&(d.history=l)}function J(){}function i(a,b,c){if(a!=k&&""!==a&&!b){var b=i(),e=g.getElementsByTagName("base")[0];!c&&e&&e.getAttribute("href")&&(e.href=e.href,b=i(e.href,k,j));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!s||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/, -":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href),b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",p=c+e+d,w=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+p,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:p,j:w,d:w+d}}function ba(){var a;try{a=d.sessionStorage,a.setItem(E+"t","1"),a.removeItem(E+"t")}catch(b){a= -{getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(q[f.href]=a)}};y=function(b,c, -f,g){e.apply(this,arguments)||(b===r?r[c]=f:b===l?(l[c]=f,"state"===c&&(r=a(r),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=i().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,I=g.documentElement,F=d.Object,t=d.JSON,f=d.location,o= -d.history,l=o,O=o.pushState,Y=o.replaceState,s=!!O,H="state"in o,C=F.defineProperty,r=y({},"t")?{}:g.createElement("a"),x="",P=d.addEventListener?"addEventListener":(x="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},E="__historyAPI__",S=g.createElement("a"),A=f.href,V="",T=1,D=n,m=0,q={},z={},B=g.title,ha={onhashchange:k,onpopstate:k},aa={setup:function(a, -b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=i(k,n,j).c,e=f.pathname+f.search;s?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;B!=k&&(g.title=B); -O&&R(O,arguments);u(a,c);g.title=d;B=b},replaceState:function(a,b,c){var d=g.title;B!=k&&(g.title=B);delete q[f.href];Y&&R(Y,arguments);u(a,c,j);g.title=d;B=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return s?f:r}},state:{get:function(){return q[f.href]||k}}},M={assign:function(a){0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?u(k,a,j):f.replace(a)},toString:function(){return this.href}, -href:{get:function(){return i().a}},protocol:k,host:k,hostname:k,port:k,pathname:{get:function(){return i().e}},search:{get:function(){return i().f}},hash:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),n,A)},get:function(){return i().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(x+"hashchange",N,n);var b=[M,r,ha,d,aa, -l];H&&delete aa.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};A=function(b,c, +f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,o= +d.history,l=o,P=o.pushState,X=o.replaceState,t=!!P,J="state"in o,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent",Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Y],fa=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",R=g.createElement("a"),C=f.href,U="",S=1,F=n,m=0,r={},B={},D=g.title,ia={onhashchange:j,onpopstate:j},$={setup:function(a, +b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D); +P&&p(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];X&&p(X,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href}, +href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/,"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ha();w(z+"hashchange",O,n);var b=[N,s,ia,d,$,l]; +J&&delete $.state;for(var c=0;c Date: Sun, 26 Jul 2015 23:34:47 +0300 Subject: [PATCH 53/81] #75 commonJS support. Bump version to 4.2.2 --- LICENSE-MIT | 2 +- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 13 +++++++++---- history.ielte7.min.js | 42 +++++++++++++++++++++--------------------- history.js | 13 +++++++++---- history.min.js | 30 +++++++++++++++--------------- package.json | 2 +- 8 files changed, 58 insertions(+), 48 deletions(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index e59748e..7f96fb1 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License (MIT) -Copyright (c) 2010-2014 Dmitrii Pakhtinov +Copyright (c) 2010-2015 Dmitrii Pakhtinov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bower.json b/bower.json index 56edb55..0401820 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "history", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.1", + "version": "4.2.2", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 310d48f..4ab786a 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.1", + "version": "4.2.2", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index 436c0d8..221fd51 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.1 + * History API JavaScript Library v4.2.2 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-05-22 13:02 + * Update: 2015-06-26 23:22 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -28,8 +28,13 @@ }; define([], factory); } - // execute anyway - factory(); + // commonJS support + if (typeof exports === "object" && typeof module !== "undefined") { + module['exports'] = factory(); + } else { + // execute anyway + return factory(); + } })(function() { // Define global variable var global = (typeof window === 'object' ? window : this) || {}; diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 175fca6..a5b7f1f 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.1 + * History API JavaScript Library v4.2.2 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,25 +11,25 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-05-22 13:02 + * Update: 2015-06-26 23:22 */ -(function(p){if("function"===typeof define&&define.amd){var x="[history"+(new Date).getTime()+"]",k=requirejs.onError;p.toString=function(){return x};requirejs.onError=function(p){-1===p.message.indexOf(x)&&k.call(requirejs,p)};define([],p)}p()})(function(){var i=!0,j=null,n=!1;function p(a,b){var c=d.history!==o;c&&(d.history=o);a.apply(o,b);c&&(d.history=l)}function x(){}function k(a,b,c){if(a!=j&&""!==a&&!b){var b=k(),e=g.getElementsByTagName("base")[0];!c&&(e&&e.getAttribute("href"))&&(e.href=e.href,b=k(e.href, -j,i));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!t||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href),b=a[2]+(a[3]?":"+a[3]:""), -c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",q=c+e+d,y=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+q,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:q,j:y,d:y+d}}function aa(){var a;try{a=d.sessionStorage,a.setItem(G+"t","1"),a.removeItem(G+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};A=function(b,c, -f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,o= -d.history,l=o,P=o.pushState,X=o.replaceState,t=!!P,J="state"in o,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent",Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Y],fa=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",R=g.createElement("a"),C=f.href,U="",S=1,F=n,m=0,r={},B={},D=g.title,ia={onhashchange:j,onpopstate:j},$={setup:function(a, -b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D); -P&&p(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];X&&p(X,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href}, -href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/,"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ha();w(z+"hashchange",O,n);var b=[N,s,ia,d,$,l]; -J&&delete $.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(r[f.href]=a)}};A=function(b,c,f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b}; +setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,p=d.history,l=p,P=p.pushState,X=p.replaceState,t=!!P,J="state"in p,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent", +Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Y],da=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",R=g.createElement("a"),C=f.href,U="",S=1,F=n,m=0,r={},B={},D=g.title,ga={onhashchange:j,onpopstate:j},$={setup:function(a,b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c= +k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);P&&o(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];X&&o(X,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1); +d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/, +"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});fa();w(z+"hashchange",O,n);var b=[N,s,ga,d,$,l];J&&delete $.state;for(var c=0;c Date: Wed, 2 Sep 2015 11:08:23 -0400 Subject: [PATCH 54/81] Update bower.json Previous package name was "history" and it downloaded this instead: https://github.com/browserstate/history.js --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 0401820..ab9bdb2 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "history", + "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "version": "4.2.2", @@ -23,4 +23,4 @@ }, { "type": "MIT" }] -} \ No newline at end of file +} From 21520162a037e001796caf200dcc563627d069b6 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 9 Oct 2015 00:57:23 +0800 Subject: [PATCH 55/81] Update package.json Use `licenses` instead of unparsable license with multiple licenses :) --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 08f7789..6399bad 100644 --- a/package.json +++ b/package.json @@ -28,5 +28,8 @@ "devote" ], "author": "Dmitrii Pakhtinov", - "license": "GPL/MIT" + "licenses": [ + "GPL", + "MIT" + ] } From a9a1c7f778eee18647eaa1ea1f96765b6cb433bd Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Fri, 16 Oct 2015 11:22:57 +0300 Subject: [PATCH 56/81] Update readme --- README.md | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/README.md b/README.md index 29341f6..18fb442 100644 --- a/README.md +++ b/README.md @@ -185,19 +185,6 @@ Demo Site: http://history.spb-piksel.ru/ or http://devote.github.io/demos/histor Follow me on Twitter: https://twitter.com/DimaPakhtinov ------------------------------ -Want to thank you for my job? - -PayPal: spb.piksel@gmail.com - -WebMoney: -WMR: R258217300226 -WMZ: Z314183434448 - -Yandex.Money: 41001414127851 - -Alfa-Bank Card # 5486732005875430 - 11/15 - ------------------------------------------------------------------------------------------------------------- РУССКИЙ @@ -391,16 +378,3 @@ history.redirect(/* type = */ '/', /* basepath = */ '/pathtosite/'); Демо-сайт: http://history.spb-piksel.ru/ или http://devote.github.io/demos/history/ Я в Twitter: https://twitter.com/DimaPakhtinov - ------------------------------------ -Хочешь поблагодарить за мою работу? - -PayPal: spb.piksel@gmail.com - -WebMoney: -WMR: R258217300226 -WMZ: Z314183434448 - -Yandex.Money: 41001414127851 - -Alfa-Bank Card # 5486732005875430 - 11/15 From 0bd8d079369d7469ae5a7730d3c0b366ee7d779e Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Fri, 16 Oct 2015 11:58:31 +0300 Subject: [PATCH 57/81] Added origin polyfill. Bump version to 4.2.3 --- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 25 +++++++++++++++++++++++-- history.ielte7.min.js | 43 ++++++++++++++++++++++--------------------- history.js | 25 +++++++++++++++++++++++-- history.min.js | 29 +++++++++++++++-------------- package.json | 2 +- 7 files changed, 86 insertions(+), 42 deletions(-) diff --git a/bower.json b/bower.json index ab9bdb2..9c32cda 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.2", + "version": "4.2.3", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 4ab786a..51e017d 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.2", + "version": "4.2.3", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index 221fd51..3cd3af2 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.2 + * History API JavaScript Library v4.2.3 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-06-26 23:22 + * Update: 2015-10-16 11:23 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -100,6 +100,8 @@ var eventsList = {}; // stored last title var lastTitle = document.title; + // store a custom origin + var customOrigin; /** * Properties that will be replaced in the global @@ -294,6 +296,25 @@ toString: function() { return this.href; }, + /** + * Returns the current origin. + * + * @namespace history.location + */ + "origin": { + get: function() { + if (customOrigin !== void 0) { + return customOrigin; + } + if (!windowLocation.origin) { + return windowLocation.protocol + "//" + windowLocation.hostname + (windowLocation.port ? ':' + windowLocation.port: ''); + } + return windowLocation.origin; + }, + set: function(value) { + customOrigin = value; + } + }, /** * Returns the current page's location. * Can be set, to navigate to another page. diff --git a/history.ielte7.min.js b/history.ielte7.min.js index a5b7f1f..30c73de 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.2 + * History API JavaScript Library v4.2.3 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,25 +11,26 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-06-26 23:22 + * Update: 2015-10-16 11:23 */ (function(o){if("function"===typeof define&&define.amd){var x="[history"+(new Date).getTime()+"]",k=requirejs.onError;o.toString=function(){return x};requirejs.onError=function(o){-1===o.message.indexOf(x)&&k.call(requirejs,o)};define([],o)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=o();else return o()})(function(){var i=!0,j=null,n=!1;function o(a,b){var c=d.history!==p;c&&(d.history=p);a.apply(p,b);c&&(d.history=l)}function x(){}function k(a,b,c){if(a!=j&&""!==a&&!b){var b=k(),e=g.getElementsByTagName("base")[0]; -!c&&e&&e.getAttribute("href")&&(e.href=e.href,b=k(e.href,j,i));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!t||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",q=c+e+d,y=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+q,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:q,j:y,d:y+d}}function aa(){var a;try{a=d.sessionStorage,a.setItem(G+"t","1"),a.removeItem(G+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(r[f.href]=a)}};A=function(b,c,f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b}; -setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,p=d.history,l=p,P=p.pushState,X=p.replaceState,t=!!P,J="state"in p,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent", -Y=d.removeEventListener?"removeEventListener":"detachEvent",Z=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Y],da=d[Z],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",R=g.createElement("a"),C=f.href,U="",S=1,F=n,m=0,r={},B={},D=g.title,ga={onhashchange:j,onpopstate:j},$={setup:function(a,b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c= -k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);P&&o(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];X&&o(X,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1); -d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/, -"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});fa();w(z+"hashchange",O,n);var b=[N,s,ga,d,$,l];J&&delete $.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};A=function(b,c, +f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,p= +d.history,l=p,P=p.pushState,Y=p.replaceState,t=!!P,J="state"in p,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Z],ga=d[$],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",S=g.createElement("a"),C=f.href,V="",T=1,F=n,m=0,r={},B={},D=g.title,R,ja={onhashchange:j,onpopstate:j},aa={setup:function(a, +b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D); +P&&o(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];Y&&o(Y,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href}, +origin:{get:function(){return void 0!==R?R:!f.origin?f.protocol+"//"+f.hostname+(f.port?":"+f.port:""):f.origin},set:function(a){R=a}},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/,"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g, +function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ia();w(z+"hashchange",O,n);var b=[N,s,ja,d,aa,l];J&&delete aa.state;for(var c=0;c Date: Fri, 16 Oct 2015 22:28:19 +0300 Subject: [PATCH 58/81] fix origin in IE10-11. Bump version to 4.2.4 --- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 24 +++++++++++----------- history.ielte7.min.js | 46 +++++++++++++++++++++---------------------- history.js | 24 +++++++++++----------- history.min.js | 34 ++++++++++++++++---------------- package.json | 2 +- 7 files changed, 67 insertions(+), 67 deletions(-) diff --git a/bower.json b/bower.json index 9c32cda..ebdfcd0 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.3", + "version": "4.2.4", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 51e017d..20b159d 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.3", + "version": "4.2.4", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index 3cd3af2..6865c65 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.3 + * History API JavaScript Library v4.2.4 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-10-16 11:23 + * Update: 2015-10-16 22:16 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -229,7 +229,7 @@ }, get: function() { if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; - return isSupportHistoryAPI ? windowLocation : locationObject; + return locationObject; } }, /** @@ -260,7 +260,7 @@ * @namespace history.location */ assign: function(url) { - if (('' + url).indexOf('#') === 0) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { changeState(null, url); } else { windowLocation.assign(url); @@ -271,8 +271,8 @@ * * @namespace history.location */ - reload: function() { - windowLocation.reload(); + reload: function(flag) { + windowLocation.reload(flag); }, /** * Removes the current page from @@ -282,7 +282,7 @@ * @namespace history.location */ replace: function(url) { - if (('' + url).indexOf('#') === 0) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { changeState(null, url, true); } else { windowLocation.replace(url); @@ -321,7 +321,7 @@ * * @namespace history.location */ - "href": { + "href": isSupportHistoryAPI ? null : { get: function() { return parseURL()._href; } @@ -355,7 +355,7 @@ * * @namespace history.location */ - "pathname": { + "pathname": isSupportHistoryAPI ? null : { get: function() { return parseURL()._pathname; } @@ -367,7 +367,7 @@ * * @namespace history.location */ - "search": { + "search": isSupportHistoryAPI ? null : { get: function() { return parseURL()._search; } @@ -379,7 +379,7 @@ * * @namespace history.location */ - "hash": { + "hash": isSupportHistoryAPI ? null : { set: function(value) { changeState(null, ('' + value).replace(/^(#|)/, '#'), false, lastURL); }, @@ -991,7 +991,7 @@ for(var i = 0; i < data.length; i += 2) { for(var prop in data[i]) { if (data[i].hasOwnProperty(prop)) { - if (typeof data[i][prop] === 'function') { + if (typeof data[i][prop] !== 'object') { // If the descriptor is a simple function, simply just assign it an object data[i + 1][prop] = data[i][prop]; } else { diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 30c73de..ea94ed7 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.3 + * History API JavaScript Library v4.2.4 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,26 +11,26 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-10-16 11:23 + * Update: 2015-10-16 22:16 */ -(function(o){if("function"===typeof define&&define.amd){var x="[history"+(new Date).getTime()+"]",k=requirejs.onError;o.toString=function(){return x};requirejs.onError=function(o){-1===o.message.indexOf(x)&&k.call(requirejs,o)};define([],o)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=o();else return o()})(function(){var i=!0,j=null,n=!1;function o(a,b){var c=d.history!==p;c&&(d.history=p);a.apply(p,b);c&&(d.history=l)}function x(){}function k(a,b,c){if(a!=j&&""!==a&&!b){var b=k(),e=g.getElementsByTagName("base")[0]; -!c&&(e&&e.getAttribute("href"))&&(e.href=e.href,b=k(e.href,j,i));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!t||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",q=c+e+d,y=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+q,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:q,j:y,d:y+d}}function ba(){var a;try{a=d.sessionStorage,a.setItem(G+"t","1"),a.removeItem(G+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!e&&a&&(r[f.href]=a)}};A=function(b,c, -f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===l?(l[c]=f,"state"===c&&(s=a(s),d.history=l=a(l),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b};setInterval(function(){var a=k().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);d.JSON=u}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,H=d.Object,u=d.JSON,f=d.location,p= -d.history,l=p,P=p.pushState,Y=p.replaceState,t=!!P,J="state"in p,E=H.defineProperty,s=A({},"t")?{}:g.createElement("a"),z="",Q=d.addEventListener?"addEventListener":(z="on")&&"attachEvent",Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",w=d[Q],M=d[Z],ga=d[$],h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",S=g.createElement("a"),C=f.href,V="",T=1,F=n,m=0,r={},B={},D=g.title,R,ja={onhashchange:j,onpopstate:j},aa={setup:function(a, -b,c){h.basepath=(""+(a==j?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==j?h.type:b;h.redirect=c==j?h.redirect:!!c},redirect:function(a,b){l.setup(b,a);b=h.basepath;if(d.top==d.self){var c=k(j,n,i).c,e=f.pathname+f.search;t?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;D!=j&&(g.title=D); -P&&o(P,arguments);v(a,c);g.title=d;D=b},replaceState:function(a,b,c){var d=g.title;D!=j&&(g.title=D);delete r[f.href];Y&&o(Y,arguments);v(a,c,i);g.title=d;D=b},location:{set:function(a){0===m&&(m=1);d.location=a},get:function(){0===m&&(m=1);return t?f:s}},state:{get:function(){return r[f.href]||j}}},N={assign:function(a){0===(""+a).indexOf("#")?v(j,a):f.assign(a)},reload:function(){f.reload()},replace:function(a){0===(""+a).indexOf("#")?v(j,a,i):f.replace(a)},toString:function(){return this.href}, -origin:{get:function(){return void 0!==R?R:!f.origin?f.protocol+"//"+f.hostname+(f.port?":"+f.port:""):f.origin},set:function(a){R=a}},href:{get:function(){return k().a}},protocol:j,host:j,hostname:j,port:j,pathname:{get:function(){return k().e}},search:{get:function(){return k().f}},hash:{set:function(a){v(j,(""+a).replace(/^(#|)/,"#"),n,C)},get:function(){return k().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g, -function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ia();w(z+"hashchange",O,n);var b=[N,s,ja,d,aa,l];J&&delete aa.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(r[f.href]=a)}};z=function(b,c,f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===m?(m[c]=f,"state"===c&&(s=a(s),d.history=m=a(m),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b}; +setInterval(function(){var a=l().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,J=g.documentElement,G=d.Object,t=d.JSON,f=d.location,q=d.history,m=q,O=q.pushState,Y=q.replaceState,j=!!O,I="state"in q,D=G.defineProperty,s=z({},"t")?{}:g.createElement("a"),y="",P=d.addEventListener?"addEventListener":(y="on")&&"attachEvent", +Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},F="__historyAPI__",R=g.createElement("a"),B=f.href,V="",T=1,E=o,n=0,r={},A={},C=g.title,Q,ha={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){m.setup(b,a);b=h.basepath;if(d.top==d.self){var c= +l(k,o,i).c,e=f.pathname+f.search;j?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;C!=k&&(g.title=C);O&&p(O,arguments);u(a,c);g.title=d;C=b},replaceState:function(a,b,c){var d=g.title;C!=k&&(g.title=C);delete r[f.href];Y&&p(Y,arguments);u(a,c,i);g.title=d;C=b},location:{set:function(a){0===n&&(n=1); +d.location=a},get:function(){0===n&&(n=1);return s}},state:{get:function(){return r[f.href]||k}}},M={assign:function(a){!j&&0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(a){f.reload(a)},replace:function(a){!j&&0===(""+a).indexOf("#")?u(k,a,i):f.replace(a)},toString:function(){return this.href},origin:{get:function(){return void 0!==Q?Q:!f.origin?f.protocol+"//"+f.hostname+(f.port?":"+f.port:""):f.origin},set:function(a){Q=a}},href:j?k:{get:function(){return l().a}},protocol:k,host:k, +hostname:k,port:k,pathname:j?k:{get:function(){return l().e}},search:j?k:{get:function(){return l().f}},hash:j?k:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),o,B)},get:function(){return l().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(y+"hashchange",N,o);var b=[M,s,ha,d,aa,m];I&&delete aa.state;for(var c=0;c Date: Wed, 28 Oct 2015 15:58:11 +0300 Subject: [PATCH 59/81] #79 fixed license name --- component.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/component.json b/component.json index 20b159d..5f1c42b 100644 --- a/component.json +++ b/component.json @@ -19,5 +19,5 @@ "devote" ], "author": "Dmitrii Pakhtinov", - "license": "GPL/MIT" + "license": "GPL3/MIT" } diff --git a/package.json b/package.json index 5fb961c..fd1b0c8 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ ], "author": "Dmitrii Pakhtinov", "licenses": [ - "GPL", + "GPL3", "MIT" ] } From 23c45203f8b01ab97d1c4df2dc8d2526da5cd074 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Wed, 28 Oct 2015 16:39:51 +0300 Subject: [PATCH 60/81] #79 fixed license name again --- bower.json | 2 +- component.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index ebdfcd0..3c8624a 100644 --- a/bower.json +++ b/bower.json @@ -19,7 +19,7 @@ "url": "http://spb-piksel.ru" }, "licenses": [{ - "type": "GPL3" + "type": "GPL-3.0" }, { "type": "MIT" }] diff --git a/component.json b/component.json index 5f1c42b..bc73384 100644 --- a/component.json +++ b/component.json @@ -19,5 +19,5 @@ "devote" ], "author": "Dmitrii Pakhtinov", - "license": "GPL3/MIT" + "license": "GPL-3.0/MIT" } diff --git a/package.json b/package.json index fd1b0c8..bcdf672 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ ], "author": "Dmitrii Pakhtinov", "licenses": [ - "GPL3", + "GPL-3.0", "MIT" ] } From eda389e1bff94934670760d2d8b7a25306978e47 Mon Sep 17 00:00:00 2001 From: pazams Date: Tue, 15 Dec 2015 01:20:35 +0200 Subject: [PATCH 61/81] detect history API support as modernizer does --- history.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/history.js b/history.js index 9f14533..44cf498 100644 --- a/history.js +++ b/history.js @@ -59,7 +59,7 @@ // symlink to method 'history.replaceState' var historyReplaceState = windowHistory.replaceState; // if the browser supports HTML5-History-API - var isSupportHistoryAPI = !!historyPushState; + var isSupportHistoryAPI = isSupportHistoryAPIDetect(); // verifies the presence of an object 'state' in interface 'History' var isSupportStateObjectInHistory = 'state' in windowHistory; // symlink to method 'Object.defineProperty' @@ -471,6 +471,29 @@ } } + /** + * Detect HistoryAPI support while taking into account false positives. + * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + */ + function isSupportHistoryAPIDetect(){ + + var ua = global.navigator.userAgent; + + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). + if ((ua.indexOf('Android 2.') !== -1 || + (ua.indexOf('Android 4.0') !== -1)) && + ua.indexOf('Mobile Safari') !== -1 && + ua.indexOf('Chrome') === -1 && + ua.indexOf('Windows Phone') === -1) { + return false; + } + + // Return the regular check + return (window.history && 'pushState' in window.history); + + } + /** * Initializing storage for the custom state's object */ From b55956f921acf27ec4291e694ebf0e545b91810d Mon Sep 17 00:00:00 2001 From: pazams Date: Thu, 17 Dec 2015 22:17:24 +0200 Subject: [PATCH 62/81] in isSupportHistoryAPIDetect() use local variable historyPushState --- history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history.js b/history.js index 44cf498..b9fb70d 100644 --- a/history.js +++ b/history.js @@ -490,7 +490,7 @@ } // Return the regular check - return (window.history && 'pushState' in window.history); + return !!historyPushState; } From 39ba3fc4490e48b82a39e79abfd4dcbeb19313da Mon Sep 17 00:00:00 2001 From: pazams Date: Thu, 17 Dec 2015 22:46:49 +0200 Subject: [PATCH 63/81] detect history API support as modernizer does - also in history.ielte7.js --- history.ielte7.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/history.ielte7.js b/history.ielte7.js index 6865c65..e14f870 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -59,7 +59,7 @@ // symlink to method 'history.replaceState' var historyReplaceState = windowHistory.replaceState; // if the browser supports HTML5-History-API - var isSupportHistoryAPI = !!historyPushState; + var isSupportHistoryAPI = isSupportHistoryAPIDetect(); // verifies the presence of an object 'state' in interface 'History' var isSupportStateObjectInHistory = 'state' in windowHistory; // symlink to method 'Object.defineProperty' @@ -471,6 +471,29 @@ } } + /** + * Detect HistoryAPI support while taking into account false positives. + * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + */ + function isSupportHistoryAPIDetect(){ + + var ua = global.navigator.userAgent; + + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). + if ((ua.indexOf('Android 2.') !== -1 || + (ua.indexOf('Android 4.0') !== -1)) && + ua.indexOf('Mobile Safari') !== -1 && + ua.indexOf('Chrome') === -1 && + ua.indexOf('Windows Phone') === -1) { + return false; + } + + // Return the regular check + return !!historyPushState; + + } + /** * Initializing storage for the custom state's object */ From a50633b3ab853c4367da1ac0b8945a3ec120ed0b Mon Sep 17 00:00:00 2001 From: izhyvaiev Date: Fri, 18 Dec 2015 18:46:21 +0200 Subject: [PATCH 64/81] Fixed returning state as reference instead of copy. --- history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history.js b/history.js index 9f14533..d62d94a 100644 --- a/history.js +++ b/history.js @@ -240,7 +240,7 @@ */ "state": { get: function() { - return stateStorage[windowLocation.href] || null; + return typeof stateStorage[windowLocation.href] === 'object' ? JSON.parse(JSON.stringify(stateStorage[windowLocation.href])) : (stateStorage[windowLocation.href] || null); } } }; From b1a73c0b205e04d0a0425bb01db8dd4a56a58696 Mon Sep 17 00:00:00 2001 From: izhyvaiev Date: Tue, 22 Dec 2015 11:42:08 +0200 Subject: [PATCH 65/81] Changes added to ielte7 and changes to standard if syntax instead of short one. --- history.ielte7.js | 8 +++++++- history.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index 6865c65..553eac2 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -240,7 +240,13 @@ */ "state": { get: function() { - return stateStorage[windowLocation.href] || null; + if (typeof stateStorage[windowLocation.href] === 'object') { + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; + } else { + return null; + } } } }; diff --git a/history.js b/history.js index d62d94a..50265ff 100644 --- a/history.js +++ b/history.js @@ -240,7 +240,13 @@ */ "state": { get: function() { - return typeof stateStorage[windowLocation.href] === 'object' ? JSON.parse(JSON.stringify(stateStorage[windowLocation.href])) : (stateStorage[windowLocation.href] || null); + if (typeof stateStorage[windowLocation.href] === 'object') { + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; + } else { + return null; + } } } }; From 64b6489876c354a02a14a9f350237cd61f90fec6 Mon Sep 17 00:00:00 2001 From: izhyvaiev Date: Tue, 22 Dec 2015 11:44:33 +0200 Subject: [PATCH 66/81] changes formatting from tabs to spaces --- history.ielte7.js | 12 ++++++------ history.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index 553eac2..c4212f5 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -241,12 +241,12 @@ "state": { get: function() { if (typeof stateStorage[windowLocation.href] === 'object') { - return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); - } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { - return stateStorage[windowLocation.href]; - } else { - return null; - } + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; + } else { + return null; + } } } }; diff --git a/history.js b/history.js index 50265ff..36be6e2 100644 --- a/history.js +++ b/history.js @@ -241,12 +241,12 @@ "state": { get: function() { if (typeof stateStorage[windowLocation.href] === 'object') { - return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); - } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { - return stateStorage[windowLocation.href]; - } else { - return null; - } + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; + } else { + return null; + } } } }; From d38f4595d7aca1e9e439bde953800ea4c2fece13 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Tue, 22 Dec 2015 14:26:11 +0300 Subject: [PATCH 67/81] Reformat code --- history.ielte7.js | 2463 ++++++++++++++++++++++----------------------- history.js | 2001 ++++++++++++++++++------------------ 2 files changed, 2229 insertions(+), 2235 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index 9d10796..709109b 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -14,1344 +14,1341 @@ * Update: 2015-10-16 22:16 */ (function(factory) { - if (typeof define === 'function' && define['amd']) { - // https://github.com/devote/HTML5-History-API/issues/73 - var rndKey = '[history' + (new Date()).getTime() + ']'; - var onError = requirejs['onError']; - factory.toString = function() { - return rndKey; - }; - requirejs['onError'] = function(err) { - if (err.message.indexOf(rndKey) === -1) { - onError.call(requirejs, err); - } - }; - define([], factory); + if (typeof define === 'function' && define['amd']) { + // https://github.com/devote/HTML5-History-API/issues/73 + var rndKey = '[history' + (new Date()).getTime() + ']'; + var onError = requirejs['onError']; + factory.toString = function() { + return rndKey; + }; + requirejs['onError'] = function(err) { + if (err.message.indexOf(rndKey) === -1) { + onError.call(requirejs, err); + } + }; + define([], factory); + } + // commonJS support + if (typeof exports === "object" && typeof module !== "undefined") { + module['exports'] = factory(); + } else { + // execute anyway + return factory(); + } +})(function() { + // Define global variable + var global = (typeof window === 'object' ? window : this) || {}; + // Prevent the code from running if there is no window.history object or library already loaded + if (!global.history || "emulate" in global.history) return global.history; + // symlink to document + var document = global.document; + // HTML element + var documentElement = document.documentElement; + // symlink to constructor of Object + var Object = global['Object']; + // symlink to JSON Object + var JSON = global['JSON']; + // symlink to instance object of 'Location' + var windowLocation = global.location; + // symlink to instance object of 'History' + var windowHistory = global.history; + // new instance of 'History'. The default is a reference to the original object instance + var historyObject = windowHistory; + // symlink to method 'history.pushState' + var historyPushState = windowHistory.pushState; + // symlink to method 'history.replaceState' + var historyReplaceState = windowHistory.replaceState; + // if the browser supports HTML5-History-API + var isSupportHistoryAPI = isSupportHistoryAPIDetect(); + // verifies the presence of an object 'state' in interface 'History' + var isSupportStateObjectInHistory = 'state' in windowHistory; + // symlink to method 'Object.defineProperty' + var defineProperty = Object.defineProperty; + // new instance of 'Location', for IE8 will use the element HTMLAnchorElement, instead of pure object + var locationObject = redefineProperty({}, 't') ? {} : document.createElement('a'); + // prefix for the names of events + var eventNamePrefix = ''; + // String that will contain the name of the method + var addEventListenerName = global.addEventListener ? 'addEventListener' : (eventNamePrefix = 'on') && 'attachEvent'; + // String that will contain the name of the method + var removeEventListenerName = global.removeEventListener ? 'removeEventListener' : 'detachEvent'; + // String that will contain the name of the method + var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; + // reference native methods for the events + var addEvent = global[addEventListenerName]; + var removeEvent = global[removeEventListenerName]; + var dispatch = global[dispatchEventName]; + // default settings + var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; + // key for the sessionStorage + var sessionStorageKey = '__historyAPI__'; + // Anchor Element for parseURL function + var anchorElement = document.createElement('a'); + // last URL before change to new URL + var lastURL = windowLocation.href; + // Control URL, need to fix the bug in Opera + var checkUrlForPopState = ''; + // for fix on Safari 8 + var triggerEventsInWindowAttributes = 1; + // trigger event 'onpopstate' on page load + var isFireInitialState = false; + // if used history.location of other code + var isUsedHistoryLocationFlag = 0; + // store a list of 'state' objects in the current session + var stateStorage = {}; + // in this object will be stored custom handlers + var eventsList = {}; + // stored last title + var lastTitle = document.title; + // store a custom origin + var customOrigin; + + /** + * Properties that will be replaced in the global + * object 'window', to prevent conflicts + * + * @type {Object} + */ + var eventsDescriptors = { + "onhashchange": null, + "onpopstate": null + }; + + /** + * Fix for Chrome in iOS + * See https://github.com/devote/HTML5-History-API/issues/29 + */ + var fastFixChrome = function(method, args) { + var isNeedFix = global.history !== windowHistory; + if (isNeedFix) { + global.history = windowHistory; } - // commonJS support - if (typeof exports === "object" && typeof module !== "undefined") { - module['exports'] = factory(); - } else { - // execute anyway - return factory(); + method.apply(windowHistory, args); + if (isNeedFix) { + global.history = historyObject; } -})(function() { - // Define global variable - var global = (typeof window === 'object' ? window : this) || {}; - // Prevent the code from running if there is no window.history object or library already loaded - if (!global.history || "emulate" in global.history) return global.history; - // symlink to document - var document = global.document; - // HTML element - var documentElement = document.documentElement; - // symlink to constructor of Object - var Object = global['Object']; - // symlink to JSON Object - var JSON = global['JSON']; - // symlink to instance object of 'Location' - var windowLocation = global.location; - // symlink to instance object of 'History' - var windowHistory = global.history; - // new instance of 'History'. The default is a reference to the original object instance - var historyObject = windowHistory; - // symlink to method 'history.pushState' - var historyPushState = windowHistory.pushState; - // symlink to method 'history.replaceState' - var historyReplaceState = windowHistory.replaceState; - // if the browser supports HTML5-History-API - var isSupportHistoryAPI = isSupportHistoryAPIDetect(); - // verifies the presence of an object 'state' in interface 'History' - var isSupportStateObjectInHistory = 'state' in windowHistory; - // symlink to method 'Object.defineProperty' - var defineProperty = Object.defineProperty; - // new instance of 'Location', for IE8 will use the element HTMLAnchorElement, instead of pure object - var locationObject = redefineProperty({}, 't') ? {} : document.createElement('a'); - // prefix for the names of events - var eventNamePrefix = ''; - // String that will contain the name of the method - var addEventListenerName = global.addEventListener ? 'addEventListener' : (eventNamePrefix = 'on') && 'attachEvent'; - // String that will contain the name of the method - var removeEventListenerName = global.removeEventListener ? 'removeEventListener' : 'detachEvent'; - // String that will contain the name of the method - var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; - // reference native methods for the events - var addEvent = global[addEventListenerName]; - var removeEvent = global[removeEventListenerName]; - var dispatch = global[dispatchEventName]; - // default settings - var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; - // key for the sessionStorage - var sessionStorageKey = '__historyAPI__'; - // Anchor Element for parseURL function - var anchorElement = document.createElement('a'); - // last URL before change to new URL - var lastURL = windowLocation.href; - // Control URL, need to fix the bug in Opera - var checkUrlForPopState = ''; - // for fix on Safari 8 - var triggerEventsInWindowAttributes = 1; - // trigger event 'onpopstate' on page load - var isFireInitialState = false; - // if used history.location of other code - var isUsedHistoryLocationFlag = 0; - // store a list of 'state' objects in the current session - var stateStorage = {}; - // in this object will be stored custom handlers - var eventsList = {}; - // stored last title - var lastTitle = document.title; - // store a custom origin - var customOrigin; - + }; + + /** + * Properties that will be replaced/added to object + * 'window.history', includes the object 'history.location', + * for a complete the work with the URL address + * + * @type {Object} + */ + var historyDescriptors = { /** - * Properties that will be replaced in the global - * object 'window', to prevent conflicts + * Setting library initialization * - * @type {Object} + * @param {null|String} [basepath] The base path to the site; defaults to the root "/". + * @param {null|String} [type] Substitute the string after the anchor; by default "/". + * @param {null|Boolean} [redirect] Enable link translation. */ - var eventsDescriptors = { - "onhashchange": null, - "onpopstate": null - }; - + "setup": function(basepath, type, redirect) { + settings["basepath"] = ('' + (basepath == null ? settings["basepath"] : basepath)) + .replace(/(?:^|\/)[^\/]*$/, '/'); + settings["type"] = type == null ? settings["type"] : type; + settings["redirect"] = redirect == null ? settings["redirect"] : !!redirect; + }, /** - * Fix for Chrome in iOS - * See https://github.com/devote/HTML5-History-API/issues/29 + * @namespace history + * @param {String} [type] + * @param {String} [basepath] */ - var fastFixChrome = function(method, args) { - var isNeedFix = global.history !== windowHistory; - if (isNeedFix) { - global.history = windowHistory; - } - method.apply(windowHistory, args); - if (isNeedFix) { - global.history = historyObject; + "redirect": function(type, basepath) { + historyObject['setup'](basepath, type); + basepath = settings["basepath"]; + if (global.top == global.self) { + var relative = parseURL(null, false, true)._relative; + var path = windowLocation.pathname + windowLocation.search; + if (isSupportHistoryAPI) { + path = path.replace(/([^\/])$/, '$1/'); + if (relative != basepath && (new RegExp("^" + basepath + "$", "i")).test(path)) { + windowLocation.replace(relative); + } + } else if (path != basepath) { + path = path.replace(/([^\/])\?/, '$1/?'); + if ((new RegExp("^" + basepath, "i")).test(path)) { + windowLocation.replace(basepath + '#' + path. + replace(new RegExp("^" + basepath, "i"), settings["type"]) + windowLocation.hash); + } } - }; - + } + }, /** - * Properties that will be replaced/added to object - * 'window.history', includes the object 'history.location', - * for a complete the work with the URL address + * The method adds a state object entry + * to the history. * - * @type {Object} + * @namespace history + * @param {Object} state + * @param {string} title + * @param {string} [url] */ - var historyDescriptors = { - /** - * Setting library initialization - * - * @param {null|String} [basepath] The base path to the site; defaults to the root "/". - * @param {null|String} [type] Substitute the string after the anchor; by default "/". - * @param {null|Boolean} [redirect] Enable link translation. - */ - "setup": function(basepath, type, redirect) { - settings["basepath"] = ('' + (basepath == null ? settings["basepath"] : basepath)) - .replace(/(?:^|\/)[^\/]*$/, '/'); - settings["type"] = type == null ? settings["type"] : type; - settings["redirect"] = redirect == null ? settings["redirect"] : !!redirect; - }, - /** - * @namespace history - * @param {String} [type] - * @param {String} [basepath] - */ - "redirect": function(type, basepath) { - historyObject['setup'](basepath, type); - basepath = settings["basepath"]; - if (global.top == global.self) { - var relative = parseURL(null, false, true)._relative; - var path = windowLocation.pathname + windowLocation.search; - if (isSupportHistoryAPI) { - path = path.replace(/([^\/])$/, '$1/'); - if (relative != basepath && (new RegExp("^" + basepath + "$", "i")).test(path)) { - windowLocation.replace(relative); - } - } else if (path != basepath) { - path = path.replace(/([^\/])\?/, '$1/?'); - if ((new RegExp("^" + basepath, "i")).test(path)) { - windowLocation.replace(basepath + '#' + path. - replace(new RegExp("^" + basepath, "i"), settings["type"]) + windowLocation.hash); - } - } - } - }, - /** - * The method adds a state object entry - * to the history. - * - * @namespace history - * @param {Object} state - * @param {string} title - * @param {string} [url] - */ - pushState: function(state, title, url) { - var t = document.title; - if (lastTitle != null) { - document.title = lastTitle; - } - historyPushState && fastFixChrome(historyPushState, arguments); - changeState(state, url); - document.title = t; - lastTitle = title; - }, - /** - * The method updates the state object, - * title, and optionally the URL of the - * current entry in the history. - * - * @namespace history - * @param {Object} state - * @param {string} title - * @param {string} [url] - */ - replaceState: function(state, title, url) { - var t = document.title; - if (lastTitle != null) { - document.title = lastTitle; - } - delete stateStorage[windowLocation.href]; - historyReplaceState && fastFixChrome(historyReplaceState, arguments); - changeState(state, url, true); - document.title = t; - lastTitle = title; - }, - /** - * Object 'history.location' is similar to the - * object 'window.location', except that in - * HTML4 browsers it will behave a bit differently - * - * @namespace history - */ - "location": { - set: function(value) { - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; - global.location = value; - }, - get: function() { - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; - return locationObject; - } - }, - /** - * A state object is an object representing - * a user interface state. - * - * @namespace history - */ - "state": { - get: function() { - if (typeof stateStorage[windowLocation.href] === 'object') { - return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); - } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { - return stateStorage[windowLocation.href]; - } else { - return null; - } - } - } - }; - + pushState: function(state, title, url) { + var t = document.title; + if (lastTitle != null) { + document.title = lastTitle; + } + historyPushState && fastFixChrome(historyPushState, arguments); + changeState(state, url); + document.title = t; + lastTitle = title; + }, /** - * Properties for object 'history.location'. - * Object 'history.location' is similar to the - * object 'window.location', except that in - * HTML4 browsers it will behave a bit differently + * The method updates the state object, + * title, and optionally the URL of the + * current entry in the history. * - * @type {Object} + * @namespace history + * @param {Object} state + * @param {string} title + * @param {string} [url] */ - var locationDescriptors = { - /** - * Navigates to the given page. - * - * @namespace history.location - */ - assign: function(url) { - if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { - changeState(null, url); - } else { - windowLocation.assign(url); - } - }, - /** - * Reloads the current page. - * - * @namespace history.location - */ - reload: function(flag) { - windowLocation.reload(flag); - }, - /** - * Removes the current page from - * the session history and navigates - * to the given page. - * - * @namespace history.location - */ - replace: function(url) { - if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { - changeState(null, url, true); - } else { - windowLocation.replace(url); - } - }, - /** - * Returns the current page's location. - * - * @namespace history.location - */ - toString: function() { - return this.href; - }, - /** - * Returns the current origin. - * - * @namespace history.location - */ - "origin": { - get: function() { - if (customOrigin !== void 0) { - return customOrigin; - } - if (!windowLocation.origin) { - return windowLocation.protocol + "//" + windowLocation.hostname + (windowLocation.port ? ':' + windowLocation.port: ''); - } - return windowLocation.origin; - }, - set: function(value) { - customOrigin = value; - } - }, - /** - * Returns the current page's location. - * Can be set, to navigate to another page. - * - * @namespace history.location - */ - "href": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._href; - } - }, - /** - * Returns the current page's protocol. - * - * @namespace history.location - */ - "protocol": null, - /** - * Returns the current page's host and port number. - * - * @namespace history.location - */ - "host": null, - /** - * Returns the current page's host. - * - * @namespace history.location - */ - "hostname": null, - /** - * Returns the current page's port number. - * - * @namespace history.location - */ - "port": null, - /** - * Returns the current page's path only. - * - * @namespace history.location - */ - "pathname": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._pathname; - } - }, - /** - * Returns the current page's search - * string, beginning with the character - * '?' and to the symbol '#' - * - * @namespace history.location - */ - "search": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._search; - } - }, - /** - * Returns the current page's hash - * string, beginning with the character - * '#' and to the end line - * - * @namespace history.location - */ - "hash": isSupportHistoryAPI ? null : { - set: function(value) { - changeState(null, ('' + value).replace(/^(#|)/, '#'), false, lastURL); - }, - get: function() { - return parseURL()._hash; - } - } - }; - + replaceState: function(state, title, url) { + var t = document.title; + if (lastTitle != null) { + document.title = lastTitle; + } + delete stateStorage[windowLocation.href]; + historyReplaceState && fastFixChrome(historyReplaceState, arguments); + changeState(state, url, true); + document.title = t; + lastTitle = title; + }, /** - * Just empty function + * Object 'history.location' is similar to the + * object 'window.location', except that in + * HTML4 browsers it will behave a bit differently * - * @return void + * @namespace history */ - function emptyFunction() { - // dummy - } - + "location": { + set: function(value) { + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; + global.location = value; + }, + get: function() { + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; + return locationObject; + } + }, /** - * Prepares a parts of the current or specified reference for later use in the library + * A state object is an object representing + * a user interface state. * - * @param {string} [href] - * @param {boolean} [isWindowLocation] - * @param {boolean} [isNotAPI] - * @return {Object} + * @namespace history */ - function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; - if (href != null && href !== '' && !isWindowLocation) { - var current = parseURL(), - base = document.getElementsByTagName('base')[0]; - if (!isNotAPI && base && base.getAttribute('href')) { - // Fix for IE ignoring relative base tags. - // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer - base.href = base.href; - current = parseURL(base.href, null, true); - } - var _pathname = current._pathname, _protocol = current._protocol; - // convert to type of string - href = '' + href; - // convert relative link to the absolute - href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 - ? _protocol + href : href : _protocol + "//" + current._host + ( - href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 - ? _pathname + href : href.indexOf("#") === 0 - ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href - ); + "state": { + get: function() { + if (typeof stateStorage[windowLocation.href] === 'object') { + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; } else { - href = isWindowLocation ? href : windowLocation.href; - // if current browser not support History-API - if (!isSupportHistoryAPI || isNotAPI) { - // get hash fragment - href = href.replace(/^[^#]*/, '') || "#"; - // form the absolute link from the hash - // https://github.com/devote/HTML5-History-API/issues/50 - href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath'] - + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), ""); - } - } - // that would get rid of the links of the form: /../../ - anchorElement.href = href; - // decompose the link in parts - var result = re.exec(anchorElement.href); - // host name with the port number - var host = result[2] + (result[3] ? ':' + result[3] : ''); - // folder - var pathname = result[4] || '/'; - // the query string - var search = result[5] || ''; - // hash - var hash = result[6] === '#' ? '' : (result[6] || ''); - // relative link, no protocol, no host - var relative = pathname + search + hash; - // special links for set to hash-link, if browser not support History API - var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search; - // result - return { - _href: result[1] + '//' + host + relative, - _protocol: result[1], - _host: host, - _hostname: result[2], - _port: result[3] || '', - _pathname: pathname, - _search: search, - _hash: hash, - _relative: relative, - _nohash: nohash, - _special: nohash + hash + return null; } + } } - + }; + + /** + * Properties for object 'history.location'. + * Object 'history.location' is similar to the + * object 'window.location', except that in + * HTML4 browsers it will behave a bit differently + * + * @type {Object} + */ + var locationDescriptors = { /** - * Detect HistoryAPI support while taking into account false positives. - * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js - */ - function isSupportHistoryAPIDetect(){ - - var ua = global.navigator.userAgent; - - // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies - // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). - if ((ua.indexOf('Android 2.') !== -1 || - (ua.indexOf('Android 4.0') !== -1)) && - ua.indexOf('Mobile Safari') !== -1 && - ua.indexOf('Chrome') === -1 && - ua.indexOf('Windows Phone') === -1) { - return false; - } - - // Return the regular check - return !!historyPushState; - - } - - /** - * Initializing storage for the custom state's object - */ - function storageInitialize() { - var sessionStorage; - /** - * sessionStorage throws error when cookies are disabled - * Chrome content settings when running the site in a Facebook IFrame. - * see: https://github.com/devote/HTML5-History-API/issues/34 - * and: http://stackoverflow.com/a/12976988/669360 - */ - try { - sessionStorage = global['sessionStorage']; - sessionStorage.setItem(sessionStorageKey + 't', '1'); - sessionStorage.removeItem(sessionStorageKey + 't'); - } catch(_e_) { - sessionStorage = { - getItem: function(key) { - var cookie = document.cookie.split(key + "="); - return cookie.length > 1 && cookie.pop().split(";").shift() || 'null'; - }, - setItem: function(key, value) { - var state = {}; - // insert one current element to cookie - if (state[windowLocation.href] = historyObject.state) { - document.cookie = key + '=' + JSON.stringify(state); - } - } - } - } - - try { - // get cache from the storage in browser - stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {}; - } catch(_e_) { - stateStorage = {}; - } - - // hang up the event handler to event unload page - addEvent(eventNamePrefix + 'unload', function() { - // save current state's object - sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); - }, false); - } - - /** - * This method is implemented to override the built-in(native) - * properties in the browser, unfortunately some browsers are - * not allowed to override all the properties and even add. - * For this reason, this was written by a method that tries to - * do everything necessary to get the desired result. + * Navigates to the given page. * - * @param {Object} object The object in which will be overridden/added property - * @param {String} prop The property name to be overridden/added - * @param {Object} [descriptor] An object containing properties set/get - * @param {Function} [onWrapped] The function to be called when the wrapper is created - * @return {Object|Boolean} Returns an object on success, otherwise returns false + * @namespace history.location */ - function redefineProperty(object, prop, descriptor, onWrapped) { - var testOnly = 0; - // test only if descriptor is undefined - if (!descriptor) { - descriptor = {set: emptyFunction}; - testOnly = 1; - } - // variable will have a value of true the success of attempts to set descriptors - var isDefinedSetter = !descriptor.set; - var isDefinedGetter = !descriptor.get; - // for tests of attempts to set descriptors - var test = {configurable: true, set: function() { - isDefinedSetter = 1; - }, get: function() { - isDefinedGetter = 1; - }}; - - try { - // testing for the possibility of overriding/adding properties - defineProperty(object, prop, test); - // running the test - object[prop] = object[prop]; - // attempt to override property using the standard method - defineProperty(object, prop, descriptor); - } catch(_e_) { - } - - // If the variable 'isDefined' has a false value, it means that need to try other methods - if (!isDefinedSetter || !isDefinedGetter) { - // try to override/add the property, using deprecated functions - if (object.__defineGetter__) { - // testing for the possibility of overriding/adding properties - object.__defineGetter__(prop, test.get); - object.__defineSetter__(prop, test.set); - // running the test - object[prop] = object[prop]; - // attempt to override property using the deprecated functions - descriptor.get && object.__defineGetter__(prop, descriptor.get); - descriptor.set && object.__defineSetter__(prop, descriptor.set); - } - - // Browser refused to override the property, using the standard and deprecated methods - if (!isDefinedSetter || !isDefinedGetter) { - if (testOnly) { - return false; - } else if (object === global) { - // try override global properties - try { - // save original value from this property - var originalValue = object[prop]; - // set null to built-in(native) property - object[prop] = null; - } catch(_e_) { - } - // This rule for Internet Explorer 8 - if ('execScript' in global) { - /** - * to IE8 override the global properties using - * VBScript, declaring it in global scope with - * the same names. - */ - global['execScript']('Public ' + prop, 'VBScript'); - global['execScript']('var ' + prop + ';', 'JavaScript'); - } else { - try { - /** - * This hack allows to override a property - * with the set 'configurable: false', working - * in the hack 'Safari' to 'Mac' - */ - defineProperty(object, prop, {value: emptyFunction}); - } catch(_e_) { - if (prop === 'onpopstate') { - /** - * window.onpopstate fires twice in Safari 8.0. - * Block initial event on window.onpopstate - * See: https://github.com/devote/HTML5-History-API/issues/69 - */ - addEvent('popstate', descriptor = function() { - removeEvent('popstate', descriptor, false); - var onpopstate = object.onpopstate; - // cancel initial event on attribute handler - object.onpopstate = null; - setTimeout(function() { - // restore attribute value after short time - object.onpopstate = onpopstate; - }, 1); - }, false); - // cancel trigger events on attributes in object the window - triggerEventsInWindowAttributes = 0; - } - } - } - // set old value to new variable - object[prop] = originalValue; - - } else { - // the last stage of trying to override the property - try { - try { - // wrap the object in a new empty object - var temp = Object.create(object); - defineProperty(Object.getPrototypeOf(temp) === object ? temp : object, prop, descriptor); - for(var key in object) { - // need to bind a function to the original object - if (typeof object[key] === 'function') { - temp[key] = object[key].bind(object); - } - } - try { - // to run a function that will inform about what the object was to wrapped - onWrapped.call(temp, temp, object); - } catch(_e_) { - } - object = temp; - } catch(_e_) { - // sometimes works override simply by assigning the prototype property of the constructor - defineProperty(object.constructor.prototype, prop, descriptor); - } - } catch(_e_) { - // all methods have failed - return false; - } - } - } - } - - return object; - } - + assign: function(url) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { + changeState(null, url); + } else { + windowLocation.assign(url); + } + }, /** - * Adds the missing property in descriptor + * Reloads the current page. * - * @param {Object} object An object that stores values - * @param {String} prop Name of the property in the object - * @param {Object|null} descriptor Descriptor - * @return {Object} Returns the generated descriptor + * @namespace history.location */ - function prepareDescriptorsForObject(object, prop, descriptor) { - descriptor = descriptor || {}; - // the default for the object 'location' is the standard object 'window.location' - object = object === locationDescriptors ? windowLocation : object; - // setter for object properties - descriptor.set = (descriptor.set || function(value) { - object[prop] = value; - }); - // getter for object properties - descriptor.get = (descriptor.get || function() { - return object[prop]; - }); - return descriptor; - } - + reload: function(flag) { + windowLocation.reload(flag); + }, /** - * Wrapper for the methods 'addEventListener/attachEvent' in the context of the 'window' + * Removes the current page from + * the session history and navigates + * to the given page. * - * @param {String} event The event type for which the user is registering - * @param {Function} listener The method to be called when the event occurs. - * @param {Boolean} capture If true, capture indicates that the user wishes to initiate capture. - * @return void + * @namespace history.location */ - function addEventListener(event, listener, capture) { - if (event in eventsList) { - // here stored the event listeners 'popstate/hashchange' - eventsList[event].push(listener); - } else { - // FireFox support non-standart four argument aWantsUntrusted - // https://github.com/devote/HTML5-History-API/issues/13 - if (arguments.length > 3) { - addEvent(event, listener, capture, arguments[3]); - } else { - addEvent(event, listener, capture); - } - } - } - + replace: function(url) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { + changeState(null, url, true); + } else { + windowLocation.replace(url); + } + }, /** - * Wrapper for the methods 'removeEventListener/detachEvent' in the context of the 'window' + * Returns the current page's location. * - * @param {String} event The event type for which the user is registered - * @param {Function} listener The parameter indicates the Listener to be removed. - * @param {Boolean} capture Was registered as a capturing listener or not. - * @return void + * @namespace history.location */ - function removeEventListener(event, listener, capture) { - var list = eventsList[event]; - if (list) { - for(var i = list.length; i--;) { - if (list[i] === listener) { - list.splice(i, 1); - break; - } - } - } else { - removeEvent(event, listener, capture); - } - } - + toString: function() { + return this.href; + }, /** - * Wrapper for the methods 'dispatchEvent/fireEvent' in the context of the 'window' + * Returns the current origin. * - * @param {Event|String} event Instance of Event or event type string if 'eventObject' used - * @param {*} [eventObject] For Internet Explorer 8 required event object on this argument - * @return {Boolean} If 'preventDefault' was called the value is false, else the value is true. + * @namespace history.location */ - function dispatchEvent(event, eventObject) { - var eventType = ('' + (typeof event === "string" ? event : event.type)).replace(/^on/, ''); - var list = eventsList[eventType]; - if (list) { - // need to understand that there is one object of Event - eventObject = typeof event === "string" ? eventObject : event; - if (eventObject.target == null) { - // need to override some of the properties of the Event object - for(var props = ['target', 'currentTarget', 'srcElement', 'type']; event = props.pop();) { - // use 'redefineProperty' to override the properties - eventObject = redefineProperty(eventObject, event, { - get: event === 'type' ? function() { - return eventType; - } : function() { - return global; - } - }); - } - } - if (triggerEventsInWindowAttributes) { - // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context - ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) - || emptyFunction).call(global, eventObject); - } - // run other functions that are in the list of handlers - for(var i = 0, len = list.length; i < len; i++) { - list[i].call(global, eventObject); - } - return true; - } else { - return dispatch(event, eventObject); + "origin": { + get: function() { + if (customOrigin !== void 0) { + return customOrigin; } - } - + if (!windowLocation.origin) { + return windowLocation.protocol + "//" + windowLocation.hostname + (windowLocation.port ? ':' + windowLocation.port: ''); + } + return windowLocation.origin; + }, + set: function(value) { + customOrigin = value; + } + }, /** - * dispatch current state event + * Returns the current page's location. + * Can be set, to navigate to another page. + * + * @namespace history.location */ - function firePopState() { - var o = document.createEvent ? document.createEvent('Event') : document.createEventObject(); - if (o.initEvent) { - o.initEvent('popstate', false, false); - } else { - o.type = 'popstate'; - } - o.state = historyObject.state; - // send a newly created events to be processed - dispatchEvent(o); - } - + "href": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._href; + } + }, /** - * fire initial state for non-HTML5 browsers + * Returns the current page's protocol. + * + * @namespace history.location */ - function fireInitialState() { - if (isFireInitialState) { - isFireInitialState = false; - firePopState(); - } - } - + "protocol": null, /** - * Change the data of the current history for HTML4 browsers + * Returns the current page's host and port number. * - * @param {Object} state - * @param {string} [url] - * @param {Boolean} [replace] - * @param {string} [lastURLValue] - * @return void + * @namespace history.location */ - function changeState(state, url, replace, lastURLValue) { - if (!isSupportHistoryAPI) { - // if not used implementation history.location - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; - // normalization url - var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); - // if current url not equal new url - if (urlObject._relative !== parseURL()._relative) { - // if empty lastURLValue to skip hash change event - lastURL = lastURLValue; - if (replace) { - // only replace hash, not store to history - windowLocation.replace("#" + urlObject._special); - } else { - // change hash and add new record to history - windowLocation.hash = urlObject._special; - } - } - } else { - lastURL = windowLocation.href; - } - if (!isSupportStateObjectInHistory && state) { - stateStorage[windowLocation.href] = state; - } - isFireInitialState = false; - } - + "host": null, /** - * Event handler function changes the hash in the address bar + * Returns the current page's host. * - * @param {Event} event - * @return void + * @namespace history.location */ - function onHashChange(event) { - // https://github.com/devote/HTML5-History-API/issues/46 - var fireNow = lastURL; - // new value to lastURL - lastURL = windowLocation.href; - // if not empty fireNow, otherwise skipped the current handler event - if (fireNow) { - // if checkUrlForPopState equal current url, this means that the event was raised popstate browser - if (checkUrlForPopState !== windowLocation.href) { - // otherwise, - // the browser does not support popstate event or just does not run the event by changing the hash. - firePopState(); - } - // current event object - event = event || global.event; - - var oldURLObject = parseURL(fireNow, true); - var newURLObject = parseURL(); - // HTML4 browser not support properties oldURL/newURL - if (!event.oldURL) { - event.oldURL = oldURLObject._href; - event.newURL = newURLObject._href; - } - if (oldURLObject._hash !== newURLObject._hash) { - // if current hash not equal previous hash - dispatchEvent(event); - } - } - } - + "hostname": null, /** - * The event handler is fully loaded document + * Returns the current page's port number. * - * @param {*} [noScroll] - * @return void + * @namespace history.location */ - function onLoad(noScroll) { - // Get rid of the events popstate when the first loading a document in the webkit browsers - setTimeout(function() { - // hang up the event handler for the built-in popstate event in the browser - addEvent('popstate', function(e) { - // set the current url, that suppress the creation of the popstate event by changing the hash - checkUrlForPopState = windowLocation.href; - // for Safari browser in OS Windows not implemented 'state' object in 'History' interface - // and not implemented in old HTML4 browsers - if (!isSupportStateObjectInHistory) { - e = redefineProperty(e, 'state', {get: function() { - return historyObject.state; - }}); - } - // send events to be processed - dispatchEvent(e); - }, false); - }, 0); - // for non-HTML5 browsers - if (!isSupportHistoryAPI && noScroll !== true && "location" in historyObject) { - // scroll window to anchor element - scrollToAnchorId(locationObject.hash); - // fire initial state for non-HTML5 browser after load page - fireInitialState(); - } - } - + "port": null, /** - * Finds the closest ancestor anchor element (including the target itself). + * Returns the current page's path only. * - * @param {HTMLElement} target The element to start scanning from. - * @return {HTMLElement} An element which is the closest ancestor anchor. + * @namespace history.location */ - function anchorTarget(target) { - while (target) { - if (target.nodeName === 'A') return target; - target = target.parentNode; - } - } - + "pathname": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._pathname; + } + }, /** - * Handles anchor elements with a hash fragment for non-HTML5 browsers + * Returns the current page's search + * string, beginning with the character + * '?' and to the symbol '#' * - * @param {Event} e + * @namespace history.location */ - function onAnchorClick(e) { - var event = e || global.event; - var target = anchorTarget(event.target || event.srcElement); - var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; - if (target && target.nodeName === "A" && !defaultPrevented) { - var current = parseURL(); - var expect = parseURL(target.getAttribute("href", 2)); - var isEqualBaseURL = current._href.split('#').shift() === expect._href.split('#').shift(); - if (isEqualBaseURL && expect._hash) { - if (current._hash !== expect._hash) { - locationObject.hash = expect._hash; - } - scrollToAnchorId(expect._hash); - if (event.preventDefault) { - event.preventDefault(); - } else { - event.returnValue = false; - } - } - } - } - + "search": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._search; + } + }, /** - * Scroll page to current anchor in url-hash + * Returns the current page's hash + * string, beginning with the character + * '#' and to the end line * - * @param hash + * @namespace history.location */ - function scrollToAnchorId(hash) { - var target = document.getElementById(hash = (hash || '').replace(/^#/, '')); - if (target && target.id === hash && target.nodeName === "A") { - var rect = target.getBoundingClientRect(); - global.scrollTo((documentElement.scrollLeft || 0), rect.top + (documentElement.scrollTop || 0) - - (documentElement.clientTop || 0)); - } + "hash": isSupportHistoryAPI ? null : { + set: function(value) { + changeState(null, ('' + value).replace(/^(#|)/, '#'), false, lastURL); + }, + get: function() { + return parseURL()._hash; + } } - + }; + + /** + * Just empty function + * + * @return void + */ + function emptyFunction() { + // dummy + } + + /** + * Prepares a parts of the current or specified reference for later use in the library + * + * @param {string} [href] + * @param {boolean} [isWindowLocation] + * @param {boolean} [isNotAPI] + * @return {Object} + */ + function parseURL(href, isWindowLocation, isNotAPI) { + var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + if (href != null && href !== '' && !isWindowLocation) { + var current = parseURL(), + base = document.getElementsByTagName('base')[0]; + if (!isNotAPI && base && base.getAttribute('href')) { + // Fix for IE ignoring relative base tags. + // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer + base.href = base.href; + current = parseURL(base.href, null, true); + } + var _pathname = current._pathname, _protocol = current._protocol; + // convert to type of string + href = '' + href; + // convert relative link to the absolute + href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 + ? _protocol + href : href : _protocol + "//" + current._host + ( + href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 + ? _pathname + href : href.indexOf("#") === 0 + ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href + ); + } else { + href = isWindowLocation ? href : windowLocation.href; + // if current browser not support History-API + if (!isSupportHistoryAPI || isNotAPI) { + // get hash fragment + href = href.replace(/^[^#]*/, '') || "#"; + // form the absolute link from the hash + // https://github.com/devote/HTML5-History-API/issues/50 + href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath'] + + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), ""); + } + } + // that would get rid of the links of the form: /../../ + anchorElement.href = href; + // decompose the link in parts + var result = re.exec(anchorElement.href); + // host name with the port number + var host = result[2] + (result[3] ? ':' + result[3] : ''); + // folder + var pathname = result[4] || '/'; + // the query string + var search = result[5] || ''; + // hash + var hash = result[6] === '#' ? '' : (result[6] || ''); + // relative link, no protocol, no host + var relative = pathname + search + hash; + // special links for set to hash-link, if browser not support History API + var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search; + // result + return { + _href: result[1] + '//' + host + relative, + _protocol: result[1], + _host: host, + _hostname: result[2], + _port: result[3] || '', + _pathname: pathname, + _search: search, + _hash: hash, + _relative: relative, + _nohash: nohash, + _special: nohash + hash + } + } + + /** + * Detect HistoryAPI support while taking into account false positives. + * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + */ + function isSupportHistoryAPIDetect(){ + var ua = global.navigator.userAgent; + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). + if ((ua.indexOf('Android 2.') !== -1 || + (ua.indexOf('Android 4.0') !== -1)) && + ua.indexOf('Mobile Safari') !== -1 && + ua.indexOf('Chrome') === -1 && + ua.indexOf('Windows Phone') === -1) + { + return false; + } + // Return the regular check + return !!historyPushState; + } + + /** + * Initializing storage for the custom state's object + */ + function storageInitialize() { + var sessionStorage; /** - * Library initialization - * - * @return {Boolean} return true if all is well, otherwise return false value + * sessionStorage throws error when cookies are disabled + * Chrome content settings when running the site in a Facebook IFrame. + * see: https://github.com/devote/HTML5-History-API/issues/34 + * and: http://stackoverflow.com/a/12976988/669360 */ - function initialize() { - /** - * Get custom settings from the query string - */ - var scripts = document.getElementsByTagName('script'); - var src = (scripts[scripts.length - 1] || {}).src || ''; - var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : ''; - arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) { - settings[key] = (value || '').replace(/^(0|false)$/, ''); - }); - - /** - * Includes support for IE6+ - */ - ie6DriverStart(); - - /** - * hang up the event handler to listen to the events hashchange - */ - addEvent(eventNamePrefix + 'hashchange', onHashChange, false); - - // a list of objects with pairs of descriptors/object - var data = [locationDescriptors, locationObject, eventsDescriptors, global, historyDescriptors, historyObject]; - - // if browser support object 'state' in interface 'History' - if (isSupportStateObjectInHistory) { - // remove state property from descriptor - delete historyDescriptors['state']; + try { + sessionStorage = global['sessionStorage']; + sessionStorage.setItem(sessionStorageKey + 't', '1'); + sessionStorage.removeItem(sessionStorageKey + 't'); + } catch(_e_) { + sessionStorage = { + getItem: function(key) { + var cookie = document.cookie.split(key + "="); + return cookie.length > 1 && cookie.pop().split(";").shift() || 'null'; + }, + setItem: function(key, value) { + var state = {}; + // insert one current element to cookie + if (state[windowLocation.href] = historyObject.state) { + document.cookie = key + '=' + JSON.stringify(state); + } } + } + } - // initializing descriptors - for(var i = 0; i < data.length; i += 2) { - for(var prop in data[i]) { - if (data[i].hasOwnProperty(prop)) { - if (typeof data[i][prop] !== 'object') { - // If the descriptor is a simple function, simply just assign it an object - data[i + 1][prop] = data[i][prop]; - } else { - // prepare the descriptor the required format - var descriptor = prepareDescriptorsForObject(data[i], prop, data[i][prop]); - // try to set the descriptor object - if (!redefineProperty(data[i + 1], prop, descriptor, function(n, o) { - // is satisfied if the failed override property - if (o === historyObject) { - // the problem occurs in Safari on the Mac - global.history = historyObject = data[i + 1] = n; - } - })) { - // if there is no possibility override. - // This browser does not support descriptors, such as IE7 + try { + // get cache from the storage in browser + stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {}; + } catch(_e_) { + stateStorage = {}; + } - // remove previously hung event handlers - removeEvent(eventNamePrefix + 'hashchange', onHashChange, false); + // hang up the event handler to event unload page + addEvent(eventNamePrefix + 'unload', function() { + // save current state's object + sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); + }, false); + } + + /** + * This method is implemented to override the built-in(native) + * properties in the browser, unfortunately some browsers are + * not allowed to override all the properties and even add. + * For this reason, this was written by a method that tries to + * do everything necessary to get the desired result. + * + * @param {Object} object The object in which will be overridden/added property + * @param {String} prop The property name to be overridden/added + * @param {Object} [descriptor] An object containing properties set/get + * @param {Function} [onWrapped] The function to be called when the wrapper is created + * @return {Object|Boolean} Returns an object on success, otherwise returns false + */ + function redefineProperty(object, prop, descriptor, onWrapped) { + var testOnly = 0; + // test only if descriptor is undefined + if (!descriptor) { + descriptor = {set: emptyFunction}; + testOnly = 1; + } + // variable will have a value of true the success of attempts to set descriptors + var isDefinedSetter = !descriptor.set; + var isDefinedGetter = !descriptor.get; + // for tests of attempts to set descriptors + var test = {configurable: true, set: function() { + isDefinedSetter = 1; + }, get: function() { + isDefinedGetter = 1; + }}; + + try { + // testing for the possibility of overriding/adding properties + defineProperty(object, prop, test); + // running the test + object[prop] = object[prop]; + // attempt to override property using the standard method + defineProperty(object, prop, descriptor); + } catch(_e_) { + } - // fail to initialize :( - return false; - } + // If the variable 'isDefined' has a false value, it means that need to try other methods + if (!isDefinedSetter || !isDefinedGetter) { + // try to override/add the property, using deprecated functions + if (object.__defineGetter__) { + // testing for the possibility of overriding/adding properties + object.__defineGetter__(prop, test.get); + object.__defineSetter__(prop, test.set); + // running the test + object[prop] = object[prop]; + // attempt to override property using the deprecated functions + descriptor.get && object.__defineGetter__(prop, descriptor.get); + descriptor.set && object.__defineSetter__(prop, descriptor.set); + } + + // Browser refused to override the property, using the standard and deprecated methods + if (!isDefinedSetter || !isDefinedGetter) { + if (testOnly) { + return false; + } else if (object === global) { + // try override global properties + try { + // save original value from this property + var originalValue = object[prop]; + // set null to built-in(native) property + object[prop] = null; + } catch(_e_) { + } + // This rule for Internet Explorer 8 + if ('execScript' in global) { + /** + * to IE8 override the global properties using + * VBScript, declaring it in global scope with + * the same names. + */ + global['execScript']('Public ' + prop, 'VBScript'); + global['execScript']('var ' + prop + ';', 'JavaScript'); + } else { + try { + /** + * This hack allows to override a property + * with the set 'configurable: false', working + * in the hack 'Safari' to 'Mac' + */ + defineProperty(object, prop, {value: emptyFunction}); + } catch(_e_) { + if (prop === 'onpopstate') { + /** + * window.onpopstate fires twice in Safari 8.0. + * Block initial event on window.onpopstate + * See: https://github.com/devote/HTML5-History-API/issues/69 + */ + addEvent('popstate', descriptor = function() { + removeEvent('popstate', descriptor, false); + var onpopstate = object.onpopstate; + // cancel initial event on attribute handler + object.onpopstate = null; + setTimeout(function() { + // restore attribute value after short time + object.onpopstate = onpopstate; + }, 1); + }, false); + // cancel trigger events on attributes in object the window + triggerEventsInWindowAttributes = 0; + } + } + } + // set old value to new variable + object[prop] = originalValue; - // create a repository for custom handlers onpopstate/onhashchange - if (data[i + 1] === global) { - eventsList[prop] = eventsList[prop.substr(2)] = []; - } - } + } else { + // the last stage of trying to override the property + try { + try { + // wrap the object in a new empty object + var temp = Object.create(object); + defineProperty(Object.getPrototypeOf(temp) === object ? temp : object, prop, descriptor); + for(var key in object) { + // need to bind a function to the original object + if (typeof object[key] === 'function') { + temp[key] = object[key].bind(object); } + } + try { + // to run a function that will inform about what the object was to wrapped + onWrapped.call(temp, temp, object); + } catch(_e_) { + } + object = temp; + } catch(_e_) { + // sometimes works override simply by assigning the prototype property of the constructor + defineProperty(object.constructor.prototype, prop, descriptor); } + } catch(_e_) { + // all methods have failed + return false; + } } + } + } - // check settings - historyObject['setup'](); - - // redirect if necessary - if (settings['redirect']) { - historyObject['redirect'](); + return object; + } + + /** + * Adds the missing property in descriptor + * + * @param {Object} object An object that stores values + * @param {String} prop Name of the property in the object + * @param {Object|null} descriptor Descriptor + * @return {Object} Returns the generated descriptor + */ + function prepareDescriptorsForObject(object, prop, descriptor) { + descriptor = descriptor || {}; + // the default for the object 'location' is the standard object 'window.location' + object = object === locationDescriptors ? windowLocation : object; + // setter for object properties + descriptor.set = (descriptor.set || function(value) { + object[prop] = value; + }); + // getter for object properties + descriptor.get = (descriptor.get || function() { + return object[prop]; + }); + return descriptor; + } + + /** + * Wrapper for the methods 'addEventListener/attachEvent' in the context of the 'window' + * + * @param {String} event The event type for which the user is registering + * @param {Function} listener The method to be called when the event occurs. + * @param {Boolean} capture If true, capture indicates that the user wishes to initiate capture. + * @return void + */ + function addEventListener(event, listener, capture) { + if (event in eventsList) { + // here stored the event listeners 'popstate/hashchange' + eventsList[event].push(listener); + } else { + // FireFox support non-standart four argument aWantsUntrusted + // https://github.com/devote/HTML5-History-API/issues/13 + if (arguments.length > 3) { + addEvent(event, listener, capture, arguments[3]); + } else { + addEvent(event, listener, capture); + } + } + } + + /** + * Wrapper for the methods 'removeEventListener/detachEvent' in the context of the 'window' + * + * @param {String} event The event type for which the user is registered + * @param {Function} listener The parameter indicates the Listener to be removed. + * @param {Boolean} capture Was registered as a capturing listener or not. + * @return void + */ + function removeEventListener(event, listener, capture) { + var list = eventsList[event]; + if (list) { + for(var i = list.length; i--;) { + if (list[i] === listener) { + list.splice(i, 1); + break; } - - // initialize - if (settings["init"]) { - // You agree that you will use window.history.location instead window.location - isUsedHistoryLocationFlag = 1; + } + } else { + removeEvent(event, listener, capture); + } + } + + /** + * Wrapper for the methods 'dispatchEvent/fireEvent' in the context of the 'window' + * + * @param {Event|String} event Instance of Event or event type string if 'eventObject' used + * @param {*} [eventObject] For Internet Explorer 8 required event object on this argument + * @return {Boolean} If 'preventDefault' was called the value is false, else the value is true. + */ + function dispatchEvent(event, eventObject) { + var eventType = ('' + (typeof event === "string" ? event : event.type)).replace(/^on/, ''); + var list = eventsList[eventType]; + if (list) { + // need to understand that there is one object of Event + eventObject = typeof event === "string" ? eventObject : event; + if (eventObject.target == null) { + // need to override some of the properties of the Event object + for(var props = ['target', 'currentTarget', 'srcElement', 'type']; event = props.pop();) { + // use 'redefineProperty' to override the properties + eventObject = redefineProperty(eventObject, event, { + get: event === 'type' ? function() { + return eventType; + } : function() { + return global; + } + }); } - - // If browser does not support object 'state' in interface 'History' - if (!isSupportStateObjectInHistory && JSON) { - storageInitialize(); + } + if (triggerEventsInWindowAttributes) { + // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context + ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) + || emptyFunction).call(global, eventObject); + } + // run other functions that are in the list of handlers + for(var i = 0, len = list.length; i < len; i++) { + list[i].call(global, eventObject); + } + return true; + } else { + return dispatch(event, eventObject); + } + } + + /** + * dispatch current state event + */ + function firePopState() { + var o = document.createEvent ? document.createEvent('Event') : document.createEventObject(); + if (o.initEvent) { + o.initEvent('popstate', false, false); + } else { + o.type = 'popstate'; + } + o.state = historyObject.state; + // send a newly created events to be processed + dispatchEvent(o); + } + + /** + * fire initial state for non-HTML5 browsers + */ + function fireInitialState() { + if (isFireInitialState) { + isFireInitialState = false; + firePopState(); + } + } + + /** + * Change the data of the current history for HTML4 browsers + * + * @param {Object} state + * @param {string} [url] + * @param {Boolean} [replace] + * @param {string} [lastURLValue] + * @return void + */ + function changeState(state, url, replace, lastURLValue) { + if (!isSupportHistoryAPI) { + // if not used implementation history.location + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; + // normalization url + var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); + // if current url not equal new url + if (urlObject._relative !== parseURL()._relative) { + // if empty lastURLValue to skip hash change event + lastURL = lastURLValue; + if (replace) { + // only replace hash, not store to history + windowLocation.replace("#" + urlObject._special); + } else { + // change hash and add new record to history + windowLocation.hash = urlObject._special; } - - // track clicks on anchors - if (!isSupportHistoryAPI) { - document[addEventListenerName](eventNamePrefix + "click", onAnchorClick, false); + } + } else { + lastURL = windowLocation.href; + } + if (!isSupportStateObjectInHistory && state) { + stateStorage[windowLocation.href] = state; + } + isFireInitialState = false; + } + + /** + * Event handler function changes the hash in the address bar + * + * @param {Event} event + * @return void + */ + function onHashChange(event) { + // https://github.com/devote/HTML5-History-API/issues/46 + var fireNow = lastURL; + // new value to lastURL + lastURL = windowLocation.href; + // if not empty fireNow, otherwise skipped the current handler event + if (fireNow) { + // if checkUrlForPopState equal current url, this means that the event was raised popstate browser + if (checkUrlForPopState !== windowLocation.href) { + // otherwise, + // the browser does not support popstate event or just does not run the event by changing the hash. + firePopState(); + } + // current event object + event = event || global.event; + + var oldURLObject = parseURL(fireNow, true); + var newURLObject = parseURL(); + // HTML4 browser not support properties oldURL/newURL + if (!event.oldURL) { + event.oldURL = oldURLObject._href; + event.newURL = newURLObject._href; + } + if (oldURLObject._hash !== newURLObject._hash) { + // if current hash not equal previous hash + dispatchEvent(event); + } + } + } + + /** + * The event handler is fully loaded document + * + * @param {*} [noScroll] + * @return void + */ + function onLoad(noScroll) { + // Get rid of the events popstate when the first loading a document in the webkit browsers + setTimeout(function() { + // hang up the event handler for the built-in popstate event in the browser + addEvent('popstate', function(e) { + // set the current url, that suppress the creation of the popstate event by changing the hash + checkUrlForPopState = windowLocation.href; + // for Safari browser in OS Windows not implemented 'state' object in 'History' interface + // and not implemented in old HTML4 browsers + if (!isSupportStateObjectInHistory) { + e = redefineProperty(e, 'state', {get: function() { + return historyObject.state; + }}); } - - if (document.readyState === 'complete') { - onLoad(true); + // send events to be processed + dispatchEvent(e); + }, false); + }, 0); + // for non-HTML5 browsers + if (!isSupportHistoryAPI && noScroll !== true && "location" in historyObject) { + // scroll window to anchor element + scrollToAnchorId(locationObject.hash); + // fire initial state for non-HTML5 browser after load page + fireInitialState(); + } + } + + /** + * Finds the closest ancestor anchor element (including the target itself). + * + * @param {HTMLElement} target The element to start scanning from. + * @return {HTMLElement} An element which is the closest ancestor anchor. + */ + function anchorTarget(target) { + while (target) { + if (target.nodeName === 'A') return target; + target = target.parentNode; + } + } + + /** + * Handles anchor elements with a hash fragment for non-HTML5 browsers + * + * @param {Event} e + */ + function onAnchorClick(e) { + var event = e || global.event; + var target = anchorTarget(event.target || event.srcElement); + var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; + if (target && target.nodeName === "A" && !defaultPrevented) { + var current = parseURL(); + var expect = parseURL(target.getAttribute("href", 2)); + var isEqualBaseURL = current._href.split('#').shift() === expect._href.split('#').shift(); + if (isEqualBaseURL && expect._hash) { + if (current._hash !== expect._hash) { + locationObject.hash = expect._hash; + } + scrollToAnchorId(expect._hash); + if (event.preventDefault) { + event.preventDefault(); } else { - if (!isSupportHistoryAPI && parseURL()._relative !== settings["basepath"]) { - isFireInitialState = true; - } - /** - * Need to avoid triggering events popstate the initial page load. - * Hang handler popstate as will be fully loaded document that - * would prevent triggering event onpopstate - */ - addEvent(eventNamePrefix + 'load', onLoad, false); + event.returnValue = false; } - - // everything went well - return true; + } } - + } + + /** + * Scroll page to current anchor in url-hash + * + * @param hash + */ + function scrollToAnchorId(hash) { + var target = document.getElementById(hash = (hash || '').replace(/^#/, '')); + if (target && target.id === hash && target.nodeName === "A") { + var rect = target.getBoundingClientRect(); + global.scrollTo((documentElement.scrollLeft || 0), rect.top + (documentElement.scrollTop || 0) + - (documentElement.clientTop || 0)); + } + } + + /** + * Library initialization + * + * @return {Boolean} return true if all is well, otherwise return false value + */ + function initialize() { /** - * Starting the library + * Get custom settings from the query string */ - if (!initialize()) { - // if unable to initialize descriptors - // therefore quite old browser and there - // is no sense to continue to perform - return; - } + var scripts = document.getElementsByTagName('script'); + var src = (scripts[scripts.length - 1] || {}).src || ''; + var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : ''; + arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) { + settings[key] = (value || '').replace(/^(0|false)$/, ''); + }); /** - * If the property history.emulate will be true, - * this will be talking about what's going on - * emulation capabilities HTML5-History-API. - * Otherwise there is no emulation, ie the - * built-in browser capabilities. - * - * @type {boolean} - * @const + * Includes support for IE6+ */ - historyObject['emulate'] = !isSupportHistoryAPI; + ie6DriverStart(); /** - * Replace the original methods on the wrapper + * hang up the event handler to listen to the events hashchange */ - global[addEventListenerName] = addEventListener; - global[removeEventListenerName] = removeEventListener; - global[dispatchEventName] = dispatchEvent; + addEvent(eventNamePrefix + 'hashchange', onHashChange, false); - return historyObject; + // a list of objects with pairs of descriptors/object + var data = [locationDescriptors, locationObject, eventsDescriptors, global, historyDescriptors, historyObject]; - // ====================================================================================== // - // Driver for IE6+ or below - // ====================================================================================== // - function ie6DriverStart() { - /** - * Creates a static object - * - * @param object - * @returns {*} - */ - function createVBObjects(object) { - var properties = []; - var className = 'VBHistoryClass' + (new Date()).getTime() + msie++; - var staticClassParts = ["Class " + className]; - for(var prop in object) { - if (object.hasOwnProperty(prop)) { - var value = object[prop]; - if (value && (value.get || value.set)) { - if (value.get) { - staticClassParts.push( - 'Public ' + (prop === '_' ? 'Default ' : '') + 'Property Get [' + prop + ']', - 'Call VBCVal([(accessors)].[' + prop + '].get.call(me),[' + prop + '])', - 'End Property' - ); - } - if (value.set) { - staticClassParts.push('Public Property Let [' + prop + '](val)', - (value = 'Call [(accessors)].[' + prop + '].set.call(me,val)\nEnd Property'), - 'Public Property Set [' + prop + '](val)', value); - } - } else { - properties.push(prop); - staticClassParts.push('Public [' + prop + ']'); - } - } + // if browser support object 'state' in interface 'History' + if (isSupportStateObjectInHistory) { + // remove state property from descriptor + delete historyDescriptors['state']; + } + + // initializing descriptors + for(var i = 0; i < data.length; i += 2) { + for(var prop in data[i]) { + if (data[i].hasOwnProperty(prop)) { + if (typeof data[i][prop] !== 'object') { + // If the descriptor is a simple function, simply just assign it an object + data[i + 1][prop] = data[i][prop]; + } else { + // prepare the descriptor the required format + var descriptor = prepareDescriptorsForObject(data[i], prop, data[i][prop]); + // try to set the descriptor object + if (!redefineProperty(data[i + 1], prop, descriptor, function(n, o) { + // is satisfied if the failed override property + if (o === historyObject) { + // the problem occurs in Safari on the Mac + global.history = historyObject = data[i + 1] = n; + } + })) { + // if there is no possibility override. + // This browser does not support descriptors, such as IE7 + + // remove previously hung event handlers + removeEvent(eventNamePrefix + 'hashchange', onHashChange, false); + + // fail to initialize :( + return false; } - staticClassParts.push( - 'Private [(accessors)]', - 'Private Sub Class_Initialize()', - 'Set [(accessors)]=' + className + 'FactoryJS()', - 'End Sub', - 'End Class', - 'Function ' + className + 'Factory()', - 'Set ' + className + 'Factory=New ' + className, - 'End Function' - ); - global['execScript'](staticClassParts.join('\n'), 'VBScript'); - global[className + 'FactoryJS'] = function() { - return object; - }; - var result = global[className + 'Factory'](); - for(var i = 0; i < properties.length; i++) { - result[properties[i]] = object[properties[i]]; + + // create a repository for custom handlers onpopstate/onhashchange + if (data[i + 1] === global) { + eventsList[prop] = eventsList[prop.substr(2)] = []; } - return result; + } } + } + } - /** - * Escape special symbols - * - * @param string - * @returns {string} - */ - function quote(string) { - var escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - var meta = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\'}; - return escapable.test(string) ? '"' + string.replace(escapable, function(a) { - return a in meta ? meta[a] : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; - } + // check settings + historyObject['setup'](); - // testing IE browser - var msie = global['execScript'] && (global['execScript']('var documentMsie/*@cc_on =1@*/;', 'JavaScript'), global['documentMsie']); - if (!msie || (document.documentMode && document.documentMode > 7)) { - // If it is not IE or a version greater than seven - return; - } + // redirect if necessary + if (settings['redirect']) { + historyObject['redirect'](); + } - // save original links to methods - var originalChangeState = changeState; - var originalRedefineProperty = redefineProperty; - var currentHref = parseURL()._href; - var iFrame = document.createElement('iframe'); + // initialize + if (settings["init"]) { + // You agree that you will use window.history.location instead window.location + isUsedHistoryLocationFlag = 1; + } - // insert IFRAME element to DOM - iFrame.src = "javascript:true;"; - iFrame = documentElement.firstChild.appendChild(iFrame).contentWindow; + // If browser does not support object 'state' in interface 'History' + if (!isSupportStateObjectInHistory && JSON) { + storageInitialize(); + } - // correction value for VB Script - global['execScript']( - 'Public history\nFunction VBCVal(o,r) If IsObject(o) Then Set r=o Else r=o End If End Function', - 'VBScript' - ); + // track clicks on anchors + if (!isSupportHistoryAPI) { + document[addEventListenerName](eventNamePrefix + "click", onAnchorClick, false); + } - // renew standard object - locationObject = {"_": {get: locationDescriptors.toString}}; - historyObject = { - // properties to create an object in IE - "back": windowHistory.back, - "forward": windowHistory.forward, - "go": windowHistory.go, - "emulate": null, - "_": {get: function() { - return '[object History]'; - }} - }; + if (document.readyState === 'complete') { + onLoad(true); + } else { + if (!isSupportHistoryAPI && parseURL()._relative !== settings["basepath"]) { + isFireInitialState = true; + } + /** + * Need to avoid triggering events popstate the initial page load. + * Hang handler popstate as will be fully loaded document that + * would prevent triggering event onpopstate + */ + addEvent(eventNamePrefix + 'load', onLoad, false); + } - JSON = { - /** - * Analogue of JSON.parse() - * - * @param value - * @returns {*} - */ - "parse": function(value) { - try { - return new Function('', 'return ' + value)(); - } catch(_e_) { - return null; - } - }, - /** - * Analogue of JSON.stringify() - * - * @param value - * @returns {*} - */ - "stringify": function(value) { - var n = (typeof value).charCodeAt(2); - return n === 114 ? quote(value) : n === 109 ? isFinite(value) ? String(value) : 'null' : n === 111 || n - === 108 ? String(value) : n === 106 ? !value ? 'null' : (function(isArray) { - var out = isArray ? '[' : '{'; - if (isArray) { - for(var i = 0; i < value.length; i++) { - out += (i == 0 ? "" : ",") + JSON.stringify(value[i]); - } - } else { - for(var k in value) { - if (value.hasOwnProperty(k)) { - out += (out.length == 1 ? "" : ",") + quote(k) + ":" + JSON.stringify(value[k]); - } - } - } - return out + (isArray ? ']' : '}'); - })(Object.prototype.toString.call(value) === '[object Array]') : 'void 0'; + // everything went well + return true; + } + + /** + * Starting the library + */ + if (!initialize()) { + // if unable to initialize descriptors + // therefore quite old browser and there + // is no sense to continue to perform + return; + } + + /** + * If the property history.emulate will be true, + * this will be talking about what's going on + * emulation capabilities HTML5-History-API. + * Otherwise there is no emulation, ie the + * built-in browser capabilities. + * + * @type {boolean} + * @const + */ + historyObject['emulate'] = !isSupportHistoryAPI; + + /** + * Replace the original methods on the wrapper + */ + global[addEventListenerName] = addEventListener; + global[removeEventListenerName] = removeEventListener; + global[dispatchEventName] = dispatchEvent; + + return historyObject; + + // ====================================================================================== // + // Driver for IE6+ or below + // ====================================================================================== // + function ie6DriverStart() { + /** + * Creates a static object + * + * @param object + * @returns {*} + */ + function createVBObjects(object) { + var properties = []; + var className = 'VBHistoryClass' + (new Date()).getTime() + msie++; + var staticClassParts = ["Class " + className]; + for(var prop in object) { + if (object.hasOwnProperty(prop)) { + var value = object[prop]; + if (value && (value.get || value.set)) { + if (value.get) { + staticClassParts.push( + 'Public ' + (prop === '_' ? 'Default ' : '') + 'Property Get [' + prop + ']', + 'Call VBCVal([(accessors)].[' + prop + '].get.call(me),[' + prop + '])', + 'End Property' + ); } - }; - - /** - * Change the data of the current history for IE6+ - */ - changeState = function(state, url, replace, lastURLValue, lfirst) { - var iFrameDocument = iFrame.document; - // if not used implementation history.location - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; - // normalization url - var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); - isFireInitialState = false; - if (urlObject._relative === parseURL()._relative && !lfirst) { - if (state) { - stateStorage[windowLocation.href] = state; - } - return; + if (value.set) { + staticClassParts.push('Public Property Let [' + prop + '](val)', + (value = 'Call [(accessors)].[' + prop + '].set.call(me,val)\nEnd Property'), + 'Public Property Set [' + prop + '](val)', value); } - lastURL = lastURLValue; - if (replace) { - if (iFrame["lfirst"]) { - history.back(); - changeState(state, urlObject._href, 0, lastURLValue, 1); - } else { - windowLocation.replace("#" + urlObject._special); - } - } else if (urlObject._href != currentHref || lfirst) { - if (!iFrame['lfirst']) { - iFrame["lfirst"] = 1; - changeState(state, currentHref, 0, lastURLValue, 1); - } else if (lfirst) { - lfirst = 0; - state = stateStorage[windowLocation.href]; - } - iFrameDocument.open(); - iFrameDocument.write('\x3Cscript\x3Elfirst=1;parent.location.hash="' - + urlObject._special.replace(/"/g, '\\"') + '";\x3C/script\x3E'); - iFrameDocument.close(); + } else { + properties.push(prop); + staticClassParts.push('Public [' + prop + ']'); + } + } + } + staticClassParts.push( + 'Private [(accessors)]', + 'Private Sub Class_Initialize()', + 'Set [(accessors)]=' + className + 'FactoryJS()', + 'End Sub', + 'End Class', + 'Function ' + className + 'Factory()', + 'Set ' + className + 'Factory=New ' + className, + 'End Function' + ); + global['execScript'](staticClassParts.join('\n'), 'VBScript'); + global[className + 'FactoryJS'] = function() { + return object; + }; + var result = global[className + 'Factory'](); + for(var i = 0; i < properties.length; i++) { + result[properties[i]] = object[properties[i]]; + } + return result; + } + + /** + * Escape special symbols + * + * @param string + * @returns {string} + */ + function quote(string) { + var escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + var meta = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\'}; + return escapable.test(string) ? '"' + string.replace(escapable, function(a) { + return a in meta ? meta[a] : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }) + '"' : '"' + string + '"'; + } + + // testing IE browser + var msie = global['execScript'] && (global['execScript']('var documentMsie/*@cc_on =1@*/;', 'JavaScript'), global['documentMsie']); + if (!msie || (document.documentMode && document.documentMode > 7)) { + // If it is not IE or a version greater than seven + return; + } + + // save original links to methods + var originalChangeState = changeState; + var originalRedefineProperty = redefineProperty; + var currentHref = parseURL()._href; + var iFrame = document.createElement('iframe'); + + // insert IFRAME element to DOM + iFrame.src = "javascript:true;"; + iFrame = documentElement.firstChild.appendChild(iFrame).contentWindow; + + // correction value for VB Script + global['execScript']( + 'Public history\nFunction VBCVal(o,r) If IsObject(o) Then Set r=o Else r=o End If End Function', + 'VBScript' + ); + + // renew standard object + locationObject = {"_": {get: locationDescriptors.toString}}; + historyObject = { + // properties to create an object in IE + "back": windowHistory.back, + "forward": windowHistory.forward, + "go": windowHistory.go, + "emulate": null, + "_": {get: function() { + return '[object History]'; + }} + }; + + JSON = { + /** + * Analogue of JSON.parse() + * + * @param value + * @returns {*} + */ + "parse": function(value) { + try { + return new Function('', 'return ' + value)(); + } catch(_e_) { + return null; + } + }, + /** + * Analogue of JSON.stringify() + * + * @param value + * @returns {*} + */ + "stringify": function(value) { + var n = (typeof value).charCodeAt(2); + return n === 114 ? quote(value) : n === 109 ? isFinite(value) ? String(value) : 'null' : n === 111 || n + === 108 ? String(value) : n === 106 ? !value ? 'null' : (function(isArray) { + var out = isArray ? '[' : '{'; + if (isArray) { + for(var i = 0; i < value.length; i++) { + out += (i == 0 ? "" : ",") + JSON.stringify(value[i]); } - if (!lfirst && state) { - stateStorage[windowLocation.href] = state; + } else { + for(var k in value) { + if (value.hasOwnProperty(k)) { + out += (out.length == 1 ? "" : ",") + quote(k) + ":" + JSON.stringify(value[k]); + } } - }; + } + return out + (isArray ? ']' : '}'); + })(Object.prototype.toString.call(value) === '[object Array]') : 'void 0'; + } + }; - /** - * See original method - */ - redefineProperty = function(object, prop, descriptor, onWrapped) { - if (!originalRedefineProperty.apply(this, arguments)) { - if (object === locationObject) { - locationObject[prop] = descriptor; - } else if (object === historyObject) { - historyObject[prop] = descriptor; - if (prop === 'state') { - locationObject = createVBObjects(locationObject); - global.history = historyObject = createVBObjects(historyObject); - // hack for IE7 - global['execScript']('var history = window.history;', 'JavaScript'); - } - } else { - object[prop] = descriptor.get && descriptor.get(); - } - } - return object; - }; + /** + * Change the data of the current history for IE6+ + */ + changeState = function(state, url, replace, lastURLValue, lfirst) { + var iFrameDocument = iFrame.document; + // if not used implementation history.location + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; + // normalization url + var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); + isFireInitialState = false; + if (urlObject._relative === parseURL()._relative && !lfirst) { + if (state) { + stateStorage[windowLocation.href] = state; + } + return; + } + lastURL = lastURLValue; + if (replace) { + if (iFrame["lfirst"]) { + history.back(); + changeState(state, urlObject._href, 0, lastURLValue, 1); + } else { + windowLocation.replace("#" + urlObject._special); + } + } else if (urlObject._href != currentHref || lfirst) { + if (!iFrame['lfirst']) { + iFrame["lfirst"] = 1; + changeState(state, currentHref, 0, lastURLValue, 1); + } else if (lfirst) { + lfirst = 0; + state = stateStorage[windowLocation.href]; + } + iFrameDocument.open(); + iFrameDocument.write('\x3Cscript\x3Elfirst=1;parent.location.hash="' + + urlObject._special.replace(/"/g, '\\"') + '";\x3C/script\x3E'); + iFrameDocument.close(); + } + if (!lfirst && state) { + stateStorage[windowLocation.href] = state; + } + }; - /** - * Tracking changes in the hash in the address bar - */ - var interval = setInterval(function() { - var href = parseURL()._href; - if (href != currentHref) { - var e = document.createEventObject(); - e.oldURL = currentHref; - e.newURL = currentHref = href; - e.type = 'hashchange'; - onHashChange(e); - } - }, 100); + /** + * See original method + */ + redefineProperty = function(object, prop, descriptor, onWrapped) { + if (!originalRedefineProperty.apply(this, arguments)) { + if (object === locationObject) { + locationObject[prop] = descriptor; + } else if (object === historyObject) { + historyObject[prop] = descriptor; + if (prop === 'state') { + locationObject = createVBObjects(locationObject); + global.history = historyObject = createVBObjects(historyObject); + // hack for IE7 + global['execScript']('var history = window.history;', 'JavaScript'); + } + } else { + object[prop] = descriptor.get && descriptor.get(); + } + } + return object; + }; - global['JSON'] = JSON; - } + /** + * Tracking changes in the hash in the address bar + */ + var interval = setInterval(function() { + var href = parseURL()._href; + if (href != currentHref) { + var e = document.createEventObject(); + e.oldURL = currentHref; + e.newURL = currentHref = href; + e.type = 'hashchange'; + onHashChange(e); + } + }, 100); + + global['JSON'] = JSON; + } }); diff --git a/history.js b/history.js index f683f32..13689ee 100644 --- a/history.js +++ b/history.js @@ -14,1110 +14,1107 @@ * Update: 2015-10-16 22:16 */ (function(factory) { - if (typeof define === 'function' && define['amd']) { - // https://github.com/devote/HTML5-History-API/issues/73 - var rndKey = '[history' + (new Date()).getTime() + ']'; - var onError = requirejs['onError']; - factory.toString = function() { - return rndKey; - }; - requirejs['onError'] = function(err) { - if (err.message.indexOf(rndKey) === -1) { - onError.call(requirejs, err); - } - }; - define([], factory); + if (typeof define === 'function' && define['amd']) { + // https://github.com/devote/HTML5-History-API/issues/73 + var rndKey = '[history' + (new Date()).getTime() + ']'; + var onError = requirejs['onError']; + factory.toString = function() { + return rndKey; + }; + requirejs['onError'] = function(err) { + if (err.message.indexOf(rndKey) === -1) { + onError.call(requirejs, err); + } + }; + define([], factory); + } + // commonJS support + if (typeof exports === "object" && typeof module !== "undefined") { + module['exports'] = factory(); + } else { + // execute anyway + return factory(); + } +})(function() { + // Define global variable + var global = (typeof window === 'object' ? window : this) || {}; + // Prevent the code from running if there is no window.history object or library already loaded + if (!global.history || "emulate" in global.history) return global.history; + // symlink to document + var document = global.document; + // HTML element + var documentElement = document.documentElement; + // symlink to constructor of Object + var Object = global['Object']; + // symlink to JSON Object + var JSON = global['JSON']; + // symlink to instance object of 'Location' + var windowLocation = global.location; + // symlink to instance object of 'History' + var windowHistory = global.history; + // new instance of 'History'. The default is a reference to the original object instance + var historyObject = windowHistory; + // symlink to method 'history.pushState' + var historyPushState = windowHistory.pushState; + // symlink to method 'history.replaceState' + var historyReplaceState = windowHistory.replaceState; + // if the browser supports HTML5-History-API + var isSupportHistoryAPI = isSupportHistoryAPIDetect(); + // verifies the presence of an object 'state' in interface 'History' + var isSupportStateObjectInHistory = 'state' in windowHistory; + // symlink to method 'Object.defineProperty' + var defineProperty = Object.defineProperty; + // new instance of 'Location', for IE8 will use the element HTMLAnchorElement, instead of pure object + var locationObject = redefineProperty({}, 't') ? {} : document.createElement('a'); + // prefix for the names of events + var eventNamePrefix = ''; + // String that will contain the name of the method + var addEventListenerName = global.addEventListener ? 'addEventListener' : (eventNamePrefix = 'on') && 'attachEvent'; + // String that will contain the name of the method + var removeEventListenerName = global.removeEventListener ? 'removeEventListener' : 'detachEvent'; + // String that will contain the name of the method + var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; + // reference native methods for the events + var addEvent = global[addEventListenerName]; + var removeEvent = global[removeEventListenerName]; + var dispatch = global[dispatchEventName]; + // default settings + var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; + // key for the sessionStorage + var sessionStorageKey = '__historyAPI__'; + // Anchor Element for parseURL function + var anchorElement = document.createElement('a'); + // last URL before change to new URL + var lastURL = windowLocation.href; + // Control URL, need to fix the bug in Opera + var checkUrlForPopState = ''; + // for fix on Safari 8 + var triggerEventsInWindowAttributes = 1; + // trigger event 'onpopstate' on page load + var isFireInitialState = false; + // if used history.location of other code + var isUsedHistoryLocationFlag = 0; + // store a list of 'state' objects in the current session + var stateStorage = {}; + // in this object will be stored custom handlers + var eventsList = {}; + // stored last title + var lastTitle = document.title; + // store a custom origin + var customOrigin; + + /** + * Properties that will be replaced in the global + * object 'window', to prevent conflicts + * + * @type {Object} + */ + var eventsDescriptors = { + "onhashchange": null, + "onpopstate": null + }; + + /** + * Fix for Chrome in iOS + * See https://github.com/devote/HTML5-History-API/issues/29 + */ + var fastFixChrome = function(method, args) { + var isNeedFix = global.history !== windowHistory; + if (isNeedFix) { + global.history = windowHistory; } - // commonJS support - if (typeof exports === "object" && typeof module !== "undefined") { - module['exports'] = factory(); - } else { - // execute anyway - return factory(); + method.apply(windowHistory, args); + if (isNeedFix) { + global.history = historyObject; } -})(function() { - // Define global variable - var global = (typeof window === 'object' ? window : this) || {}; - // Prevent the code from running if there is no window.history object or library already loaded - if (!global.history || "emulate" in global.history) return global.history; - // symlink to document - var document = global.document; - // HTML element - var documentElement = document.documentElement; - // symlink to constructor of Object - var Object = global['Object']; - // symlink to JSON Object - var JSON = global['JSON']; - // symlink to instance object of 'Location' - var windowLocation = global.location; - // symlink to instance object of 'History' - var windowHistory = global.history; - // new instance of 'History'. The default is a reference to the original object instance - var historyObject = windowHistory; - // symlink to method 'history.pushState' - var historyPushState = windowHistory.pushState; - // symlink to method 'history.replaceState' - var historyReplaceState = windowHistory.replaceState; - // if the browser supports HTML5-History-API - var isSupportHistoryAPI = isSupportHistoryAPIDetect(); - // verifies the presence of an object 'state' in interface 'History' - var isSupportStateObjectInHistory = 'state' in windowHistory; - // symlink to method 'Object.defineProperty' - var defineProperty = Object.defineProperty; - // new instance of 'Location', for IE8 will use the element HTMLAnchorElement, instead of pure object - var locationObject = redefineProperty({}, 't') ? {} : document.createElement('a'); - // prefix for the names of events - var eventNamePrefix = ''; - // String that will contain the name of the method - var addEventListenerName = global.addEventListener ? 'addEventListener' : (eventNamePrefix = 'on') && 'attachEvent'; - // String that will contain the name of the method - var removeEventListenerName = global.removeEventListener ? 'removeEventListener' : 'detachEvent'; - // String that will contain the name of the method - var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; - // reference native methods for the events - var addEvent = global[addEventListenerName]; - var removeEvent = global[removeEventListenerName]; - var dispatch = global[dispatchEventName]; - // default settings - var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; - // key for the sessionStorage - var sessionStorageKey = '__historyAPI__'; - // Anchor Element for parseURL function - var anchorElement = document.createElement('a'); - // last URL before change to new URL - var lastURL = windowLocation.href; - // Control URL, need to fix the bug in Opera - var checkUrlForPopState = ''; - // for fix on Safari 8 - var triggerEventsInWindowAttributes = 1; - // trigger event 'onpopstate' on page load - var isFireInitialState = false; - // if used history.location of other code - var isUsedHistoryLocationFlag = 0; - // store a list of 'state' objects in the current session - var stateStorage = {}; - // in this object will be stored custom handlers - var eventsList = {}; - // stored last title - var lastTitle = document.title; - // store a custom origin - var customOrigin; + }; + /** + * Properties that will be replaced/added to object + * 'window.history', includes the object 'history.location', + * for a complete the work with the URL address + * + * @type {Object} + */ + var historyDescriptors = { /** - * Properties that will be replaced in the global - * object 'window', to prevent conflicts + * Setting library initialization * - * @type {Object} + * @param {null|String} [basepath] The base path to the site; defaults to the root "/". + * @param {null|String} [type] Substitute the string after the anchor; by default "/". + * @param {null|Boolean} [redirect] Enable link translation. */ - var eventsDescriptors = { - "onhashchange": null, - "onpopstate": null - }; - + "setup": function(basepath, type, redirect) { + settings["basepath"] = ('' + (basepath == null ? settings["basepath"] : basepath)) + .replace(/(?:^|\/)[^\/]*$/, '/'); + settings["type"] = type == null ? settings["type"] : type; + settings["redirect"] = redirect == null ? settings["redirect"] : !!redirect; + }, /** - * Fix for Chrome in iOS - * See https://github.com/devote/HTML5-History-API/issues/29 + * @namespace history + * @param {String} [type] + * @param {String} [basepath] */ - var fastFixChrome = function(method, args) { - var isNeedFix = global.history !== windowHistory; - if (isNeedFix) { - global.history = windowHistory; - } - method.apply(windowHistory, args); - if (isNeedFix) { - global.history = historyObject; + "redirect": function(type, basepath) { + historyObject['setup'](basepath, type); + basepath = settings["basepath"]; + if (global.top == global.self) { + var relative = parseURL(null, false, true)._relative; + var path = windowLocation.pathname + windowLocation.search; + if (isSupportHistoryAPI) { + path = path.replace(/([^\/])$/, '$1/'); + if (relative != basepath && (new RegExp("^" + basepath + "$", "i")).test(path)) { + windowLocation.replace(relative); + } + } else if (path != basepath) { + path = path.replace(/([^\/])\?/, '$1/?'); + if ((new RegExp("^" + basepath, "i")).test(path)) { + windowLocation.replace(basepath + '#' + path. + replace(new RegExp("^" + basepath, "i"), settings["type"]) + windowLocation.hash); + } } - }; - + } + }, /** - * Properties that will be replaced/added to object - * 'window.history', includes the object 'history.location', - * for a complete the work with the URL address + * The method adds a state object entry + * to the history. * - * @type {Object} + * @namespace history + * @param {Object} state + * @param {string} title + * @param {string} [url] */ - var historyDescriptors = { - /** - * Setting library initialization - * - * @param {null|String} [basepath] The base path to the site; defaults to the root "/". - * @param {null|String} [type] Substitute the string after the anchor; by default "/". - * @param {null|Boolean} [redirect] Enable link translation. - */ - "setup": function(basepath, type, redirect) { - settings["basepath"] = ('' + (basepath == null ? settings["basepath"] : basepath)) - .replace(/(?:^|\/)[^\/]*$/, '/'); - settings["type"] = type == null ? settings["type"] : type; - settings["redirect"] = redirect == null ? settings["redirect"] : !!redirect; - }, - /** - * @namespace history - * @param {String} [type] - * @param {String} [basepath] - */ - "redirect": function(type, basepath) { - historyObject['setup'](basepath, type); - basepath = settings["basepath"]; - if (global.top == global.self) { - var relative = parseURL(null, false, true)._relative; - var path = windowLocation.pathname + windowLocation.search; - if (isSupportHistoryAPI) { - path = path.replace(/([^\/])$/, '$1/'); - if (relative != basepath && (new RegExp("^" + basepath + "$", "i")).test(path)) { - windowLocation.replace(relative); - } - } else if (path != basepath) { - path = path.replace(/([^\/])\?/, '$1/?'); - if ((new RegExp("^" + basepath, "i")).test(path)) { - windowLocation.replace(basepath + '#' + path. - replace(new RegExp("^" + basepath, "i"), settings["type"]) + windowLocation.hash); - } - } - } - }, - /** - * The method adds a state object entry - * to the history. - * - * @namespace history - * @param {Object} state - * @param {string} title - * @param {string} [url] - */ - pushState: function(state, title, url) { - var t = document.title; - if (lastTitle != null) { - document.title = lastTitle; - } - historyPushState && fastFixChrome(historyPushState, arguments); - changeState(state, url); - document.title = t; - lastTitle = title; - }, - /** - * The method updates the state object, - * title, and optionally the URL of the - * current entry in the history. - * - * @namespace history - * @param {Object} state - * @param {string} title - * @param {string} [url] - */ - replaceState: function(state, title, url) { - var t = document.title; - if (lastTitle != null) { - document.title = lastTitle; - } - delete stateStorage[windowLocation.href]; - historyReplaceState && fastFixChrome(historyReplaceState, arguments); - changeState(state, url, true); - document.title = t; - lastTitle = title; - }, - /** - * Object 'history.location' is similar to the - * object 'window.location', except that in - * HTML4 browsers it will behave a bit differently - * - * @namespace history - */ - "location": { - set: function(value) { - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; - global.location = value; - }, - get: function() { - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; - return locationObject; - } - }, - /** - * A state object is an object representing - * a user interface state. - * - * @namespace history - */ - "state": { - get: function() { - if (typeof stateStorage[windowLocation.href] === 'object') { - return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); - } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { - return stateStorage[windowLocation.href]; - } else { - return null; - } - } - } - }; - + pushState: function(state, title, url) { + var t = document.title; + if (lastTitle != null) { + document.title = lastTitle; + } + historyPushState && fastFixChrome(historyPushState, arguments); + changeState(state, url); + document.title = t; + lastTitle = title; + }, + /** + * The method updates the state object, + * title, and optionally the URL of the + * current entry in the history. + * + * @namespace history + * @param {Object} state + * @param {string} title + * @param {string} [url] + */ + replaceState: function(state, title, url) { + var t = document.title; + if (lastTitle != null) { + document.title = lastTitle; + } + delete stateStorage[windowLocation.href]; + historyReplaceState && fastFixChrome(historyReplaceState, arguments); + changeState(state, url, true); + document.title = t; + lastTitle = title; + }, /** - * Properties for object 'history.location'. * Object 'history.location' is similar to the * object 'window.location', except that in * HTML4 browsers it will behave a bit differently * - * @type {Object} + * @namespace history */ - var locationDescriptors = { - /** - * Navigates to the given page. - * - * @namespace history.location - */ - assign: function(url) { - if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { - changeState(null, url); - } else { - windowLocation.assign(url); - } - }, - /** - * Reloads the current page. - * - * @namespace history.location - */ - reload: function(flag) { - windowLocation.reload(flag); - }, - /** - * Removes the current page from - * the session history and navigates - * to the given page. - * - * @namespace history.location - */ - replace: function(url) { - if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { - changeState(null, url, true); - } else { - windowLocation.replace(url); - } - }, - /** - * Returns the current page's location. - * - * @namespace history.location - */ - toString: function() { - return this.href; - }, - /** - * Returns the current origin. - * - * @namespace history.location - */ - "origin": { - get: function() { - if (customOrigin !== void 0) { - return customOrigin; - } - if (!windowLocation.origin) { - return windowLocation.protocol + "//" + windowLocation.hostname + (windowLocation.port ? ':' + windowLocation.port: ''); - } - return windowLocation.origin; - }, - set: function(value) { - customOrigin = value; - } - }, - /** - * Returns the current page's location. - * Can be set, to navigate to another page. - * - * @namespace history.location - */ - "href": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._href; - } - }, - /** - * Returns the current page's protocol. - * - * @namespace history.location - */ - "protocol": null, - /** - * Returns the current page's host and port number. - * - * @namespace history.location - */ - "host": null, - /** - * Returns the current page's host. - * - * @namespace history.location - */ - "hostname": null, - /** - * Returns the current page's port number. - * - * @namespace history.location - */ - "port": null, - /** - * Returns the current page's path only. - * - * @namespace history.location - */ - "pathname": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._pathname; - } - }, - /** - * Returns the current page's search - * string, beginning with the character - * '?' and to the symbol '#' - * - * @namespace history.location - */ - "search": isSupportHistoryAPI ? null : { - get: function() { - return parseURL()._search; - } - }, - /** - * Returns the current page's hash - * string, beginning with the character - * '#' and to the end line - * - * @namespace history.location - */ - "hash": isSupportHistoryAPI ? null : { - set: function(value) { - changeState(null, ('' + value).replace(/^(#|)/, '#'), false, lastURL); - }, - get: function() { - return parseURL()._hash; - } - } - }; - + "location": { + set: function(value) { + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; + global.location = value; + }, + get: function() { + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 1; + return locationObject; + } + }, /** - * Just empty function + * A state object is an object representing + * a user interface state. * - * @return void + * @namespace history */ - function emptyFunction() { - // dummy + "state": { + get: function() { + if (typeof stateStorage[windowLocation.href] === 'object') { + return JSON.parse(JSON.stringify(stateStorage[windowLocation.href])); + } else if(typeof stateStorage[windowLocation.href] !== 'undefined') { + return stateStorage[windowLocation.href]; + } else { + return null; + } + } } + }; + /** + * Properties for object 'history.location'. + * Object 'history.location' is similar to the + * object 'window.location', except that in + * HTML4 browsers it will behave a bit differently + * + * @type {Object} + */ + var locationDescriptors = { /** - * Prepares a parts of the current or specified reference for later use in the library + * Navigates to the given page. * - * @param {string} [href] - * @param {boolean} [isWindowLocation] - * @param {boolean} [isNotAPI] - * @return {Object} + * @namespace history.location */ - function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; - if (href != null && href !== '' && !isWindowLocation) { - var current = parseURL(), - base = document.getElementsByTagName('base')[0]; - if (!isNotAPI && base && base.getAttribute('href')) { - // Fix for IE ignoring relative base tags. - // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer - base.href = base.href; - current = parseURL(base.href, null, true); - } - var _pathname = current._pathname, _protocol = current._protocol; - // convert to type of string - href = '' + href; - // convert relative link to the absolute - href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 - ? _protocol + href : href : _protocol + "//" + current._host + ( - href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 - ? _pathname + href : href.indexOf("#") === 0 - ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href - ); - } else { - href = isWindowLocation ? href : windowLocation.href; - // if current browser not support History-API - if (!isSupportHistoryAPI || isNotAPI) { - // get hash fragment - href = href.replace(/^[^#]*/, '') || "#"; - // form the absolute link from the hash - // https://github.com/devote/HTML5-History-API/issues/50 - href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath'] - + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), ""); - } + assign: function(url) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { + changeState(null, url); + } else { + windowLocation.assign(url); + } + }, + /** + * Reloads the current page. + * + * @namespace history.location + */ + reload: function(flag) { + windowLocation.reload(flag); + }, + /** + * Removes the current page from + * the session history and navigates + * to the given page. + * + * @namespace history.location + */ + replace: function(url) { + if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) { + changeState(null, url, true); + } else { + windowLocation.replace(url); + } + }, + /** + * Returns the current page's location. + * + * @namespace history.location + */ + toString: function() { + return this.href; + }, + /** + * Returns the current origin. + * + * @namespace history.location + */ + "origin": { + get: function() { + if (customOrigin !== void 0) { + return customOrigin; } - // that would get rid of the links of the form: /../../ - anchorElement.href = href; - // decompose the link in parts - var result = re.exec(anchorElement.href); - // host name with the port number - var host = result[2] + (result[3] ? ':' + result[3] : ''); - // folder - var pathname = result[4] || '/'; - // the query string - var search = result[5] || ''; - // hash - var hash = result[6] === '#' ? '' : (result[6] || ''); - // relative link, no protocol, no host - var relative = pathname + search + hash; - // special links for set to hash-link, if browser not support History API - var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search; - // result - return { - _href: result[1] + '//' + host + relative, - _protocol: result[1], - _host: host, - _hostname: result[2], - _port: result[3] || '', - _pathname: pathname, - _search: search, - _hash: hash, - _relative: relative, - _nohash: nohash, - _special: nohash + hash + if (!windowLocation.origin) { + return windowLocation.protocol + "//" + windowLocation.hostname + (windowLocation.port ? ':' + windowLocation.port: ''); } - } - + return windowLocation.origin; + }, + set: function(value) { + customOrigin = value; + } + }, /** - * Detect HistoryAPI support while taking into account false positives. - * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * Returns the current page's location. + * Can be set, to navigate to another page. + * + * @namespace history.location */ - function isSupportHistoryAPIDetect(){ - - var ua = global.navigator.userAgent; + "href": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._href; + } + }, + /** + * Returns the current page's protocol. + * + * @namespace history.location + */ + "protocol": null, + /** + * Returns the current page's host and port number. + * + * @namespace history.location + */ + "host": null, + /** + * Returns the current page's host. + * + * @namespace history.location + */ + "hostname": null, + /** + * Returns the current page's port number. + * + * @namespace history.location + */ + "port": null, + /** + * Returns the current page's path only. + * + * @namespace history.location + */ + "pathname": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._pathname; + } + }, + /** + * Returns the current page's search + * string, beginning with the character + * '?' and to the symbol '#' + * + * @namespace history.location + */ + "search": isSupportHistoryAPI ? null : { + get: function() { + return parseURL()._search; + } + }, + /** + * Returns the current page's hash + * string, beginning with the character + * '#' and to the end line + * + * @namespace history.location + */ + "hash": isSupportHistoryAPI ? null : { + set: function(value) { + changeState(null, ('' + value).replace(/^(#|)/, '#'), false, lastURL); + }, + get: function() { + return parseURL()._hash; + } + } + }; - // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies - // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). - if ((ua.indexOf('Android 2.') !== -1 || - (ua.indexOf('Android 4.0') !== -1)) && - ua.indexOf('Mobile Safari') !== -1 && - ua.indexOf('Chrome') === -1 && - ua.indexOf('Windows Phone') === -1) { - return false; - } + /** + * Just empty function + * + * @return void + */ + function emptyFunction() { + // dummy + } - // Return the regular check - return !!historyPushState; + /** + * Prepares a parts of the current or specified reference for later use in the library + * + * @param {string} [href] + * @param {boolean} [isWindowLocation] + * @param {boolean} [isNotAPI] + * @return {Object} + */ + function parseURL(href, isWindowLocation, isNotAPI) { + var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + if (href != null && href !== '' && !isWindowLocation) { + var current = parseURL(), + base = document.getElementsByTagName('base')[0]; + if (!isNotAPI && base && base.getAttribute('href')) { + // Fix for IE ignoring relative base tags. + // See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer + base.href = base.href; + current = parseURL(base.href, null, true); + } + var _pathname = current._pathname, _protocol = current._protocol; + // convert to type of string + href = '' + href; + // convert relative link to the absolute + href = /^(?:\w+\:)?\/\//.test(href) ? href.indexOf("/") === 0 + ? _protocol + href : href : _protocol + "//" + current._host + ( + href.indexOf("/") === 0 ? href : href.indexOf("?") === 0 + ? _pathname + href : href.indexOf("#") === 0 + ? _pathname + current._search + href : _pathname.replace(/[^\/]+$/g, '') + href + ); + } else { + href = isWindowLocation ? href : windowLocation.href; + // if current browser not support History-API + if (!isSupportHistoryAPI || isNotAPI) { + // get hash fragment + href = href.replace(/^[^#]*/, '') || "#"; + // form the absolute link from the hash + // https://github.com/devote/HTML5-History-API/issues/50 + href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath'] + + href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), ""); + } + } + // that would get rid of the links of the form: /../../ + anchorElement.href = href; + // decompose the link in parts + var result = re.exec(anchorElement.href); + // host name with the port number + var host = result[2] + (result[3] ? ':' + result[3] : ''); + // folder + var pathname = result[4] || '/'; + // the query string + var search = result[5] || ''; + // hash + var hash = result[6] === '#' ? '' : (result[6] || ''); + // relative link, no protocol, no host + var relative = pathname + search + hash; + // special links for set to hash-link, if browser not support History API + var nohash = pathname.replace(new RegExp("^" + settings["basepath"], "i"), settings["type"]) + search; + // result + return { + _href: result[1] + '//' + host + relative, + _protocol: result[1], + _host: host, + _hostname: result[2], + _port: result[3] || '', + _pathname: pathname, + _search: search, + _hash: hash, + _relative: relative, + _nohash: nohash, + _special: nohash + hash + } + } + /** + * Detect HistoryAPI support while taking into account false positives. + * Based on https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + */ + function isSupportHistoryAPIDetect(){ + var ua = global.navigator.userAgent; + // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies + // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471). + if ((ua.indexOf('Android 2.') !== -1 || + (ua.indexOf('Android 4.0') !== -1)) && + ua.indexOf('Mobile Safari') !== -1 && + ua.indexOf('Chrome') === -1 && + ua.indexOf('Windows Phone') === -1) + { + return false; } + // Return the regular check + return !!historyPushState; + } + /** + * Initializing storage for the custom state's object + */ + function storageInitialize() { + var sessionStorage; /** - * Initializing storage for the custom state's object + * sessionStorage throws error when cookies are disabled + * Chrome content settings when running the site in a Facebook IFrame. + * see: https://github.com/devote/HTML5-History-API/issues/34 + * and: http://stackoverflow.com/a/12976988/669360 */ - function storageInitialize() { - var sessionStorage; - /** - * sessionStorage throws error when cookies are disabled - * Chrome content settings when running the site in a Facebook IFrame. - * see: https://github.com/devote/HTML5-History-API/issues/34 - * and: http://stackoverflow.com/a/12976988/669360 - */ - try { - sessionStorage = global['sessionStorage']; - sessionStorage.setItem(sessionStorageKey + 't', '1'); - sessionStorage.removeItem(sessionStorageKey + 't'); - } catch(_e_) { - sessionStorage = { - getItem: function(key) { - var cookie = document.cookie.split(key + "="); - return cookie.length > 1 && cookie.pop().split(";").shift() || 'null'; - }, - setItem: function(key, value) { - var state = {}; - // insert one current element to cookie - if (state[windowLocation.href] = historyObject.state) { - document.cookie = key + '=' + JSON.stringify(state); - } - } - } + try { + sessionStorage = global['sessionStorage']; + sessionStorage.setItem(sessionStorageKey + 't', '1'); + sessionStorage.removeItem(sessionStorageKey + 't'); + } catch(_e_) { + sessionStorage = { + getItem: function(key) { + var cookie = document.cookie.split(key + "="); + return cookie.length > 1 && cookie.pop().split(";").shift() || 'null'; + }, + setItem: function(key, value) { + var state = {}; + // insert one current element to cookie + if (state[windowLocation.href] = historyObject.state) { + document.cookie = key + '=' + JSON.stringify(state); + } } + } + } - try { - // get cache from the storage in browser - stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {}; - } catch(_e_) { - stateStorage = {}; - } + try { + // get cache from the storage in browser + stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {}; + } catch(_e_) { + stateStorage = {}; + } - // hang up the event handler to event unload page - addEvent(eventNamePrefix + 'unload', function() { - // save current state's object - sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); - }, false); + // hang up the event handler to event unload page + addEvent(eventNamePrefix + 'unload', function() { + // save current state's object + sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage)); + }, false); + } + + /** + * This method is implemented to override the built-in(native) + * properties in the browser, unfortunately some browsers are + * not allowed to override all the properties and even add. + * For this reason, this was written by a method that tries to + * do everything necessary to get the desired result. + * + * @param {Object} object The object in which will be overridden/added property + * @param {String} prop The property name to be overridden/added + * @param {Object} [descriptor] An object containing properties set/get + * @param {Function} [onWrapped] The function to be called when the wrapper is created + * @return {Object|Boolean} Returns an object on success, otherwise returns false + */ + function redefineProperty(object, prop, descriptor, onWrapped) { + var testOnly = 0; + // test only if descriptor is undefined + if (!descriptor) { + descriptor = {set: emptyFunction}; + testOnly = 1; } + // variable will have a value of true the success of attempts to set descriptors + var isDefinedSetter = !descriptor.set; + var isDefinedGetter = !descriptor.get; + // for tests of attempts to set descriptors + var test = {configurable: true, set: function() { + isDefinedSetter = 1; + }, get: function() { + isDefinedGetter = 1; + }}; - /** - * This method is implemented to override the built-in(native) - * properties in the browser, unfortunately some browsers are - * not allowed to override all the properties and even add. - * For this reason, this was written by a method that tries to - * do everything necessary to get the desired result. - * - * @param {Object} object The object in which will be overridden/added property - * @param {String} prop The property name to be overridden/added - * @param {Object} [descriptor] An object containing properties set/get - * @param {Function} [onWrapped] The function to be called when the wrapper is created - * @return {Object|Boolean} Returns an object on success, otherwise returns false - */ - function redefineProperty(object, prop, descriptor, onWrapped) { - var testOnly = 0; - // test only if descriptor is undefined - if (!descriptor) { - descriptor = {set: emptyFunction}; - testOnly = 1; - } - // variable will have a value of true the success of attempts to set descriptors - var isDefinedSetter = !descriptor.set; - var isDefinedGetter = !descriptor.get; - // for tests of attempts to set descriptors - var test = {configurable: true, set: function() { - isDefinedSetter = 1; - }, get: function() { - isDefinedGetter = 1; - }}; + try { + // testing for the possibility of overriding/adding properties + defineProperty(object, prop, test); + // running the test + object[prop] = object[prop]; + // attempt to override property using the standard method + defineProperty(object, prop, descriptor); + } catch(_e_) { + } - try { - // testing for the possibility of overriding/adding properties - defineProperty(object, prop, test); - // running the test - object[prop] = object[prop]; - // attempt to override property using the standard method - defineProperty(object, prop, descriptor); - } catch(_e_) { - } + // If the variable 'isDefined' has a false value, it means that need to try other methods + if (!isDefinedSetter || !isDefinedGetter) { + // try to override/add the property, using deprecated functions + if (object.__defineGetter__) { + // testing for the possibility of overriding/adding properties + object.__defineGetter__(prop, test.get); + object.__defineSetter__(prop, test.set); + // running the test + object[prop] = object[prop]; + // attempt to override property using the deprecated functions + descriptor.get && object.__defineGetter__(prop, descriptor.get); + descriptor.set && object.__defineSetter__(prop, descriptor.set); + } - // If the variable 'isDefined' has a false value, it means that need to try other methods - if (!isDefinedSetter || !isDefinedGetter) { - // try to override/add the property, using deprecated functions - if (object.__defineGetter__) { - // testing for the possibility of overriding/adding properties - object.__defineGetter__(prop, test.get); - object.__defineSetter__(prop, test.set); - // running the test - object[prop] = object[prop]; - // attempt to override property using the deprecated functions - descriptor.get && object.__defineGetter__(prop, descriptor.get); - descriptor.set && object.__defineSetter__(prop, descriptor.set); + // Browser refused to override the property, using the standard and deprecated methods + if (!isDefinedSetter || !isDefinedGetter) { + if (testOnly) { + return false; + } else if (object === global) { + // try override global properties + try { + // save original value from this property + var originalValue = object[prop]; + // set null to built-in(native) property + object[prop] = null; + } catch(_e_) { + } + // This rule for Internet Explorer 8 + if ('execScript' in global) { + /** + * to IE8 override the global properties using + * VBScript, declaring it in global scope with + * the same names. + */ + global['execScript']('Public ' + prop, 'VBScript'); + global['execScript']('var ' + prop + ';', 'JavaScript'); + } else { + try { + /** + * This hack allows to override a property + * with the set 'configurable: false', working + * in the hack 'Safari' to 'Mac' + */ + defineProperty(object, prop, {value: emptyFunction}); + } catch(_e_) { + if (prop === 'onpopstate') { + /** + * window.onpopstate fires twice in Safari 8.0. + * Block initial event on window.onpopstate + * See: https://github.com/devote/HTML5-History-API/issues/69 + */ + addEvent('popstate', descriptor = function() { + removeEvent('popstate', descriptor, false); + var onpopstate = object.onpopstate; + // cancel initial event on attribute handler + object.onpopstate = null; + setTimeout(function() { + // restore attribute value after short time + object.onpopstate = onpopstate; + }, 1); + }, false); + // cancel trigger events on attributes in object the window + triggerEventsInWindowAttributes = 0; + } } + } + // set old value to new variable + object[prop] = originalValue; - // Browser refused to override the property, using the standard and deprecated methods - if (!isDefinedSetter || !isDefinedGetter) { - if (testOnly) { - return false; - } else if (object === global) { - // try override global properties - try { - // save original value from this property - var originalValue = object[prop]; - // set null to built-in(native) property - object[prop] = null; - } catch(_e_) { - } - // This rule for Internet Explorer 8 - if ('execScript' in global) { - /** - * to IE8 override the global properties using - * VBScript, declaring it in global scope with - * the same names. - */ - global['execScript']('Public ' + prop, 'VBScript'); - global['execScript']('var ' + prop + ';', 'JavaScript'); - } else { - try { - /** - * This hack allows to override a property - * with the set 'configurable: false', working - * in the hack 'Safari' to 'Mac' - */ - defineProperty(object, prop, {value: emptyFunction}); - } catch(_e_) { - if (prop === 'onpopstate') { - /** - * window.onpopstate fires twice in Safari 8.0. - * Block initial event on window.onpopstate - * See: https://github.com/devote/HTML5-History-API/issues/69 - */ - addEvent('popstate', descriptor = function() { - removeEvent('popstate', descriptor, false); - var onpopstate = object.onpopstate; - // cancel initial event on attribute handler - object.onpopstate = null; - setTimeout(function() { - // restore attribute value after short time - object.onpopstate = onpopstate; - }, 1); - }, false); - // cancel trigger events on attributes in object the window - triggerEventsInWindowAttributes = 0; - } - } - } - // set old value to new variable - object[prop] = originalValue; - - } else { - // the last stage of trying to override the property - try { - try { - // wrap the object in a new empty object - var temp = Object.create(object); - defineProperty(Object.getPrototypeOf(temp) === object ? temp : object, prop, descriptor); - for(var key in object) { - // need to bind a function to the original object - if (typeof object[key] === 'function') { - temp[key] = object[key].bind(object); - } - } - try { - // to run a function that will inform about what the object was to wrapped - onWrapped.call(temp, temp, object); - } catch(_e_) { - } - object = temp; - } catch(_e_) { - // sometimes works override simply by assigning the prototype property of the constructor - defineProperty(object.constructor.prototype, prop, descriptor); - } - } catch(_e_) { - // all methods have failed - return false; - } + } else { + // the last stage of trying to override the property + try { + try { + // wrap the object in a new empty object + var temp = Object.create(object); + defineProperty(Object.getPrototypeOf(temp) === object ? temp : object, prop, descriptor); + for(var key in object) { + // need to bind a function to the original object + if (typeof object[key] === 'function') { + temp[key] = object[key].bind(object); } + } + try { + // to run a function that will inform about what the object was to wrapped + onWrapped.call(temp, temp, object); + } catch(_e_) { + } + object = temp; + } catch(_e_) { + // sometimes works override simply by assigning the prototype property of the constructor + defineProperty(object.constructor.prototype, prop, descriptor); } + } catch(_e_) { + // all methods have failed + return false; + } } - - return object; + } } - /** - * Adds the missing property in descriptor - * - * @param {Object} object An object that stores values - * @param {String} prop Name of the property in the object - * @param {Object|null} descriptor Descriptor - * @return {Object} Returns the generated descriptor - */ - function prepareDescriptorsForObject(object, prop, descriptor) { - descriptor = descriptor || {}; - // the default for the object 'location' is the standard object 'window.location' - object = object === locationDescriptors ? windowLocation : object; - // setter for object properties - descriptor.set = (descriptor.set || function(value) { - object[prop] = value; - }); - // getter for object properties - descriptor.get = (descriptor.get || function() { - return object[prop]; - }); - return descriptor; - } + return object; + } - /** - * Wrapper for the methods 'addEventListener/attachEvent' in the context of the 'window' - * - * @param {String} event The event type for which the user is registering - * @param {Function} listener The method to be called when the event occurs. - * @param {Boolean} capture If true, capture indicates that the user wishes to initiate capture. - * @return void - */ - function addEventListener(event, listener, capture) { - if (event in eventsList) { - // here stored the event listeners 'popstate/hashchange' - eventsList[event].push(listener); - } else { - // FireFox support non-standart four argument aWantsUntrusted - // https://github.com/devote/HTML5-History-API/issues/13 - if (arguments.length > 3) { - addEvent(event, listener, capture, arguments[3]); - } else { - addEvent(event, listener, capture); - } - } + /** + * Adds the missing property in descriptor + * + * @param {Object} object An object that stores values + * @param {String} prop Name of the property in the object + * @param {Object|null} descriptor Descriptor + * @return {Object} Returns the generated descriptor + */ + function prepareDescriptorsForObject(object, prop, descriptor) { + descriptor = descriptor || {}; + // the default for the object 'location' is the standard object 'window.location' + object = object === locationDescriptors ? windowLocation : object; + // setter for object properties + descriptor.set = (descriptor.set || function(value) { + object[prop] = value; + }); + // getter for object properties + descriptor.get = (descriptor.get || function() { + return object[prop]; + }); + return descriptor; + } + + /** + * Wrapper for the methods 'addEventListener/attachEvent' in the context of the 'window' + * + * @param {String} event The event type for which the user is registering + * @param {Function} listener The method to be called when the event occurs. + * @param {Boolean} capture If true, capture indicates that the user wishes to initiate capture. + * @return void + */ + function addEventListener(event, listener, capture) { + if (event in eventsList) { + // here stored the event listeners 'popstate/hashchange' + eventsList[event].push(listener); + } else { + // FireFox support non-standart four argument aWantsUntrusted + // https://github.com/devote/HTML5-History-API/issues/13 + if (arguments.length > 3) { + addEvent(event, listener, capture, arguments[3]); + } else { + addEvent(event, listener, capture); + } } + } - /** - * Wrapper for the methods 'removeEventListener/detachEvent' in the context of the 'window' - * - * @param {String} event The event type for which the user is registered - * @param {Function} listener The parameter indicates the Listener to be removed. - * @param {Boolean} capture Was registered as a capturing listener or not. - * @return void - */ - function removeEventListener(event, listener, capture) { - var list = eventsList[event]; - if (list) { - for(var i = list.length; i--;) { - if (list[i] === listener) { - list.splice(i, 1); - break; - } - } - } else { - removeEvent(event, listener, capture); + /** + * Wrapper for the methods 'removeEventListener/detachEvent' in the context of the 'window' + * + * @param {String} event The event type for which the user is registered + * @param {Function} listener The parameter indicates the Listener to be removed. + * @param {Boolean} capture Was registered as a capturing listener or not. + * @return void + */ + function removeEventListener(event, listener, capture) { + var list = eventsList[event]; + if (list) { + for(var i = list.length; i--;) { + if (list[i] === listener) { + list.splice(i, 1); + break; } + } + } else { + removeEvent(event, listener, capture); } + } - /** - * Wrapper for the methods 'dispatchEvent/fireEvent' in the context of the 'window' - * - * @param {Event|String} event Instance of Event or event type string if 'eventObject' used - * @param {*} [eventObject] For Internet Explorer 8 required event object on this argument - * @return {Boolean} If 'preventDefault' was called the value is false, else the value is true. - */ - function dispatchEvent(event, eventObject) { - var eventType = ('' + (typeof event === "string" ? event : event.type)).replace(/^on/, ''); - var list = eventsList[eventType]; - if (list) { - // need to understand that there is one object of Event - eventObject = typeof event === "string" ? eventObject : event; - if (eventObject.target == null) { - // need to override some of the properties of the Event object - for(var props = ['target', 'currentTarget', 'srcElement', 'type']; event = props.pop();) { - // use 'redefineProperty' to override the properties - eventObject = redefineProperty(eventObject, event, { - get: event === 'type' ? function() { - return eventType; - } : function() { - return global; - } - }); - } - } - if (triggerEventsInWindowAttributes) { - // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context - ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) - || emptyFunction).call(global, eventObject); + /** + * Wrapper for the methods 'dispatchEvent/fireEvent' in the context of the 'window' + * + * @param {Event|String} event Instance of Event or event type string if 'eventObject' used + * @param {*} [eventObject] For Internet Explorer 8 required event object on this argument + * @return {Boolean} If 'preventDefault' was called the value is false, else the value is true. + */ + function dispatchEvent(event, eventObject) { + var eventType = ('' + (typeof event === "string" ? event : event.type)).replace(/^on/, ''); + var list = eventsList[eventType]; + if (list) { + // need to understand that there is one object of Event + eventObject = typeof event === "string" ? eventObject : event; + if (eventObject.target == null) { + // need to override some of the properties of the Event object + for(var props = ['target', 'currentTarget', 'srcElement', 'type']; event = props.pop();) { + // use 'redefineProperty' to override the properties + eventObject = redefineProperty(eventObject, event, { + get: event === 'type' ? function() { + return eventType; + } : function() { + return global; } - // run other functions that are in the list of handlers - for(var i = 0, len = list.length; i < len; i++) { - list[i].call(global, eventObject); - } - return true; - } else { - return dispatch(event, eventObject); + }); } + } + if (triggerEventsInWindowAttributes) { + // run function defined in the attributes 'onpopstate/onhashchange' in the 'window' context + ((eventType === 'popstate' ? global.onpopstate : global.onhashchange) + || emptyFunction).call(global, eventObject); + } + // run other functions that are in the list of handlers + for(var i = 0, len = list.length; i < len; i++) { + list[i].call(global, eventObject); + } + return true; + } else { + return dispatch(event, eventObject); } + } - /** - * dispatch current state event - */ - function firePopState() { - var o = document.createEvent ? document.createEvent('Event') : document.createEventObject(); - if (o.initEvent) { - o.initEvent('popstate', false, false); - } else { - o.type = 'popstate'; - } - o.state = historyObject.state; - // send a newly created events to be processed - dispatchEvent(o); + /** + * dispatch current state event + */ + function firePopState() { + var o = document.createEvent ? document.createEvent('Event') : document.createEventObject(); + if (o.initEvent) { + o.initEvent('popstate', false, false); + } else { + o.type = 'popstate'; } + o.state = historyObject.state; + // send a newly created events to be processed + dispatchEvent(o); + } - /** - * fire initial state for non-HTML5 browsers - */ - function fireInitialState() { - if (isFireInitialState) { - isFireInitialState = false; - firePopState(); - } + /** + * fire initial state for non-HTML5 browsers + */ + function fireInitialState() { + if (isFireInitialState) { + isFireInitialState = false; + firePopState(); } + } - /** - * Change the data of the current history for HTML4 browsers - * - * @param {Object} state - * @param {string} [url] - * @param {Boolean} [replace] - * @param {string} [lastURLValue] - * @return void - */ - function changeState(state, url, replace, lastURLValue) { - if (!isSupportHistoryAPI) { - // if not used implementation history.location - if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; - // normalization url - var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); - // if current url not equal new url - if (urlObject._relative !== parseURL()._relative) { - // if empty lastURLValue to skip hash change event - lastURL = lastURLValue; - if (replace) { - // only replace hash, not store to history - windowLocation.replace("#" + urlObject._special); - } else { - // change hash and add new record to history - windowLocation.hash = urlObject._special; - } - } + /** + * Change the data of the current history for HTML4 browsers + * + * @param {Object} state + * @param {string} [url] + * @param {Boolean} [replace] + * @param {string} [lastURLValue] + * @return void + */ + function changeState(state, url, replace, lastURLValue) { + if (!isSupportHistoryAPI) { + // if not used implementation history.location + if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; + // normalization url + var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); + // if current url not equal new url + if (urlObject._relative !== parseURL()._relative) { + // if empty lastURLValue to skip hash change event + lastURL = lastURLValue; + if (replace) { + // only replace hash, not store to history + windowLocation.replace("#" + urlObject._special); } else { - lastURL = windowLocation.href; + // change hash and add new record to history + windowLocation.hash = urlObject._special; } - if (!isSupportStateObjectInHistory && state) { - stateStorage[windowLocation.href] = state; - } - isFireInitialState = false; + } + } else { + lastURL = windowLocation.href; } + if (!isSupportStateObjectInHistory && state) { + stateStorage[windowLocation.href] = state; + } + isFireInitialState = false; + } - /** - * Event handler function changes the hash in the address bar - * - * @param {Event} event - * @return void - */ - function onHashChange(event) { - // https://github.com/devote/HTML5-History-API/issues/46 - var fireNow = lastURL; - // new value to lastURL - lastURL = windowLocation.href; - // if not empty fireNow, otherwise skipped the current handler event - if (fireNow) { - // if checkUrlForPopState equal current url, this means that the event was raised popstate browser - if (checkUrlForPopState !== windowLocation.href) { - // otherwise, - // the browser does not support popstate event or just does not run the event by changing the hash. - firePopState(); - } - // current event object - event = event || global.event; + /** + * Event handler function changes the hash in the address bar + * + * @param {Event} event + * @return void + */ + function onHashChange(event) { + // https://github.com/devote/HTML5-History-API/issues/46 + var fireNow = lastURL; + // new value to lastURL + lastURL = windowLocation.href; + // if not empty fireNow, otherwise skipped the current handler event + if (fireNow) { + // if checkUrlForPopState equal current url, this means that the event was raised popstate browser + if (checkUrlForPopState !== windowLocation.href) { + // otherwise, + // the browser does not support popstate event or just does not run the event by changing the hash. + firePopState(); + } + // current event object + event = event || global.event; - var oldURLObject = parseURL(fireNow, true); - var newURLObject = parseURL(); - // HTML4 browser not support properties oldURL/newURL - if (!event.oldURL) { - event.oldURL = oldURLObject._href; - event.newURL = newURLObject._href; - } - if (oldURLObject._hash !== newURLObject._hash) { - // if current hash not equal previous hash - dispatchEvent(event); - } - } + var oldURLObject = parseURL(fireNow, true); + var newURLObject = parseURL(); + // HTML4 browser not support properties oldURL/newURL + if (!event.oldURL) { + event.oldURL = oldURLObject._href; + event.newURL = newURLObject._href; + } + if (oldURLObject._hash !== newURLObject._hash) { + // if current hash not equal previous hash + dispatchEvent(event); + } } + } - /** - * The event handler is fully loaded document - * - * @param {*} [noScroll] - * @return void - */ - function onLoad(noScroll) { - // Get rid of the events popstate when the first loading a document in the webkit browsers - setTimeout(function() { - // hang up the event handler for the built-in popstate event in the browser - addEvent('popstate', function(e) { - // set the current url, that suppress the creation of the popstate event by changing the hash - checkUrlForPopState = windowLocation.href; - // for Safari browser in OS Windows not implemented 'state' object in 'History' interface - // and not implemented in old HTML4 browsers - if (!isSupportStateObjectInHistory) { - e = redefineProperty(e, 'state', {get: function() { - return historyObject.state; - }}); - } - // send events to be processed - dispatchEvent(e); - }, false); - }, 0); - // for non-HTML5 browsers - if (!isSupportHistoryAPI && noScroll !== true && "location" in historyObject) { - // scroll window to anchor element - scrollToAnchorId(locationObject.hash); - // fire initial state for non-HTML5 browser after load page - fireInitialState(); + /** + * The event handler is fully loaded document + * + * @param {*} [noScroll] + * @return void + */ + function onLoad(noScroll) { + // Get rid of the events popstate when the first loading a document in the webkit browsers + setTimeout(function() { + // hang up the event handler for the built-in popstate event in the browser + addEvent('popstate', function(e) { + // set the current url, that suppress the creation of the popstate event by changing the hash + checkUrlForPopState = windowLocation.href; + // for Safari browser in OS Windows not implemented 'state' object in 'History' interface + // and not implemented in old HTML4 browsers + if (!isSupportStateObjectInHistory) { + e = redefineProperty(e, 'state', {get: function() { + return historyObject.state; + }}); } + // send events to be processed + dispatchEvent(e); + }, false); + }, 0); + // for non-HTML5 browsers + if (!isSupportHistoryAPI && noScroll !== true && "location" in historyObject) { + // scroll window to anchor element + scrollToAnchorId(locationObject.hash); + // fire initial state for non-HTML5 browser after load page + fireInitialState(); } + } - /** - * Finds the closest ancestor anchor element (including the target itself). - * - * @param {HTMLElement} target The element to start scanning from. - * @return {HTMLElement} An element which is the closest ancestor anchor. - */ - function anchorTarget(target) { - while (target) { - if (target.nodeName === 'A') return target; - target = target.parentNode; - } + /** + * Finds the closest ancestor anchor element (including the target itself). + * + * @param {HTMLElement} target The element to start scanning from. + * @return {HTMLElement} An element which is the closest ancestor anchor. + */ + function anchorTarget(target) { + while (target) { + if (target.nodeName === 'A') return target; + target = target.parentNode; } + } - /** - * Handles anchor elements with a hash fragment for non-HTML5 browsers - * - * @param {Event} e - */ - function onAnchorClick(e) { - var event = e || global.event; - var target = anchorTarget(event.target || event.srcElement); - var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; - if (target && target.nodeName === "A" && !defaultPrevented) { - var current = parseURL(); - var expect = parseURL(target.getAttribute("href", 2)); - var isEqualBaseURL = current._href.split('#').shift() === expect._href.split('#').shift(); - if (isEqualBaseURL && expect._hash) { - if (current._hash !== expect._hash) { - locationObject.hash = expect._hash; - } - scrollToAnchorId(expect._hash); - if (event.preventDefault) { - event.preventDefault(); - } else { - event.returnValue = false; - } - } + /** + * Handles anchor elements with a hash fragment for non-HTML5 browsers + * + * @param {Event} e + */ + function onAnchorClick(e) { + var event = e || global.event; + var target = anchorTarget(event.target || event.srcElement); + var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; + if (target && target.nodeName === "A" && !defaultPrevented) { + var current = parseURL(); + var expect = parseURL(target.getAttribute("href", 2)); + var isEqualBaseURL = current._href.split('#').shift() === expect._href.split('#').shift(); + if (isEqualBaseURL && expect._hash) { + if (current._hash !== expect._hash) { + locationObject.hash = expect._hash; } + scrollToAnchorId(expect._hash); + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; + } + } } + } - /** - * Scroll page to current anchor in url-hash - * - * @param hash - */ - function scrollToAnchorId(hash) { - var target = document.getElementById(hash = (hash || '').replace(/^#/, '')); - if (target && target.id === hash && target.nodeName === "A") { - var rect = target.getBoundingClientRect(); - global.scrollTo((documentElement.scrollLeft || 0), rect.top + (documentElement.scrollTop || 0) - - (documentElement.clientTop || 0)); - } + /** + * Scroll page to current anchor in url-hash + * + * @param hash + */ + function scrollToAnchorId(hash) { + var target = document.getElementById(hash = (hash || '').replace(/^#/, '')); + if (target && target.id === hash && target.nodeName === "A") { + var rect = target.getBoundingClientRect(); + global.scrollTo((documentElement.scrollLeft || 0), rect.top + (documentElement.scrollTop || 0) + - (documentElement.clientTop || 0)); } + } + /** + * Library initialization + * + * @return {Boolean} return true if all is well, otherwise return false value + */ + function initialize() { /** - * Library initialization - * - * @return {Boolean} return true if all is well, otherwise return false value + * Get custom settings from the query string */ - function initialize() { - /** - * Get custom settings from the query string - */ - var scripts = document.getElementsByTagName('script'); - var src = (scripts[scripts.length - 1] || {}).src || ''; - var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : ''; - arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) { - settings[key] = (value || '').replace(/^(0|false)$/, ''); - }); + var scripts = document.getElementsByTagName('script'); + var src = (scripts[scripts.length - 1] || {}).src || ''; + var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : ''; + arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) { + settings[key] = (value || '').replace(/^(0|false)$/, ''); + }); - /** - * hang up the event handler to listen to the events hashchange - */ - addEvent(eventNamePrefix + 'hashchange', onHashChange, false); - - // a list of objects with pairs of descriptors/object - var data = [locationDescriptors, locationObject, eventsDescriptors, global, historyDescriptors, historyObject]; + /** + * hang up the event handler to listen to the events hashchange + */ + addEvent(eventNamePrefix + 'hashchange', onHashChange, false); - // if browser support object 'state' in interface 'History' - if (isSupportStateObjectInHistory) { - // remove state property from descriptor - delete historyDescriptors['state']; - } + // a list of objects with pairs of descriptors/object + var data = [locationDescriptors, locationObject, eventsDescriptors, global, historyDescriptors, historyObject]; - // initializing descriptors - for(var i = 0; i < data.length; i += 2) { - for(var prop in data[i]) { - if (data[i].hasOwnProperty(prop)) { - if (typeof data[i][prop] !== 'object') { - // If the descriptor is a simple function, simply just assign it an object - data[i + 1][prop] = data[i][prop]; - } else { - // prepare the descriptor the required format - var descriptor = prepareDescriptorsForObject(data[i], prop, data[i][prop]); - // try to set the descriptor object - if (!redefineProperty(data[i + 1], prop, descriptor, function(n, o) { - // is satisfied if the failed override property - if (o === historyObject) { - // the problem occurs in Safari on the Mac - global.history = historyObject = data[i + 1] = n; - } - })) { - // if there is no possibility override. - // This browser does not support descriptors, such as IE7 + // if browser support object 'state' in interface 'History' + if (isSupportStateObjectInHistory) { + // remove state property from descriptor + delete historyDescriptors['state']; + } - // remove previously hung event handlers - removeEvent(eventNamePrefix + 'hashchange', onHashChange, false); + // initializing descriptors + for(var i = 0; i < data.length; i += 2) { + for(var prop in data[i]) { + if (data[i].hasOwnProperty(prop)) { + if (typeof data[i][prop] !== 'object') { + // If the descriptor is a simple function, simply just assign it an object + data[i + 1][prop] = data[i][prop]; + } else { + // prepare the descriptor the required format + var descriptor = prepareDescriptorsForObject(data[i], prop, data[i][prop]); + // try to set the descriptor object + if (!redefineProperty(data[i + 1], prop, descriptor, function(n, o) { + // is satisfied if the failed override property + if (o === historyObject) { + // the problem occurs in Safari on the Mac + global.history = historyObject = data[i + 1] = n; + } + })) { + // if there is no possibility override. + // This browser does not support descriptors, such as IE7 - // fail to initialize :( - return false; - } + // remove previously hung event handlers + removeEvent(eventNamePrefix + 'hashchange', onHashChange, false); - // create a repository for custom handlers onpopstate/onhashchange - if (data[i + 1] === global) { - eventsList[prop] = eventsList[prop.substr(2)] = []; - } - } - } + // fail to initialize :( + return false; } - } - // check settings - historyObject['setup'](); - - // redirect if necessary - if (settings['redirect']) { - historyObject['redirect'](); + // create a repository for custom handlers onpopstate/onhashchange + if (data[i + 1] === global) { + eventsList[prop] = eventsList[prop.substr(2)] = []; + } + } } + } + } - // initialize - if (settings["init"]) { - // You agree that you will use window.history.location instead window.location - isUsedHistoryLocationFlag = 1; - } + // check settings + historyObject['setup'](); - // If browser does not support object 'state' in interface 'History' - if (!isSupportStateObjectInHistory && JSON) { - storageInitialize(); - } + // redirect if necessary + if (settings['redirect']) { + historyObject['redirect'](); + } - // track clicks on anchors - if (!isSupportHistoryAPI) { - document[addEventListenerName](eventNamePrefix + "click", onAnchorClick, false); - } + // initialize + if (settings["init"]) { + // You agree that you will use window.history.location instead window.location + isUsedHistoryLocationFlag = 1; + } - if (document.readyState === 'complete') { - onLoad(true); - } else { - if (!isSupportHistoryAPI && parseURL()._relative !== settings["basepath"]) { - isFireInitialState = true; - } - /** - * Need to avoid triggering events popstate the initial page load. - * Hang handler popstate as will be fully loaded document that - * would prevent triggering event onpopstate - */ - addEvent(eventNamePrefix + 'load', onLoad, false); - } + // If browser does not support object 'state' in interface 'History' + if (!isSupportStateObjectInHistory && JSON) { + storageInitialize(); + } - // everything went well - return true; + // track clicks on anchors + if (!isSupportHistoryAPI) { + document[addEventListenerName](eventNamePrefix + "click", onAnchorClick, false); } - /** - * Starting the library - */ - if (!initialize()) { - // if unable to initialize descriptors - // therefore quite old browser and there - // is no sense to continue to perform - return; + if (document.readyState === 'complete') { + onLoad(true); + } else { + if (!isSupportHistoryAPI && parseURL()._relative !== settings["basepath"]) { + isFireInitialState = true; + } + /** + * Need to avoid triggering events popstate the initial page load. + * Hang handler popstate as will be fully loaded document that + * would prevent triggering event onpopstate + */ + addEvent(eventNamePrefix + 'load', onLoad, false); } - /** - * If the property history.emulate will be true, - * this will be talking about what's going on - * emulation capabilities HTML5-History-API. - * Otherwise there is no emulation, ie the - * built-in browser capabilities. - * - * @type {boolean} - * @const - */ - historyObject['emulate'] = !isSupportHistoryAPI; + // everything went well + return true; + } - /** - * Replace the original methods on the wrapper - */ - global[addEventListenerName] = addEventListener; - global[removeEventListenerName] = removeEventListener; - global[dispatchEventName] = dispatchEvent; + /** + * Starting the library + */ + if (!initialize()) { + // if unable to initialize descriptors + // therefore quite old browser and there + // is no sense to continue to perform + return; + } + + /** + * If the property history.emulate will be true, + * this will be talking about what's going on + * emulation capabilities HTML5-History-API. + * Otherwise there is no emulation, ie the + * built-in browser capabilities. + * + * @type {boolean} + * @const + */ + historyObject['emulate'] = !isSupportHistoryAPI; + + /** + * Replace the original methods on the wrapper + */ + global[addEventListenerName] = addEventListener; + global[removeEventListenerName] = removeEventListener; + global[dispatchEventName] = dispatchEvent; - return historyObject; + return historyObject; }); From 99b5d22cdd48bd9d1d9d5cd0132b39995f210b07 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Tue, 22 Dec 2015 14:33:08 +0300 Subject: [PATCH 68/81] bump version to 4.2.5 --- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 4 ++-- history.ielte7.min.js | 46 +++++++++++++++++++++---------------------- history.js | 4 ++-- history.min.js | 34 ++++++++++++++++---------------- package.json | 2 +- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/bower.json b/bower.json index 3c8624a..901ad3b 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.4", + "version": "4.2.5", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index bc73384..f982671 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.4", + "version": "4.2.5", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index 709109b..69570f2 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.4 + * History API JavaScript Library v4.2.5 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,7 +11,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-10-16 22:16 + * Update: 2015-12-22 14:26 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.ielte7.min.js b/history.ielte7.min.js index ea94ed7..ca21954 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.4 + * History API JavaScript Library v4.2.5 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -11,26 +11,26 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-10-16 22:16 + * Update: 2015-12-22 14:26 */ -(function(p){if("function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;p.toString=function(){return w};requirejs.onError=function(p){-1===p.message.indexOf(w)&&l.call(requirejs,p)};define([],p)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=p();else return p()})(function(){var i=!0,k=null,o=!1;function p(a,b){var c=d.history!==q;c&&(d.history=q);a.apply(q,b);c&&(d.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),e=g.getElementsByTagName("base")[0]; -!c&&e&&e.getAttribute("href")&&(e.href=e.href,b=l(e.href,k,i));c=b.e;e=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?e+a:a:e+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",e=a[5]||"",d="#"===a[6]?"":a[6]||"",S=c+e+d,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+e;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:e,b:d,c:S,j:x,d:x+d}}function ba(){var a;try{a=d.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),g.close();!d&&a&&(r[f.href]=a)}};z=function(b,c,f,g){e.apply(this,arguments)||(b===s?s[c]=f:b===m?(m[c]=f,"state"===c&&(s=a(s),d.history=m=a(m),d.execScript("var history = window.history;","JavaScript"))):b[c]=f.get&&f.get());return b}; -setInterval(function(){var a=l().a;if(a!=h){var b=g.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);d.JSON=t}}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,J=g.documentElement,G=d.Object,t=d.JSON,f=d.location,q=d.history,m=q,O=q.pushState,Y=q.replaceState,j=!!O,I="state"in q,D=G.defineProperty,s=z({},"t")?{}:g.createElement("a"),y="",P=d.addEventListener?"addEventListener":(y="on")&&"attachEvent", -Z=d.removeEventListener?"removeEventListener":"detachEvent",$=d.dispatchEvent?"dispatchEvent":"fireEvent",v=d[P],L=d[Z],ea=d[$],h={basepath:"/",redirect:0,type:"/",init:0},F="__historyAPI__",R=g.createElement("a"),B=f.href,V="",T=1,E=o,n=0,r={},A={},C=g.title,Q,ha={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){m.setup(b,a);b=h.basepath;if(d.top==d.self){var c= -l(k,o,i).c,e=f.pathname+f.search;j?(e=e.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(e)&&f.replace(c)):e!=b&&(e=e.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(e)&&f.replace(b+"#"+e.replace(RegExp("^"+b,"i"),h.type)+f.hash))}},pushState:function(a,b,c){var d=g.title;C!=k&&(g.title=C);O&&p(O,arguments);u(a,c);g.title=d;C=b},replaceState:function(a,b,c){var d=g.title;C!=k&&(g.title=C);delete r[f.href];Y&&p(Y,arguments);u(a,c,i);g.title=d;C=b},location:{set:function(a){0===n&&(n=1); -d.location=a},get:function(){0===n&&(n=1);return s}},state:{get:function(){return r[f.href]||k}}},M={assign:function(a){!j&&0===(""+a).indexOf("#")?u(k,a):f.assign(a)},reload:function(a){f.reload(a)},replace:function(a){!j&&0===(""+a).indexOf("#")?u(k,a,i):f.replace(a)},toString:function(){return this.href},origin:{get:function(){return void 0!==Q?Q:!f.origin?f.protocol+"//"+f.hostname+(f.port?":"+f.port:""):f.origin},set:function(a){Q=a}},href:j?k:{get:function(){return l().a}},protocol:k,host:k, -hostname:k,port:k,pathname:j?k:{get:function(){return l().e}},search:j?k:{get:function(){return l().f}},hash:j?k:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),o,B)},get:function(){return l().b}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ga();v(y+"hashchange",N,o);var b=[M,s,ha,d,aa,m];I&&delete aa.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),f.close();!g&&a&&(n[d.href]=a)}};z=function(b,c, +d,f){g.apply(this,arguments)||(b===t?t[c]=d:b===m?(m[c]=d,"state"===c&&(t=a(t),e.history=m=a(m),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=l().a;if(a!=h){var b=f.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);e.JSON=s}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var f=e.document,J=f.documentElement,G=e.Object,s=e.JSON,d=e.location,r= +e.history,m=r,O=r.pushState,Y=r.replaceState,j=function(){var a=e.navigator.userAgent;return(-1!==a.indexOf("Android 2.")||-1!==a.indexOf("Android 4.0"))&&-1!==a.indexOf("Mobile Safari")&&-1===a.indexOf("Chrome")&&-1===a.indexOf("Windows Phone")?p:!!O}(),I="state"in r,D=G.defineProperty,t=z({},"t")?{}:f.createElement("a"),y="",P=e.addEventListener?"addEventListener":(y="on")&&"attachEvent",Z=e.removeEventListener?"removeEventListener":"detachEvent",$=e.dispatchEvent?"dispatchEvent":"fireEvent",v= +e[P],L=e[Z],ga=e[$],h={basepath:"/",redirect:0,type:"/",init:0},F="__historyAPI__",R=f.createElement("a"),B=d.href,V="",T=1,E=p,o=0,n={},A={},C=f.title,Q,ja={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){m.setup(b,a);b=h.basepath;if(e.top==e.self){var c=l(k,p,i).c,g=d.pathname+d.search;j?(g=g.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(g)&& +d.replace(c)):g!=b&&(g=g.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(g)&&d.replace(b+"#"+g.replace(RegExp("^"+b,"i"),h.type)+d.hash))}},pushState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);O&&q(O,arguments);u(a,c);f.title=e;C=b},replaceState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);delete n[d.href];Y&&q(Y,arguments);u(a,c,i);f.title=e;C=b},location:{set:function(a){0===o&&(o=1);e.location=a},get:function(){0===o&&(o=1);return t}},state:{get:function(){return"object"===typeof n[d.href]? +s.parse(s.stringify(n[d.href])):"undefined"!==typeof n[d.href]?n[d.href]:k}}},M={assign:function(a){!j&&0===(""+a).indexOf("#")?u(k,a):d.assign(a)},reload:function(a){d.reload(a)},replace:function(a){!j&&0===(""+a).indexOf("#")?u(k,a,i):d.replace(a)},toString:function(){return this.href},origin:{get:function(){return void 0!==Q?Q:!d.origin?d.protocol+"//"+d.hostname+(d.port?":"+d.port:""):d.origin},set:function(a){Q=a}},href:j?k:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:j? +k:{get:function(){return l().e}},search:j?k:{get:function(){return l().f}},hash:j?k:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return l().b}}};if(function(){var a=f.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ia();v(y+"hashchange",N,p);var b=[M,t,ja,e,aa,m];I&&delete aa.state;for(var c=0;c Date: Sun, 7 Feb 2016 23:39:51 +0000 Subject: [PATCH 69/81] Fixed #87 parse URL regex now works with Chrome apps scheme. --- history.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/history.js b/history.js index 0cb296b..0f14ca5 100644 --- a/history.js +++ b/history.js @@ -413,8 +413,8 @@ * @return {Object} */ function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; - if (href != null && href !== '' && !isWindowLocation) { + var re = /(?:([a-zA-Z\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + if (href !== null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; if (!isNotAPI && base && base.getAttribute('href')) { From e40f70bb67e64c043bf3edad8573de98cb88de0b Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Wed, 10 Feb 2016 04:09:48 +0000 Subject: [PATCH 70/81] Parse URL regex now support digits in schema. --- history.ielte7.js | 2 +- history.ielte7.min.js | 4 +-- history.js | 2 +- history.min.js | 4 +-- package.json | 68 ++++++++++++++++++++++--------------------- 5 files changed, 41 insertions(+), 39 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index 69570f2..776baf9 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -413,7 +413,7 @@ * @return {Object} */ function parseURL(href, isWindowLocation, isNotAPI) { - var re = /(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; + var re = /(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; diff --git a/history.ielte7.min.js b/history.ielte7.min.js index ca21954..75d8412 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -14,7 +14,7 @@ * Update: 2015-12-22 14:26 */ (function(q){if("function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)};define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; -!c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:(\w+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), +!c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",S=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:S,j:x,d:x+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1 Date: Wed, 10 Feb 2016 10:24:42 +0000 Subject: [PATCH 71/81] Restored original manifest file. --- package.json | 68 +++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index f3c3d6b..2eba648 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,35 @@ { - "name": "html5-history-api", - "version": "4.2.5", - "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "keywords": [ - "javascript", - "html5 history api", - "hashchange", - "popstate", - "pushstate", - "replacestate", - "hashes", - "hashbang", - "history", - "html5", - "devote" - ], - "licenses": [ - {}, - {} - ], - "author": "Dmitrii Pakhtinov", - "main": "history.js", - "repository": { - "type": "git", - "url": "git://github.com/devote/HTML5-History-API.git" - }, - "npmName": "html5-history-api", - "npmFileMap": [ - { - "basePath": "/", - "files": [ - "*.js" - ] - } - ] + "name": "html5-history-api", + "npmName": "html5-history-api", + "npmFileMap": [{ + "basePath": "/", + "files": [ + "*.js" + ] + }], + "version": "4.2.5", + "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", + "main": "history.js", + "repository": { + "type": "git", + "url": "git://github.com/devote/HTML5-History-API.git" + }, + "keywords": [ + "javascript", + "html5 history api", + "hashchange", + "popstate", + "pushstate", + "replacestate", + "hashes", + "hashbang", + "history", + "html5", + "devote" + ], + "author": "Dmitrii Pakhtinov", + "licenses": [ + "GPL-3.0", + "MIT" + ] } From 825d10706749e918a15c388e435365340743bf93 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Thu, 3 Mar 2016 00:12:06 +0300 Subject: [PATCH 72/81] Remove GPL license and bump version --- LICENSE-GPL | 674 ------------------------------------------ LICENSE-MIT | 2 +- bower.json | 4 +- component.json | 4 +- history.ielte7.js | 7 +- history.ielte7.min.js | 7 +- history.js | 7 +- history.min.js | 7 +- package.json | 3 +- 9 files changed, 17 insertions(+), 698 deletions(-) delete mode 100644 LICENSE-GPL diff --git a/LICENSE-GPL b/LICENSE-GPL deleted file mode 100644 index 94a9ed0..0000000 --- a/LICENSE-GPL +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/LICENSE-MIT b/LICENSE-MIT index 7f96fb1..334d054 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License (MIT) -Copyright (c) 2010-2015 Dmitrii Pakhtinov +Copyright (c) 2010-2016 Dmitrii Pakhtinov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bower.json b/bower.json index 901ad3b..defe941 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.5", + "version": "4.2.6", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], @@ -19,8 +19,6 @@ "url": "http://spb-piksel.ru" }, "licenses": [{ - "type": "GPL-3.0" - }, { "type": "MIT" }] } diff --git a/component.json b/component.json index f982671..8d278ca 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.5", + "version": "4.2.6", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], @@ -19,5 +19,5 @@ "devote" ], "author": "Dmitrii Pakhtinov", - "license": "GPL-3.0/MIT" + "license": "MIT" } diff --git a/history.ielte7.js b/history.ielte7.js index 776baf9..fb675a5 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.5 + * History API JavaScript Library v4.2.6 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -7,11 +7,10 @@ * * http://spb-piksel.ru/ * - * Dual licensed under the MIT and GPL licenses: + * MIT license: * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-12-22 14:26 + * Update: 2016-02-10 11:37 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 75d8412..9ed4899 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.5 + * History API JavaScript Library v4.2.6 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -7,11 +7,10 @@ * * http://spb-piksel.ru/ * - * Dual licensed under the MIT and GPL licenses: + * MIT license: * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-12-22 14:26 + * Update: 2016-02-10 11:37 */ (function(q){if("function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)};define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; !c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), diff --git a/history.js b/history.js index 51b7eaf..b5cb19f 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.5 + * History API JavaScript Library v4.2.6 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -7,11 +7,10 @@ * * http://spb-piksel.ru/ * - * Dual licensed under the MIT and GPL licenses: + * MIT license: * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-12-22 14:26 + * Update: 2016-02-10 11:37 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.min.js b/history.min.js index 8d35fbc..f9391bd 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.5 + * History API JavaScript Library v4.2.6 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -7,11 +7,10 @@ * * http://spb-piksel.ru/ * - * Dual licensed under the MIT and GPL licenses: + * MIT license: * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html * - * Update: 2015-12-22 14:26 + * Update: 2016-02-10 11:37 */ (function(m){if("function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",j=requirejs.onError;m.toString=function(){return w};requirejs.onError=function(m){-1===m.message.indexOf(w)&&j.call(requirejs,m)};define([],m)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=m();else return m()})(function(){var h=!0,i=null,p=!1;function m(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=k)}function w(){}function j(a,b,c){if(a!=i&&""!==a&&!b){var b=j(),d=g.getElementsByTagName("base")[0]; !c&&(d&&d.getAttribute("href"))&&(d.href=d.href,b=j(d.href,i,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");N.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(N.href), diff --git a/package.json b/package.json index 2eba648..4b4dfc0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "*.js" ] }], - "version": "4.2.5", + "version": "4.2.6", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { @@ -29,7 +29,6 @@ ], "author": "Dmitrii Pakhtinov", "licenses": [ - "GPL-3.0", "MIT" ] } From 94dd3bc3523f7c67aec95f8ae4d7d1f21a24c363 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Tue, 8 Mar 2016 16:36:58 +0300 Subject: [PATCH 73/81] #92 Added check for requirejs --- history.ielte7.js | 2 +- history.ielte7.min.js | 2 +- history.js | 2 +- history.min.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index fb675a5..a297dd7 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -13,7 +13,7 @@ * Update: 2016-02-10 11:37 */ (function(factory) { - if (typeof define === 'function' && define['amd']) { + if (typeof requirejs !== 'undefined' && typeof define === 'function' && define['amd']) { // https://github.com/devote/HTML5-History-API/issues/73 var rndKey = '[history' + (new Date()).getTime() + ']'; var onError = requirejs['onError']; diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 9ed4899..e4f076e 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -12,7 +12,7 @@ * * Update: 2016-02-10 11:37 */ -(function(q){if("function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)};define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; +(function(q){if("undefined"!==typeof requirejs&&"function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)};define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; !c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",S=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:S,j:x,d:x+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1 Date: Tue, 8 Mar 2016 16:42:52 +0300 Subject: [PATCH 74/81] #92 moved condition --- history.ielte7.js | 26 ++++++++++++++------------ history.ielte7.min.js | 2 +- history.js | 26 ++++++++++++++------------ history.min.js | 2 +- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/history.ielte7.js b/history.ielte7.js index a297dd7..bb2946f 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -13,18 +13,20 @@ * Update: 2016-02-10 11:37 */ (function(factory) { - if (typeof requirejs !== 'undefined' && typeof define === 'function' && define['amd']) { - // https://github.com/devote/HTML5-History-API/issues/73 - var rndKey = '[history' + (new Date()).getTime() + ']'; - var onError = requirejs['onError']; - factory.toString = function() { - return rndKey; - }; - requirejs['onError'] = function(err) { - if (err.message.indexOf(rndKey) === -1) { - onError.call(requirejs, err); - } - }; + if (typeof define === 'function' && define['amd']) { + if (typeof requirejs !== 'undefined') { + // https://github.com/devote/HTML5-History-API/issues/73 + var rndKey = '[history' + (new Date()).getTime() + ']'; + var onError = requirejs['onError']; + factory.toString = function() { + return rndKey; + }; + requirejs['onError'] = function(err) { + if (err.message.indexOf(rndKey) === -1) { + onError.call(requirejs, err); + } + }; + } define([], factory); } // commonJS support diff --git a/history.ielte7.min.js b/history.ielte7.min.js index e4f076e..6aff079 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -12,7 +12,7 @@ * * Update: 2016-02-10 11:37 */ -(function(q){if("undefined"!==typeof requirejs&&"function"===typeof define&&define.amd){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)};define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; +(function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; !c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",S=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:S,j:x,d:x+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1 Date: Tue, 8 Mar 2016 16:52:17 +0300 Subject: [PATCH 75/81] #89 condition as in minified version files --- history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history.js b/history.js index c0d45cb..646b76a 100644 --- a/history.js +++ b/history.js @@ -415,7 +415,7 @@ */ function parseURL(href, isWindowLocation, isNotAPI) { var re = /(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/; - if (href !== null && href !== '' && !isWindowLocation) { + if (href != null && href !== '' && !isWindowLocation) { var current = parseURL(), base = document.getElementsByTagName('base')[0]; if (!isNotAPI && base && base.getAttribute('href')) { From 91c6dc97c22f035e212fd1f0668e99eeec4b750b Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Tue, 8 Mar 2016 16:58:31 +0300 Subject: [PATCH 76/81] bump version --- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 4 ++-- history.ielte7.min.js | 4 ++-- history.js | 4 ++-- history.min.js | 4 ++-- package.json | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index defe941..4420e3a 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.6", + "version": "4.2.7", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 8d278ca..a6dad71 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.6", + "version": "4.2.7", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index bb2946f..a835cf2 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.6 + * History API JavaScript Library v4.2.7 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-02-10 11:37 + * Update: 2016-03-08 16:57 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 6aff079..f773e6b 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.6 + * History API JavaScript Library v4.2.7 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-02-10 11:37 + * Update: 2016-03-08 16:57 */ (function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; !c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), diff --git a/history.js b/history.js index 646b76a..59cf345 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.6 + * History API JavaScript Library v4.2.7 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-02-10 11:37 + * Update: 2016-03-08 16:57 */ (function(factory) { if (typeof define === 'function' && define['amd']) { diff --git a/history.min.js b/history.min.js index d12409d..4883c27 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.6 + * History API JavaScript Library v4.2.7 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-02-10 11:37 + * Update: 2016-03-08 16:57 */ (function(m){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var w="[history"+(new Date).getTime()+"]",j=requirejs.onError;m.toString=function(){return w};requirejs.onError=function(m){-1===m.message.indexOf(w)&&j.call(requirejs,m)}}define([],m)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=m();else return m()})(function(){var h=!0,i=null,p=!1;function m(a,b){var c=e.history!==q;c&&(e.history=q);a.apply(q,b);c&&(e.history=k)}function w(){}function j(a,b,c){if(a!=i&&""!==a&&!b){var b=j(),d=g.getElementsByTagName("base")[0]; !c&&(d&&d.getAttribute("href"))&&(d.href=d.href,b=j(d.href,i,h));c=b.d;d=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?d+a:a:d+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:f.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=f.protocol.replace(/:.*$|$/,":")+"//"+f.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");N.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(N.href), diff --git a/package.json b/package.json index 4b4dfc0..7320043 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "*.js" ] }], - "version": "4.2.6", + "version": "4.2.7", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "repository": { From 6883b7e98fd6fcadeee0125b87b48cb6b8d8fd57 Mon Sep 17 00:00:00 2001 From: Dmitriy Pakhtinov Date: Wed, 1 Mar 2017 12:10:24 +0300 Subject: [PATCH 77/81] #104 Can not bundle package using webpack 2 --- LICENSE-MIT | 2 +- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 15 ++++++++------- history.ielte7.min.js | 8 ++++---- history.js | 15 ++++++++------- history.min.js | 8 ++++---- package.json | 2 +- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index 334d054..d381b35 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License (MIT) -Copyright (c) 2010-2016 Dmitrii Pakhtinov +Copyright (c) 2010-2017 Dmitrii Pakhtinov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bower.json b/bower.json index 4420e3a..f19ece9 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.7", + "version": "4.2.8", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index a6dad71..072f524 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.7", + "version": "4.2.8", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index a835cf2..964324a 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,29 +1,30 @@ /*! - * History API JavaScript Library v4.2.7 + * History API JavaScript Library v4.2.8 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2015, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2017, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-03-08 16:57 + * Update: 2017-03-01 12:07 */ (function(factory) { if (typeof define === 'function' && define['amd']) { if (typeof requirejs !== 'undefined') { // https://github.com/devote/HTML5-History-API/issues/73 - var rndKey = '[history' + (new Date()).getTime() + ']'; - var onError = requirejs['onError']; + var r = requirejs, + rndKey = '[history' + (new Date()).getTime() + ']'; + var onError = r['onError']; factory.toString = function() { return rndKey; }; - requirejs['onError'] = function(err) { + r['onError'] = function(err) { if (err.message.indexOf(rndKey) === -1) { - onError.call(requirejs, err); + onError.call(r, err); } }; } diff --git a/history.ielte7.min.js b/history.ielte7.min.js index f773e6b..8390d3f 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,18 +1,18 @@ /*! - * History API JavaScript Library v4.2.7 + * History API JavaScript Library v4.2.8 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2015, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2017, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2016-03-08 16:57 + * Update: 2017-03-01 12:07 */ -(function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var w="[history"+(new Date).getTime()+"]",l=requirejs.onError;q.toString=function(){return w};requirejs.onError=function(q){-1===q.message.indexOf(w)&&l.call(requirejs,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; +(function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var r=requirejs,w="[history"+(new Date).getTime()+"]",l=r.onError;q.toString=function(){return w};r.onError=function(q){-1===q.message.indexOf(w)&&l.call(r,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; !c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",S=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:S,j:x,d:x+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1 Date: Tue, 20 Mar 2018 14:00:11 -0500 Subject: [PATCH 78/81] bind addEventListener, removeEventListener, and dispatchEvent for browsers that support EventTarget --- history.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/history.js b/history.js index 50b1290..71f638f 100644 --- a/history.js +++ b/history.js @@ -77,9 +77,9 @@ // String that will contain the name of the method var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; // reference native methods for the events - var addEvent = global[addEventListenerName]; - var removeEvent = global[removeEventListenerName]; - var dispatch = global[dispatchEventName]; + var addEvent = maybeBindToWindow(global[addEventListenerName]); + var removeEvent = maybeBindToWindow(global[removeEventListenerName]); + var dispatch = maybeBindToWindow(global[dispatchEventName]); // default settings var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; // key for the sessionStorage @@ -499,6 +499,22 @@ return !!historyPushState; } + /** + * This method attempts to bind a function to global. + * + * @param {Function} [func] The function to be bound + * @return {Function} Returns the bound function or func + */ + function maybeBindToWindow(func) { + if (window && + window.EventTarget && + typeof window.EventTarget.prototype.addEventListener === 'function' && + typeof func.bind === 'function') { + return func.bind(window); + } + return func; + } + /** * Initializing storage for the custom state's object */ From 7c10f3bc6a22361bd134d0328dd42f157500f7f8 Mon Sep 17 00:00:00 2001 From: Dmitrii Pakhtinov Date: Fri, 13 Apr 2018 10:48:08 +0300 Subject: [PATCH 79/81] bump version --- LICENSE-MIT | 2 +- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 28 +++++++++++++++++++------ history.ielte7.min.js | 49 ++++++++++++++++++++++--------------------- history.js | 22 +++++++++---------- history.min.js | 37 ++++++++++++++++---------------- package.json | 2 +- 8 files changed, 81 insertions(+), 63 deletions(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index d381b35..4ca5750 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License (MIT) -Copyright (c) 2010-2017 Dmitrii Pakhtinov +Copyright (c) 2010-2018 Dmitrii Pakhtinov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bower.json b/bower.json index f19ece9..b306738 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.8", + "version": "4.2.9", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 072f524..06339d7 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.8", + "version": "4.2.9", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index 964324a..af1beb9 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,16 +1,16 @@ /*! - * History API JavaScript Library v4.2.8 + * History API JavaScript Library v4.2.9 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2017, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2018, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2017-03-01 12:07 + * Update: 2018-04-13 10:30 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -77,9 +77,9 @@ // String that will contain the name of the method var dispatchEventName = global.dispatchEvent ? 'dispatchEvent' : 'fireEvent'; // reference native methods for the events - var addEvent = global[addEventListenerName]; - var removeEvent = global[removeEventListenerName]; - var dispatch = global[dispatchEventName]; + var addEvent = maybeBindToGlobal(global[addEventListenerName]); + var removeEvent = maybeBindToGlobal(global[removeEventListenerName]); + var dispatch = maybeBindToGlobal(global[dispatchEventName]); // default settings var settings = {"basepath": '/', "redirect": 0, "type": '/', "init": 0}; // key for the sessionStorage @@ -499,6 +499,22 @@ return !!historyPushState; } + /** + * This method attempts to bind a function to global. + * + * @param {Function} [func] The function to be bound + * @return {Function} Returns the bound function or func + */ + function maybeBindToGlobal(func) { + if (func && global && + global.EventTarget && + typeof global.EventTarget.prototype.addEventListener === 'function' && + typeof func.bind === 'function') { + return func.bind(global); + } + return func; + } + /** * Initializing storage for the custom state's object */ diff --git a/history.ielte7.min.js b/history.ielte7.min.js index 8390d3f..d3dba49 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,35 +1,36 @@ /*! - * History API JavaScript Library v4.2.8 + * History API JavaScript Library v4.2.9 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * - * Copyright 2011-2017, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) + * Copyright 2011-2018, Dmitrii Pakhtinov ( spb.piksel@gmail.com ) * * http://spb-piksel.ru/ * * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2017-03-01 12:07 + * Update: 2018-04-13 10:30 */ -(function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var r=requirejs,w="[history"+(new Date).getTime()+"]",l=r.onError;q.toString=function(){return w};r.onError=function(q){-1===q.message.indexOf(w)&&l.call(r,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function w(){}function l(a,b,c){if(a!=k&&""!==a&&!b){var b=l(),g=f.getElementsByTagName("base")[0]; -!c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");R.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(R.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",S=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+S,h:a[1],g:b,i:a[2],k:a[3]||"",e:c,f:g,b:e,c:S,j:x,d:x+e}}function ba(){var a;try{a=e.sessionStorage,a.setItem(F+"t","1"),a.removeItem(F+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g,'\\"')+'";<\/script>'),f.close();!g&&a&&(n[d.href]=a)}};z=function(b,c, -d,f){g.apply(this,arguments)||(b===t?t[c]=d:b===m?(m[c]=d,"state"===c&&(t=a(t),e.history=m=a(m),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=l().a;if(a!=h){var b=f.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";N(b)}},100);e.JSON=s}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var f=e.document,J=f.documentElement,G=e.Object,s=e.JSON,d=e.location,r= -e.history,m=r,O=r.pushState,Y=r.replaceState,j=function(){var a=e.navigator.userAgent;return(-1!==a.indexOf("Android 2.")||-1!==a.indexOf("Android 4.0"))&&-1!==a.indexOf("Mobile Safari")&&-1===a.indexOf("Chrome")&&-1===a.indexOf("Windows Phone")?p:!!O}(),I="state"in r,D=G.defineProperty,t=z({},"t")?{}:f.createElement("a"),y="",P=e.addEventListener?"addEventListener":(y="on")&&"attachEvent",Z=e.removeEventListener?"removeEventListener":"detachEvent",$=e.dispatchEvent?"dispatchEvent":"fireEvent",v= -e[P],L=e[Z],ga=e[$],h={basepath:"/",redirect:0,type:"/",init:0},F="__historyAPI__",R=f.createElement("a"),B=d.href,V="",T=1,E=p,o=0,n={},A={},C=f.title,Q,ja={onhashchange:k,onpopstate:k},aa={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){m.setup(b,a);b=h.basepath;if(e.top==e.self){var c=l(k,p,i).c,g=d.pathname+d.search;j?(g=g.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(g)&& -d.replace(c)):g!=b&&(g=g.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(g)&&d.replace(b+"#"+g.replace(RegExp("^"+b,"i"),h.type)+d.hash))}},pushState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);O&&q(O,arguments);u(a,c);f.title=e;C=b},replaceState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);delete n[d.href];Y&&q(Y,arguments);u(a,c,i);f.title=e;C=b},location:{set:function(a){0===o&&(o=1);e.location=a},get:function(){0===o&&(o=1);return t}},state:{get:function(){return"object"===typeof n[d.href]? -s.parse(s.stringify(n[d.href])):"undefined"!==typeof n[d.href]?n[d.href]:k}}},M={assign:function(a){!j&&0===(""+a).indexOf("#")?u(k,a):d.assign(a)},reload:function(a){d.reload(a)},replace:function(a){!j&&0===(""+a).indexOf("#")?u(k,a,i):d.replace(a)},toString:function(){return this.href},origin:{get:function(){return void 0!==Q?Q:!d.origin?d.protocol+"//"+d.hostname+(d.port?":"+d.port:""):d.origin},set:function(a){Q=a}},href:j?k:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:j? -k:{get:function(){return l().e}},search:j?k:{get:function(){return l().f}},hash:j?k:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return l().b}}};if(function(){var a=f.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ia();v(y+"hashchange",N,p);var b=[M,t,ja,e,aa,m];I&&delete aa.state;for(var c=0;clfirst=1;parent.location.hash="'+b.d.replace(/"/g, +'\\"')+'";<\/script>'),f.close();!g&&a&&(n[d.href]=a)}};z=function(b,c,d,f){g.apply(this,arguments)||(b===t?t[c]=d:b===m?(m[c]=d,"state"===c&&(t=a(t),e.history=m=a(m),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=l().a;if(a!=h){var b=f.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);e.JSON=s}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var f= +e.document,K=f.documentElement,H=e.Object,s=e.JSON,d=e.location,r=e.history,m=r,P=r.pushState,Z=r.replaceState,j=function(){var a=e.navigator.userAgent;return(-1!==a.indexOf("Android 2.")||-1!==a.indexOf("Android 4.0"))&&-1!==a.indexOf("Mobile Safari")&&-1===a.indexOf("Chrome")&&-1===a.indexOf("Windows Phone")?p:!!P}(),J="state"in r,E=H.defineProperty,t=z({},"t")?{}:f.createElement("a"),y="",Q=e.addEventListener?"addEventListener":(y="on")&&"attachEvent",$=e.removeEventListener?"removeEventListener": +"detachEvent",aa=e.dispatchEvent?"dispatchEvent":"fireEvent",w=D(e[Q]),M=D(e[$]),ha=D(e[aa]),h={basepath:"/",redirect:0,type:"/",init:0},G="__historyAPI__",S=f.createElement("a"),B=d.href,W="",U=1,F=p,o=0,n={},A={},C=f.title,R,ka={onhashchange:k,onpopstate:k},ba={setup:function(a,b,c){h.basepath=(""+(a==k?h.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");h.type=b==k?h.type:b;h.redirect=c==k?h.redirect:!!c},redirect:function(a,b){m.setup(b,a);b=h.basepath;if(e.top==e.self){var c=l(k,p,i).c,g=d.pathname+ +d.search;j?(g=g.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(g)&&d.replace(c)):g!=b&&(g=g.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(g)&&d.replace(b+"#"+g.replace(RegExp("^"+b,"i"),h.type)+d.hash))}},pushState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);P&&q(P,arguments);u(a,c);f.title=e;C=b},replaceState:function(a,b,c){var e=f.title;C!=k&&(f.title=C);delete n[d.href];Z&&q(Z,arguments);u(a,c,i);f.title=e;C=b},location:{set:function(a){0===o&&(o=1);e.location=a},get:function(){0=== +o&&(o=1);return t}},state:{get:function(){return"object"===typeof n[d.href]?s.parse(s.stringify(n[d.href])):"undefined"!==typeof n[d.href]?n[d.href]:k}}},N={assign:function(a){!j&&0===(""+a).indexOf("#")?u(k,a):d.assign(a)},reload:function(a){d.reload(a)},replace:function(a){!j&&0===(""+a).indexOf("#")?u(k,a,i):d.replace(a)},toString:function(){return this.href},origin:{get:function(){return void 0!==R?R:!d.origin?d.protocol+"//"+d.hostname+(d.port?":"+d.port:""):d.origin},set:function(a){R=a}},href:j? +k:{get:function(){return l().a}},protocol:k,host:k,hostname:k,port:k,pathname:j?k:{get:function(){return l().e}},search:j?k:{get:function(){return l().f}},hash:j?k:{set:function(a){u(k,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return l().b}}};if(function(){var a=f.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():"").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){h[b]=(c||"").replace(/^(0|false)$/,"")});ja();w(y+"hashchange",O,p);var b=[N,t, +ka,e,ba,m];J&&delete ba.state;for(var c=0;c Date: Sun, 15 Apr 2018 13:59:16 +0300 Subject: [PATCH 80/81] fast fix: advanced compression failed --- bower.json | 2 +- component.json | 2 +- history.ielte7.js | 8 ++++---- history.ielte7.min.js | 26 +++++++++++++------------- history.js | 8 ++++---- history.min.js | 34 +++++++++++++++++----------------- package.json | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/bower.json b/bower.json index b306738..865be98 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "html5-history-api", "repo": "devote/HTML5-History-API", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", - "version": "4.2.9", + "version": "4.2.10", "keywords": ["history", "pushState", "replaceState"], "main": "history.js", "scripts": ["history.js"], diff --git a/component.json b/component.json index 06339d7..ef1add6 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "html5-history-api", - "version": "4.2.9", + "version": "4.2.10", "description": "HTML5 History API expansion for browsers not supporting pushState, replaceState", "main": "history.js", "scripts": ["history.js"], diff --git a/history.ielte7.js b/history.ielte7.js index af1beb9..2eb7a91 100644 --- a/history.ielte7.js +++ b/history.ielte7.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.9 + * History API JavaScript Library v4.2.10 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2018-04-13 10:30 + * Update: 2018-04-15 13:54 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -507,8 +507,8 @@ */ function maybeBindToGlobal(func) { if (func && global && - global.EventTarget && - typeof global.EventTarget.prototype.addEventListener === 'function' && + global['EventTarget'] && + typeof global['EventTarget'].prototype.addEventListener === 'function' && typeof func.bind === 'function') { return func.bind(global); } diff --git a/history.ielte7.min.js b/history.ielte7.min.js index d3dba49..7758572 100644 --- a/history.ielte7.min.js +++ b/history.ielte7.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.9 + * History API JavaScript Library v4.2.10 * * Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,20 +10,20 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2018-04-13 10:30 + * Update: 2018-04-15 13:54 */ (function(q){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var v=requirejs,l="[history"+(new Date).getTime()+"]",D=v.onError;q.toString=function(){return l};v.onError=function(q){-1===q.message.indexOf(l)&&D.call(v,q)}}define([],q)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=q();else return q()})(function(){var i=!0,k=null,p=!1;function q(a,b){var c=e.history!==r;c&&(e.history=r);a.apply(r,b);c&&(e.history=m)}function v(){}function l(a,b,c){if(a!=k&&""!==a&& -!b){var b=l(),g=f.getElementsByTagName("base")[0];!c&&(g&&g.getAttribute("href"))&&(g.href=g.href,b=l(g.href,k,i));c=b.e;g=b.i;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?g+a:a:g+"//"+b.h+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.f+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:d.href,!j||c)a=a.replace(/^[^#]*/,"")||"#",a=d.protocol.replace(/:.*$|$/,":")+"//"+d.host+h.basepath+a.replace(RegExp("^#[/]?(?:"+h.type+")?"),"");S.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(S.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",g=a[5]||"",e="#"===a[6]?"":a[6]||"",T=c+g+e,x=c.replace(RegExp("^"+h.basepath,"i"),h.type)+g;return{a:a[1]+"//"+b+T,i:a[1],h:b,j:a[2],l:a[3]||"",e:c,f:g,b:e,c:T,k:x,d:x+e}}function D(a){return a&&e&&e.g&&"function"===typeof e.g.prototype.addEventListener&&"function"===typeof a.bind?a.bind(e):a}function ca(){var a;try{a=e.sessionStorage,a.setItem(G+"t","1"),a.removeItem(G+"t")}catch(b){a={getItem:function(a){a=f.cookie.split(a+"=");return 1lfirst=1;parent.location.hash="'+b.d.replace(/"/g, '\\"')+'";<\/script>'),f.close();!g&&a&&(n[d.href]=a)}};z=function(b,c,d,f){g.apply(this,arguments)||(b===t?t[c]=d:b===m?(m[c]=d,"state"===c&&(t=a(t),e.history=m=a(m),e.execScript("var history = window.history;","JavaScript"))):b[c]=d.get&&d.get());return b};setInterval(function(){var a=l().a;if(a!=h){var b=f.createEventObject();b.oldURL=h;b.newURL=h=a;b.type="hashchange";O(b)}},100);e.JSON=s}}var e=("object"===typeof window?window:this)||{};if(!e.history||"emulate"in e.history)return e.history;var f= diff --git a/history.js b/history.js index 9e33d16..31b76da 100644 --- a/history.js +++ b/history.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.9 + * History API JavaScript Library v4.2.10 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,7 +10,7 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2018-04-13 10:30 + * Update: 2018-04-15 13:54 */ (function(factory) { if (typeof define === 'function' && define['amd']) { @@ -507,8 +507,8 @@ */ function maybeBindToGlobal(func) { if (func && global && - global.EventTarget && - typeof global.EventTarget.prototype.addEventListener === 'function' && + global['EventTarget'] && + typeof global['EventTarget'].prototype.addEventListener === 'function' && typeof func.bind === 'function') { return func.bind(global); } diff --git a/history.min.js b/history.min.js index 7c33eb9..d2bab18 100644 --- a/history.min.js +++ b/history.min.js @@ -1,5 +1,5 @@ /*! - * History API JavaScript Library v4.2.9 + * History API JavaScript Library v4.2.10 * * Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other * @@ -10,21 +10,21 @@ * MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Update: 2018-04-13 10:30 + * Update: 2018-04-15 13:54 */ (function(m){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var s=requirejs,j="[history"+(new Date).getTime()+"]",y=s.onError;m.toString=function(){return j};s.onError=function(m){-1===m.message.indexOf(j)&&y.call(s,m)}}define([],m)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=m();else return m()})(function(){var h=!0,i=null,p=!1;function m(a,b){var c=d.history!==q;c&&(d.history=q);a.apply(q,b);c&&(d.history=k)}function s(){}function j(a,b,c){if(a!=i&&""!==a&& -!b){var b=j(),f=g.getElementsByTagName("base")[0];!c&&(f&&f.getAttribute("href"))&&(f.href=f.href,b=j(f.href,i,h));c=b.d;f=b.i;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?f+a:a:f+"//"+b.h+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:e.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=e.protocol.replace(/:.*$|$/,":")+"//"+e.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");O.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(O.href), -b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",f=a[5]||"",d="#"===a[6]?"":a[6]||"",k=c+f+d,m=c.replace(RegExp("^"+l.basepath,"i"),l.type)+f;return{b:a[1]+"//"+b+k,i:a[1],h:b,j:a[2],l:a[3]||"",d:c,e:f,a:d,c:k,k:m,f:m+d}}function y(a){return a&&d&&d.g&&"function"===typeof d.g.prototype.addEventListener&&"function"===typeof a.bind?a.bind(d):a}function $(){var a;try{a=d.sessionStorage,a.setItem(C+"t","1"),a.removeItem(C+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1 Date: Wed, 30 Sep 2020 20:52:14 +0530 Subject: [PATCH 81/81] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 18fb442..258c630 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ Follow me on Twitter: https://twitter.com/DimaPakhtinov ------------------------------------------------------------------------------------------------------------- -РУССКИЙ +РУССКИЙ (Russian) ============================================================================================================= Библиотека эмулирует HTML5 History API в старых браузерах.