mirror of https://github.com/keeweb/keeweb.git
Merge pull request #1059 from dploeger/issue-857
Added tooltip when field from history was copied. Fixes #857
This commit is contained in:
commit
3136abc337
|
@ -0,0 +1,43 @@
|
|||
const AppSettingsModel = require('../models/app-settings-model');
|
||||
const Backbone = require('backbone');
|
||||
|
||||
const Locale = require('../util/locale');
|
||||
|
||||
const Tip = require('../util/tip');
|
||||
const Timeouts = require('../const/timeouts');
|
||||
|
||||
const Copyable = {
|
||||
hideFieldCopyTip: function() {
|
||||
if (this.fieldCopyTip) {
|
||||
this.fieldCopyTip.hide();
|
||||
this.fieldCopyTip = null;
|
||||
}
|
||||
},
|
||||
|
||||
fieldCopied: function(e) {
|
||||
this.hideFieldCopyTip();
|
||||
const fieldLabel = e.source.labelEl;
|
||||
const clipboardTime = e.copyRes.seconds;
|
||||
const msg = clipboardTime ? Locale.detFieldCopiedTime.replace('{}', clipboardTime)
|
||||
: Locale.detFieldCopied;
|
||||
let tip;
|
||||
if (!this.isHidden()) {
|
||||
tip = Tip.createTip(fieldLabel[0], {title: msg, placement: 'right', fast: true, force: true, noInit: true});
|
||||
this.fieldCopyTip = tip;
|
||||
tip.show();
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (tip) {
|
||||
tip.hide();
|
||||
}
|
||||
this.fieldCopyTip = null;
|
||||
if (e.source.model.name === '$Password' && AppSettingsModel.instance.get('lockOnCopy')) {
|
||||
setTimeout(() => {
|
||||
Backbone.trigger('lock-workspace');
|
||||
}, Timeouts.BeforeAutoLock);
|
||||
}
|
||||
}, Timeouts.CopyTip);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Copyable;
|
|
@ -6,6 +6,7 @@ const Locale = require('../../util/locale');
|
|||
const Alerts = require('../../comp/alerts');
|
||||
const FieldViewReadOnly = require('../fields/field-view-read-only');
|
||||
const FieldViewReadOnlyRaw = require('../fields/field-view-read-only-raw');
|
||||
const Copyable = require('../../mixins/copyable');
|
||||
|
||||
const DetailsHistoryView = Backbone.View.extend({
|
||||
template: require('templates/details/details-history.hbs'),
|
||||
|
@ -106,6 +107,7 @@ const DetailsHistoryView = Backbone.View.extend({
|
|||
}
|
||||
this.fieldViews.forEach(function(fieldView) {
|
||||
fieldView.setElement(this.bodyEl).render();
|
||||
fieldView.on('copy', this.fieldCopied.bind(this));
|
||||
}, this);
|
||||
const buttons = this.$el.find('.details__history-buttons');
|
||||
buttons.find('.details__history-button-revert').toggle(ix < this.history.length - 1);
|
||||
|
@ -212,4 +214,6 @@ const DetailsHistoryView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
_.extend(DetailsHistoryView.prototype, Copyable);
|
||||
|
||||
module.exports = DetailsHistoryView;
|
||||
|
|
|
@ -30,6 +30,7 @@ const Locale = require('../../util/locale');
|
|||
const Tip = require('../../util/tip');
|
||||
const Timeouts = require('../../const/timeouts');
|
||||
const FileSaver = require('file-saver');
|
||||
const Copyable = require('../../mixins/copyable');
|
||||
|
||||
const DetailsView = Backbone.View.extend({
|
||||
template: require('templates/details/details.hbs'),
|
||||
|
@ -451,13 +452,6 @@ const DetailsView = Backbone.View.extend({
|
|||
setTimeout(() => { tip.hide(); }, Timeouts.AutoHideHint);
|
||||
},
|
||||
|
||||
hideFieldCopyTip: function() {
|
||||
if (this.fieldCopyTip) {
|
||||
this.fieldCopyTip.hide();
|
||||
this.fieldCopyTip = null;
|
||||
}
|
||||
},
|
||||
|
||||
settingsToggled: function() {
|
||||
this.hideFieldCopyTip();
|
||||
},
|
||||
|
@ -539,31 +533,6 @@ const DetailsView = Backbone.View.extend({
|
|||
return true;
|
||||
},
|
||||
|
||||
fieldCopied: function(e) {
|
||||
this.hideFieldCopyTip();
|
||||
const fieldLabel = e.source.labelEl;
|
||||
const clipboardTime = e.copyRes.seconds;
|
||||
const msg = clipboardTime ? Locale.detFieldCopiedTime.replace('{}', clipboardTime)
|
||||
: Locale.detFieldCopied;
|
||||
let tip;
|
||||
if (!this.isHidden()) {
|
||||
tip = Tip.createTip(fieldLabel[0], {title: msg, placement: 'right', fast: true, force: true, noInit: true});
|
||||
this.fieldCopyTip = tip;
|
||||
tip.show();
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (tip) {
|
||||
tip.hide();
|
||||
}
|
||||
this.fieldCopyTip = null;
|
||||
if (e.source.model.name === '$Password' && AppSettingsModel.instance.get('lockOnCopy')) {
|
||||
setTimeout(() => {
|
||||
Backbone.trigger('lock-workspace');
|
||||
}, Timeouts.BeforeAutoLock);
|
||||
}
|
||||
}, Timeouts.CopyTip);
|
||||
},
|
||||
|
||||
dragover: function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -853,5 +822,6 @@ const DetailsView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
_.extend(DetailsView.prototype, Scrollable);
|
||||
_.extend(DetailsView.prototype, Copyable);
|
||||
|
||||
module.exports = DetailsView;
|
||||
|
|
Loading…
Reference in New Issue