diff options
author | Pushkar Joshi | 2012-04-27 15:05:38 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-27 15:05:38 -0700 |
commit | c8fc8e1bd1c394f433b4fc1677f4bc596e7cc2cc (patch) | |
tree | 74fcb9818a917d4f8ddb0db0c78a8cff9af86339 /js/components/editable.reel | |
parent | 28d1594b868e3c08e5603adbd5b29df1e24d57e9 (diff) | |
parent | c8fac64d4ad8ac18744a17a5e0f0d17204355fd6 (diff) | |
download | ninja-c8fc8e1bd1c394f433b4fc1677f4bc596e7cc2cc.tar.gz |
Merge branch 'master' into pentool
Diffstat (limited to 'js/components/editable.reel')
-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 9c8946c4..dad93b31 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 | 43 | ||
43 | if(this.startOnEvent) { | 44 | if(this.startOnEvent) { |
@@ -115,12 +116,15 @@ exports.Editable = Montage.create(Component, { | |||
115 | ///// Save the preEditValue | 116 | ///// Save the preEditValue |
116 | this._preEditValue = this.value; | 117 | this._preEditValue = this.value; |
117 | 118 | ||
119 | // Initialize enteredValue with current value | ||
120 | this.enteredValue = this.value; | ||
121 | |||
118 | if(this.selectOnStart) { | 122 | if(this.selectOnStart) { |
119 | this.selectAll(); | 123 | this.selectAll(); |
120 | } | 124 | } |
121 | 125 | ||
122 | if(this.stopOnBlur) { | 126 | if(this.stopOnBlur) { |
123 | console.log('adding mousedown event listener'); | 127 | //console.log('adding mousedown event listener'); |
124 | ///// Simulate blur on editable node by listening to the doc | 128 | ///// Simulate blur on editable node by listening to the doc |
125 | document.addEventListener('mouseup', this, false); | 129 | document.addEventListener('mouseup', this, false); |
126 | } | 130 | } |
@@ -189,7 +193,13 @@ exports.Editable = Montage.create(Component, { | |||
189 | handleKeydown : { | 193 | handleKeydown : { |
190 | value : function(e) { | 194 | value : function(e) { |
191 | var k = e.keyCode; | 195 | var k = e.keyCode; |
192 | console.log('keyCode: ' + k); | 196 | } |
197 | }, | ||
198 | |||
199 | handleKeyup : { | ||
200 | value : function(e) { | ||
201 | // Record change in value | ||
202 | this.enteredValue = this._element.firstChild.data; | ||
193 | } | 203 | } |
194 | }, | 204 | }, |
195 | ///// Text input has changed values | 205 | ///// Text input has changed values |
@@ -204,7 +214,7 @@ exports.Editable = Montage.create(Component, { | |||
204 | }, | 214 | }, |
205 | handleMouseup : { | 215 | handleMouseup : { |
206 | value : function(e) { | 216 | value : function(e) { |
207 | console.log('handle mouse down'); | 217 | //console.log('handle mouse down'); |
208 | ///// Listen for simulated blur event | 218 | ///// Listen for simulated blur event |
209 | if(this.stopOnBlur && e._event.target !== this._element) { | 219 | if(this.stopOnBlur && e._event.target !== this._element) { |
210 | this.blur(); | 220 | this.blur(); |
@@ -213,7 +223,7 @@ exports.Editable = Montage.create(Component, { | |||
213 | }, | 223 | }, |
214 | handleEvent : { | 224 | handleEvent : { |
215 | value : function(e) { | 225 | value : function(e) { |
216 | console.log("event type : " + e._event.type); | 226 | //console.log("event type : " + e._event.type); |
217 | ///// If configured, start on specified event | 227 | ///// If configured, start on specified event |
218 | if(e._event.type === this.startOnEvent) { | 228 | if(e._event.type === this.startOnEvent) { |
219 | this.start(); | 229 | this.start(); |