diff options
Diffstat (limited to 'js/components/editable.reel')
-rw-r--r-- | js/components/editable.reel/editable.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index 9c8946c4..1ebe33f1 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js | |||
@@ -122,7 +122,7 @@ exports.Editable = Montage.create(Component, { | |||
122 | if(this.stopOnBlur) { | 122 | if(this.stopOnBlur) { |
123 | console.log('adding mousedown event listener'); | 123 | console.log('adding mousedown event listener'); |
124 | ///// Simulate blur on editable node by listening to the doc | 124 | ///// Simulate blur on editable node by listening to the doc |
125 | document.addEventListener('mouseup', this, false); | 125 | document.addEventListener('mousedown', this, false); |
126 | } | 126 | } |
127 | 127 | ||
128 | this._sendEvent('start'); | 128 | this._sendEvent('start'); |
@@ -131,11 +131,11 @@ exports.Editable = Montage.create(Component, { | |||
131 | } | 131 | } |
132 | }, | 132 | }, |
133 | stop : { | 133 | stop : { |
134 | value: function() { | 134 | value: function(eventData) { |
135 | this._isEditable = this._element.contentEditable = false; | 135 | this._isEditable = this._element.contentEditable = false; |
136 | this._element.classList.remove(this.editingClass); | 136 | this._element.classList.remove(this.editingClass); |
137 | 137 | ||
138 | this._sendEvent('stop'); | 138 | this._sendEvent('stop', eventData); |
139 | 139 | ||
140 | ///// if value is different than pre-edit val, call onchange method | 140 | ///// if value is different than pre-edit val, call onchange method |
141 | if(this._preEditValue !== this.value) { | 141 | if(this._preEditValue !== this.value) { |
@@ -174,12 +174,12 @@ exports.Editable = Montage.create(Component, { | |||
174 | } | 174 | } |
175 | }, | 175 | }, |
176 | blur : { | 176 | blur : { |
177 | value : function() { | 177 | value : function(eventData) { |
178 | if(this._hint) { | 178 | if(this._hint) { |
179 | this.accept(); | 179 | this.accept(); |
180 | } | 180 | } |
181 | this.stop(); | 181 | this.stop(eventData); |
182 | document.removeEventListener('mouseup', this, false); | 182 | document.removeEventListener('mousedown', this, false); |
183 | this._sendEvent('blur'); | 183 | this._sendEvent('blur'); |
184 | } | 184 | } |
185 | }, | 185 | }, |
@@ -202,12 +202,15 @@ exports.Editable = Montage.create(Component, { | |||
202 | this._sendEvent('input'); | 202 | this._sendEvent('input'); |
203 | } | 203 | } |
204 | }, | 204 | }, |
205 | handleMouseup : { | 205 | handleMousedown : { |
206 | value : function(e) { | 206 | value : function(e) { |
207 | console.log('handle mouse down'); | 207 | console.log('handle mouse down'); |
208 | ///// Listen for simulated blur event | 208 | ///// Listen for simulated blur event |
209 | if(this.stopOnBlur && e._event.target !== this._element) { | 209 | if(this.stopOnBlur && e._event.target !== this._element) { |
210 | this.blur(); | 210 | this.blur({ |
211 | "originalEventType": "mousedown", | ||
212 | "originalEvent": e | ||
213 | }); | ||
211 | } | 214 | } |
212 | } | 215 | } |
213 | }, | 216 | }, |
@@ -221,9 +224,9 @@ exports.Editable = Montage.create(Component, { | |||
221 | } | 224 | } |
222 | }, | 225 | }, |
223 | _sendEvent : { | 226 | _sendEvent : { |
224 | value : function(type) { | 227 | value : function(type, data) { |
225 | var evt = document.createEvent("CustomEvent"); | 228 | var evt = document.createEvent("CustomEvent"); |
226 | evt.initCustomEvent(type, true, true); | 229 | evt.initCustomEvent(type, true, true, data); |
227 | this.dispatchEvent(evt); | 230 | this.dispatchEvent(evt); |
228 | } | 231 | } |
229 | }, | 232 | }, |