prototype: Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520.

This commit is contained in:
Sam Stephenson 2007-10-17 13:26:49 +00:00
parent 082fa20deb
commit d114e76e97
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,7 @@
*1.6.0_rc1* (October 16, 2007)
* Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520 (again). [Mislav Marohnić]
* Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont]
* Don't translate "keypress" events into "keydown" events. [sam]

View File

@ -30,24 +30,27 @@ Object.extend(Event, {
});
Event.Methods = (function() {
var isButton;
if (Prototype.Browser.IE) {
function isButton(event, code) {
return event.button == ({ 0: 1, 1: 4, 2: 2 })[code];
}
var buttonMap = { 0: 1, 1: 4, 2: 2 };
isButton = function(event, code) {
return event.button == buttonMap[code];
};
} else if (Prototype.Browser.WebKit) {
function isButton(event, code) {
isButton = function(event, code) {
switch (code) {
case 0: return event.which == 1 && !event.metaKey;
case 1: return event.which == 1 && event.metaKey;
default: return false;
}
}
};
} else {
function isButton(event, code) {
isButton = function(event, code) {
return event.which ? (event.which === code + 1) : (event.button === code);
}
};
}
return {