2150 |
mathias |
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");
|
|
|
4 |
|
|
|
5 |
dojo._gearsObject = function(){
|
|
|
6 |
// summary:
|
|
|
7 |
// factory method to get a Google Gears plugin instance to
|
|
|
8 |
// expose in the browser runtime environment, if present
|
|
|
9 |
var factory;
|
|
|
10 |
var results;
|
|
|
11 |
|
|
|
12 |
var gearsObj = dojo.getObject("google.gears");
|
|
|
13 |
if(gearsObj){ return gearsObj; } // already defined elsewhere
|
|
|
14 |
|
|
|
15 |
if(typeof GearsFactory != "undefined"){ // Firefox
|
|
|
16 |
factory = new GearsFactory();
|
|
|
17 |
}else{
|
|
|
18 |
if(dojo.isIE){
|
|
|
19 |
// IE
|
|
|
20 |
try{
|
|
|
21 |
factory = new ActiveXObject("Gears.Factory");
|
|
|
22 |
}catch(e){
|
|
|
23 |
// ok to squelch; there's no gears factory. move on.
|
|
|
24 |
}
|
|
|
25 |
}else if(navigator.mimeTypes["application/x-googlegears"]){
|
|
|
26 |
// Safari?
|
|
|
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);
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
// still nothing?
|
|
|
37 |
if(!factory){ return null; }
|
|
|
38 |
|
|
|
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");
|
|
|
44 |
};
|
|
|
45 |
|
|
|
46 |
// see if we have Google Gears installed, and if
|
|
|
47 |
// so, make it available in the runtime environment
|
|
|
48 |
// and in the Google standard 'google.gears' global object
|
|
|
49 |
dojo.isGears = (!!dojo._gearsObject())||0;
|
|
|
50 |
|
|
|
51 |
// @global: dojo.doc
|
|
|
52 |
|
|
|
53 |
// summary:
|
|
|
54 |
// Current document object. 'dojo.doc' can be modified
|
|
|
55 |
// for temporary context shifting. Also see dojo.withDoc().
|
|
|
56 |
// description:
|
|
|
57 |
// Refer to dojo.doc rather
|
|
|
58 |
// than referring to 'window.document' to ensure your code runs
|
|
|
59 |
// correctly in managed contexts.
|
|
|
60 |
dojo.doc = window["document"] || null;
|
|
|
61 |
|
|
|
62 |
dojo.body = function(){
|
|
|
63 |
// summary:
|
|
|
64 |
// return the body object associated with dojo.doc
|
|
|
65 |
|
|
|
66 |
// Note: document.body is not defined for a strict xhtml document
|
|
|
67 |
// Would like to memoize this, but dojo.doc can change vi dojo.withDoc().
|
|
|
68 |
return dojo.doc.body || dojo.doc.getElementsByTagName("body")[0];
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
dojo.setContext = function(/*Object*/globalObject, /*DocumentElement*/globalDocument){
|
|
|
72 |
// summary:
|
|
|
73 |
// changes the behavior of many core Dojo functions that deal with
|
|
|
74 |
// namespace and DOM lookup, changing them to work in a new global
|
|
|
75 |
// context. The varibles dojo.global and dojo.doc
|
|
|
76 |
// are modified as a result of calling this function.
|
|
|
77 |
dojo.global = globalObject;
|
|
|
78 |
dojo.doc = globalDocument;
|
|
|
79 |
};
|
|
|
80 |
|
|
|
81 |
dojo._fireCallback = function(callback, context, cbArguments){
|
|
|
82 |
// FIXME: should migrate to using "dojo.isString"!
|
|
|
83 |
if(context && dojo.isString(callback)){
|
|
|
84 |
callback = context[callback];
|
|
|
85 |
}
|
|
|
86 |
return (context ? callback.apply(context, cbArguments || [ ]) : callback());
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
dojo.withGlobal = function( /*Object*/globalObject,
|
|
|
90 |
/*Function*/callback,
|
|
|
91 |
/*Object?*/thisObject,
|
|
|
92 |
/*Array?*/cbArguments){
|
|
|
93 |
// summary:
|
|
|
94 |
// Call callback with globalObject as dojo.global and
|
|
|
95 |
// globalObject.document as dojo.doc. If provided, globalObject
|
|
|
96 |
// will be executed in the context of object thisObject
|
|
|
97 |
// description:
|
|
|
98 |
// When callback() returns or throws an error, the dojo.global
|
|
|
99 |
// and dojo.doc will be restored to its previous state.
|
|
|
100 |
var rval;
|
|
|
101 |
var oldGlob = dojo.global;
|
|
|
102 |
var oldDoc = dojo.doc;
|
|
|
103 |
try{
|
|
|
104 |
dojo.setContext(globalObject, globalObject.document);
|
|
|
105 |
rval = dojo._fireCallback(callback, thisObject, cbArguments);
|
|
|
106 |
}finally{
|
|
|
107 |
dojo.setContext(oldGlob, oldDoc);
|
|
|
108 |
}
|
|
|
109 |
return rval;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
dojo.withDoc = function( /*Object*/documentObject,
|
|
|
113 |
/*Function*/callback,
|
|
|
114 |
/*Object?*/thisObject,
|
|
|
115 |
/*Array?*/cbArguments){
|
|
|
116 |
// summary:
|
|
|
117 |
// Call callback with documentObject as dojo.doc. If provided,
|
|
|
118 |
// callback will be executed in the context of object thisObject
|
|
|
119 |
// description:
|
|
|
120 |
// When callback() returns or throws an error, the dojo.doc will
|
|
|
121 |
// be restored to its previous state.
|
|
|
122 |
var rval;
|
|
|
123 |
var oldDoc = dojo.doc;
|
|
|
124 |
try{
|
|
|
125 |
dojo.doc = documentObject;
|
|
|
126 |
rval = dojo._fireCallback(callback, thisObject, cbArguments);
|
|
|
127 |
}finally{
|
|
|
128 |
dojo.doc = oldDoc;
|
|
|
129 |
}
|
|
|
130 |
return rval;
|
|
|
131 |
};
|
|
|
132 |
|
|
|
133 |
//Register any module paths set up in djConfig. Need to do this
|
|
|
134 |
//in the hostenvs since hostenv_browser can read djConfig from a
|
|
|
135 |
//script tag's attribute.
|
|
|
136 |
(function(){
|
|
|
137 |
var mp = djConfig["modulePaths"];
|
|
|
138 |
if(mp){
|
|
|
139 |
for(var param in mp){
|
|
|
140 |
dojo.registerModulePath(param, mp[param]);
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
})();
|
|
|
144 |
|
|
|
145 |
}
|