diff --git a/settings/css/settings.css b/settings/css/settings.css index 4cd8559844..b6d0e57995 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -145,6 +145,16 @@ 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; + margin-right: 8px; +} + .app-password-label { display: table-cell; padding-right: 1em; diff --git a/settings/js/authtoken_view.js b/settings/js/authtoken_view.js index 354173341b..6eb04b63f2 100644 --- a/settings/js/authtoken_view.js +++ b/settings/js/authtoken_view.js @@ -183,6 +183,8 @@ _newAppPassword: undefined, + _newAppId: undefined, + _hideAppPasswordBtn: undefined, _addingToken: false, @@ -216,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 () { @@ -255,10 +289,13 @@ }); $.when(creatingToken).done(function (resp) { + // We can delete token we add + resp.deviceToken.canDelete = true; _this.collection.add(resp.deviceToken); _this.render(); _this._newAppLoginName.val(resp.loginName); _this._newAppPassword.val(resp.token); + _this._newAppId = resp.deviceToken.id; _this._toggleFormResult(false); _this._newAppPassword.select(); _this._tokenName.val(''); @@ -293,6 +330,10 @@ var $row = $target.closest('tr'); var id = $row.data('id'); + if (id === this._newAppId) { + this._toggleFormResult(true); + } + var token = this.collection.get(id); if (_.isUndefined(token)) { // Ignore event @@ -313,8 +354,13 @@ }, _toggleFormResult: function (showForm) { - this._form.toggleClass('hidden', !showForm); - this._result.toggleClass('hidden', showForm); + if (showForm) { + this._result.slideUp(); + this._form.slideDown(); + } else { + this._form.slideUp(); + this._result.slideDown(); + } } }); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 890bfd1bbe..edbc0d24c5 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -200,7 +200,10 @@ if($_['passwordChangeSupported']) {