]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/analytics/plugins/mouseOver.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojox / analytics / plugins / mouseOver.js
1 if(!dojo._hasResource["dojox.analytics.plugins.mouseOver"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.analytics.plugins.mouseOver"] = true;
3 dojo.provide("dojox.analytics.plugins.mouseOver");
4
5 dojox.analytics.plugins.mouseOver = new (function(){
6         this.watchMouse = dojo.config["watchMouseOver"] || true;
7         this.mouseSampleDelay = dojo.config["sampleDelay"] || 2500;
8         this.addData = dojo.hitch(dojox.analytics, "addData", "mouseOver");
9         this.targetProps = dojo.config["targetProps"] || ["id","className","localName","href", "spellcheck", "lang", "textContent", "value" ];
10
11         this.toggleWatchMouse=function(){
12                 if (this._watchingMouse){
13                         dojo.disconnect(this._watchingMouse);
14                         delete this._watchingMouse;
15                         return;
16                 }       
17                 dojo.connect(dojo.doc, "onmousemove", this, "sampleMouse");
18         }
19
20         if (this.watchMouse){
21                 dojo.connect(dojo.doc, "onmouseover", this, "toggleWatchMouse");        
22                 dojo.connect(dojo.doc, "onmouseout", this, "toggleWatchMouse");
23         }
24
25         this.sampleMouse=function(e){
26                 if (!this._rateLimited){
27                         this.addData("sample",this.trimMouseEvent(e));  
28                         this._rateLimited=true;
29                         setTimeout(dojo.hitch(this, function(){
30                                 if (this._rateLimited){
31                                         //this.addData("sample", this.trimMouseEvent(this._lastMouseEvent));
32                                         this.trimMouseEvent(this._lastMouseEvent);
33                                         delete this._lastMouseEvent;
34                                         delete this._rateLimited;
35                                 }
36                         }), this.mouseSampleDelay);
37                 }       
38                 this._lastMouseEvent = e;
39                 return e;
40         }
41
42         this.trimMouseEvent=function(e){
43                 var t = {};
44                 for (var i in e){
45                         switch(i){
46                                 //case "currentTarget":
47                                 case "target":
48                                 //case "originalTarget":
49                                 //case "explicitOriginalTarget":
50                                         var props=this.targetProps;
51                                         t[i]={};
52                                         //console.log(e, i, e[i]);
53                                         for(var j=0;j<props.length;j++){
54                                                 if(dojo.isObject(e[i]) && props[j] in e[i]){
55                                                          
56                                                         if (props[j]=="text" || props[j]=="textContent"){
57                                                                 if (e[i]["localName"] && (e[i]["localName"]!="HTML")&&(e[i]["localName"]!="BODY")){
58                                                                         t[i][props[j]]=e[i][props[j]].substr(0,50);
59                                                                 }
60                                                         }else{
61                                                                 t[i][props[j]]=e[i][props[j]];
62                                                         }
63                                                 }
64                                         }
65                                         break;
66                                 //case "clientX":
67                                 //case "clientY":
68                                 //case "pageX":
69                                 //case "pageY":
70                                 //case "screenX":
71                                 //case "screenY":
72                                 case "x":
73                                 case "y":
74                                         if (e[i]) {
75                                                 //console.log("Attempting: " + i);
76                                                 var val = e[i];
77                                                 //console.log("val: " +  val); console.log(i + "e of i: " + val);
78                                                 t[i]=val + '';                                                  
79                                         }
80                                         break;
81                                 default: 
82                                         //console.log("Skipping: ", i);
83                                         break;
84                         }
85                 }
86                 return t;
87         }       
88 })();
89
90 }