auto-type shortcuts

This commit is contained in:
antelle 2016-04-10 10:02:32 +03:00
parent e07055f7df
commit ba1624e631
5 changed files with 24 additions and 2 deletions

View File

@ -345,6 +345,7 @@ var Locale = {
setShCopyPass: 'copy password or selected field',
setShCopyUser: 'copy username',
setShCopyUrl: 'copy website',
setShAutoType: 'auto-type selected entry',
setShPrev: 'go to previous item',
setShNext: 'go to next item',
setShCreateEntry: 'create entry',
@ -355,6 +356,7 @@ var Locale = {
setShCopyPassGlobal: 'copy password (when app is in background)',
setShCopyUserGlobal: 'copy username (when app is in background)',
setShCopyUrlGlobal: 'copy website (when app is in background)',
setShAutoTypeGlobal: 'auto-type (when app is in background)',
setShLock: 'lock database',
setAboutTitle: 'About',

View File

@ -24,6 +24,7 @@ var Backbone = require('backbone'),
Alerts = require('../../comp/alerts'),
CopyPaste = require('../../comp/copy-paste'),
OtpQrReqder = require('../../comp/otp-qr-reader'),
AutoType = require('../../comp/auto-type'),
Format = require('../../util/format'),
Locale = require('../../util/locale'),
Tip = require('../../util/tip'),
@ -62,6 +63,7 @@ var DetailsView = Backbone.View.extend({
this.initScroll();
this.listenTo(Backbone, 'select-entry', this.showEntry);
this.listenTo(Backbone, 'copy-password', this.copyPassword);
this.listenTo(Backbone, 'auto-type', this.autoTypeGlobal);
this.listenTo(Backbone, 'copy-user', this.copyUserName);
this.listenTo(Backbone, 'copy-url', this.copyUrl);
this.listenTo(OtpQrReqder, 'qr-read', this.otpCodeRead);
@ -69,6 +71,7 @@ var DetailsView = Backbone.View.extend({
KeyHandler.onKey(Keys.DOM_VK_C, this.copyPassword, this, KeyHandler.SHORTCUT_ACTION, false, true);
KeyHandler.onKey(Keys.DOM_VK_B, this.copyUserName, this, KeyHandler.SHORTCUT_ACTION, false, true);
KeyHandler.onKey(Keys.DOM_VK_U, this.copyUrl, this, KeyHandler.SHORTCUT_ACTION, false, true);
KeyHandler.onKey(Keys.DOM_VK_T, this.autoType, this, KeyHandler.SHORTCUT_ACTION);
KeyHandler.onKey(Keys.DOM_VK_DELETE, this.deleteKeyPress, this, KeyHandler.SHORTCUT_ACTION);
KeyHandler.onKey(Keys.DOM_VK_BACK_SPACE, this.deleteKeyPress, this, KeyHandler.SHORTCUT_ACTION);
},
@ -738,6 +741,17 @@ var DetailsView = Backbone.View.extend({
fieldView.edit();
this.fieldViews.push(fieldView);
}
},
autoType: function() {
var entry = this.model;
AutoType.hideWindow(function() {
AutoType.run(entry, '{password}', false, _.noop);
});
},
autoTypeGlobal: function() {
// TODO
}
});

View File

@ -13,7 +13,8 @@ var SettingsShortcutsView = Backbone.View.extend({
alt: FeatureDetector.altShortcutSymbol(true),
global: FeatureDetector.globalShortcutSymbol(true),
globalIsLarge: FeatureDetector.globalShortcutIsLarge(),
globalShortcutsSupported: !!Launcher
globalShortcutsSupported: !!Launcher,
autoTypeSupported: !!Launcher
});
}
});

View File

@ -9,6 +9,9 @@
<div><span class="shortcut">{{{cmd}}}C</span> {{res 'setShCopyPass'}}</div>
<div><span class="shortcut">{{{cmd}}}B</span> {{res 'setShCopyUser'}}</div>
<div><span class="shortcut">{{{cmd}}}U</span> {{res 'setShCopyUrl'}}</div>
{{#if autoTypeSupported}}
<div><span class="shortcut">{{{cmd}}}T</span> {{res 'setShAutoType'}}</div>
{{/if}}
<div><span class="shortcut">&uarr;</span> {{res 'setShPrev'}}</div>
<div><span class="shortcut">&darr;</span> {{res 'setShNext'}}</div>
<div><span class="shortcut">{{{alt}}}N</span> {{res 'setShCreateEntry'}}</div>
@ -21,5 +24,6 @@
<div><span class="shortcut {{#if globalIsLarge}}shortcut-large{{/if}}">{{{global}}}C</span> {{res 'setShCopyPassGlobal'}}</div>
<div><span class="shortcut {{#if globalIsLarge}}shortcut-large{{/if}}">{{{global}}}B</span> {{res 'setShCopyUserGlobal'}}</div>
<div><span class="shortcut {{#if globalIsLarge}}shortcut-large{{/if}}">{{{global}}}U</span> {{res 'setShCopyUrlGlobal'}}</div>
<div><span class="shortcut {{#if globalIsLarge}}shortcut-large{{/if}}">{{{global}}}T</span> {{res 'setShAutoTypeGlobal'}}</div>
{{/if}}
</div>

View File

@ -247,7 +247,8 @@ function setGlobalShortcuts() {
var shortcuts = {
C: 'copy-password',
B: 'copy-user',
U: 'copy-url'
U: 'copy-url',
T: 'auto-type'
};
Object.keys(shortcuts).forEach(function(key) {
var shortcut = shortcutModifiers + key;