daisydiff.js.dojo.src.event.browser.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testcasegenerator Show documentation
Show all versions of testcasegenerator Show documentation
Generates test cases from the crawl session.
The newest version!
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.event.browser");
dojo.require("dojo.event.common");
// FIXME: any particular reason this is in the global scope?
dojo._ie_clobber = new function(){
this.clobberNodes = [];
function nukeProp(node, prop){
// try{ node.removeAttribute(prop); }catch(e){ /* squelch */ }
try{ node[prop] = null; }catch(e){ /* squelch */ }
try{ delete node[prop]; }catch(e){ /* squelch */ }
// FIXME: JotLive needs this, but I'm not sure if it's too slow or not
try{ node.removeAttribute(prop); }catch(e){ /* squelch */ }
}
this.clobber = function(nodeRef){
var na;
var tna;
if(nodeRef){
tna = nodeRef.all || nodeRef.getElementsByTagName("*");
na = [nodeRef];
for(var x=0; x=0; i=i-1){
var el = na[i];
try{
if(el && el["__clobberAttrs__"]){
for(var j=0; j= 65 && unifiedCharCode <= 90 && evt.shiftKey == false){
unifiedCharCode += 32;
}
if(unifiedCharCode >= 1 && unifiedCharCode <= 26 && evt.ctrlKey){
unifiedCharCode += 96; // 001-032 = ctrl+[a-z]
}
evt.key = String.fromCharCode(unifiedCharCode);
}
}
} else if(evt["type"] == "keypress"){
if(dojo.render.html.opera){
if(evt.which == 0){
evt.key = evt.keyCode;
}else if(evt.which > 0){
switch(evt.which){
case evt.KEY_SHIFT:
case evt.KEY_CTRL:
case evt.KEY_ALT:
case evt.KEY_CAPS_LOCK:
case evt.KEY_NUM_LOCK:
case evt.KEY_SCROLL_LOCK:
break;
case evt.KEY_PAUSE:
case evt.KEY_TAB:
case evt.KEY_BACKSPACE:
case evt.KEY_ENTER:
case evt.KEY_ESCAPE:
evt.key = evt.which;
break;
default:
var unifiedCharCode = evt.which;
if((evt.ctrlKey || evt.altKey || evt.metaKey) && (evt.which >= 65 && evt.which <= 90 && evt.shiftKey == false)){
unifiedCharCode += 32;
}
evt.key = String.fromCharCode(unifiedCharCode);
}
}
}else if(dojo.render.html.ie){ // catch some IE keys that are hard to get in keyDown
// key combinations were handled in onKeyDown
if(!evt.ctrlKey && !evt.altKey && evt.keyCode >= evt.KEY_SPACE){
evt.key = String.fromCharCode(evt.keyCode);
}
}else if(dojo.render.html.safari){
switch(evt.keyCode){
case 25: evt.key = evt.KEY_TAB; evt.shift = true;break;
case 63232: evt.key = evt.KEY_UP_ARROW; break;
case 63233: evt.key = evt.KEY_DOWN_ARROW; break;
case 63234: evt.key = evt.KEY_LEFT_ARROW; break;
case 63235: evt.key = evt.KEY_RIGHT_ARROW; break;
case 63236: evt.key = evt.KEY_F1; break;
case 63237: evt.key = evt.KEY_F2; break;
case 63238: evt.key = evt.KEY_F3; break;
case 63239: evt.key = evt.KEY_F4; break;
case 63240: evt.key = evt.KEY_F5; break;
case 63241: evt.key = evt.KEY_F6; break;
case 63242: evt.key = evt.KEY_F7; break;
case 63243: evt.key = evt.KEY_F8; break;
case 63244: evt.key = evt.KEY_F9; break;
case 63245: evt.key = evt.KEY_F10; break;
case 63246: evt.key = evt.KEY_F11; break;
case 63247: evt.key = evt.KEY_F12; break;
case 63250: evt.key = evt.KEY_PAUSE; break;
case 63272: evt.key = evt.KEY_DELETE; break;
case 63273: evt.key = evt.KEY_HOME; break;
case 63275: evt.key = evt.KEY_END; break;
case 63276: evt.key = evt.KEY_PAGE_UP; break;
case 63277: evt.key = evt.KEY_PAGE_DOWN; break;
case 63302: evt.key = evt.KEY_INSERT; break;
case 63248://prtscr
case 63249://scrolllock
case 63289://numlock
break;
default:
evt.key = evt.charCode >= evt.KEY_SPACE ? String.fromCharCode(evt.charCode) : evt.keyCode;
}
}else{
evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode;
}
}
}
if(dojo.render.html.ie){
if(!evt.target){ evt.target = evt.srcElement; }
if(!evt.currentTarget){ evt.currentTarget = (sender ? sender : evt.srcElement); }
if(!evt.layerX){ evt.layerX = evt.offsetX; }
if(!evt.layerY){ evt.layerY = evt.offsetY; }
// FIXME: scroll position query is duped from dojo.html to avoid dependency on that entire module
// DONOT replace the following to use dojo.body(), in IE, document.documentElement should be used
// here rather than document.body
var doc = (evt.srcElement && evt.srcElement.ownerDocument) ? evt.srcElement.ownerDocument : document;
var docBody = ((dojo.render.html.ie55)||(doc["compatMode"] == "BackCompat")) ? doc.body : doc.documentElement;
if(!evt.pageX){ evt.pageX = evt.clientX + (docBody.scrollLeft || 0) }
if(!evt.pageY){ evt.pageY = evt.clientY + (docBody.scrollTop || 0) }
// mouseover
if(evt.type == "mouseover"){ evt.relatedTarget = evt.fromElement; }
// mouseout
if(evt.type == "mouseout"){ evt.relatedTarget = evt.toElement; }
this.currentEvent = evt;
evt.callListener = this.callListener;
evt.stopPropagation = this._stopPropagation;
evt.preventDefault = this._preventDefault;
}
return evt; // Event
}
this.stopEvent = function(/*Event*/evt){
// summary:
// prevents propigation and clobbers the default action of the
// passed event
// evt: Optional for IE. The native event object.
if(window.event){
evt.cancelBubble = true;
evt.returnValue = false;
}else{
evt.preventDefault();
evt.stopPropagation();
}
}
}