Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-04 12:17:53 +0300
committerVincent Petry <pvince81@owncloud.com>2016-05-06 17:46:59 +0300
commitfdeafef6a08c45f8b45ab9fac303e3bffc3607b0 (patch)
treea96ca5a4bfeca3b5a2a330c125e7f6738f67b10a /apps/files/js/app.js
parent093e9dd4225e6681140523c75bfc20809cd6d651 (diff)
Auto-add fileid in URL for currently displayed folder
Diffstat (limited to 'apps/files/js/app.js')
-rw-r--r--apps/files/js/app.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index eac080a009d..60b5f1816ab 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);
}
},
@@ -263,12 +273,20 @@
/**
* 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(params);
+ } else {
+ OC.Util.History.pushState(params);
}
- OC.Util.History.pushState(params);
}
};
})();