2011-01-25 08:22:04 +00:00
|
|
|
var StringController = function() {
|
2011-01-29 02:25:48 +00:00
|
|
|
|
2011-01-25 08:22:04 +00:00
|
|
|
this.type = "string";
|
2011-01-29 02:25:48 +00:00
|
|
|
|
2011-01-29 03:56:32 +00:00
|
|
|
var that = this;
|
2011-01-29 02:25:48 +00:00
|
|
|
|
|
|
|
Controller.apply(this, arguments);
|
|
|
|
|
2011-01-29 03:56:32 +00:00
|
|
|
this.value = this.getTargetValue();
|
2011-01-29 02:25:48 +00:00
|
|
|
|
2011-01-29 03:56:32 +00:00
|
|
|
var input = document.createElement('input');
|
|
|
|
input.setAttribute('value', this.value);
|
2011-01-29 02:25:48 +00:00
|
|
|
input.setAttribute('spellcheck', 'false');
|
|
|
|
|
|
|
|
this.domElement.addEventListener('mouseup', function() {
|
|
|
|
input.focus();
|
|
|
|
input.select();
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
input.addEventListener('keyup', function() {
|
2011-01-29 03:56:32 +00:00
|
|
|
that.updateValue(input.value);
|
|
|
|
that.setTargetValue(that.value);
|
2011-01-29 02:25:48 +00:00
|
|
|
}, false);
|
|
|
|
|
|
|
|
this.domElement.appendChild(input);
|
|
|
|
|
|
|
|
this.updateValue = function(val) {
|
2011-01-29 03:56:32 +00:00
|
|
|
that.value = val;
|
|
|
|
input.setAttribute('value', that.value);
|
2011-01-29 02:25:48 +00:00
|
|
|
}
|
|
|
|
|
2011-01-25 08:22:04 +00:00
|
|
|
};
|
|
|
|
StringController.prototype = new Controller();
|
2011-01-29 02:25:48 +00:00
|
|
|
StringController.prototype.constructor = StringController;
|