Ticket #658 (assigned enhancement)
enhanced IE event handling
| Reported by: | mokhet | Owned by: | mokhet |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.96 |
| Component: | Xinha Core | Version: | |
| Severity: | normal | Keywords: | event |
| Cc: |
Description
For every events we want to manipulate, we always have to check if HTMLArea.is_ie or not to take the correct event object. (by the way, it may be better to do ev?ev:window.event instead of is_ie?window.event:ev, but that's not the point here)
I think we could simulate the DOM behavior for IE if we change a little bit the function _addEvent as following
HTMLArea._addEvent = function(el, evname, func)
{
el['xinha_evt' + evname + func] = function() { func(window.event); }
el.attachEvent("on" + evname, el['xinha_evt' + evname + func]);
HTMLArea._eventFlushers.push([el, evname, el['xinha_evt' + evname + func]]);
};
HTMLArea._removeEvent = function(el, evname, func)
{
el.detachEvent("on" + evname, el['xinha_evt' + evname + func]);
el['xinha_evt' + evname + func] = null;
};
This way, i think we would never have to check if we have the event object or not. Here is a sample of what we have to do, checking if is_ie to get the correct object :
HTMLArea._addEvent(el, "mousedown", function (ev) {
if (obj.enabled) with (HTMLArea) {
_addClass(el, "buttonActive");
_removeClass(el, "buttonPressed");
_stopEvent(is_ie ? window.event : ev);
}
});
but simply
HTMLArea._addEvent(el, "mousedown", function (ev) {
if (obj.enabled) with (HTMLArea) {
_addClass(el, "buttonActive");
_removeClass(el, "buttonPressed");
_stopEvent(ev); // <--- MODIFICATION HERE, NO TEST, WE KNOW WE HAVE OUR EVENT
}
});
This way, the event object will always be correctly populated if we are IE or not and we will not have to ponder again about this boring crossbrowser stuff inside Xinha events.
I dont have tested it yet but as you may have noticed i'm actually focused on reducing the maximum of tests inside xinha i can, and i think this one can be a good one. What do you think ?
