diff options
Diffstat (limited to 'js/components/editable.reel/editable.js')
-rw-r--r-- | js/components/editable.reel/editable.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index f2cf0e5d..b7fdd707 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js | |||
@@ -38,6 +38,7 @@ exports.Editable = Montage.create(Component, { | |||
38 | set : function(el) { | 38 | set : function(el) { |
39 | this._element = el; | 39 | this._element = el; |
40 | this._element.addEventListener('keydown', this, false); | 40 | this._element.addEventListener('keydown', this, false); |
41 | this._element.addEventListener('keyup', this, false); | ||
41 | this._element.addEventListener('input', this, false); | 42 | this._element.addEventListener('input', this, false); |
42 | this._element.addEventListener('paste', this, false); | 43 | this._element.addEventListener('paste', this, false); |
43 | 44 | ||
@@ -117,12 +118,15 @@ exports.Editable = Montage.create(Component, { | |||
117 | ///// Save the preEditValue | 118 | ///// Save the preEditValue |
118 | this._preEditValue = this.value; | 119 | this._preEditValue = this.value; |
119 | 120 | ||
121 | // Initialize enteredValue with current value | ||
122 | this.enteredValue = this.value; | ||
123 | |||
120 | if(this.selectOnStart) { | 124 | if(this.selectOnStart) { |
121 | this.selectAll(); | 125 | this.selectAll(); |
122 | } | 126 | } |
123 | 127 | ||
124 | if(this.stopOnBlur) { | 128 | if(this.stopOnBlur) { |
125 | console.log('adding mousedown event listener'); | 129 | //console.log('adding mousedown event listener'); |
126 | ///// Simulate blur on editable node by listening to the doc | 130 | ///// Simulate blur on editable node by listening to the doc |
127 | document.addEventListener('mousedown', this, false); | 131 | document.addEventListener('mousedown', this, false); |
128 | } | 132 | } |
@@ -192,7 +196,13 @@ exports.Editable = Montage.create(Component, { | |||
192 | handleKeydown : { | 196 | handleKeydown : { |
193 | value : function(e) { | 197 | value : function(e) { |
194 | var k = e.keyCode; | 198 | var k = e.keyCode; |
195 | console.log('keyCode: ' + k); | 199 | } |
200 | }, | ||
201 | |||
202 | handleKeyup : { | ||
203 | value : function(e) { | ||
204 | // Record change in value | ||
205 | this.enteredValue = this._element.firstChild.data; | ||
196 | } | 206 | } |
197 | }, | 207 | }, |
198 | ///// Text input has changed values | 208 | ///// Text input has changed values |
@@ -207,7 +217,7 @@ exports.Editable = Montage.create(Component, { | |||
207 | }, | 217 | }, |
208 | handleMousedown : { | 218 | handleMousedown : { |
209 | value : function(e) { | 219 | value : function(e) { |
210 | console.log('handle mouse down'); | 220 | //console.log('handle mouse down'); |
211 | ///// Listen for simulated blur event | 221 | ///// Listen for simulated blur event |
212 | if(this.stopOnBlur && e._event.target !== this._element) { | 222 | if(this.stopOnBlur && e._event.target !== this._element) { |
213 | this.blur({ | 223 | this.blur({ |
@@ -224,7 +234,7 @@ exports.Editable = Montage.create(Component, { | |||
224 | }, | 234 | }, |
225 | handleEvent : { | 235 | handleEvent : { |
226 | value : function(e) { | 236 | value : function(e) { |
227 | console.log("event type : " + e._event.type); | 237 | //console.log("event type : " + e._event.type); |
228 | ///// If configured, start on specified event | 238 | ///// If configured, start on specified event |
229 | if(e._event.type === this.startOnEvent) { | 239 | if(e._event.type === this.startOnEvent) { |
230 | this.start(); | 240 | this.start(); |