Changeset 7650
- Timestamp:
- 03/18/07 17:12:40 (22 months ago)
- Location:
- dojo/trunk
- Files:
-
- 7 modified
-
dojo.js (modified) (4 diffs)
-
tests/runner.js (modified) (1 diff)
-
tests/_base.js (modified) (1 diff)
-
tests/_browserRunner.js (modified) (1 diff)
-
_base/_loader/bootstrap.js (modified) (1 diff)
-
_base/_loader/hostenv_browser.js (modified) (18 diffs)
-
_base/_loader/loader.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/dojo.js
r7645 r7650 29 29 } 30 30 31 if((this["djConfig"])&&(djConfig["baseScriptUri"])){ 32 var root = djConfig["baseScriptUri"]; 33 }else if((this["djConfig"])&&(djConfig["baseRelativePath"])){ 34 var root = djConfig["baseRelativePath"]; 31 if((this["djConfig"])&&(djConfig["baseUrl"])){ 32 var root = djConfig["baseUrl"]; 35 33 }else{ 36 34 var root = "./"; … … 40 38 } 41 39 if(!this["djConfig"]){ 42 djConfig = { base RelativePath: root };40 djConfig = { baseUrl: root }; 43 41 } 44 42 … … 54 52 root = src.substring(0, m.index); 55 53 if(!this["djConfig"]){ djConfig = {}; } 56 djConfig["base ScriptUri"] = djConfig["baseRelativePath"] = root;54 djConfig["baseUrl"] = root; 57 55 break; 58 56 } … … 61 59 } 62 60 63 var loaderRoot = root;64 if((this["djConfig"])&&(djConfig["baseLoaderUri"])){65 loaderRoot = djConfig["baseLoaderUri"];66 }67 68 61 for(var x=0; x < tmps.length; x++){ 69 var spath = loaderRoot+"_base/_loader/"+tmps[x];62 var spath = root+"_base/_loader/"+tmps[x]; 70 63 if(isRhino||isSpidermonkey){ 71 64 load(spath); -
dojo/trunk/tests/runner.js
r7647 r7650 663 663 664 664 if(this["dojo"]){ 665 dojo. kwCompoundRequire({665 dojo.platformRequire({ 666 666 browser: ["tests._browserRunner"], 667 667 rhino: ["tests._rhinoRunner"], -
dojo/trunk/tests/_base.js
r7631 r7650 1 if(this["dojo"]){1 try{ 2 2 dojo.provide("tests._base"); 3 } 3 }catch(e){} 4 4 5 5 // the test suite for the bootstrap. Requires hostenv and other base tests at -
dojo/trunk/tests/_browserRunner.js
r7647 r7650 1 if( this["dojo"]){1 if(window["dojo"]){ 2 2 dojo.provide("tests._browserRunner"); 3 3 } -
dojo/trunk/_base/_loader/bootstrap.js
r7649 r7650 6 6 // description: The variables that can be set are as follows: 7 7 // - isDebug: false 8 // - allowQueryConfig: false9 8 // - baseScriptUri: "" 10 9 // - baseRelativePath: "" -
dojo/trunk/_base/_loader/hostenv_browser.js
r7642 r7650 1 1 if(typeof window != 'undefined'){ 2 dojo.isBrowser = true; 3 dojo._name = "browser"; 2 4 3 5 // attempt to figure out the path to dojo if it isn't set in the config 4 6 (function(){ 7 var d = dojo; 8 // this is a scope protection closure. We set browser versions and grab 9 // the URL we were loaded from here. 10 5 11 // before we get any further with the config options, try to pick them out 6 12 // of the URL. Most of this code is from NW 7 if(djConfig.allowQueryConfig){8 var baseUrl = document.location.toString(); // FIXME: use location.query instead?9 var params = baseUrl.split("?", 2);10 if(params.length > 1){11 var paramStr = params[1];12 var pairs = paramStr.split("&");13 for(var x in pairs){14 var sp = pairs[x].split("=");15 // FIXME: is this eval dangerous?16 if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){17 var opt = sp[0].substr(9);18 try{19 djConfig[opt]=eval(sp[1]);20 }catch(e){21 djConfig[opt]=sp[1];22 }23 }24 }25 }26 }27 28 13 if( 29 ((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) && 30 (document && document.getElementsByTagName) 14 (djConfig["baseUrl"] == "") && (document && document.getElementsByTagName) 31 15 ){ 32 16 var scripts = document.getElementsByTagName("script"); 33 var rePkg = /( __package__|dojo|bootstrap1)\.js([\?\.]|$)/i;17 var rePkg = /(dojo|bootstrap)\.js([\?\.]|$)/i; 34 18 for(var i = 0; i < scripts.length; i++) { 35 19 var src = scripts[i].getAttribute("src"); … … 38 22 if(m) { 39 23 var root = src.substring(0, m.index); 40 if(src.indexOf("bootstrap1") > -1) { root += "../"; } 41 if(!this["djConfig"]) { djConfig = {}; } 42 if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; } 43 if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; } 24 if(src.indexOf("bootstrap") > -1) { root += "../"; } 25 d._baseUrl = root; 26 console.debug(root); 44 27 break; 45 28 } 46 29 } 30 }else{ 31 d._baseUrl = djConfig["baseUrl"]; 47 32 } 48 33 49 34 // fill in the rendering support information in dojo.render.* 50 var dr = dojo.render; 51 var drh = dojo.render.html; 52 var drs = dojo.render.svg; 53 var dua = (drh.UA = navigator.userAgent); 54 var dav = (drh.AV = navigator.appVersion); 55 var t = true; 56 var f = false; 57 drh.capable = t; 58 drh.support.builtin = t; 59 60 dr.ver = parseFloat(drh.AV); 61 dr.os.mac = dav.indexOf("Macintosh") >= 0; 62 dr.os.win = dav.indexOf("Windows") >= 0; 63 // could also be Solaris or something, but it's the same browser 64 dr.os.linux = dav.indexOf("X11") >= 0; 65 66 drh.opera = dua.indexOf("Opera") >= 0; 67 drh.khtml = (dav.indexOf("Konqueror") >= 0)||(dav.indexOf("Safari") >= 0); 68 drh.safari = dav.indexOf("Safari") >= 0; 35 var n = navigator; 36 var dua = n.userAgent; 37 var dav = n.appVersion; 38 var tv = parseFloat(dav); 39 40 d.isOpera = (dua.indexOf("Opera") >= 0) ? tv : 0; 41 d.isKhtml = (dav.indexOf("Konqueror") >= 0)||(dav.indexOf("Safari") >= 0) ? tv : 0; 42 d.isSafari = (dav.indexOf("Safari") >= 0) ? tv : 0; 69 43 var geckoPos = dua.indexOf("Gecko"); 70 drh.mozilla = drh.moz = (geckoPos >= 0)&&(!drh.khtml); 71 if (drh.mozilla) { 72 // gecko version is YYYYMMDD 73 drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14); 74 } 75 drh.ie = (document.all)&&(!drh.opera); 76 drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0")>=0; 77 drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5")>=0; 78 drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0; 79 drh.ie70 = drh.ie && dav.indexOf("MSIE 7.0")>=0; 44 d.isMozilla = d.isMoz = ((geckoPos >= 0)&&(!d.isKhtml)) ? tv : 0; 45 d.isIE = ((document.all)&&(!d.isOpera)) ? tv : 0; 80 46 81 47 var cm = document["compatMode"]; 82 d rh.quirks = (cm == "BackCompat")||(cm == "QuirksMode")||drh.ie55||drh.ie50;48 d.isQuirks = (cm == "BackCompat")||(cm == "QuirksMode")||(d.isIE < 6); 83 49 84 50 // TODO: is the HTML LANG attribute relevant? 85 dojo.locale = dojo.locale || (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase(); 86 87 dr.vml.capable=drh.ie; 88 drs.capable = f; 89 drs.support.plugin = f; 90 drs.support.builtin = f; 91 var tdoc = window["document"]; 92 var tdi = tdoc["implementation"]; 93 94 if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg", "1.0"))){ 95 drs.capable = t; 96 drs.support.builtin = t; 97 drs.support.plugin = f; 98 } 99 // webkits after 420 support SVG natively. The test string is "AppleWebKit/420+" 100 if(drh.safari){ 101 var tmp = dua.split("AppleWebKit/")[1]; 102 var ver = parseFloat(tmp.split(" ")[0]); 103 if(ver >= 420){ 104 drs.capable = t; 105 drs.support.builtin = t; 106 drs.support.plugin = f; 107 } 108 }else{ 109 } 51 d.locale = d.locale || (d.isIE ? n.userLanguage : n.language).toLowerCase(); 110 52 })(); 111 53 112 dojo.hostenv.startPackage("dojo.hostenv");113 114 dojo.render.name = dojo.hostenv.name_ = 'browser';115 dojo.hostenv.searchIds = [];116 54 117 55 // These are in order of decreasing likelihood; this will change in time. 118 dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; 119 120 dojo.hostenv.getXmlhttpObject = function(){ 121 // summary: does the work of portably generating a new XMLHTTPRequest object. 56 dojo._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; 57 58 dojo._xhrObj= function(){ 59 // summary: 60 // does the work of portably generating a new XMLHTTPRequest 61 // object. 122 62 var http = null; 123 63 var last_e = null; … … 125 65 if(!http){ 126 66 for(var i=0; i<3; ++i){ 127 var progid = dojo. hostenv._XMLHTTP_PROGIDS[i];67 var progid = dojo._XMLHTTP_PROGIDS[i]; 128 68 try{ 129 69 http = new ActiveXObject(progid); … … 133 73 134 74 if(http){ 135 dojo. hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time75 dojo._XMLHTTP_PROGIDS = [progid]; // so faster next time 136 76 break; 137 77 } … … 144 84 145 85 if(!http){ 146 return dojo.raise("XMLHTTP not available",last_e);86 throw new Error("XMLHTTP not available: "+last_e); 147 87 } 148 88 … … 150 90 } 151 91 152 dojo. hostenv._blockAsync = false;153 dojo. hostenv.getText = function(uri, async_cb, fail_ok){92 dojo._blockAsync = false; 93 dojo._getText = function(uri, async_cb, fail_ok){ 154 94 // summary: Read the contents of the specified uri and return those contents. 155 95 // uri: … … 168 108 // of an async callback might call another sync XHR, this hangs khtml forever 169 109 // hostenv._blockAsync must also be checked in BrowserIO's watchInFlight() 170 // NOTE: must be declared before scope switches ie. this. getXmlhttpObject()110 // NOTE: must be declared before scope switches ie. this._xhrObj() 171 111 if(!async_cb){ this._blockAsync = true; } 172 112 173 var http = this. getXmlhttpObject();113 var http = this._xhrObj(); 174 114 175 115 function isDocumentOk(http){ 176 116 var stat = http["status"]; 177 // allow a 304 use cache, needed in konq (is this compliant with the http spec?) 117 // allow a 304 use cache, needed in konq (is this compliant with 118 // the http spec?) 178 119 return Boolean((!stat)||((200 <= stat)&&(300 > stat))||(stat==304)); 179 120 } … … 181 122 if(async_cb){ 182 123 var _this = this, timer = null, gbl = dojo.global(); 183 var xhr = dojo.getObject("dojo.io.XMLHTTPTransport");184 124 http.onreadystatechange = function(){ 185 125 if(timer){ gbl.clearTimeout(timer); timer = null; } 186 if(_this._blockAsync || (xhr && xhr._blockAsync)){ 187 timer = gbl.setTimeout(function () { http.onreadystatechange.apply(this); }, 10); 126 if(_this._blockAsync){ 127 timer = gbl.setTimeout(function(){ 128 http.onreadystatechange.apply(this); 129 }, 10); 188 130 }else{ 189 131 if(4==http.readyState){ … … 222 164 } 223 165 224 dojo.hostenv.defaultDebugContainerId = 'dojoDebug'; 225 dojo.hostenv._println_buffer = []; 226 dojo.hostenv._println_safe = false; 227 dojo.hostenv.println = function(/*String*/line){ 228 // summary: 229 // prints the provided line to whatever logging container is 230 // available. If the page isn't loaded yet, the line may be added 231 // to a buffer for printing later. 232 if(!dojo.hostenv._println_safe){ 233 dojo.hostenv._println_buffer.push(line); 234 }else{ 235 try { 236 var console = document.getElementById(djConfig.debugContainerId ? 237 djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId); 238 if(!console) { console = dojo.body(); } 239 240 var div = document.createElement("div"); 241 div.appendChild(document.createTextNode(line)); 242 console.appendChild(div); 243 } catch (e) { 244 try{ 245 // safari needs the output wrapped in an element for some reason 246 document.write("<div>" + line + "</div>"); 247 }catch(e2){ 248 window.status = line; 249 } 250 } 251 } 252 } 253 254 dojo.addOnLoad(function(){ 255 dojo.hostenv._println_safe = true; 256 while(dojo.hostenv._println_buffer.length > 0){ 257 dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); 258 } 259 }); 260 261 function dj_addNodeEvtHdlr(/*DomNode*/node, /*String*/evtName, /*Function*/fp){ 166 dojo._println = console.debug; 167 168 dojo._handleNodeEvent = function(/*DomNode*/node, /*String*/evtName, /*Function*/fp){ 262 169 // summary: 263 170 // non-destructively adds the specified function to the node's … … 274 181 275 182 // BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/) 276 function dj_load_init(e){183 dojo._loadInit = function(e){ 277 184 // allow multiple calls, only first one will take effect 278 185 // A bug in khtml calls events callbacks for document for event which isnt supported … … 286 193 } 287 194 288 var initFunc = function(){ 289 //perform initialization 290 if(dojo.render.html.ie){ 291 dojo.hostenv.makeWidgets(); 292 } 293 }; 294 295 if(dojo.hostenv.inFlightCount == 0){ 296 initFunc(); 297 dojo.hostenv.modulesLoaded(); 298 }else{ 299 //This else case should be xdomain loading. 300 //Make sure this is the first thing in the load listener array. 301 //Part of the dojo.addOnLoad guarantee is that when the listeners are notified, 302 //It means the DOM (or page) has loaded and that widgets have been parsed. 303 dojo.hostenv.modulesLoadedListeners.unshift(initFunc); 195 if(dojo._inFlightCount == 0){ 196 dojo._modulesLoaded(); 304 197 } 305 198 } … … 312 205 // DOMContentLoaded on that platform. For more information, see: 313 206 // http://trac.dojotoolkit.org/ticket/1704 314 if(dojo. render.html.opera || (dojo.render.html.moz && (djConfig["enableMozDomContentLoaded"] === true))){315 document.addEventListener("DOMContentLoaded", d j_load_init, null);207 if(dojo.isOpera|| (dojo.isMoz && (djConfig["enableMozDomContentLoaded"] === true))){ 208 document.addEventListener("DOMContentLoaded", dojo._loadInit, null); 316 209 } 317 210 318 211 // mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already. 319 212 // also used for Mozilla because of trac #1640 320 window.addEventListener("load", dj_load_init, null); 321 } 322 323 // for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it 324 // however, we'll include it because we don't know if there are other functions added that might. 325 // Note that this has changed because the build process strips all comments--including conditional 326 // ones. 327 if(dojo.render.html.ie && dojo.render.os.win){ 213 window.addEventListener("load", dojo._loadInit, null); 214 } 215 216 // for Internet Explorer. readyState will not be achieved on init call, 217 // but dojo doesn't need it however, we'll include it because we don't 218 // know if there are other functions added that might. Note that this has 219 // changed because the build process strips all comments -- including 220 // conditional ones. 221 if(dojo.isIE){ 328 222 document.write('<scr'+'ipt defer src="//:" ' 329 + 'onreadystatechange="if(this.readyState==\'complete\'){d j_load_init();}">'223 + 'onreadystatechange="if(this.readyState==\'complete\'){dojo._loadInit();}">' 330 224 + '</scr'+'ipt>' 331 225 ); 332 226 } 333 227 334 if (/(WebKit|khtml)/i.test(navigator.userAgent)){ // sniff335 var _timer = setInterval(function() {336 if (/loaded|complete/.test(document.readyState)){337 d j_load_init(); // call the onload handler228 if(/(WebKit|khtml)/i.test(navigator.userAgent)){ // sniff 229 var _timer = setInterval(function(){ 230 if(/loaded|complete/.test(document.readyState)){ 231 dojo._loadInit(); // call the onload handler 338 232 } 339 233 }, 10); … … 345 239 // following code fixes the problem 346 240 // Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155 347 if(dojo. render.html.ie){348 d j_addNodeEvtHdlr(window, "beforeunload", function(){349 dojo. hostenv._unloading = true;241 if(dojo.isIE){ 242 dojo._handleNodeEvent(window, "beforeunload", function(){ 243 dojo._unloading = true; 350 244 window.setTimeout(function() { 351 dojo. hostenv._unloading = false;245 dojo._unloading = false; 352 246 }, 0); 353 247 }); 354 248 } 355 249 356 d j_addNodeEvtHdlr(window, "unload", function(){357 if((!dojo. render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){358 dojo. hostenv.unloaded();250 dojo._handleNodeEvent(window, "unload", function(){ 251 if((!dojo.isIE)||(dojo.isIE && dojo._unloading)){ 252 dojo.unloaded(); 359 253 } 360 254 }); 361 255 362 dojo.hostenv.makeWidgets = function(){363 // you can put searchIds in djConfig and dojo.hostenv at the moment364 // we should probably eventually move to one or the other365 var sids = [];366 if(djConfig.searchIds && djConfig.searchIds.length > 0) {367 sids = sids.concat(djConfig.searchIds);368 }369 if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {370 sids = sids.concat(dojo.hostenv.searchIds);371 }372 373 if((djConfig.parseWidgets)||(sids.length > 0)){374 if(dojo.getObject("dojo.widget.Parse")){375 // we must do this on a delay to avoid:376 // http://www.shaftek.org/blog/archives/000212.html377 // (IE bug)378 var parser = new dojo.xml.Parse();379 if(sids.length > 0){380 for(var x=0; x<sids.length; x++){381 var tmpNode = document.getElementById(sids[x]);382 if(!tmpNode){ continue; }383 var frag = parser.parseElement(tmpNode, null, true);384 dojo.widget.getParser().createComponents(frag);385 }386 }else if(djConfig.parseWidgets){387 var frag = parser.parseElement(dojo.body(), null, true);388 dojo.widget.getParser().createComponents(frag);389 }390 }391 }392 }393 394 dojo.addOnLoad(function(){395 if(!dojo.render.html.ie) {396 dojo.hostenv.makeWidgets();397 }398 });399 400 256 try{ 401 if(dojo. render.html.ie){257 if(dojo.isIE){ 402 258 document.namespaces.add("v","urn:schemas-microsoft-com:vml"); 403 259 document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)"); … … 407 263 // stub, over-ridden by debugging code. This will at least keep us from 408 264 // breaking when it's not included 409 dojo. hostenv.writeIncludes = function(){}265 dojo._writeIncludes = function(){} 410 266 411 267 //TODOC: HOW TO DOC THIS? 412 // @global: d j_currentDocument268 // @global: dojo._currentDocument 413 269 // summary: 414 // Current document object. 'dj_currentDocument' can be modified for temporary context shifting. 270 // Current document object. 'dojo._currentDocument' can be modified 271 // for temporary context shifting. 415 272 // description: 416 // dojo.doc() returns dojo. currentDocument.417 // Refer to dojo.doc() rather than referring to 'window.document' to ensure your418 // code runscorrectly in managed contexts.419 if( !dj_undef("document", this)){420 d j_currentDocument = this.document;273 // dojo.doc() returns dojo._currentDocument. Refer to dojo.doc() rather 274 // than referring to 'window.document' to ensure your code runs 275 // correctly in managed contexts. 276 if(this["document"]){ 277 dojo._currentDocument = this.document; 421 278 } 422 279 … … 424 281