diff options
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/core/js/js.js b/core/js/js.js index 541ce003a7b..1c49d38f950 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -2050,8 +2050,9 @@ OC.Util.History = { * * @param params to append to the URL, can be either a string * or a map + * @param {boolean} [replace=false] whether to replace instead of pushing */ - pushState: function(params) { + _pushState: function(params, replace) { var strParams; if (typeof(params) === 'string') { strParams = params; @@ -2061,7 +2062,11 @@ OC.Util.History = { } if (window.history.pushState) { var url = location.pathname + '?' + strParams; - window.history.pushState(params, '', url); + if (replace) { + window.history.replaceState(params, '', url); + } else { + window.history.pushState(params, '', url); + } } // use URL hash for IE8 else { @@ -2073,6 +2078,32 @@ OC.Util.History = { }, /** + * Push the current URL parameters to the history stack + * and change the visible URL. + * Note: this includes a workaround for IE8/IE9 that uses + * the hash part instead of the search part. + * + * @param params to append to the URL, can be either a string + * or a map + */ + pushState: function(params) { + return this._pushState(params, false); + }, + + /** + * Push the current URL parameters to the history stack + * and change the visible URL. + * Note: this includes a workaround for IE8/IE9 that uses + * the hash part instead of the search part. + * + * @param params to append to the URL, can be either a string + * or a map + */ + replaceState: function(params) { + return this._pushState(params, true); + }, + + /** * Add a popstate handler * * @param handler function @@ -2129,7 +2160,12 @@ OC.Util.History = { if (!this._handlers.length) { return; } - params = (e && e.state) || this.parseUrlQuery() || {}; + params = (e && e.state); + if (_.isString(params)) { + params = OC.parseQueryString(params); + } else if (!params) { + params = this.parseUrlQuery() || {}; + } for (var i = 0; i < this._handlers.length; i++) { this._handlers[i](params); } |