From 965804425dd13ec9d7d2f5edbfbd62ed6939b12e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 10 Aug 2016 09:10:39 +0200 Subject: Add clipboardjs for token --- settings/js/authtoken_view.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'settings/js/authtoken_view.js') 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 () { -- cgit v1.2.3