-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
- var e = document.documentElement || document.body;
- event.pageX = event.clientX + e.scrollLeft;
- event.pageY = event.clientY + e.scrollTop;
- }
-
- // Add which for keypresses: keyCode
- if ( (event.which == null || event.type == "keypress") && event.keyCode != null )
- event.which = event.keyCode;
-
- // If it's a keypress event, add charCode to IE
- if ( event.charCode == null && event.type == "keypress" )
- event.charCode = event.keyCode;
-
- // check if target is a textnode (safari)
- if (jQuery.browser.safari && event.target.nodeType == 3) {
- // store a copy of the original event object
- // and clone because target is read only
- var originalEvent = event;
- event = jQuery.extend({}, originalEvent);
-
- // get parentnode from textnode
- event.target = originalEvent.target.parentNode;
-
- // add preventDefault and stopPropagation since
- // they will not work on the clone
- event.preventDefault = function() {
- return originalEvent.preventDefault();
- };
- event.stopPropagation = function() {
- return originalEvent.stopPropagation();
- };
- }
-
- // fix preventDefault and stopPropagation
- if (!event.preventDefault)
- event.preventDefault = function() {
- this.returnValue = false;
- };
-
- if (!event.stopPropagation)
- event.stopPropagation = function() {
- this.cancelBubble = true;
- };