summaryrefslogtreecommitdiff
path: root/lib/dojo/robot.js
blob: 88af37cefb27b2e1cc6ab7ea70327cbeb8e1f9fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
	Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(!dojo._hasResource["dojo.robot"]){
dojo._hasResource["dojo.robot"]=true;
dojo.provide("dojo.robot");
dojo.experimental("dojo.robot");
dojo.require("doh.robot");
dojo.require("dojo.window");
(function(){
dojo.mixin(doh.robot,{_resolveNode:function(n){
if(typeof n=="function"){
n=n();
}
return n?dojo.byId(n):null;
},_scrollIntoView:function(n){
var d=dojo,dr=doh.robot,p=null;
d.forEach(dr._getWindowChain(n),function(w){
d.withGlobal(w,function(){
var p2=d.position(n,false),b=d._getPadBorderExtents(n),_1=null;
if(!p){
p=p2;
}else{
_1=p;
p={x:p.x+p2.x+b.l,y:p.y+p2.y+b.t,w:p.w,h:p.h};
}
dojo.window.scrollIntoView(n,p);
p2=d.position(n,false);
if(!_1){
p=p2;
}else{
p={x:_1.x+p2.x+b.l,y:_1.y+p2.y+b.t,w:p.w,h:p.h};
}
n=w.frameElement;
});
});
},_position:function(n){
var d=dojo,p=null,M=Math.max,m=Math.min;
d.forEach(doh.robot._getWindowChain(n),function(w){
d.withGlobal(w,function(){
var p2=d.position(n,false),b=d._getPadBorderExtents(n);
if(!p){
p=p2;
}else{
var _2;
d.withGlobal(n.contentWindow,function(){
_2=dojo.window.getBox();
});
p2.r=p2.x+_2.w;
p2.b=p2.y+_2.h;
p={x:M(p.x+p2.x,p2.x)+b.l,y:M(p.y+p2.y,p2.y)+b.t,r:m(p.x+p2.x+p.w,p2.r)+b.l,b:m(p.y+p2.y+p.h,p2.b)+b.t};
p.w=p.r-p.x;
p.h=p.b-p.y;
}
n=w.frameElement;
});
});
return p;
},_getWindowChain:function(n){
var cW=dojo.window.get(n.ownerDocument);
var _3=[cW];
var f=cW.frameElement;
return (cW==dojo.global||f==null)?_3:_3.concat(doh.robot._getWindowChain(f));
},scrollIntoView:function(_4,_5){
doh.robot.sequence(function(){
doh.robot._scrollIntoView(doh.robot._resolveNode(_4));
},_5);
},mouseMoveAt:function(_6,_7,_8,_9,_a){
doh.robot._assertRobot();
_8=_8||100;
this.sequence(function(){
_6=doh.robot._resolveNode(_6);
doh.robot._scrollIntoView(_6);
var _b=doh.robot._position(_6);
if(_a===undefined){
_9=_b.w/2;
_a=_b.h/2;
}
var x=_b.x+_9;
var y=_b.y+_a;
doh.robot._mouseMove(x,y,false,_8);
},_7,_8);
}});
})();
}