]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add clipboardjs for token
authorRoeland Jago Douma <roeland@famdouma.nl>
Wed, 10 Aug 2016 07:10:39 +0000 (09:10 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 10 Aug 2016 07:10:39 +0000 (09:10 +0200)
settings/css/settings.css
settings/js/authtoken_view.js
settings/templates/personal.php

index fe586205bdfa17637f2036fd5f80457f7e68803a..346b8ffa1cf3faa0f9fd826a20ca364ae41f370c 100644 (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;
index c8cf66a6cea49e947e2273c91ecbe6c48794c8b7..03d6c188f6e3d8ff17bdf822ef76b4e8fb7f1201 100644 (file)
                        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 () {
index 182fc3c658508b1fa957def1758a2d3e916a0e46..edbc0d24c5dd31b6f5cdcd291d49caa984e97e87 100644 (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>