From 965804425dd13ec9d7d2f5edbfbd62ed6939b12e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 10 Aug 2016 09:10:39 +0200 Subject: [PATCH] Add clipboardjs for token --- settings/css/settings.css | 9 +++++++++ settings/js/authtoken_view.js | 32 ++++++++++++++++++++++++++++++++ settings/templates/personal.php | 1 + 3 files changed, 42 insertions(+) diff --git a/settings/css/settings.css b/settings/css/settings.css index fe586205bdf..346b8ffa1cf 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -145,6 +145,15 @@ table.nostyle td { padding: 0.2em 0; } .app-password-row { display: table-row; } + +.app-password-row .icon { + background-size: 16px 16px; + display: inline-block; + position: relative; + top: 3px; + margin-left: 5px; +} + .app-password-label { display: table-cell; padding-right: 1em; diff --git a/settings/js/authtoken_view.js b/settings/js/authtoken_view.js index c8cf66a6cea..03d6c188f6e 100644 --- a/settings/js/authtoken_view.js +++ b/settings/js/authtoken_view.js @@ -218,6 +218,38 @@ this._newAppPassword.on('focus', _.bind(this._onNewTokenFocus, this)); this._hideAppPasswordBtn = $('#app-password-hide'); this._hideAppPasswordBtn.click(_.bind(this._hideToken, this)); + + // Clipboard! + var clipboard = new Clipboard('.clipboardButton'); + clipboard.on('success', function(e) { + var $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) { + var $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); + }); }, render: function () { diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 182fc3c6585..edbc0d24c5d 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -211,6 +211,7 @@ if($_['passwordChangeSupported']) {
t('Password')); ?> +
-- 2.39.5