Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hide the characterReader inside the inputManager

Nothing outside of the inputManager should know that its using a
hidden field to read the keys. This is still awkward, but its a step
in the right direcion
  • Loading branch information...
commit 6789e3e2ca41597e268d6e3a5429ad87068dbb9a 1 parent 8c8fb7d
@rhburrows authored
Showing with 16 additions and 8 deletions.
  1. +2 −7 src/core.js
  2. +13 −0 src/input.js
  3. +1 −1  test/inputTest.js
View
9 src/core.js
@@ -49,7 +49,7 @@
display.paint(editor);
$(display).bind('s2e:click', function(ev) {
- $(inputManager.characterReader).focus();
+ inputManager.focus();
editor.movePointTo(ev.position);
});
@@ -58,12 +58,7 @@
textarea.trigger(extendEvent(e, editor, display));
});
- $(inputManager.characterReader).keydown(inputManager.handler(editor));
- $(inputManager.characterReader).css({
- position: 'absolute',
- left: '-300px',
- top: '-300px'
- });
+ inputManager.keydown(inputManager.handler(editor));
return editor;
});
View
13 src/input.js
@@ -2,6 +2,11 @@
function InputManager() {
this.characterReader = document.createElement('input');
$(this.characterReader).attr('type', 'text');
+ $(this.characterReader).css({
+ position : 'absolute',
+ left : '-300px',
+ top : '-300px'
+ });
this.bindings = {};
}
@@ -121,6 +126,14 @@
return true;
}
};
+ },
+
+ focus : function() {
+ $(this.characterReader).focus();
+ },
+
+ keydown : function(f) {
+ $(this.characterReader).keydown(f);
}
};
View
2  test/inputTest.js
@@ -1,7 +1,7 @@
module("input", {
setup: function() {
var nullEditor = {};
- inputManager = new $.fn.s2e.config.InputManager(nullEditor);
+ inputManager = new $.fn.s2e.config.InputManager();
inputHandler = inputManager.handler();
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.