Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions scripts/uncompressed/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
baseHref = baseElement.href.replace(/[^\/]+$/,'');
}

// Adjust trailing slash
// Adjusts trailing slash
baseHref = baseHref.replace(/\/+$/,'');
if ( baseHref ) baseHref += '/';

Expand Down Expand Up @@ -895,7 +895,9 @@
*/
History.getIdByUrl = function(url){
// Fetch
var id = History.urlToId[url] || History.store.urlToId[url] || undefined;
var unescaped = History.unescapeString(url);
var id = History.urlToId[url] || History.store.urlToId[url] ||
History.urlToId[unescaped] || History.store.urlToId[unescaped] || undefined;

// Return
return id;
Expand Down Expand Up @@ -948,7 +950,9 @@
*/
History.storeState = function(newState){
// Store the State
History.urlToId[newState.url] = newState.id;
History.urlToId[newState.cleanUrl] = newState.id;
History.idToState[newState.id] = newState;
History.stateToId[History.getStateString(newState)] = newState.id;

// Push the State
History.storedStates.push(History.cloneObject(newState));
Expand Down Expand Up @@ -1442,8 +1446,12 @@
* @return {History}
*/
History.safariStatePoll = function(){
// Poll the URL
// check if we just pushed state, if so.. bail
if (History.waitForPropagation) {
return;
}

// Poll the URL
// Get the Last State which has the new URL
var
urlState = History.extractState(document.location.href),
Expand Down Expand Up @@ -1472,6 +1480,23 @@
return History;
};

History.blockSafariPollUntilPropagation = function(newState){
// clear existing interval in preparation for the new one
if (History.waitForPropagationInterval) {
clearInterval(History.waitForPropagationInterval);
}
History.waitForPropagation = true;
History.waitForPropagationInterval = setInterval(function() {
var urlState = History.extractState(document.location.href);
if (!urlState || (urlState.id == newState.id)) {
//History.debug('url state propagated, un-blocking Safari poll');
History.waitForPropagation = false;
clearInterval(History.waitForPropagationInterval);
}
}, 250);
History.intervalList.push(History.waitForPropagationInterval);
};


// ====================================================================
// State Aliases
Expand Down Expand Up @@ -1613,7 +1638,7 @@
// Reset the double check
History.doubleCheckComplete();

// Check for a Hash, and handle apporiatly
// Check for a Hash, and handle appropriately
currentHash = History.getHash();
if ( currentHash ) {
// Expand Hash
Expand Down Expand Up @@ -1732,6 +1757,11 @@
History.storeState(newState);
History.expectedStateId = newState.id;

if (History.bugs.safariPoll) {
//History.debug('Blocking safariPoll until url state propagation');
History.blockSafariPollUntilPropagation(newState);
}

// Push the newState
history.pushState(newState.id,newState.title,newState.url);

Expand Down Expand Up @@ -1908,6 +1938,7 @@
* Setup Safari Fix
*/
if ( History.bugs.safariPoll ) {
History.waitForPropagation = false;
History.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));
}

Expand Down