rewrite history, again
This commit is contained in:
parent
bb59e0a3b4
commit
724561a373
1 changed files with 14 additions and 12 deletions
|
@ -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 <f> 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;
|
||||
|
|
Loading…
Reference in a new issue