root / trunk / web / dojo / dojox / analytics / plugins / mouseOver.js
History | View | Annotate | Download (1.91 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.analytics.plugins.mouseOver"]){ |
9 |
dojo._hasResource["dojox.analytics.plugins.mouseOver"]=true; |
10 |
dojo.require("dojox.analytics._base");
|
11 |
dojo.provide("dojox.analytics.plugins.mouseOver");
|
12 |
dojox.analytics.plugins.mouseOver=new (function(){ |
13 |
this.watchMouse=dojo.config["watchMouseOver"]||true; |
14 |
this.mouseSampleDelay=dojo.config["sampleDelay"]||2500; |
15 |
this.addData=dojo.hitch(dojox.analytics,"addData","mouseOver"); |
16 |
this.targetProps=dojo.config["targetProps"]||["id","className","localName","href","spellcheck","lang","textContent","value"]; |
17 |
this.toggleWatchMouse=function(){ |
18 |
if(this._watchingMouse){ |
19 |
dojo.disconnect(this._watchingMouse);
|
20 |
delete this._watchingMouse; |
21 |
return;
|
22 |
} |
23 |
dojo.connect(dojo.doc,"onmousemove",this,"sampleMouse"); |
24 |
}; |
25 |
if(this.watchMouse){ |
26 |
dojo.connect(dojo.doc,"onmouseover",this,"toggleWatchMouse"); |
27 |
dojo.connect(dojo.doc,"onmouseout",this,"toggleWatchMouse"); |
28 |
} |
29 |
this.sampleMouse=function(e){ |
30 |
if(!this._rateLimited){ |
31 |
this.addData("sample",this.trimMouseEvent(e)); |
32 |
this._rateLimited=true; |
33 |
setTimeout(dojo.hitch(this,function(){ |
34 |
if(this._rateLimited){ |
35 |
this.trimMouseEvent(this._lastMouseEvent); |
36 |
delete this._lastMouseEvent; |
37 |
delete this._rateLimited; |
38 |
} |
39 |
}),this.mouseSampleDelay);
|
40 |
} |
41 |
this._lastMouseEvent=e;
|
42 |
return e;
|
43 |
}; |
44 |
this.trimMouseEvent=function(e){ |
45 |
var t={};
|
46 |
for(var i in e){ |
47 |
switch(i){
|
48 |
case "target": |
49 |
var _1=this.targetProps; |
50 |
t[i]={}; |
51 |
for(var j=0;j<_1.length;j++){ |
52 |
if(dojo.isObject(e[i])&&_1[j] in e[i]){ |
53 |
if(_1[j]=="text"||_1[j]=="textContent"){ |
54 |
if(e[i]["localName"]&&(e[i]["localName"]!="HTML")&&(e[i]["localName"]!="BODY")){ |
55 |
t[i][_1[j]]=e[i][_1[j]].substr(0,50); |
56 |
} |
57 |
}else{
|
58 |
t[i][_1[j]]=e[i][_1[j]]; |
59 |
} |
60 |
} |
61 |
} |
62 |
break;
|
63 |
case "x": |
64 |
case "y": |
65 |
if(e[i]){
|
66 |
var _2=e[i];
|
67 |
t[i]=_2+"";
|
68 |
} |
69 |
break;
|
70 |
default:
|
71 |
break;
|
72 |
} |
73 |
} |
74 |
return t;
|
75 |
}; |
76 |
})(); |
77 |
} |