Add clipboardjs for token

This commit is contained in:
Roeland Jago Douma 2016-08-10 09:10:39 +02:00
parent 806f9b80f1
commit 79b7ff3bf8
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
3 changed files with 42 additions and 0 deletions

View File

@ -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;

View File

@ -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 () {

View File

@ -211,6 +211,7 @@ if($_['passwordChangeSupported']) {
<div class="app-password-row">
<span class="app-password-label"><?php p($l->t('Password')); ?></span>
<input id="new-app-password" type="text" readonly="readonly"/>
<a class="clipboardButton icon icon-clippy" data-clipboard-target="#new-app-password"></a>
<button id="app-password-hide" class="button"><?php p($l->t('Done')); ?></button>
</div>
</div>