diff options
author | Roeland Douma <rullzer@users.noreply.github.com> | 2016-07-20 20:11:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 20:11:08 +0200 |
commit | 9f219f55f29fa17b3a92c3b8316d57225cc98302 (patch) | |
tree | 0a5caf0af23c7841ebcb676a46fc9d3a4bf2bee2 /core/js | |
parent | 26cf51403e51c8753b9075df76ebc9ea90901851 (diff) | |
parent | 4d67429cf034ef4912bd78fb9dac91155ff0fec1 (diff) | |
download | nextcloud-server-9f219f55f29fa17b3a92c3b8316d57225cc98302.tar.gz nextcloud-server-9f219f55f29fa17b3a92c3b8316d57225cc98302.zip |
Merge pull request #467 from nextcloud/use-clipboard-api
Use clipboard api
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/core.json | 3 | ||||
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 35 | ||||
-rw-r--r-- | core/js/sharedialogmailview.js | 8 | ||||
-rw-r--r-- | core/js/sharedialogview.js | 2 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogviewSpec.js | 4 |
5 files changed, 44 insertions, 8 deletions
diff --git a/core/js/core.json b/core/js/core.json index 03c72e9b3ff..5254e7b3d03 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -10,7 +10,8 @@ "bootstrap/js/tooltip.js", "backbone/backbone.js", "es6-promise/dist/es6-promise.js", - "davclient.js/lib/client.js" + "davclient.js/lib/client.js", + "clipboard/dist/clipboard.js" ], "libraries": [ "jquery-showpassword.js", diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 457a788d589..8ad2e270099 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -22,8 +22,11 @@ '<input type="checkbox" name="linkCheckbox" id="linkCheckbox-{{cid}}" class="checkbox linkCheckbox" value="1" {{#if isLinkShare}}checked="checked"{{/if}} />' + '<label for="linkCheckbox-{{cid}}">{{linkShareLabel}}</label>' + '<br />' + + '<div class="oneline">' + '<label for="linkText-{{cid}}" class="hidden-visually">{{urlLabel}}</label>' + '<input id="linkText-{{cid}}" class="linkText {{#unless isLinkShare}}hidden{{/unless}}" type="text" readonly="readonly" value="{{shareLinkURL}}" />' + + '<a class="{{#unless isLinkShare}}hidden-visually{{/unless}} clipboardButton icon icon-clippy" data-clipboard-target="#linkText-{{cid}}"></a>' + + '</div>' + ' {{#if publicUpload}}' + '<div id="allowPublicUploadWrapper">' + ' <span class="icon-loading-small hidden"></span>' + @@ -125,6 +128,38 @@ 'onHideFileListChange', 'onAllowPublicUploadChange' ); + + var clipboard = new Clipboard('.clipboardButton'); + clipboard.on('success', function(e) { + $input = $(e.trigger); + $input.tooltip({placement: 'bottom', trigger: 'manual', title: t('core', 'Copied!')}); + $input.tooltip('show'); + _.delay(function() { + $input.tooltip('hide'); + }, 3000); + }); + clipboard.on('error', function (e) { + $input = $(e.trigger); + var actionMsg = ''; + if (/iPhone|iPad/i.test(navigator.userAgent)) { + actionMsg = t('core', 'Not supported!'); + } else if (/Mac/i.test(navigator.userAgent)) { + actionMsg = t('core', 'Press ⌘-C to copy.'); + } else { + actionMsg = t('core', 'Press Ctrl-C to copy.'); + } + + $input.tooltip({ + placement: 'bottom', + trigger: 'manual', + title: actionMsg + }); + $input.tooltip('show'); + _.delay(function () { + $input.tooltip('hide'); + }, 3000); + }); + }, onLinkCheckBoxChange: function() { diff --git a/core/js/sharedialogmailview.js b/core/js/sharedialogmailview.js index 84e3f3242ad..79741e92ac5 100644 --- a/core/js/sharedialogmailview.js +++ b/core/js/sharedialogmailview.js @@ -16,9 +16,9 @@ var TEMPLATE = '{{#if shareAllowed}}' + ' {{#if mailPublicNotificationEnabled}}' + - '<form id="emailPrivateLink" class="emailPrivateLinkForm">' + + '<form id="emailPrivateLink" class="emailPrivateLinkForm oneline">' + ' <input id="email" class="emailField" value="{{email}}" placeholder="{{mailPrivatePlaceholder}}" type="text" />' + - ' <input id="emailButton" class="emailButton" type="submit" value="{{mailButtonText}}" />' + + ' <a id="emailButton" class="icon icon-mail-grey" />' + '</form>' + ' {{/if}}' + '{{/if}}' @@ -48,7 +48,7 @@ showLink: true, events: { - 'submit .emailPrivateLinkForm': '_onEmailPrivateLink' + 'click #emailButton': '_onEmailPrivateLink' }, initialize: function(options) { @@ -173,4 +173,4 @@ OC.Share.ShareDialogMailView = ShareDialogMailView; -})();
\ No newline at end of file +})(); diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index c17da94bab3..5637ffc3a0a 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -30,7 +30,7 @@ '<div class="loading hidden" style="height: 50px"></div>'; var TEMPLATE_REMOTE_SHARE_INFO = - '<a target="_blank" class="icon-info shareWithRemoteInfo hasTooltip" href="{{docLink}}" ' + + '<a target="_blank" class="icon icon-info shareWithRemoteInfo hasTooltip" href="{{docLink}}" ' + 'title="{{tooltip}}"></a>'; /** diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js index 23214a7fe86..f0e027d9fb9 100644 --- a/core/js/tests/specs/sharedialogviewSpec.js +++ b/core/js/tests/specs/sharedialogviewSpec.js @@ -444,7 +444,7 @@ describe('OC.Share.ShareDialogView', function() { dialog.render(); dialog.$el.find('.emailPrivateLinkForm .emailField').val('a@b.c'); - dialog.$el.find('.emailPrivateLinkForm').trigger('submit'); + dialog.$el.find('#emailButton').trigger('click'); expect(sendEmailPrivateLinkStub.callCount).toEqual(1); expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('Sending ...'); @@ -463,7 +463,7 @@ describe('OC.Share.ShareDialogView', function() { dialog.render(); dialog.$el.find('.emailPrivateLinkForm .emailField').val('a@b.c'); - dialog.$el.find('.emailPrivateLinkForm').trigger('submit'); + dialog.$el.find('#emailButton').trigger('click'); expect(sendEmailPrivateLinkStub.callCount).toEqual(1); expect(dialog.$el.find('.emailPrivateLinkForm .emailField').val()).toEqual('Sending ...'); |