1
dojo.provide("dojo.robot");
2
dojo.experimental("dojo.robot");
3
dojo.require("doh.robot");
6
// users who use doh+dojo get the added convenience of dojo.mouseMoveAt,
7
// instead of computing the absolute coordinates of their elements themselves
10
// TODO: point to dojo.scrollIntoView post 1.2
11
_scrollIntoView : function(/*String||DOMNode||Function*/ node){
13
// Scroll the passed node into view, if it is not.
14
// Stub to be replaced dijit.robot.
15
if(typeof node == "function"){
16
// if the user passed a function returning a node, evaluate it
19
node.scrollIntoView(false);
22
scrollIntoView : function(/*String||DOMNode||Function*/ node, /*Number, optional*/ delay){
24
// Scroll the passed node into view, if it is not.
27
// The id of the node, or the node itself, to move the mouse to.
28
// If you pass an id or a function that returns a node, the node will not be evaluated until the movement executes.
29
// This is useful if you need to move the mouse to an node that is not yet present.
32
// Delay, in milliseconds, to wait before firing.
33
// The delay is a delta with respect to the previous automation call.
35
doh.robot.sequence(function(){
36
doh.robot._scrollIntoView(node);
40
mouseMoveAt : function(/*String||DOMNode||Function*/ node, /*Integer, optional*/ delay, /*Integer, optional*/ duration, /*Number, optional*/ offsetX, /*Number, optional*/ offsetY){
42
// Moves the mouse over the specified node at the specified relative x,y offset.
45
// Moves the mouse over the specified node at the specified relative x,y offset.
46
// You should manually scroll off-screen nodes into view; use dijit.robot for automatic scrolling support.
47
// If you do not specify an offset, mouseMove will default to move to the middle of the node.
48
// Example: to move the mouse over a ComboBox's down arrow node, call doh.mouseMoveAt(dijit.byId('setvaluetest').downArrowNode);
51
// The id of the node, or the node itself, to move the mouse to.
52
// If you pass an id or a function that returns a node, the node will not be evaluated until the movement executes.
53
// This is useful if you need to move the mouse to an node that is not yet present.
56
// Delay, in milliseconds, to wait before firing.
57
// The delay is a delta with respect to the previous automation call.
58
// For example, the following code ends after 600ms:
59
// doh.mouseClick({left:true}, 100) // first call; wait 100ms
60
// doh.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
63
// Approximate time Robot will spend moving the mouse
64
// The default is 100ms.
67
// x offset relative to the node, in pixels, to move the mouse. The default is half the node's width.
70
// y offset relative to the node, in pixels, to move the mouse. The default is half the node's height.
73
doh.robot._assertRobot();
74
duration = duration||100;
75
this.sequence(function(){
76
if(typeof node == "function"){
77
// if the user passed a function returning a node, evaluate it
82
if(offsetY === undefined){
83
var box=dojo.contentBox(node);
89
doh.robot._scrollIntoView(node);
90
// coords relative to viewport be default
91
var c = dojo.coords(node);
94
doh.robot._mouseMove(x, y, false, duration);