merge dploeger-autotypeopendatabase

This commit is contained in:
antelle 2019-03-31 14:30:14 +02:00
parent 443a7b4f8d
commit 35ed03021a
3 changed files with 35 additions and 7 deletions

View File

@ -221,6 +221,14 @@ const AutoType = {
}
});
});
this.selectEntryView.on('show-open-files', () => {
this.selectEntryView.hide();
Backbone.trigger('open-file');
Backbone.once('closed-open-view', () => {
this.selectEntryView.show();
this.selectEntryView.setupKeys();
}, this);
});
},
resetPendingEvent() {

View File

@ -158,6 +158,9 @@ const AppView = Backbone.View.extend({
this.hideKeyChange();
this.views.open = new OpenView({ model: this.model });
this.views.open.setElement(this.$el.find('.app__body')).render();
this.views.open.on('close', () => {
Backbone.trigger('closed-open-view');
}, this);
this.views.open.on('close', this.showEntries, this);
},

View File

@ -26,6 +26,10 @@ const AutoTypePopupView = Backbone.View.extend({
this.initScroll();
this.listenTo(Backbone, 'main-window-blur', this.mainWindowBlur);
this.listenTo(Backbone, 'main-window-will-close', this.mainWindowWillClose);
this.setupKeys();
},
setupKeys() {
KeyHandler.onKey(Keys.DOM_VK_ESCAPE, this.escPressed, this, false, true);
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.enterPressed, this, false, true);
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.actionEnterPressed, this, KeyHandler.SHORTCUT_ACTION, true);
@ -33,10 +37,24 @@ const AutoTypePopupView = Backbone.View.extend({
KeyHandler.onKey(Keys.DOM_VK_UP, this.upPressed, this, false, true);
KeyHandler.onKey(Keys.DOM_VK_DOWN, this.downPressed, this, false, true);
KeyHandler.onKey(Keys.DOM_VK_BACK_SPACE, this.backSpacePressed, this, false, true);
KeyHandler.onKey(Keys.DOM_VK_O, this.openKeyPressed, this, KeyHandler.SHORTCUT_ACTION, true);
KeyHandler.on('keypress:auto-type', this.keyPressed.bind(this));
KeyHandler.setModal('auto-type');
},
removeKeys() {
KeyHandler.offKey(Keys.DOM_VK_ESCAPE, this.escPressed, this);
KeyHandler.offKey(Keys.DOM_VK_RETURN, this.enterPressed, this);
KeyHandler.offKey(Keys.DOM_VK_RETURN, this.actionEnterPressed, this);
KeyHandler.offKey(Keys.DOM_VK_RETURN, this.optEnterPressed, this);
KeyHandler.offKey(Keys.DOM_VK_UP, this.upPressed, this);
KeyHandler.offKey(Keys.DOM_VK_DOWN, this.downPressed, this);
KeyHandler.offKey(Keys.DOM_VK_BACK_SPACE, this.backSpacePressed, this);
KeyHandler.offKey(Keys.DOM_VK_O, this.openKeyPressed, this);
KeyHandler.off('keypress:auto-type');
KeyHandler.setModal(null);
},
render() {
let topMessage;
if (this.model.filter.title || this.model.filter.url) {
@ -76,13 +94,7 @@ const AutoTypePopupView = Backbone.View.extend({
},
remove() {
KeyHandler.offKey(Keys.DOM_VK_ESCAPE, this.escPressed, this);
KeyHandler.offKey(Keys.DOM_VK_RETURN, this.enterPressed, this);
KeyHandler.offKey(Keys.DOM_VK_UP, this.upPressed, this);
KeyHandler.offKey(Keys.DOM_VK_DOWN, this.downPressed, this);
KeyHandler.offKey(Keys.DOM_VK_BACK_SPACE, this.backSpacePressed, this);
KeyHandler.off('keypress:auto-type');
KeyHandler.setModal(null);
this.removeKeys();
Backbone.View.prototype.remove.apply(this, arguments);
},
@ -121,6 +133,11 @@ const AutoTypePopupView = Backbone.View.extend({
this.closeWithResult(AutoTypeSequenceType.USERNAME);
},
openKeyPressed() {
this.removeKeys();
this.trigger('show-open-files');
},
upPressed(e) {
e.preventDefault();
const activeIndex = this.entries.indexOf(this.result) - 1;