summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-06-04 12:18:53 -0500
committerGitHub <noreply@github.com>2017-06-04 12:18:53 -0500
commit529d8122bbbb8da4b54bac92fe7bea26381ca580 (patch)
treee2049e389a389331148512011d787dec7883a921
parentf03d6f225e7460cff935f0d0b77e86af3d394887 (diff)
parent91315f63cf31f0ff82a9539a5cf40694e1252996 (diff)
downloadnextcloud-server-529d8122bbbb8da4b54bac92fe7bea26381ca580.tar.gz
nextcloud-server-529d8122bbbb8da4b54bac92fe7bea26381ca580.zip
Merge pull request #4791 from nextcloud/permalink_copy_on_click
Copy permalink directly on click
-rw-r--r--apps/files/js/mainfileinfodetailview.js39
1 files changed, 30 insertions, 9 deletions
diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js
index f5f9e926f64..26472e0766d 100644
--- a/apps/files/js/mainfileinfodetailview.js
+++ b/apps/files/js/mainfileinfodetailview.js
@@ -14,7 +14,7 @@
'<div class="file-details-container">' +
'<div class="fileName">' +
'<h3 title="{{name}}" class="ellipsis">{{name}}</h3>' +
- '<a class="permalink" href="{{permalink}}" title="{{permalinkTitle}}">' +
+ '<a class="permalink" href="{{permalink}}" title="{{permalinkTitle}}" data-clipboard-text="{{permalink}}">' +
'<span class="icon icon-clippy"></span>' +
'<span class="hidden-visually">{{permalinkTitle}}</span>' +
'</a>' +
@@ -86,16 +86,37 @@
throw 'Missing required parameter "fileActions"';
}
this._previewManager = new OCA.Files.SidebarPreviewManager(this._fileList);
+
+ this._setupClipboard();
},
- _onClickPermalink: function() {
- var $row = this.$('.permalink-field');
- $row.toggleClass('hidden');
- if (!$row.hasClass('hidden')) {
- $row.find('>input').focus();
- }
- // cancel click, user must right-click + copy or middle click
- return false;
+ _setupClipboard: function() {
+ var clipboard = new Clipboard('.permalink');
+ clipboard.on('success', function(e) {
+ var $el = $(e.trigger);
+ $el.tooltip('hide')
+ .attr('data-original-title', t('core', 'Copied!'))
+ .tooltip('fixTitle')
+ .tooltip({placement: 'bottom', trigger: 'manual'})
+ .tooltip('show');
+ _.delay(function() {
+ $el.tooltip('hide');
+ $el.attr('data-original-title', t('files', 'Copy direct link (only works for users who have access to this file/folder)'))
+ .tooltip('fixTitle');
+ }, 3000);
+ });
+ clipboard.on('error', function(e) {
+ var $row = this.$('.permalink-field');
+ $row.toggleClass('hidden');
+ if (!$row.hasClass('hidden')) {
+ $row.find('>input').focus();
+ }
+ });
+ },
+
+ _onClickPermalink: function(e) {
+ e.preventDefault();
+ return;
},
_onFocusPermalink: function() {