fix #343: blur input on window blur

This commit is contained in:
antelle 2016-09-05 22:14:50 +03:00
parent f79cba14f9
commit bba0734a81
2 changed files with 12 additions and 0 deletions

View File

@ -82,6 +82,7 @@ var AppView = Backbone.View.extend({
window.onbeforeunload = this.beforeUnload.bind(this);
window.onresize = this.windowResize.bind(this);
window.onblur = this.windowBlur.bind(this);
KeyHandler.onKey(Keys.DOM_VK_ESCAPE, this.escPressed, this);
KeyHandler.onKey(Keys.DOM_VK_BACK_SPACE, this.backspacePressed, this);
@ -333,6 +334,12 @@ var AppView = Backbone.View.extend({
Backbone.trigger('page-geometry', { source: 'window' });
},
windowBlur: function(e) {
if (e.target === window) {
Backbone.trigger('page-blur');
}
},
escPressed: function() {
if (this.views.open && this.model.files.hasOpenFiles()) {
this.showEntries();

View File

@ -67,6 +67,7 @@ var ListSearchView = Backbone.View.extend({
this.listenTo(this, 'hide', this.viewHidden);
this.listenTo(Backbone, 'filter', this.filterChanged);
this.listenTo(Backbone, 'set-locale', this.setLocale);
this.listenTo(Backbone, 'page-blur', this.pageBlur);
},
remove: function() {
@ -88,6 +89,10 @@ var ListSearchView = Backbone.View.extend({
this.render();
},
pageBlur: function() {
this.inputEl.blur();
},
viewShown: function() {
this.listenTo(KeyHandler, 'keypress', this.documentKeyPress);
},