diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/README.markdown b/README.markdown index ff3356c..534ae36 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ # jQuery hashchange event # [http://benalman.com/projects/jquery-hashchange-plugin/](http://benalman.com/projects/jquery-hashchange-plugin/) -Version: 1.3, Last updated: 7/21/2010 +Version: 1.4, Last updated: 5/29/2014 [$.browser support for jQuery 1.9+](https://github.com/sapzxc/jquery-hashchange/) This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event. @@ -25,14 +25,13 @@ tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself). ### jQuery Versions ### -1.2.6, 1.3.2, 1.4.1, 1.4.2 +1.2.6, 1.3.2, 1.4.1, 1.4.2, 1.11.1, 2.1.1 ### Browsers Tested ### -Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. +Internet Explorer 6-11, Firefox 2-32, Chrome 5-38, Safari 3.2-7.1, Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. ### Unit Tests ### -[http://benalman.com/code/projects/jquery-hashchange/unit/](http://benalman.com/code/projects/jquery-hashchange/unit/) - +[http://benalman.com/code/projects/jquery-hashchange/unit/](http://benalman.com/code/projects/jquery-hashchange/unit/) - not supported by repository owner. Clone this repo and open unit/index.html in your browser. ## A more robust solution ## @@ -61,6 +60,7 @@ event, but not report that it does, the fallback polling loop will be used. ## Release History ## +1.4 - (5/29/2014) Changed $.browser.msie to regular expression. 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile-only development. Added IE6/7 document.title support. Attempted to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604. Added support for the "shortcut" format $(window).hashchange( fn ) and $(window).hashchange() like jQuery provides for built-in events. Renamed jQuery.hashchangeDelay to jQuery.fn.hashchange.delay and lowered its default value to 50. Added jQuery.fn.hashchange.domain and jQuery.fn.hashchange.src properties plus document-domain.html file to address access denied issues when setting document.domain in IE6/7. 1.2 - (2/11/2010) Fixed a bug where coming back to a page using this plugin from a page on another domain would cause an error in Safari 4. Also, IE6/7 Iframe is now inserted after the body (this actually works), which prevents the page from scrolling when the event is first bound. Event can also now be bound before DOM ready, but it won't be usable before then in IE6/7. 1.1 - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug where browser version is incorrectly reported as 8.0, despite inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag. diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..51b6551 --- /dev/null +++ b/bower.json @@ -0,0 +1,20 @@ +{ + "name": "jquery-hashchange", + "description": "This jQuery (v1.9+) plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.", + "version": "1.4", + "main": "jquery.ba-hashchange.js", + "keywords": ["hashchange", "bookmark", "history"], + "repository": { + "type": "git", + "url": "git://github.com/sapzxc/jquery-hashchange.git" + }, + "dependencies": { + "jquery": "1.11.1" + }, + "ignore": [ + "unit", + "shared", + "examples", + "docs" + ] +} diff --git a/jquery.ba-hashchange.js b/jquery.ba-hashchange.js index 47105f4..a852070 100644 --- a/jquery.ba-hashchange.js +++ b/jquery.ba-hashchange.js @@ -1,15 +1,15 @@ /*! - * jQuery hashchange event - v1.3 - 7/21/2010 + * jQuery hashchange event - v1.4 - 5/29/2014 * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ + * @license http://benalman.com/about/license/ */ // Script: jQuery hashchange event // -// *Version: 1.3, Last updated: 7/21/2010* +// *Version: 1.4, Last updated: 5/29/2014* // // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/ // GitHub - http://github.com/cowboy/jquery-hashchange/ @@ -36,7 +36,7 @@ // tested with, what browsers it has been tested in, and where the unit tests // reside (so you can test it yourself). // -// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2 +// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2, 1.11.1 // Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. // Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/ @@ -58,6 +58,7 @@ // event, but not report that it does, the fallback polling loop will be used. // // About: Release History +// 1.4 - (5/29/2014) Changed $.browser.msie to regular expression. // // 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more // "removable" for mobile-only development. Added IE6/7 document.title @@ -297,7 +298,8 @@ // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - $.browser.msie && !supports_onhashchange && (function(){ + /msie/.test(navigator.userAgent.toLowerCase()) && + !supports_onhashchange && (function(){ // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8 // when running in "IE7 compatibility" mode. diff --git a/jquery.ba-hashchange.min.js b/jquery.ba-hashchange.min.js index 3c607ba..c645d49 100644 --- a/jquery.ba-hashchange.min.js +++ b/jquery.ba-hashchange.min.js @@ -1,9 +1,9 @@ -/* - * jQuery hashchange event - v1.3 - 7/21/2010 +/*! + * jQuery hashchange event - v1.4 - 5/29/2014 * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ + * @license http://benalman.com/about/license/ */ -(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('