mirror of https://github.com/keeweb/keeweb.git
- refactored 3 copyKeyPress functions into one
- added additional shortcut keys to settings-shortcuts.hbs - added locales for new shortcut keys - fixed code formatting issue
This commit is contained in:
parent
1fe626f4d9
commit
a7d00f8cfa
|
@ -289,6 +289,7 @@ var Locale = {
|
|||
setShEntry: 'go to entry',
|
||||
setShCopyPass: 'copy password or selected field',
|
||||
setShCopyUser: 'copy username',
|
||||
setShCopyUrl: 'copy url',
|
||||
setShPrev: 'go to previous item',
|
||||
setShNext: 'go to next item',
|
||||
setShCreateEntry: 'create entry',
|
||||
|
@ -296,6 +297,9 @@ var Locale = {
|
|||
setShSave: 'save all files',
|
||||
setShGen: 'generate password',
|
||||
setShSet: 'app settings',
|
||||
setShCopyPassGlobal: 'copy password global (works when app is in background)',
|
||||
setShCopyUserGlobal: 'copy username global (works when app is in background)',
|
||||
setShCopyUrlGlobal: 'copy url global (works when app is in background)',
|
||||
|
||||
setAboutTitle: 'About',
|
||||
setAboutBuilt: 'This app is built with these awesome tools',
|
||||
|
|
|
@ -57,12 +57,12 @@ var DetailsView = Backbone.View.extend({
|
|||
this.views = {};
|
||||
this.initScroll();
|
||||
this.listenTo(Backbone, 'select-entry', this.showEntry);
|
||||
this.listenTo(Backbone, 'copy-password', this.copyKeyPress);
|
||||
this.listenTo(Backbone, 'copy-user', this.copyUserKeyPress);
|
||||
this.listenTo(Backbone, 'copy-url', this.copyUrlKeyPress);
|
||||
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_U, this.copyUrlKeyPress, this, KeyHandler.SHORTCUT_ACTION, false, true);
|
||||
this.listenTo(Backbone, 'copy-password', function() { this.copyKeyPress(this.passEditView); } );
|
||||
this.listenTo(Backbone, 'copy-user', function() { this.copyKeyPress(this.userEditView); } );
|
||||
this.listenTo(Backbone, 'copy-url', function() { this.copyKeyPress(this.urlEditView); } );
|
||||
KeyHandler.onKey(Keys.DOM_VK_C, function() { this.copyKeyPress(this.passEditView); }, this, KeyHandler.SHORTCUT_ACTION, false, true);
|
||||
KeyHandler.onKey(Keys.DOM_VK_B, function() { this.copyKeyPress(this.userEditView); }, this, KeyHandler.SHORTCUT_ACTION, false, true);
|
||||
KeyHandler.onKey(Keys.DOM_VK_U, function() { this.copyKeyPress(this.urlEditView); }, 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);
|
||||
},
|
||||
|
@ -281,57 +281,23 @@ var DetailsView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
copyKeyPress: function() { // TODO: fix this in Safari
|
||||
copyKeyPress: function(editView) {
|
||||
if (!window.getSelection().toString()) {
|
||||
var pw = this.model.password;
|
||||
var password = pw.isProtected ? pw.getText() : pw;
|
||||
if (!password) {
|
||||
var field = editView.value;
|
||||
var fieldText = field.isProtected ? field.getText() : field;
|
||||
if (!fieldText) {
|
||||
return;
|
||||
}
|
||||
if (!CopyPaste.simpleCopy) {
|
||||
CopyPaste.createHiddenInput(password);
|
||||
CopyPaste.createHiddenInput(fieldText);
|
||||
}
|
||||
var copyRes = CopyPaste.copy(password);
|
||||
var copyRes = CopyPaste.copy(fieldText);
|
||||
if (copyRes) {
|
||||
this.fieldCopied({ source: this.passEditView, copyRes: copyRes });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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 });
|
||||
this.fieldCopied({ source: editView, copyRes: copyRes });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
copyUrlKeyPress: function() {
|
||||
if (!window.getSelection().toString()) {
|
||||
var urlField = this.model.url;
|
||||
var url = urlField.isProtected ? urlField.getText() : urlField;
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
if (!CopyPaste.simpleCopy) {
|
||||
CopyPaste.createHiddenInput(url);
|
||||
}
|
||||
var copyRes = CopyPaste.copy(url);
|
||||
if (copyRes) {
|
||||
this.fieldCopied({ source: this.urlEditView, copyRes: copyRes });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showCopyTip: function() {
|
||||
if (this.helpTipCopyShown) {
|
||||
return;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<div><span class="shortcut">⏎</span> {{res 'setShEntry'}}</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">{{{cmd}}}U</span> {{res 'setShCopyUrl'}}</div>
|
||||
<div><span class="shortcut">↑</span> {{res 'setShPrev'}}</div>
|
||||
<div><span class="shortcut">↓</span> {{res 'setShNext'}}</div>
|
||||
<div><span class="shortcut">{{{alt}}}N</span> {{res 'setShCreateEntry'}}</div>
|
||||
|
@ -15,4 +16,7 @@
|
|||
<div><span class="shortcut">{{{cmd}}}S</span> {{res 'setShSave'}}</div>
|
||||
<div><span class="shortcut">{{{cmd}}}G</span> {{res 'setShGen'}}</div>
|
||||
<div><span class="shortcut">{{{cmd}}},</span> {{res 'setShSet'}}</div>
|
||||
<div><span class="shortcut">{{{ctrl}}}{{{alt}}}C</span> {{res 'setShCopyPassGlobal'}}</div>
|
||||
<div><span class="shortcut">{{{ctrl}}}{{{alt}}}B</span> {{res 'setShCopyUserGlobal'}}</div>
|
||||
<div><span class="shortcut">{{{ctrl}}}{{{alt}}}U</span> {{res 'setShCopyUrlGlobal'}}</div>
|
||||
</div>
|
||||
|
|
|
@ -50,9 +50,7 @@ app.on('ready', function() {
|
|||
createGlobalShortcut('Ctrl+Alt+B', 'copy-user');
|
||||
createGlobalShortcut('Ctrl+Alt+C', 'copy-password');
|
||||
createGlobalShortcut('Ctrl+Alt+U', 'copy-url');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
createGlobalShortcut('Shift+Alt+B', 'copy-user');
|
||||
createGlobalShortcut('Shift+Alt+C', 'copy-password');
|
||||
createGlobalShortcut('Shift+Alt+U', 'copy-url');
|
||||
|
@ -72,7 +70,7 @@ app.on('activate', function() {
|
|||
}
|
||||
});
|
||||
app.on('will-quit', function() {
|
||||
globalShortcut.unregisterAll();
|
||||
globalShortcut.unregisterAll();
|
||||
});
|
||||
app.restartApp = function() {
|
||||
restartPending = true;
|
||||
|
@ -252,13 +250,8 @@ function notifyOpenFile() {
|
|||
}
|
||||
}
|
||||
|
||||
function createGlobalShortcut(shortcut, backboneEventname)
|
||||
{
|
||||
var ret = globalShortcut.register(shortcut, function() {
|
||||
function createGlobalShortcut(shortcut, backboneEventname) {
|
||||
globalShortcut.register(shortcut, function() {
|
||||
emitBackboneEvent(backboneEventname);
|
||||
});
|
||||
|
||||
if (!ret) {
|
||||
console.log('registration failed');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue