source: [view]
define("dojo/robotx", ["dojo", "dojo/robot"], function(dojo) {
dojo.experimental("dojo.robotx");
// loads an external app into an iframe and points dojo.doc to the iframe document, allowing the robot to control it
// to use: set robotURL in djConfig to the URL you want to load
// dojo.require this file
(function(){
var iframe = null;
var groupStarted=dojo.connect(doh, '_groupStarted', function(){
dojo.disconnect(groupStarted);
iframe.style.visibility="visible";
});
var attachIframe = function(){
dojo.addOnLoad(function(){
var emptyStyle = {
overflow: dojo.isWebKit? 'hidden' : 'visible',
margin: '0px',
borderWidth: '0px',
height: '100%',
width: '100%'
};
dojo.style(document.documentElement, emptyStyle);
dojo.style(document.body, emptyStyle);
document.body.appendChild(iframe);
var base=document.createElement('base');
base.href=iframe.src;
document.getElementsByTagName("head")[0].appendChild(base);
});
};
// Prevent race conditions between iframe loading and robot init.
// If iframe is allowed to load while the robot is typing, sync XHRs can prevent the robot from completing its initialization.
var robotReady=false;
var robotFrame=null;
var _run=doh.robot._run;
doh.robot._run=function(frame){
// Called from robot when the robot completed its initialization.
robotReady = true;
robotFrame = frame;
doh.robot._run=_run;
// If initRobot was already called, then attach the iframe.
if(iframe.src){ attachIframe(); }