aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2020-04-11 08:23:11 +0200
committerGitHub <noreply@github.com>2020-04-11 08:23:11 +0200
commite5ac5c7f34a6551f0880f05cba7f7b9c871d0b0e (patch)
tree3729e1e98b11694f385ac4ee3a7c7f523eccce04 /apps/files/js
parentb5a30d5cd6b53831c0d6d2fd074dc0000fa811de (diff)
parent43f0d2a3b5bc76ed72693695451398b4b7b78411 (diff)
downloadnextcloud-server-e5ac5c7f34a6551f0880f05cba7f7b9c871d0b0e.tar.gz
nextcloud-server-e5ac5c7f34a6551f0880f05cba7f7b9c871d0b0e.zip
Merge pull request #20185 from azul/open-new_tab
Modify do_action so default ctrl-click opens tab
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/fileactions.js15
-rw-r--r--apps/files/js/fileactionsmenu.js6
-rw-r--r--apps/files/js/filelist.js54
3 files changed, 55 insertions, 20 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 24f8279116d..1f6d5f798a9 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -257,13 +257,26 @@
},
/**
+ * Returns the default file action handler for the current file
+ *
+ * @return {OCA.Files.FileActions~actionSpec} action spec
+ * @since 8.2
+ */
+ getCurrentDefaultFileAction: function() {
+ var mime = this.getCurrentMimeType();
+ var type = this.getCurrentType();
+ var permissions = this.getCurrentPermissions();
+ return this.getDefaultFileAction(mime, type, permissions);
+ },
+
+ /**
* Returns the default file action handler for the given conditions
*
* @param {string} mime mime type
* @param {string} type "dir" or "file"
* @param {int} permissions permissions
*
- * @return {OCA.Files.FileActions~actionHandler} action handler
+ * @return {OCA.Files.FileActions~actionSpec} action spec
* @since 8.2
*/
getDefaultFileAction: function(mime, type, permissions) {
diff --git a/apps/files/js/fileactionsmenu.js b/apps/files/js/fileactionsmenu.js
index 16c4cc0d784..53dec693c1c 100644
--- a/apps/files/js/fileactionsmenu.js
+++ b/apps/files/js/fileactionsmenu.js
@@ -77,11 +77,7 @@
fileActions.getCurrentPermissions()
);
- var defaultAction = fileActions.getDefaultFileAction(
- fileActions.getCurrentMimeType(),
- fileActions.getCurrentType(),
- fileActions.getCurrentPermissions()
- );
+ var defaultAction = fileActions.getCurrentDefaultFileAction();
var items = _.filter(actions, function(actionSpec) {
return !defaultAction || actionSpec.name !== defaultAction.name;
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 9973c92c8ec..e7d48d4bcd1 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -432,7 +432,7 @@
this.setupUploadEvents(this._uploader);
}
}
-
+ this.triedActionOnce = false;
OC.Plugins.attach('OCA.Files.FileList', this);
@@ -874,16 +874,12 @@
if ($tr.hasClass('dragging')) {
return;
}
- if (this._allowSelection && (event.ctrlKey || event.shiftKey)) {
+ if (this._allowSelection && event.shiftKey) {
event.preventDefault();
- if (event.shiftKey) {
- this._selectRange($tr);
- } else {
- this._selectSingle($tr);
- }
+ this._selectRange($tr);
this._lastChecked = $tr;
this.updateSelectionSummary();
- } else {
+ } else if (!event.ctrlKey) {
// clicked directly on the name
if (!this._detailsView || $(event.target).is('.nametext, .name, .thumbnail') || $(event.target).closest('.nametext').length) {
var filename = $tr.attr('data-file');
@@ -892,13 +888,10 @@
event.preventDefault();
} else if (!renaming) {
this.fileActions.currentFile = $tr.find('td');
- var mime = this.fileActions.getCurrentMimeType();
- var type = this.fileActions.getCurrentType();
- var permissions = this.fileActions.getCurrentPermissions();
- var action = this.fileActions.getDefault(mime,type, permissions);
- if (action) {
+ var spec = this.fileActions.getCurrentDefaultFileAction();
+ if (spec && spec.action) {
event.preventDefault();
- action(filename, {
+ spec.action(filename, {
$file: $tr,
fileList: this,
fileActions: this.fileActions,
@@ -1323,6 +1316,31 @@
}, 0);
}
+ if(!this.triedActionOnce) {
+ var id = OC.Util.History.parseUrlQuery().openfile;
+ if (id) {
+ var $tr = this.$fileList.children().filterAttr('data-id', '' + id);
+ var filename = $tr.attr('data-file');
+ this.fileActions.currentFile = $tr.find('td');
+ var dir = $tr.attr('data-path') || this.getCurrentDirectory();
+ var spec = this.fileActions.getCurrentDefaultFileAction();
+ if (spec && spec.action) {
+ spec.action(filename, {
+ $file: $tr,
+ fileList: this,
+ fileActions: this.fileActions,
+ dir: dir
+ });
+
+ }
+ else {
+ var url = this.getDownloadUrl(filename, dir, true);
+ OCA.Files.Files.handleDownload(url);
+ }
+ }
+ this.triedActionOnce = true;
+ }
+
return newTrs;
},
@@ -1527,10 +1545,14 @@
td = $('<td class="filename"></td>');
+ var spec = this.fileActions.getDefaultFileAction(mime, type, permissions);
// linkUrl
if (mime === 'httpd/unix-directory') {
linkUrl = this.linkTo(path + '/' + name);
}
+ else if (spec && spec.action) {
+ linkUrl = this.getDefaultActionUrl(path, fileData.id);
+ }
else {
linkUrl = this.getDownloadUrl(name, path, type === 'dir');
}
@@ -2149,6 +2171,10 @@
return OCA.Files.Files.getDownloadUrl(files, dir || this.getCurrentDirectory(), isDir);
},
+ getDefaultActionUrl: function(path, id) {
+ return this.linkTo(path) + "&openfile="+id;
+ },
+
getUploadUrl: function(fileName, dir) {
if (_.isUndefined(dir)) {
dir = this.getCurrentDirectory();