summaryrefslogtreecommitdiffstats
path: root/apps/files/js/app.js
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-05-10 09:44:50 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-05-10 09:44:50 +0200
commite8e72aa9101b1c4b7e321dd3f17dcc9462f34a8f (patch)
tree0eec63cb17f7ad60130474a0bbdcbfaaa281d884 /apps/files/js/app.js
parent1fb7be42e55236c2663b52f89a85b54d81ae08ba (diff)
parent254576e1f7f5ec610ddbd9de81005397191cf52f (diff)
downloadnextcloud-server-e8e72aa9101b1c4b7e321dd3f17dcc9462f34a8f.tar.gz
nextcloud-server-e8e72aa9101b1c4b7e321dd3f17dcc9462f34a8f.zip
Merge pull request #24434 from owncloud/permalinks
Permalinks
Diffstat (limited to 'apps/files/js/app.js')
-rw-r--r--apps/files/js/app.js37
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index eac080a009d..7a3d78f9663 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -174,6 +174,7 @@
// detect when app changed their current directory
$('#app-content').delegate('>div', 'changeDirectory', _.bind(this._onDirectoryChanged, this));
+ $('#app-content').delegate('>div', 'afterChangeDirectory', _.bind(this._onAfterDirectoryChanged, this));
$('#app-content').delegate('>div', 'changeViewerMode', _.bind(this._onChangeViewerMode, this));
$('#app-navigation').on('itemChanged', _.bind(this._onNavigationChanged, this));
@@ -224,7 +225,16 @@
*/
_onDirectoryChanged: function(e) {
if (e.dir) {
- this._changeUrl(this.navigation.getActiveItem(), e.dir);
+ this._changeUrl(this.navigation.getActiveItem(), e.dir, e.fileId);
+ }
+ },
+
+ /**
+ * Event handler for when an app notified that its directory changed
+ */
+ _onAfterDirectoryChanged: function(e) {
+ if (e.dir && e.fileId) {
+ this._changeUrl(this.navigation.getActiveItem(), e.dir, e.fileId);
}
},
@@ -261,14 +271,35 @@
},
/**
+ * Encode URL params into a string, except for the "dir" attribute
+ * that gets encoded as path where "/" is not encoded
+ *
+ * @param {Object.<string>} params
+ * @return {string} encoded params
+ */
+ _makeUrlParams: function(params) {
+ var dir = params.dir;
+ delete params.dir;
+ return 'dir=' + OC.encodePath(dir) + '&' + OC.buildQueryString(params);
+ },
+
+ /**
* Change the URL to point to the given dir and view
*/
- _changeUrl: function(view, dir) {
+ _changeUrl: function(view, dir, fileId) {
var params = {dir: dir};
if (view !== 'files') {
params.view = view;
+ } else if (fileId) {
+ params.fileid = fileId;
+ }
+ var currentParams = OC.Util.History.parseUrlQuery();
+ if (currentParams.dir === params.dir && currentParams.view === params.view && currentParams.fileid !== params.fileid) {
+ // if only fileid changed or was added, replace instead of push
+ OC.Util.History.replaceState(this._makeUrlParams(params));
+ } else {
+ OC.Util.History.pushState(this._makeUrlParams(params));
}
- OC.Util.History.pushState(params);
}
};
})();