URL.push: add expandURL argument -- if true, subsequent update will cause a replace, not another push

This commit is contained in:
rolux 2013-07-09 14:45:01 +00:00
parent 91a227baae
commit edb5ab3efc

View file

@ -6,6 +6,7 @@ pandora.URL = (function() {
var self = {}, that = {}; var self = {}, that = {};
// translates UI settings to URL state
function getState() { function getState() {
Ox.Log('URL', 'getState:, UI', pandora.user.ui) Ox.Log('URL', 'getState:, UI', pandora.user.ui)
@ -60,8 +61,9 @@ pandora.URL = (function() {
} }
if ( if (
pandora.user.ui.hash && pandora.user.ui.hash && (
(pandora.user.ui.hash.anchor || !Ox.isEmpty(pandora.user.ui.hash.query)) pandora.user.ui.hash.anchor || !Ox.isEmpty(pandora.user.ui.hash.query)
)
) { ) {
state.hash = {}; state.hash = {};
if (pandora.user.ui.hash.anchor) { if (pandora.user.ui.hash.anchor) {
@ -78,6 +80,7 @@ pandora.URL = (function() {
} }
// translates URL state to UI settings
function setState(state, callback) { function setState(state, callback) {
var set = {}; var set = {};
@ -187,6 +190,7 @@ pandora.URL = (function() {
set.find = pandora.site.user.ui.find; set.find = pandora.site.user.ui.find;
} }
} }
} else if (state.type == 'texts') { } else if (state.type == 'texts') {
if (state.span) { if (state.span) {
set['textPositions.' + state.item] = state.span; set['textPositions.' + state.item] = state.span;
@ -413,11 +417,12 @@ pandora.URL = (function() {
}; };
// pushes a new URL (as string or from state) // pushes a new URL (as string or from state)
that.push = function(stateOrURL) { that.push = function(stateOrURL, expandURL) {
var state, var state,
title = pandora.getPageTitle(stateOrURL) title = pandora.getPageTitle(stateOrURL)
|| pandora.getDocumentTitle(), || pandora.getDocumentTitle(),
url; url;
pandora.expandURL = expandURL;
if (Ox.isObject(stateOrURL)) { if (Ox.isObject(stateOrURL)) {
state = stateOrURL; state = stateOrURL;
} else { } else {
@ -457,6 +462,7 @@ pandora.URL = (function() {
} else { } else {
if ( if (
!pandora.$ui.appPanel !pandora.$ui.appPanel
|| pandora.expandURL
|| keys.every(function(key) { || keys.every(function(key) {
return [ return [
'listColumnWidth', 'listColumns', 'listSelection', 'listColumnWidth', 'listColumns', 'listSelection',
@ -475,6 +481,7 @@ pandora.URL = (function() {
state, state,
pandora.getPageTitle(state) || pandora.getDocumentTitle() pandora.getPageTitle(state) || pandora.getDocumentTitle()
); );
pandora.expandURL = false;
} }
}; };