From 0e1f95945434475adbf33b2073b6f8d7240aca91 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 23 Apr 2012 11:46:14 -0700 Subject: Editable - Pass event data with stop event --- js/components/editable.reel/editable.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index ef4096fd..1ebe33f1 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js @@ -131,11 +131,11 @@ exports.Editable = Montage.create(Component, { } }, stop : { - value: function() { + value: function(eventData) { this._isEditable = this._element.contentEditable = false; this._element.classList.remove(this.editingClass); - this._sendEvent('stop'); + this._sendEvent('stop', eventData); ///// if value is different than pre-edit val, call onchange method if(this._preEditValue !== this.value) { @@ -174,11 +174,11 @@ exports.Editable = Montage.create(Component, { } }, blur : { - value : function() { + value : function(eventData) { if(this._hint) { this.accept(); } - this.stop(); + this.stop(eventData); document.removeEventListener('mousedown', this, false); this._sendEvent('blur'); } @@ -207,7 +207,10 @@ exports.Editable = Montage.create(Component, { console.log('handle mouse down'); ///// Listen for simulated blur event if(this.stopOnBlur && e._event.target !== this._element) { - this.blur(); + this.blur({ + "originalEventType": "mousedown", + "originalEvent": e + }); } } }, @@ -221,9 +224,9 @@ exports.Editable = Montage.create(Component, { } }, _sendEvent : { - value : function(type) { + value : function(type, data) { var evt = document.createEvent("CustomEvent"); - evt.initCustomEvent(type, true, true); + evt.initCustomEvent(type, true, true, data); this.dispatchEvent(evt); } }, -- cgit v1.2.3