This commit is contained in:
antelle 2019-09-16 20:54:14 +02:00
parent f1d9b5c645
commit 12079f6ac6
17 changed files with 20 additions and 32 deletions

View File

@ -148,7 +148,6 @@ class AppView extends View {
this.views.listDrag.render();
this.views.details.render();
this.showLastOpenFile();
return this;
}
showOpenFile() {

View File

@ -18,6 +18,10 @@ class AutoTypeHintView extends View {
this.inputBlur = this.inputBlur.bind(this);
$('body').on('click', this.bodyClick);
this.input.addEventListener('blur', this.inputBlur);
this.once('remove', () => {
$('body').off('click', this.bodyClick);
this.input.removeEventListener('blur', this.inputBlur);
});
}
render() {
@ -37,13 +41,6 @@ class AutoTypeHintView extends View {
if (selfRect.bottom > bodyRect.bottom) {
this.$el.css('height', selfRect.height + bodyRect.bottom - selfRect.bottom - 1);
}
return this;
}
remove() {
$('body').off('click', this.bodyClick);
this.input.removeEventListener('blur', this.inputBlur);
super.remove(this);
}
bodyClick(e) {

View File

@ -14,7 +14,6 @@ class DetailsAddFieldView extends View {
render() {
super.render();
this.labelEl = this.$el.find('.details__field-label');
return this;
}
fieldLabelClick() {

View File

@ -54,7 +54,8 @@ class DetailsAutoTypeView extends View {
seqFocus(e) {
if (!this.views.hint) {
this.views.hint = new AutoTypeHintView({ input: e.target }).render();
this.views.hint = new AutoTypeHintView({ input: e.target });
this.views.hint.render();
this.views.hint.on('remove', () => {
delete this.views.hint;
});

View File

@ -40,7 +40,7 @@ import groupTemplate from 'templates/details/details-group.hbs';
class DetailsView extends View {
parent = '.app__details';
fieldViews = null;
fieldViews = [];
passEditView = null;
userEditView = null;
urlEditView = null;
@ -65,7 +65,6 @@ class DetailsView extends View {
constructor(model, options) {
super(model, options);
this.fieldViews = [];
this.initScroll();
this.listenTo(Backbone, 'entry-selected', this.showEntry);
this.listenTo(Backbone, 'copy-password', this.copyPassword);
@ -146,7 +145,6 @@ class DetailsView extends View {
}
this.pageResized();
this.showCopyTip();
return this;
}
addFieldViews() {

View File

@ -12,6 +12,11 @@ class FieldViewOtp extends FieldViewText {
otpValidUntil = 0;
fieldOpacity = null;
constructor(model, options) {
super(model, options);
this.once('remove', () => this.resetOtp());
}
renderValue(value) {
if (!value) {
this.resetOtp();
@ -34,11 +39,6 @@ class FieldViewOtp extends FieldViewText {
this.otpTick();
}
remove() {
this.resetOtp();
super.remove();
}
resetOtp() {
this.otpGenerator = null;
this.otpValue = null;

View File

@ -95,7 +95,8 @@ class FieldViewText extends FieldView {
this.gen = new GeneratorView({
pos: { left: fieldRect.left, top: fieldRect.bottom + shadowSpread },
password: this.value
}).render();
});
this.gen.render();
this.gen.once('remove', this.generatorClosed.bind(this));
this.gen.once('result', this.generatorResult.bind(this));
}

View File

@ -68,7 +68,8 @@ class FooterView extends View {
const bodyRect = document.body.getBoundingClientRect();
const right = bodyRect.right - rect.right;
const bottom = bodyRect.bottom - rect.top;
const generator = new GeneratorView({ copy: true, pos: { right, bottom } }).render();
const generator = new GeneratorView({ copy: true, pos: { right, bottom } });
generator.render();
generator.once('remove', () => {
delete this.views.gen;
});

View File

@ -85,7 +85,6 @@ class GeneratorView extends View {
this.resultEl = this.$el.find('.gen__result');
this.$el.css(this.model.pos);
this.generate();
return this;
}
createPresets() {

View File

@ -80,7 +80,8 @@ class GrpView extends View {
focusAutoTypeSeq(e) {
if (!this.views.hint) {
this.views.hint = new AutoTypeHintView({ input: e.target }).render();
this.views.hint = new AutoTypeHintView({ input: e.target });
this.views.hint.render();
this.views.hint.on('remove', () => {
delete this.views.hint;
});

View File

@ -102,7 +102,6 @@ class ListSearchView extends View {
this.sortOptions.forEach(function(opt) {
this.sortIcons[opt.value] = opt.icon;
}, this);
this.views = {};
this.advancedSearch = {
user: true,
other: true,
@ -175,7 +174,6 @@ class ListSearchView extends View {
if (searchVal) {
this.inputEl.val(searchVal);
}
return this;
}
inputKeyDown(e) {

View File

@ -109,7 +109,6 @@ class ListView extends View {
this.itemsEl.html(this.emptyTemplate());
}
this.pageResized();
return this;
}
getItemsTemplate() {

View File

@ -27,11 +27,10 @@ class MenuItemView extends View {
};
iconEl = null;
itemViews = null;
itemViews = [];
constructor(model, options) {
super(model, options);
this.itemViews = [];
this.listenTo(this.model, 'change:title', this.changeTitle);
this.listenTo(this.model, 'change:icon', this.changeIcon);
this.listenTo(this.model, 'change:customIconId', this.render);

View File

@ -10,14 +10,13 @@ class MenuSectionView extends View {
events = {};
itemViews = null;
itemViews = [];
minHeight = 55;
autoHeigh = 'auto';
constructor(model, options) {
super(model, options);
this.itemViews = [];
this.listenTo(this.model, 'change-items', this.itemsChanged);
this.listenTo(this, 'view-resize', this.viewResized);
this.once('remove', () => {

View File

@ -60,7 +60,6 @@ class MenuView extends View {
if (typeof AppSettingsModel.instance.get('menuViewWidth') === 'number') {
this.$el.width(AppSettingsModel.instance.get('menuViewWidth'));
}
return this;
}
menuChanged() {

View File

@ -41,7 +41,6 @@ class ModalView extends View {
this.model.view.parent = '.modal__body';
this.model.view.render();
}
return this;
}
change(config) {

View File

@ -104,7 +104,6 @@ class OpenView extends View {
});
this.inputEl = this.$el.find('.open__pass-input');
this.passwordInput.setElement(this.inputEl);
return this;
}
resetParams() {