Permalink
Browse files

Further modularized IE6/7 code for maximum ease-of-removal for mobile…

… development. Also, slight minification tweaks.
  • Loading branch information...
1 parent 8da2c03 commit 269e0ed6ec2770ab9e97f48c65011511f1108b3f @cowboy committed Jul 7, 2010
View
@@ -1,7 +1,7 @@
# jQuery hashchange event #
[http://benalman.com/projects/jquery-hashchange-plugin/](http://benalman.com/projects/jquery-hashchange-plugin/)
-Version: 1.3pre, Last updated: 7/5/2010
+Version: 1.3pre, Last updated: 7/6/2010
This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser window.onhashchange event.
@@ -27,7 +27,7 @@ reside (so you can test it yourself).
1.2.6, 1.3.2, 1.4.1, 1.4.2
### Browsers Tested ###
-Internet Explorer 6-8, Firefox 2-4, Safari 3-5, Chrome 3-5, Opera 9.6-10.5.
+Internet Explorer 6-8, Firefox 2-4, Chrome 3-5, Safari 3-5, Opera 9.6-10.60, iPhone 3.1, Android 2.1, BlackBerry 4.6-5.
### Unit Tests ###
[http://benalman.com/code/projects/jquery-hashchange/unit/](http://benalman.com/code/projects/jquery-hashchange/unit/)
@@ -57,7 +57,7 @@ Safari: Back Button from a different domain
## Release History ##
-1.3pre - (7/5/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile development. Added jQuery.hashchangeDomain, jQuery.hashchangeIframeSrc properties and document-domain.html file to address access denied issues when setting document.domain in IE6/7. Note that when using jQuery.hashchangeIframeSrc, history won't be recorded in IE6/7 until the Iframe src file loads. Lowered the default jQuery.hashchangeDelay to 50 milliseconds. Added IE6/7 document.title support. Attempt to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.
+1.3pre - (7/6/2010) Reorganized IE6/7 Iframe code to make it more "removable" for mobile development. Added jQuery.hashchangeDomain, jQuery.hashchangeIframeSrc properties and document-domain.html file to address access denied issues when setting document.domain in IE6/7. Note that when using jQuery.hashchangeIframeSrc, history won't be recorded in IE6/7 until the Iframe src file loads. Lowered the default jQuery.hashchangeDelay to 50 milliseconds. Added IE6/7 document.title support. Attempt to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.
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.
1.0 - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special window.onhashchange functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides. This plugin will be included as part of jQuery BBQ, but also be available separately.

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -13,7 +13,7 @@
<div id=Index><div class=IPageTitle>File Index</div><div class=INavigationBar>$#! &middot; 0-9 &middot; A &middot; B &middot; C &middot; D &middot; E &middot; F &middot; G &middot; H &middot; I &middot; <a href="#J">J</a> &middot; K &middot; L &middot; M &middot; N &middot; O &middot; P &middot; Q &middot; R &middot; S &middot; T &middot; U &middot; V &middot; W &middot; X &middot; Y &middot; Z</div><table border=0 cellspacing=0 cellpadding=0><tr><td class=IHeading id=IFirstHeading><a name="J"></a>J</td><td></td></tr><tr><td class=ISymbolPrefix id=IOnlySymbolPrefix>&nbsp;</td><td class=IEntry><a href="../files/jquery-ba-hashchange-js.html#jQuery_hashchange_event" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')" class=ISymbol>jQuery hashchange event</a></td></tr></table>
<!--START_ND_TOOLTIPS-->
-<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 7/5/2010</b></div></div><!--END_ND_TOOLTIPS-->
+<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 7/6/2010</b></div></div><!--END_ND_TOOLTIPS-->
</div><!--Index-->
View
@@ -21,7 +21,7 @@
<!--START_ND_TOOLTIPS-->
-<div class=CToolTip id="tt6"><div class=CFile><b>Version: 1.3pre, Last updated: 7/5/2010</b></div></div><!--END_ND_TOOLTIPS-->
+<div class=CToolTip id="tt6"><div class=CFile><b>Version: 1.3pre, Last updated: 7/6/2010</b></div></div><!--END_ND_TOOLTIPS-->
<!--START_ND_TOOLTIPS-->
View
@@ -1,4 +1,4 @@
1.4
JavaScript
-/srv/projects/jquery-hashchange/jquery.ba-hashchange.js 1278369175 1 jQuery hashchange event
-/srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js 1278369180 0 /srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js
+/srv/projects/jquery-hashchange/jquery.ba-hashchange.js 1278468263 1 jQuery hashchange event
+/srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js 1278468471 0 /srv/projects/jquery-hashchange/jquery.ba-hashchange.min.js
View
Binary file not shown.
View
@@ -1,5 +1,5 @@
/*!
- * jQuery hashchange event - v1.3pre - 7/5/2010
+ * jQuery hashchange event - v1.3pre - 7/6/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
@@ -9,7 +9,7 @@
// Script: jQuery hashchange event
//
-// *Version: 1.3pre, Last updated: 7/5/2010*
+// *Version: 1.3pre, Last updated: 7/6/2010*
//
// Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
// GitHub - http://github.com/cowboy/jquery-hashchange/
@@ -37,7 +37,8 @@
// reside (so you can test it yourself).
//
// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
-// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Safari 3-5, Chrome 3-5, Opera 9.6-10.5.
+// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 3-5, Safari 3-5,
+// Opera 9.6-10.60, iPhone 3.1, Android 2.1, BlackBerry 4.6-5.
// Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
//
// About: Known issues
@@ -54,7 +55,7 @@
//
// About: Release History
//
-// 1.3pre - (7/5/2010) Reorganized IE6/7 Iframe code to make it more
+// 1.3pre - (7/6/2010) Reorganized IE6/7 Iframe code to make it more
// "removable" for mobile development. Added <jQuery.hashchangeDomain>,
// <jQuery.hashchangeIframeSrc> properties and document-domain.html
// file to address access denied issues when setting document.domain in
@@ -85,17 +86,15 @@
var str_hashchange = 'hashchange',
// Method / object references.
+ doc = document,
fake_onhashchange,
jq_event_special = $.event.special,
- // IE6/7 specifically need some special love when it comes to back-button
- // support, so let's do a little browser sniffing..
- browser = $.browser,
- mode = document.documentMode,
- is_old_ie = browser.msie && ( mode === undefined || mode < 8 ),
-
- // Does the browser support window.onhashchange?
- supports_onhashchange = 'on' + str_hashchange in window && ( mode === undefined || mode > 7 );
+ // Does the browser support window.onhashchange? Note that IE8 running in
+ // IE7 compatibility mode reports true for 'onhashchange' in window, even
+ // though the event isn't supported, so also test document.documentMode.
+ doc_mode = doc.documentMode,
+ supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
// Get location.hash (or what you'd expect location.hash to be) sans any
// leading #. Thanks for making this necessary, Firefox!
@@ -234,12 +233,16 @@
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7 vvvvvvvvvvvvvvvvvvv
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
- //
- // In IE 6/7, create a hidden Iframe for history handling.
- is_old_ie && (function(){
- var iframe,
+ (function(){
+ var browser = $.browser,
+ iframe,
iframe_src;
+ // If browser isn't IE 6/7, abort!! ABORT!!!
+ if ( !browser.msie || browser.version > 7 ) { return; }
+
+ // When the event is bound and polling starts in IE 6/7, create a hidden
+ // Iframe for history handling.
self.start = function(){
if ( !iframe ) {
iframe_src = $[ str_hashchange + 'IframeSrc' ];
@@ -267,10 +270,10 @@
// prettify the back/next history menu entries. Since IE sometimes
// errors with "Unspecified error" the very first time this is set
// (yes, very useful) wrap this with a try/catch block.
- document.onpropertychange = function(){
+ doc.onpropertychange = function(){
try {
if ( event.propertyName === 'title' ) {
- iframe.document.title = document.title;
+ iframe.document.title = doc.title;
}
} catch(e) {}
};
@@ -292,18 +295,18 @@
// document, *then* setting its location.hash. If document.domain has
// been set, update that as well.
history_set = function( hash, history_hash ) {
- var doc = iframe.document,
+ var iframe_doc = iframe.document,
domain = $[ str_hashchange + 'Domain' ];
if ( hash !== history_hash ) {
// Update Iframe with any initial `document.title` that might be set.
- doc.title = document.title;
+ iframe_doc.title = doc.title;
// Opening the Iframe's document after it has been closed is what
// actually adds a history entry.
- doc.open();
- domain && doc.write( '<script>document.domain="' + domain + '"</script>' );
- doc.close();
+ iframe_doc.open();
+ domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' );
+ iframe_doc.close();
// Update the Iframe's hash, for great justice.
iframe.location.hash = hash;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 269e0ed

Please sign in to comment.