This commit is contained in:
antelle 2019-09-16 21:07:39 +02:00
parent 12079f6ac6
commit 727887fb79
4 changed files with 13 additions and 15 deletions

View File

@ -152,11 +152,6 @@ class View extends EventEmitter {
this.once('remove', () => model.off(event, boundCallback));
}
stopListening(model, event, callback) {
// TODO: remove a pending callback
model.off(event, callback);
}
hide() {
Tip.hideTips(this.el);
return this.toggle(false);

View File

@ -45,7 +45,6 @@ class FieldViewCustom extends FieldViewText {
return;
}
delete this.input;
this.stopListening(Backbone, 'click', this.fieldValueBlur);
if (typeof newVal === 'string') {
if (this.isProtected) {
newVal = kdbxweb.ProtectedValue.fromString(newVal);

View File

@ -44,7 +44,7 @@ class FieldViewText extends FieldView {
click: this.fieldValueInputClick.bind(this),
mousedown: this.fieldValueInputMouseDown.bind(this)
});
this.listenTo(Backbone, 'click', this.fieldValueBlur);
Backbone.on('click', this._fieldValueBlur);
this.listenTo(Backbone, 'main-window-will-close user-idle', this.externalEndEdit);
if (this.model.multiline) {
this.setInputHeight();
@ -217,10 +217,6 @@ class FieldViewText extends FieldView {
super.endEdit(newVal, extra);
}
stopBlurListener() {
this.stopListening(Backbone, 'click main-window-will-close', this.fieldValueBlur);
}
mobileFieldControlMouseDown(e) {
e.stopPropagation();
this.stopBlurListener();

View File

@ -99,9 +99,9 @@ class ListSearchView extends View {
{ value: '-rank', icon: 'sort-amount-desc', loc: () => Locale.searchRank }
];
this.sortIcons = {};
this.sortOptions.forEach(function(opt) {
this.sortOptions.forEach(opt => {
this.sortIcons[opt.value] = opt.icon;
}, this);
});
this.advancedSearch = {
user: true,
other: true,
@ -127,6 +127,10 @@ class ListSearchView extends View {
this.listenTo(Backbone, 'filter', this.filterChanged);
this.listenTo(Backbone, 'set-locale', this.setLocale);
this.listenTo(Backbone, 'page-blur', this.pageBlur);
this.once('remove', () => {
this.removeKeypressHandler();
});
}
setLocale() {
@ -153,12 +157,16 @@ class ListSearchView extends View {
this.inputEl.blur();
}
removeKeypressHandler() {}
viewShown() {
this.listenTo(KeyHandler, 'keypress', this.documentKeyPress);
const keypressHandler = e => this.documentKeyPress(e);
KeyHandler.on('keypress', keypressHandler);
this.removeKeypressHandler = () => KeyHandler.off('keypress', keypressHandler);
}
viewHidden() {
this.stopListening(KeyHandler, 'keypress', this.documentKeyPress);
this.removeKeypressHandler();
}
render() {