fix #92: shortcut to copy username

This commit is contained in:
Antelle 2016-02-22 10:09:23 +03:00
parent 99496253d9
commit 11ab09d641
4 changed files with 31 additions and 4 deletions

View File

@ -279,7 +279,8 @@ var Locale = {
setShFind: 'search, or just start typing',
setShClearSearch: 'clear search',
setShEntry: 'go to entry',
setShCopy: 'copy password or selected field',
setShCopyPass: 'copy password or selected field',
setShCopyUser: 'copy username',
setShPrev: 'go to previous item',
setShNext: 'go to next item',
setShCreateEntry: 'create entry',

View File

@ -33,6 +33,7 @@ var DetailsView = Backbone.View.extend({
fieldViews: null,
views: null,
passEditView: null,
userEditView: null,
addNewFieldView: null,
fieldCopyTip: null,
@ -56,12 +57,14 @@ var DetailsView = Backbone.View.extend({
this.initScroll();
this.listenTo(Backbone, 'select-entry', this.showEntry);
KeyHandler.onKey(Keys.DOM_VK_C, this.copyKeyPress, this, KeyHandler.SHORTCUT_ACTION, false, true);
KeyHandler.onKey(Keys.DOM_VK_B, this.copyUserKeyPress, this, KeyHandler.SHORTCUT_ACTION, false, true);
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);
},
remove: function() {
KeyHandler.offKey(Keys.DOM_VK_C, this.copyKeyPress, this);
KeyHandler.offKey(Keys.DOM_VK_B, this.copyUserKeyPress, this);
KeyHandler.offKey(Keys.DOM_VK_DELETE, this.deleteKeyPress, this, KeyHandler.SHORTCUT_ACTION);
KeyHandler.offKey(Keys.DOM_VK_BACK_SPACE, this.deleteKeyPress, this, KeyHandler.SHORTCUT_ACTION);
this.removeFieldViews();
@ -115,8 +118,9 @@ var DetailsView = Backbone.View.extend({
addFieldViews: function() {
var model = this.model;
this.fieldViews.push(new FieldViewText({ model: { name: '$UserName', title: Locale.detUser,
value: function() { return model.user; } } }));
this.userEditView = new FieldViewText({ model: { name: '$UserName', title: Locale.detUser,
value: function() { return model.user; } } });
this.fieldViews.push(this.userEditView);
this.passEditView = new FieldViewText({ model: { name: '$Password', title: Locale.detPassword, canGen: true,
value: function() { return model.password; } } });
this.fieldViews.push(this.passEditView);
@ -274,6 +278,9 @@ var DetailsView = Backbone.View.extend({
if (!window.getSelection().toString()) {
var pw = this.model.password;
var password = pw.isProtected ? pw.getText() : pw;
if (!password) {
return;
}
if (!CopyPaste.simpleCopy) {
CopyPaste.createHiddenInput(password);
}
@ -284,6 +291,23 @@ var DetailsView = Backbone.View.extend({
}
},
copyUserKeyPress: function() {
if (!window.getSelection().toString()) {
var userField = this.model.user;
var user = userField.isProtected ? userField.getText() : userField;
if (!user) {
return;
}
if (!CopyPaste.simpleCopy) {
CopyPaste.createHiddenInput(user);
}
var copyRes = CopyPaste.copy(user);
if (copyRes) {
this.fieldCopied({ source: this.userEditView, copyRes: copyRes });
}
}
},
showCopyTip: function() {
if (this.helpTipCopyShown) {
return;

View File

@ -6,7 +6,8 @@
<div><span class="shortcut">{{{cmd}}}F</span> {{res 'setShFind'}}</div>
<div><span class="shortcut">esc</span> {{res 'setShClearSearch'}}</div>
<div><span class="shortcut">⏎</span> {{res 'setShEntry'}}</div>
<div><span class="shortcut">{{{cmd}}}C</span> {{res 'setShCopy'}}</div>
<div><span class="shortcut">{{{cmd}}}C</span> {{res 'setShCopyPass'}}</div>
<div><span class="shortcut">{{{cmd}}}B</span> {{res 'setShCopyUser'}}</div>
<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>

View File

@ -6,6 +6,7 @@ Storage providers, usability improvements
`+` beta version app
`+` option to lock on password copy
`+` save/restore window position after close
`+` shortcut to copy username
`-` fix #88: capslock indicator
##### v1.0.2 (2016-02-17)