summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-07-08 14:30:32 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-07-20 15:07:41 +0200
commitdaaa3ded8d73fe3e9eb483cbf1174ed245e6250b (patch)
treebbd225b10390909afb42abb4b792219e5a8d5dad /core/js
parentb37e1ed17f54916e3321427d92afa3f74ebea1b3 (diff)
downloadnextcloud-server-daaa3ded8d73fe3e9eb483cbf1174ed245e6250b.tar.gz
nextcloud-server-daaa3ded8d73fe3e9eb483cbf1174ed245e6250b.zip
Add clipboard button to public share link
Diffstat (limited to 'core/js')
-rw-r--r--core/js/core.json3
-rw-r--r--core/js/sharedialoglinkshareview.js35
-rw-r--r--core/js/sharedialogview.js2
3 files changed, 38 insertions, 2 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/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>';
/**