mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
ok getting better
This commit is contained in:
parent
8e8eb4f4a9
commit
e424bc27aa
5 changed files with 96 additions and 111 deletions
138
build/bundle.js
138
build/bundle.js
|
@ -11487,10 +11487,30 @@ var init = function(){
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// set up event baton for certain things
|
// we always want to focus the text area to collect input
|
||||||
$(window).focus(function() {
|
var focusTextArea = function() {
|
||||||
eventBaton.trigger('windowFocus');
|
console.log('focusing text area');
|
||||||
});
|
$('#commandTextField').focus();
|
||||||
|
};
|
||||||
|
focusTextArea();
|
||||||
|
|
||||||
|
$(window).focus(focusTextArea);
|
||||||
|
$(document).click(focusTextArea);
|
||||||
|
|
||||||
|
// but when the input is fired in the text area, we pipe that to whoever is
|
||||||
|
// listenining
|
||||||
|
var makeKeyListener = function(name) {
|
||||||
|
return function() {
|
||||||
|
var args = [name];
|
||||||
|
_.each(arguments, function(arg) {
|
||||||
|
args.push(arg);
|
||||||
|
});
|
||||||
|
eventBaton.trigger.apply(eventBaton, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#commandTextField').on('keydown', makeKeyListener('keydown'));
|
||||||
|
$('#commandTextField').on('keyup', makeKeyListener('keyup'));
|
||||||
|
|
||||||
/* hacky demo functionality */
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
|
@ -11579,6 +11599,7 @@ EventBaton.prototype.trigger = function(name) {
|
||||||
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
|
console.warn('no listeners for', name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
@ -11654,46 +11675,28 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
this.index = -1;
|
this.index = -1;
|
||||||
this.listening = false;
|
|
||||||
|
|
||||||
this.commandSpan = this.$('#prompt span.command')[0];
|
this.commandSpan = this.$('#prompt span.command')[0];
|
||||||
this.commandCursor = this.$('#prompt span.cursor')[0];
|
this.commandCursor = this.$('#prompt span.cursor')[0];
|
||||||
|
this.focus();
|
||||||
// this is evil, but we will refer to HTML outside the view
|
|
||||||
// and attach a click event listener so we can focus / unfocus
|
|
||||||
$(document).delegate('#commandLineHistory', 'click', _.bind(function() {
|
|
||||||
this.focus();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
|
|
||||||
$(document).delegate('#commandTextField', 'blur', _.bind(function() {
|
|
||||||
this.blur();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
||||||
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
||||||
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
||||||
|
|
||||||
// hacky timeout focus
|
Main.getEventBaton().stealBaton('keydown', this.onKeyDown, this);
|
||||||
setTimeout(_.bind(function() {
|
Main.getEventBaton().stealBaton('keyup', this.onKeyUp, this);
|
||||||
this.focus();
|
|
||||||
}, this), 100);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'keydown #commandTextField': 'onKey',
|
|
||||||
'keyup #commandTextField': 'onKeyUp',
|
|
||||||
'blur #commandTextField': 'hideCursor',
|
'blur #commandTextField': 'hideCursor',
|
||||||
'focus #commandTextField': 'showCursor'
|
'focus #commandTextField': 'showCursor'
|
||||||
},
|
},
|
||||||
|
|
||||||
blur: function() {
|
blur: function() {
|
||||||
this.listening = false;
|
|
||||||
this.hideCursor();
|
this.hideCursor();
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.listening = true;
|
|
||||||
this.$('#commandTextField').focus();
|
this.$('#commandTextField').focus();
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
},
|
},
|
||||||
|
@ -11710,21 +11713,13 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
$(this.commandCursor).toggleClass('shown', state);
|
$(this.commandCursor).toggleClass('shown', state);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKey: function(e) {
|
onKeyDown: function(e) {
|
||||||
if (!this.listening) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var el = e.srcElement;
|
var el = e.srcElement;
|
||||||
this.updatePrompt(el);
|
this.updatePrompt(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyUp: function(e) {
|
onKeyUp: function(e) {
|
||||||
if (!this.listening) {
|
this.onKeyDown(e);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onKey(e);
|
|
||||||
|
|
||||||
// we need to capture some of these events.
|
// we need to capture some of these events.
|
||||||
var keyToFuncMap = {
|
var keyToFuncMap = {
|
||||||
|
@ -11743,7 +11738,7 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
if (keyToFuncMap[key] !== undefined) {
|
if (keyToFuncMap[key] !== undefined) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
keyToFuncMap[key]();
|
keyToFuncMap[key]();
|
||||||
this.onKey(e);
|
this.onKeyDown(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -12044,7 +12039,6 @@ KeyboardListener.prototype.mute = function() {
|
||||||
|
|
||||||
KeyboardListener.prototype.keydown = function(e) {
|
KeyboardListener.prototype.keydown = function(e) {
|
||||||
var which = e.which;
|
var which = e.which;
|
||||||
console.log('key which', which);
|
|
||||||
|
|
||||||
var key = mapKeycodeToKey(which);
|
var key = mapKeycodeToKey(which);
|
||||||
if (key === undefined) {
|
if (key === undefined) {
|
||||||
|
@ -12062,6 +12056,7 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||||
exports.KeyboardListener = KeyboardListener;
|
exports.KeyboardListener = KeyboardListener;
|
||||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/visuals/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/visuals/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
@ -14269,10 +14264,30 @@ var init = function(){
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// set up event baton for certain things
|
// we always want to focus the text area to collect input
|
||||||
$(window).focus(function() {
|
var focusTextArea = function() {
|
||||||
eventBaton.trigger('windowFocus');
|
console.log('focusing text area');
|
||||||
});
|
$('#commandTextField').focus();
|
||||||
|
};
|
||||||
|
focusTextArea();
|
||||||
|
|
||||||
|
$(window).focus(focusTextArea);
|
||||||
|
$(document).click(focusTextArea);
|
||||||
|
|
||||||
|
// but when the input is fired in the text area, we pipe that to whoever is
|
||||||
|
// listenining
|
||||||
|
var makeKeyListener = function(name) {
|
||||||
|
return function() {
|
||||||
|
var args = [name];
|
||||||
|
_.each(arguments, function(arg) {
|
||||||
|
args.push(arg);
|
||||||
|
});
|
||||||
|
eventBaton.trigger.apply(eventBaton, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#commandTextField').on('keydown', makeKeyListener('keydown'));
|
||||||
|
$('#commandTextField').on('keyup', makeKeyListener('keyup'));
|
||||||
|
|
||||||
/* hacky demo functionality */
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
|
@ -17047,6 +17062,7 @@ EventBaton.prototype.trigger = function(name) {
|
||||||
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
|
console.warn('no listeners for', name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
@ -17146,7 +17162,6 @@ KeyboardListener.prototype.mute = function() {
|
||||||
|
|
||||||
KeyboardListener.prototype.keydown = function(e) {
|
KeyboardListener.prototype.keydown = function(e) {
|
||||||
var which = e.which;
|
var which = e.which;
|
||||||
console.log('key which', which);
|
|
||||||
|
|
||||||
var key = mapKeycodeToKey(which);
|
var key = mapKeycodeToKey(which);
|
||||||
if (key === undefined) {
|
if (key === undefined) {
|
||||||
|
@ -17164,6 +17179,7 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||||
exports.KeyboardListener = KeyboardListener;
|
exports.KeyboardListener = KeyboardListener;
|
||||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
require("/src/js/util/keyboard.js");
|
require("/src/js/util/keyboard.js");
|
||||||
|
|
||||||
|
@ -17220,46 +17236,28 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
this.index = -1;
|
this.index = -1;
|
||||||
this.listening = false;
|
|
||||||
|
|
||||||
this.commandSpan = this.$('#prompt span.command')[0];
|
this.commandSpan = this.$('#prompt span.command')[0];
|
||||||
this.commandCursor = this.$('#prompt span.cursor')[0];
|
this.commandCursor = this.$('#prompt span.cursor')[0];
|
||||||
|
this.focus();
|
||||||
// this is evil, but we will refer to HTML outside the view
|
|
||||||
// and attach a click event listener so we can focus / unfocus
|
|
||||||
$(document).delegate('#commandLineHistory', 'click', _.bind(function() {
|
|
||||||
this.focus();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
|
|
||||||
$(document).delegate('#commandTextField', 'blur', _.bind(function() {
|
|
||||||
this.blur();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
||||||
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
||||||
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
||||||
|
|
||||||
// hacky timeout focus
|
Main.getEventBaton().stealBaton('keydown', this.onKeyDown, this);
|
||||||
setTimeout(_.bind(function() {
|
Main.getEventBaton().stealBaton('keyup', this.onKeyUp, this);
|
||||||
this.focus();
|
|
||||||
}, this), 100);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'keydown #commandTextField': 'onKey',
|
|
||||||
'keyup #commandTextField': 'onKeyUp',
|
|
||||||
'blur #commandTextField': 'hideCursor',
|
'blur #commandTextField': 'hideCursor',
|
||||||
'focus #commandTextField': 'showCursor'
|
'focus #commandTextField': 'showCursor'
|
||||||
},
|
},
|
||||||
|
|
||||||
blur: function() {
|
blur: function() {
|
||||||
this.listening = false;
|
|
||||||
this.hideCursor();
|
this.hideCursor();
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.listening = true;
|
|
||||||
this.$('#commandTextField').focus();
|
this.$('#commandTextField').focus();
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
},
|
},
|
||||||
|
@ -17276,21 +17274,13 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
$(this.commandCursor).toggleClass('shown', state);
|
$(this.commandCursor).toggleClass('shown', state);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKey: function(e) {
|
onKeyDown: function(e) {
|
||||||
if (!this.listening) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var el = e.srcElement;
|
var el = e.srcElement;
|
||||||
this.updatePrompt(el);
|
this.updatePrompt(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyUp: function(e) {
|
onKeyUp: function(e) {
|
||||||
if (!this.listening) {
|
this.onKeyDown(e);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onKey(e);
|
|
||||||
|
|
||||||
// we need to capture some of these events.
|
// we need to capture some of these events.
|
||||||
var keyToFuncMap = {
|
var keyToFuncMap = {
|
||||||
|
@ -17309,7 +17299,7 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
if (keyToFuncMap[key] !== undefined) {
|
if (keyToFuncMap[key] !== undefined) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
keyToFuncMap[key]();
|
keyToFuncMap[key]();
|
||||||
this.onKey(e);
|
this.onKeyDown(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,30 @@ var init = function(){
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// set up event baton for certain things
|
// we always want to focus the text area to collect input
|
||||||
$(window).focus(function() {
|
var focusTextArea = function() {
|
||||||
eventBaton.trigger('windowFocus');
|
console.log('focusing text area');
|
||||||
});
|
$('#commandTextField').focus();
|
||||||
|
};
|
||||||
|
focusTextArea();
|
||||||
|
|
||||||
|
$(window).focus(focusTextArea);
|
||||||
|
$(document).click(focusTextArea);
|
||||||
|
|
||||||
|
// but when the input is fired in the text area, we pipe that to whoever is
|
||||||
|
// listenining
|
||||||
|
var makeKeyListener = function(name) {
|
||||||
|
return function() {
|
||||||
|
var args = [name];
|
||||||
|
_.each(arguments, function(arg) {
|
||||||
|
args.push(arg);
|
||||||
|
});
|
||||||
|
eventBaton.trigger.apply(eventBaton, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#commandTextField').on('keydown', makeKeyListener('keydown'));
|
||||||
|
$('#commandTextField').on('keyup', makeKeyListener('keyup'));
|
||||||
|
|
||||||
/* hacky demo functionality */
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ EventBaton.prototype.trigger = function(name) {
|
||||||
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
|
console.warn('no listeners for', name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
|
|
@ -32,7 +32,6 @@ KeyboardListener.prototype.mute = function() {
|
||||||
|
|
||||||
KeyboardListener.prototype.keydown = function(e) {
|
KeyboardListener.prototype.keydown = function(e) {
|
||||||
var which = e.which;
|
var which = e.which;
|
||||||
console.log('key which', which);
|
|
||||||
|
|
||||||
var key = mapKeycodeToKey(which);
|
var key = mapKeycodeToKey(which);
|
||||||
if (key === undefined) {
|
if (key === undefined) {
|
||||||
|
@ -49,3 +48,4 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||||
|
|
||||||
exports.KeyboardListener = KeyboardListener;
|
exports.KeyboardListener = KeyboardListener;
|
||||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||||
|
|
||||||
|
|
|
@ -37,46 +37,28 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
this.index = -1;
|
this.index = -1;
|
||||||
this.listening = false;
|
|
||||||
|
|
||||||
this.commandSpan = this.$('#prompt span.command')[0];
|
this.commandSpan = this.$('#prompt span.command')[0];
|
||||||
this.commandCursor = this.$('#prompt span.cursor')[0];
|
this.commandCursor = this.$('#prompt span.cursor')[0];
|
||||||
|
this.focus();
|
||||||
// this is evil, but we will refer to HTML outside the view
|
|
||||||
// and attach a click event listener so we can focus / unfocus
|
|
||||||
$(document).delegate('#commandLineHistory', 'click', _.bind(function() {
|
|
||||||
this.focus();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
|
|
||||||
$(document).delegate('#commandTextField', 'blur', _.bind(function() {
|
|
||||||
this.blur();
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
Main.getEvents().on('processCommandFromEvent', this.addToCollection, this);
|
||||||
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
Main.getEvents().on('submitCommandValueFromEvent', this.submitValue, this);
|
||||||
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
Main.getEvents().on('rollupCommands', this.rollupCommands, this);
|
||||||
|
|
||||||
// hacky timeout focus
|
Main.getEventBaton().stealBaton('keydown', this.onKeyDown, this);
|
||||||
setTimeout(_.bind(function() {
|
Main.getEventBaton().stealBaton('keyup', this.onKeyUp, this);
|
||||||
this.focus();
|
|
||||||
}, this), 100);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'keydown #commandTextField': 'onKey',
|
|
||||||
'keyup #commandTextField': 'onKeyUp',
|
|
||||||
'blur #commandTextField': 'hideCursor',
|
'blur #commandTextField': 'hideCursor',
|
||||||
'focus #commandTextField': 'showCursor'
|
'focus #commandTextField': 'showCursor'
|
||||||
},
|
},
|
||||||
|
|
||||||
blur: function() {
|
blur: function() {
|
||||||
this.listening = false;
|
|
||||||
this.hideCursor();
|
this.hideCursor();
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.listening = true;
|
|
||||||
this.$('#commandTextField').focus();
|
this.$('#commandTextField').focus();
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
},
|
},
|
||||||
|
@ -93,21 +75,13 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
$(this.commandCursor).toggleClass('shown', state);
|
$(this.commandCursor).toggleClass('shown', state);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKey: function(e) {
|
onKeyDown: function(e) {
|
||||||
if (!this.listening) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var el = e.srcElement;
|
var el = e.srcElement;
|
||||||
this.updatePrompt(el);
|
this.updatePrompt(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyUp: function(e) {
|
onKeyUp: function(e) {
|
||||||
if (!this.listening) {
|
this.onKeyDown(e);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onKey(e);
|
|
||||||
|
|
||||||
// we need to capture some of these events.
|
// we need to capture some of these events.
|
||||||
var keyToFuncMap = {
|
var keyToFuncMap = {
|
||||||
|
@ -126,7 +100,7 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
if (keyToFuncMap[key] !== undefined) {
|
if (keyToFuncMap[key] !== undefined) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
keyToFuncMap[key]();
|
keyToFuncMap[key]();
|
||||||
this.onKey(e);
|
this.onKeyDown(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue