diff options
Diffstat (limited to 'lib/dojo/hash.js')
-rw-r--r-- | lib/dojo/hash.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/dojo/hash.js b/lib/dojo/hash.js index 6ef74b521..e7f6a400f 100644 --- a/lib/dojo/hash.js +++ b/lib/dojo/hash.js @@ -1,5 +1,5 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ @@ -8,6 +8,8 @@ if(!dojo._hasResource["dojo.hash"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["dojo.hash"] = true; dojo.provide("dojo.hash"); + + //TODOC: where does this go? // summary: // Methods for monitoring and updating the hash in the browser URL. @@ -27,11 +29,11 @@ dojo.provide("dojo.hash"); // Handles getting and setting of location.hash. // - If no arguments are passed, acts as a getter. // - If a string is passed, acts as a setter. - // hash: - // String: the hash is set - #string. + // hash: + // the hash is set - #string. // replace: - // Boolean: If true, updates the hash value in the current history - // state instead of creating a new history state. + // If true, updates the hash value in the current history + // state instead of creating a new history state. // returns: // when used as a getter, returns the current hash string. // when used as a setter, returns the new hash string. @@ -50,17 +52,16 @@ dojo.provide("dojo.hash"); location.href = "#" + hash; } return hash; // String - } + }; // Global vars - var _recentHash = null, - _ieUriMonitor = null, + var _recentHash, _ieUriMonitor, _connect, _pollFrequency = dojo.config.hashPollFrequency || 100; //Internal functions function _getSegment(str, delimiter){ var i = str.indexOf(delimiter); - return (i >= 0) ? str.substring(i+1) : ""; + return (i >= 0) ? str.substring(i+1) : ""; } function _getHash(){ @@ -92,12 +93,12 @@ dojo.provide("dojo.hash"); return; } location.replace("#"+hash); - _pollLocation(); + !_connect && _pollLocation(); } function IEUriMonitor(){ // summary: - // Determine if the browser's URI has changed or if the user has pressed the + // Determine if the browser's URI has changed or if the user has pressed the // back or forward button. If so, call _dispatchEvent. // // description: @@ -147,6 +148,13 @@ dojo.provide("dojo.hash"); var ifr = document.createElement("iframe"), IFRAME_ID = "dojo-hash-iframe", ifrSrc = dojo.config.dojoBlankHtmlUrl || dojo.moduleUrl("dojo", "resources/blank.html"); + + if(dojo.config.useXDomain && !dojo.config.dojoBlankHtmlUrl){ + console.warn("dojo.hash: When using cross-domain Dojo builds," + + " please save dojo/resources/blank.html to your domain and set djConfig.dojoBlankHtmlUrl" + + " to the path on your domain to blank.html"); + } + ifr.id = IFRAME_ID; ifr.src = ifrSrc + "?" + _getHash(); ifr.style.display = "none"; @@ -165,7 +173,7 @@ dojo.provide("dojo.hash"); this.isTransitioning = function(){ return transitioning; - } + }; this.pollLocation = function(){ if(!ifrOffline) { @@ -216,13 +224,13 @@ dojo.provide("dojo.hash"); } } setTimeout(dojo.hitch(this,this.pollLocation), _pollFrequency); - } + }; resetState(); // initialize state (transition to s1) setTimeout(dojo.hitch(this,this.pollLocation), _pollFrequency); } dojo.addOnLoad(function(){ if("onhashchange" in dojo.global && (!dojo.isIE || (dojo.isIE >= 8 && document.compatMode != "BackCompat"))){ //need this IE browser test because "onhashchange" exists in IE8 in IE7 mode - dojo.connect(dojo.global,"onhashchange",_dispatchEvent); + _connect = dojo.connect(dojo.global,"onhashchange",_dispatchEvent); }else{ if(document.addEventListener){ // Non-IE _recentHash = _getHash(); @@ -230,7 +238,7 @@ dojo.provide("dojo.hash"); }else if(document.attachEvent){ // IE7- //Use hidden iframe in versions of IE that don't have onhashchange event _ieUriMonitor = new IEUriMonitor(); - } + } // else non-supported browser, do nothing. } }); |