1 if(!dojo._hasResource["dojo._base.window"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojo._base.window"] = true;
3 dojo.provide("dojo._base.window");
5 dojo._gearsObject = function(){
7 // factory method to get a Google Gears plugin instance to
8 // expose in the browser runtime environment, if present
12 var gearsObj = dojo.getObject("google.gears");
13 if(gearsObj){ return gearsObj; } // already defined elsewhere
15 if(typeof GearsFactory != "undefined"){ // Firefox
16 factory = new GearsFactory();
21 factory = new ActiveXObject("Gears.Factory");
23 // ok to squelch; there's no gears factory. move on.
25 }else if(navigator.mimeTypes["application/x-googlegears"]){
27 factory = document.createElement("object");
28 factory.setAttribute("type", "application/x-googlegears");
29 factory.setAttribute("width", 0);
30 factory.setAttribute("height", 0);
31 factory.style.display = "none";
32 document.documentElement.appendChild(factory);
37 if(!factory){ return null; }
39 // define the global objects now; don't overwrite them though if they
40 // were somehow set internally by the Gears plugin, which is on their
41 // dev roadmap for the future
42 dojo.setObject("google.gears.factory", factory);
43 return dojo.getObject("google.gears");
48 // summary: True if client is using Google Gears
51 // see if we have Google Gears installed, and if
52 // so, make it available in the runtime environment
53 // and in the Google standard 'google.gears' global object
54 dojo.isGears = (!!dojo._gearsObject())||0;
59 // Alias for the current document. 'dojo.doc' can be modified
60 // for temporary context shifting. Also see dojo.withDoc().
62 // Refer to dojo.doc rather
63 // than referring to 'window.document' to ensure your code runs
64 // correctly in managed contexts.
66 // | n.appendChild(dojo.doc.createElement('div'));
69 dojo.doc = window["document"] || null;
71 dojo.body = function(){
73 // Return the body element of the document
74 // return the body object associated with dojo.doc
76 // | dojo.body().appendChild(dojo.doc.createElement('div'));
78 // Note: document.body is not defined for a strict xhtml document
79 // Would like to memoize this, but dojo.doc can change vi dojo.withDoc().
80 return dojo.doc.body || dojo.doc.getElementsByTagName("body")[0]; // Node
83 dojo.setContext = function(/*Object*/globalObject, /*DocumentElement*/globalDocument){
85 // changes the behavior of many core Dojo functions that deal with
86 // namespace and DOM lookup, changing them to work in a new global
87 // context (e.g., an iframe). The varibles dojo.global and dojo.doc
88 // are modified as a result of calling this function and the result of
89 // `dojo.body()` likewise differs.
90 dojo.global = globalObject;
91 dojo.doc = globalDocument;
94 dojo._fireCallback = function(callback, context, cbArguments){
95 if(context && dojo.isString(callback)){
96 callback = context[callback];
98 return callback.apply(context, cbArguments || [ ]);
101 dojo.withGlobal = function( /*Object*/globalObject,
102 /*Function*/callback,
103 /*Object?*/thisObject,
104 /*Array?*/cbArguments){
106 // Call callback with globalObject as dojo.global and
107 // globalObject.document as dojo.doc. If provided, globalObject
108 // will be executed in the context of object thisObject
110 // When callback() returns or throws an error, the dojo.global
111 // and dojo.doc will be restored to its previous state.
113 var oldGlob = dojo.global;
114 var oldDoc = dojo.doc;
116 dojo.setContext(globalObject, globalObject.document);
117 rval = dojo._fireCallback(callback, thisObject, cbArguments);
119 dojo.setContext(oldGlob, oldDoc);
124 dojo.withDoc = function( /*Object*/documentObject,
125 /*Function*/callback,
126 /*Object?*/thisObject,
127 /*Array?*/cbArguments){
129 // Call callback with documentObject as dojo.doc. If provided,
130 // callback will be executed in the context of object thisObject
132 // When callback() returns or throws an error, the dojo.doc will
133 // be restored to its previous state.
135 var oldDoc = dojo.doc;
137 dojo.doc = documentObject;
138 rval = dojo._fireCallback(callback, thisObject, cbArguments);