From 91315f63cf31f0ff82a9539a5cf40694e1252996 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 10 May 2017 14:29:20 +0200 Subject: [PATCH] Copy permalink directly on click Signed-off-by: Roeland Jago Douma --- apps/files/js/mainfileinfodetailview.js | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js index f5f9e926f6..26472e0766 100644 --- a/apps/files/js/mainfileinfodetailview.js +++ b/apps/files/js/mainfileinfodetailview.js @@ -14,7 +14,7 @@ '
' + '
' + '

{{name}}

' + - '' + @@ -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() {