From 724561a37305a087ff7c6a2a68cbbd3a879f0ef8 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Wed, 9 Nov 2011 22:32:45 +0000 Subject: [PATCH] rewrite history, again --- source/Ox.UI/js/Core/Ox.URL.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.URL.js b/source/Ox.UI/js/Core/Ox.URL.js index 00d643f2..f6655029 100644 --- a/source/Ox.UI/js/Core/Ox.URL.js +++ b/source/Ox.UI/js/Core/Ox.URL.js @@ -159,8 +159,16 @@ Ox.URL = function(options) { Ox.Log('Core', 'Ox.URL options', self.options) + self.previousTitle = ''; self.previousURL = ''; + window.onpopstate = function() { + self.previousTitle = document.title; + self.previousURL = document.location.pathname + + document.location.search + + document.location.hash; + }; + function constructCondition(condition) { var key = condition.key == '*' ? '' : condition.key, operator = condition.operator, @@ -585,22 +593,12 @@ Ox.URL = function(options) { } - that._construct = function(state) { - return constructURL(state); - }; - that.parse = function() { var str = arguments.length == 2 ? arguments[0] : document.location.pathname + document.location.search + document.location.hash, callback = arguments[arguments.length - 1]; - /* - parseURL(str, function(state) { - that.replace(constructURL(state)); - callback(state); - }); - */ parseURL(str, callback); return that; } @@ -609,8 +607,11 @@ Ox.URL = function(options) { pop Sets the URL to the previous URL @*/ that.pop = function() { - history.pushState({}, '', self.previousURL); - return that; + if (self.previousURL) { + history.pushState({}, self.previousTitle, self.previousURL); + document.title = self.previousTitle; + } + return !!self.previousURL; }; /*@ @@ -634,6 +635,7 @@ Ox.URL = function(options) { pushState(state, title, url); } function pushState(state, title, url) { + self.previousTitle = document.title; self.previousURL = document.location.pathname + document.location.search + document.location.hash;