From fdeafef6a08c45f8b45ab9fac303e3bffc3607b0 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 4 May 2016 11:17:53 +0200 Subject: Auto-add fileid in URL for currently displayed folder --- core/js/js.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'core/js') diff --git a/core/js/js.js b/core/js/js.js index 69ebabdb419..edee72ca3ca 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 { @@ -2072,6 +2077,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 * -- cgit v1.2.3