From 72fe60e5b9b148db962c929870a739e80fe5860a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 8 Jul 2016 14:30:32 +0200 Subject: [PATCH 1/2] Add clipboard button to public share link --- apps/files_sharing/css/sharetabview.css | 8 +- bower.json | 3 +- core/css/icons.css | 4 + core/img/actions/clippy.svg | 3 + core/js/core.json | 3 +- core/js/sharedialoglinkshareview.js | 35 ++ core/js/sharedialogview.js | 2 +- core/vendor/.gitignore | 4 + core/vendor/clipboard/dist/clipboard.js | 742 ++++++++++++++++++++++++ 9 files changed, 798 insertions(+), 6 deletions(-) create mode 100644 core/img/actions/clippy.svg create mode 100644 core/vendor/clipboard/dist/clipboard.js diff --git a/apps/files_sharing/css/sharetabview.css b/apps/files_sharing/css/sharetabview.css index 04338820881c..66c8b4691ebd 100644 --- a/apps/files_sharing/css/sharetabview.css +++ b/apps/files_sharing/css/sharetabview.css @@ -10,8 +10,9 @@ top: 2px; } -.shareTabView .shareWithRemoteInfo { - padding: 11px 20px; +.shareTabView .shareWithRemoteInfo, +.shareTabView .clipboardButton { + padding-left: 10px; } .shareTabView label { @@ -28,7 +29,8 @@ width: 94%; margin-left: 0; } -.shareTabView input[type="text"].shareWithField { +.shareTabView input[type="text"].shareWithField, +.shareTabView input[type="text"].linkText { width: 80%; } diff --git a/bower.json b/bower.json index 74c4be96a212..3aa2cd4b3b2e 100644 --- a/bower.json +++ b/bower.json @@ -30,6 +30,7 @@ "backbone": "~1.2.3", "davclient.js": "https://github.com/evert/davclient.js.git", "es6-promise": "https://github.com/jakearchibald/es6-promise.git#~2.3.0", - "base64": "~0.3.0" + "base64": "~0.3.0", + "clipboard": "^1.5.12" } } diff --git a/core/css/icons.css b/core/css/icons.css index 8bf4c204c948..a07853526a85 100644 --- a/core/css/icons.css +++ b/core/css/icons.css @@ -368,3 +368,7 @@ img.icon-loading-small-dark, object.icon-loading-small-dark, video.icon-loading- .icon-picture { background-image: url('../img/places/picture.svg'); } + +.icon-clippy { + background-image: url('../img/actions/clippy.svg'); +} diff --git a/core/img/actions/clippy.svg b/core/img/actions/clippy.svg new file mode 100644 index 000000000000..8fa5c89c349e --- /dev/null +++ b/core/img/actions/clippy.svg @@ -0,0 +1,3 @@ + + + diff --git a/core/js/core.json b/core/js/core.json index 03c72e9b3ffd..5254e7b3d034 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 59f7ffcae036..6c551c1b0e9f 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -22,8 +22,11 @@ '' + '' + '
' + + '
' + '' + '' + + '' + + '
' + ' {{#if publicUpload}}' + '
' + ' ' + @@ -112,6 +115,38 @@ 'onShowPasswordClick', '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 c17da94bab3d..5637ffc3a0a8 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -30,7 +30,7 @@ ''; var TEMPLATE_REMOTE_SHARE_INFO = - ''; /** diff --git a/core/vendor/.gitignore b/core/vendor/.gitignore index 58a231c4bb49..5160c2a7f97c 100644 --- a/core/vendor/.gitignore +++ b/core/vendor/.gitignore @@ -137,3 +137,7 @@ es6-promise/dist/* # base64 base64/*min.js + +# clipboard +clipboard/** +!clipboard/dist/clipboard.js diff --git a/core/vendor/clipboard/dist/clipboard.js b/core/vendor/clipboard/dist/clipboard.js new file mode 100644 index 000000000000..040c5e005c3d --- /dev/null +++ b/core/vendor/clipboard/dist/clipboard.js @@ -0,0 +1,742 @@ +/*! + * clipboard.js v1.5.12 + * https://zenorocha.github.io/clipboard.js + * + * Licensed MIT © Zeno Rocha + */ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o Date: Fri, 8 Jul 2016 15:23:38 +0200 Subject: [PATCH 2/2] Use an icon to set the email instead of a button with string --- apps/files_sharing/css/sharetabview.css | 1 + core/css/icons.css | 4 ++++ core/js/sharedialogmailview.js | 8 ++++---- core/js/tests/specs/sharedialogviewSpec.js | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/files_sharing/css/sharetabview.css b/apps/files_sharing/css/sharetabview.css index 66c8b4691ebd..e048b7564ac1 100644 --- a/apps/files_sharing/css/sharetabview.css +++ b/apps/files_sharing/css/sharetabview.css @@ -30,6 +30,7 @@ margin-left: 0; } .shareTabView input[type="text"].shareWithField, +.shareTabView input[type="text"].emailField, .shareTabView input[type="text"].linkText { width: 80%; } diff --git a/core/css/icons.css b/core/css/icons.css index a07853526a85..0859c06c7cb6 100644 --- a/core/css/icons.css +++ b/core/css/icons.css @@ -204,6 +204,10 @@ img.icon-loading-small-dark, object.icon-loading-small-dark, video.icon-loading- background-image: url('../img/actions/mail.svg'); } +.icon-mail-grey { + background-image: url('../img/actions/mail-grey.svg'); +} + .icon-menu { background-image: url('../img/actions/menu.svg'); } diff --git a/core/js/sharedialogmailview.js b/core/js/sharedialogmailview.js index 84e3f3242ad5..79741e92ac55 100644 --- a/core/js/sharedialogmailview.js +++ b/core/js/sharedialogmailview.js @@ -16,9 +16,9 @@ var TEMPLATE = '{{#if shareAllowed}}' + ' {{#if mailPublicNotificationEnabled}}' + - '