mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 09:20:03 +02:00
nice modal view steals keyboard nicely
This commit is contained in:
parent
e424bc27aa
commit
0d6f2516cb
2 changed files with 1137 additions and 1071 deletions
2186
build/bundle.js
2186
build/bundle.js
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@ var GitError = require('../util/errors').GitError;
|
|||
var _ = require('underscore');
|
||||
// horrible hack to get localStorage Backbone plugin
|
||||
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||
var Main = require('../app');
|
||||
|
||||
var BaseView = Backbone.View.extend({
|
||||
getDestination: function() {
|
||||
|
@ -112,6 +113,7 @@ var ModalView = Backbone.View.extend({
|
|||
|
||||
initialize: function(options) {
|
||||
this.render();
|
||||
this.stealKeyboard();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -120,6 +122,25 @@ var ModalView = Backbone.View.extend({
|
|||
$('body').append(this.el);
|
||||
},
|
||||
|
||||
stealKeyboard: function() {
|
||||
console.warn('stealing keyboard');
|
||||
Main.getEventBaton().stealBaton('keydown', this.onKeyDown, this);
|
||||
Main.getEventBaton().stealBaton('keyup', this.onKeyUp, this);
|
||||
},
|
||||
|
||||
releaseKeyboard: function() {
|
||||
Main.getEventBaton().releaseBaton('keydown', this.onKeyDown, this);
|
||||
Main.getEventBaton().releaseBaton('keyup', this.onKeyUp, this);
|
||||
},
|
||||
|
||||
onKeyDown: function(e) {
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
onKeyUp: function(e) {
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.toggleZ(true);
|
||||
this.toggleShow(true);
|
||||
|
@ -150,6 +171,7 @@ var ModalView = Backbone.View.extend({
|
|||
tearDown: function() {
|
||||
this.$el.html('');
|
||||
$('body')[0].removeChild(this.el);
|
||||
this.releaseKeyboard();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue