mirror of https://github.com/keeweb/keeweb.git
fix #75: option to lock on password copy
This commit is contained in:
parent
4eb5eb39e9
commit
8fc4fec3c2
|
@ -4,7 +4,8 @@ var Timeouts = {
|
|||
AutoSync: 30 * 1000 * 60,
|
||||
CopyTip: 1500,
|
||||
AutoHideHint: 3000,
|
||||
FileChangeSync: 3000
|
||||
FileChangeSync: 3000,
|
||||
BeforeAutoLock: 300
|
||||
};
|
||||
|
||||
module.exports = Timeouts;
|
||||
|
|
|
@ -19,6 +19,7 @@ var AppSettingsModel = Backbone.Model.extend({
|
|||
tableView: false,
|
||||
colorfulIcons: false,
|
||||
lockOnMinimize: true,
|
||||
lockOnCopy: false,
|
||||
helpTipCopyShown: false
|
||||
},
|
||||
|
||||
|
|
|
@ -146,8 +146,8 @@ var Locale = {
|
|||
detDelFromTrash: 'Delete from trash?',
|
||||
detDelFromTrashBody: 'You will not be able to put it back.',
|
||||
detDelFromTrashBodyHint: 'To quickly remove all items from trash, click empty icon in Trash menu.',
|
||||
detPassCopied: 'Password copied',
|
||||
detPassCopiedTime: 'Password copied for {} seconds',
|
||||
detFieldCopied: 'Copied',
|
||||
detFieldCopiedTime: 'Copied for {} seconds',
|
||||
detCopyHint: 'You can copy field value with click on its title',
|
||||
|
||||
appSecWarn: 'Not Secure!',
|
||||
|
@ -213,6 +213,7 @@ var Locale = {
|
|||
setGenClearMinute: 'In a minute',
|
||||
setGenMinInstead: 'Minimize app instead of close',
|
||||
setGenLockMinimize: 'Auto-lock on minimize',
|
||||
setGenLockCopy: 'Auto-lock on password copy',
|
||||
setGenAdvanced: 'Advanced',
|
||||
setGenDevTools: 'Show dev tools',
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ var DetailsView = Backbone.View.extend({
|
|||
views: null,
|
||||
passEditView: null,
|
||||
addNewFieldView: null,
|
||||
passCopyTip: null,
|
||||
fieldCopyTip: null,
|
||||
|
||||
events: {
|
||||
'click .details__colors-popup-item': 'selectColor',
|
||||
|
@ -71,9 +71,9 @@ var DetailsView = Backbone.View.extend({
|
|||
removeFieldViews: function() {
|
||||
this.fieldViews.forEach(function(fieldView) { fieldView.remove(); });
|
||||
this.fieldViews = [];
|
||||
if (this.passCopyTip) {
|
||||
this.passCopyTip.hide();
|
||||
this.passCopyTip = null;
|
||||
if (this.fieldCopyTip) {
|
||||
this.fieldCopyTip.hide();
|
||||
this.fieldCopyTip = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -159,6 +159,7 @@ var DetailsView = Backbone.View.extend({
|
|||
this.fieldViews.forEach(function(fieldView) {
|
||||
fieldView.setElement(fieldView.readonly ? fieldsAsideEl : fieldsMainEl).render();
|
||||
fieldView.on('change', this.fieldChanged.bind(this));
|
||||
fieldView.on('copy', this.fieldCopied.bind(this));
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
@ -277,19 +278,8 @@ var DetailsView = Backbone.View.extend({
|
|||
CopyPaste.createHiddenInput(password);
|
||||
}
|
||||
var copyRes = CopyPaste.copy(password);
|
||||
if (copyRes && !this.passCopyTip) {
|
||||
var passLabel = this.passEditView.labelEl;
|
||||
var clipboardTime = copyRes.seconds;
|
||||
var msg = clipboardTime ? Locale.detPassCopiedTime.replace('{}', clipboardTime)
|
||||
: Locale.detPassCopied;
|
||||
var tip = new Tip(passLabel, { title: msg, placement: 'right', fast: true });
|
||||
this.passCopyTip = tip;
|
||||
tip.show();
|
||||
var that = this;
|
||||
setTimeout(function() {
|
||||
tip.hide();
|
||||
that.passCopyTip = null;
|
||||
}, Timeouts.CopyTip);
|
||||
if (copyRes) {
|
||||
this.fieldCopied({ source: this.passEditView, copyRes: copyRes });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -355,6 +345,30 @@ var DetailsView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
fieldCopied: function(e) {
|
||||
if (this.fieldCopyTip) {
|
||||
this.fieldCopyTip.hide();
|
||||
this.fieldCopyTip = null;
|
||||
}
|
||||
var fieldLabel = e.source.labelEl;
|
||||
var clipboardTime = e.copyRes.seconds;
|
||||
var msg = clipboardTime ? Locale.detFieldCopiedTime.replace('{}', clipboardTime)
|
||||
: Locale.detFieldCopied;
|
||||
var tip = new Tip(fieldLabel, { title: msg, placement: 'right', fast: true });
|
||||
this.fieldCopyTip = tip;
|
||||
tip.show();
|
||||
var that = this;
|
||||
setTimeout(function() {
|
||||
tip.hide();
|
||||
that.fieldCopyTip = null;
|
||||
if (e.source.model.name === '$Password' && AppSettingsModel.instance.get('lockOnCopy')) {
|
||||
setTimeout(function() {
|
||||
Backbone.trigger('lock-workspace');
|
||||
}, Timeouts.BeforeAutoLock);
|
||||
}
|
||||
}, Timeouts.CopyTip);
|
||||
},
|
||||
|
||||
dragover: function(e) {
|
||||
e.preventDefault();
|
||||
if (this.dragTimeout) {
|
||||
|
|
|
@ -44,24 +44,36 @@ var FieldView = Backbone.View.extend({
|
|||
//CopyPaste.copy(); // maybe Apple will ever support this?
|
||||
return;
|
||||
}
|
||||
var copyRes;
|
||||
if (field) {
|
||||
var value = this.value || '';
|
||||
if (value && value.isProtected) {
|
||||
var text = value.getText();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
if (!CopyPaste.simpleCopy) {
|
||||
CopyPaste.createHiddenInput(text);
|
||||
}
|
||||
CopyPaste.copy(text);
|
||||
copyRes = CopyPaste.copy(text);
|
||||
if (copyRes) {
|
||||
this.trigger('copy', { source: this, copyRes: copyRes });
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this.value) {
|
||||
return;
|
||||
}
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(this.valueEl[0]);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
if (CopyPaste.copy(this.valueEl.text())) {
|
||||
copyRes = CopyPaste.copy(this.valueEl.text());
|
||||
if (copyRes) {
|
||||
selection.removeAllRanges();
|
||||
this.trigger('copy', { source: this, copyRes: copyRes });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
'change .settings__general-remember-key-files': 'changeRememberKeyFiles',
|
||||
'change .settings__general-minimize': 'changeMinimize',
|
||||
'change .settings__general-lock-on-minimize': 'changeLockOnMinimize',
|
||||
'change .settings__general-lock-on-copy': 'changeLockOnCopy',
|
||||
'change .settings__general-table-view': 'changeTableView',
|
||||
'change .settings__general-colorful-icons': 'changeColorfulIcons',
|
||||
'click .settings__general-update-btn': 'checkUpdate',
|
||||
|
@ -62,6 +63,7 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
canAutoUpdate: Updater.enabled,
|
||||
canMinimize: Launcher && Launcher.canMinimize(),
|
||||
lockOnMinimize: Launcher && AppSettingsModel.instance.get('lockOnMinimize'),
|
||||
lockOnCopy: AppSettingsModel.instance.get('lockOnCopy'),
|
||||
tableView: AppSettingsModel.instance.get('tableView'),
|
||||
canSetTableView: FeatureDetector.isDesktop(),
|
||||
autoUpdate: Updater.getAutoUpdateType(),
|
||||
|
@ -164,6 +166,11 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
AppSettingsModel.instance.set('lockOnMinimize', lockOnMinimize);
|
||||
},
|
||||
|
||||
changeLockOnCopy: function(e) {
|
||||
var lockOnCopy = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnCopy', lockOnCopy);
|
||||
},
|
||||
|
||||
changeTableView: function(e) {
|
||||
var tableView = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('tableView', tableView);
|
||||
|
|
|
@ -105,6 +105,11 @@
|
|||
<label for="settings__general-lock-on-minimize">{{res 'setGenLockMinimize'}}</label>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div>
|
||||
<input type="checkbox" class="settings__input input-base settings__general-lock-on-copy" id="settings__general-lock-on-copy"
|
||||
{{#if lockOnCopy}}checked{{/if}} />
|
||||
<label for="settings__general-lock-on-copy">{{res 'setGenLockCopy'}}</label>
|
||||
</div>
|
||||
|
||||
{{#if devTools}}
|
||||
<h2>{{res 'setGenAdvanced'}}</h2>
|
||||
|
|
|
@ -4,6 +4,7 @@ Release notes
|
|||
Storage providers, usability improvements
|
||||
`+` option to remember keyfiles
|
||||
`+` beta version app
|
||||
`+` option to lock on password copy
|
||||
|
||||
##### v1.0.0 (2016-02-12)
|
||||
Performance, stability and quality improvements
|
||||
|
|
Loading…
Reference in New Issue