mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 17:00:04 +02:00
BOOM nice bouncing effect and prompt updates
This commit is contained in:
parent
986a2162af
commit
00111421bb
3 changed files with 24 additions and 9 deletions
|
@ -14,16 +14,21 @@ var CommandPromptView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
events: {
|
||||
'keyup #commandTextField': 'keyUp'
|
||||
'keydown #commandTextField': 'onKey',
|
||||
'keyup #commandTextField': 'onKeyUp'
|
||||
},
|
||||
|
||||
focus: function() {
|
||||
this.$('#commandTextField').focus();
|
||||
},
|
||||
|
||||
keyUp: function(e) {
|
||||
onKey: function(e) {
|
||||
var el = e.srcElement;
|
||||
this.updatePrompt(el)
|
||||
},
|
||||
|
||||
onKeyUp: function(e) {
|
||||
this.onKey(e);
|
||||
|
||||
// we need to capture some of these events.
|
||||
// WARNING: this key map is not internationalized :(
|
||||
|
@ -45,10 +50,18 @@ var CommandPromptView = Backbone.View.extend({
|
|||
if (keyMap[e.which] !== undefined) {
|
||||
e.preventDefault();
|
||||
keyMap[e.which]();
|
||||
this.updatePrompt(el);
|
||||
this.onKey(e);
|
||||
}
|
||||
},
|
||||
|
||||
badHtmlEncode: function(text) {
|
||||
return text.replace(/&/g,'&')
|
||||
.replace(/</g,'<')
|
||||
.replace(/</g,'<')
|
||||
.replace(/ /g,' ')
|
||||
.replace(/\n/g,'')
|
||||
},
|
||||
|
||||
updatePrompt: function(el) {
|
||||
// i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this
|
||||
// super annoying delay to every keystroke... I have tried everything
|
||||
|
@ -59,7 +72,7 @@ var CommandPromptView = Backbone.View.extend({
|
|||
// well...
|
||||
|
||||
var val = el.value;
|
||||
this.commandSpan.innerText = val;
|
||||
this.commandSpan.innerHTML = this.badHtmlEncode(val);
|
||||
//console.log(val, el.selectionStart, el.selectionEnd);
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue