]>
Commit | Line | Data |
---|---|---|
2f01fe57 AD |
1 | /* |
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. | |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. | |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
a089699c AD |
8 | if(!dojo._hasResource["dojo._base._loader.loader_debug"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
9 | dojo._hasResource["dojo._base._loader.loader_debug"] = true; | |
2f01fe57 | 10 | dojo.provide("dojo._base._loader.loader_debug"); |
a089699c AD |
11 | |
12 | //Override dojo.provide, so we can trigger the next | |
13 | //script tag for the next local module. We can only add one | |
14 | //at a time because there are browsers that execute script tags | |
15 | //in the order that the code is received, and not in the DOM order. | |
16 | dojo.nonDebugProvide = dojo.provide; | |
17 | ||
18 | dojo.provide = function(resourceName){ | |
19 | var dbgQueue = dojo["_xdDebugQueue"]; | |
20 | if(dbgQueue && dbgQueue.length > 0 && resourceName == dbgQueue["currentResourceName"]){ | |
21 | //Set a timeout so the module can be executed into existence. Normally the | |
22 | //dojo.provide call in a module is the first line. Don't want to risk attaching | |
23 | //another script tag until the current one finishes executing. | |
24 | if(dojo.isAIR){ | |
25 | window.setTimeout(function(){dojo._xdDebugFileLoaded(resourceName);}, 1); | |
26 | }else{ | |
27 | window.setTimeout(dojo._scopeName + "._xdDebugFileLoaded('" + resourceName + "')", 1); | |
28 | } | |
29 | } | |
30 | ||
31 | return dojo.nonDebugProvide.apply(dojo, arguments); | |
2f01fe57 | 32 | } |
a089699c AD |
33 | |
34 | dojo._xdDebugFileLoaded = function(resourceName){ | |
35 | ||
36 | if(!dojo._xdDebugScopeChecked){ | |
37 | //If using a scoped dojo, we need to expose dojo as a real global | |
38 | //for the debugAtAllCosts stuff to work. | |
39 | if(dojo._scopeName != "dojo"){ | |
40 | window.dojo = window[dojo.config.scopeMap[0][1]]; | |
41 | window.dijit = window[dojo.config.scopeMap[1][1]]; | |
42 | window.dojox = window[dojo.config.scopeMap[2][1]]; | |
43 | } | |
44 | ||
45 | dojo._xdDebugScopeChecked = true; | |
46 | } | |
47 | ||
48 | var dbgQueue = dojo._xdDebugQueue; | |
49 | ||
50 | if(resourceName && resourceName == dbgQueue.currentResourceName){ | |
51 | dbgQueue.shift(); | |
52 | } | |
53 | ||
54 | if(dbgQueue.length == 0){ | |
55 | //Check for more modules that need debug loading. | |
56 | //dojo._xdWatchInFlight will add more things to the debug | |
57 | //queue if they just recently loaded but it was not detected | |
58 | //between the dojo._xdWatchInFlight intervals. | |
59 | dojo._xdWatchInFlight(); | |
60 | } | |
61 | ||
62 | if(dbgQueue.length == 0){ | |
63 | dbgQueue.currentResourceName = null; | |
64 | ||
65 | //Make sure nothing else is in flight. | |
66 | //If something is still in flight, then it still | |
67 | //needs to be added to debug queue after it loads. | |
68 | for(var param in dojo._xdInFlight){ | |
69 | if(dojo._xdInFlight[param] === true){ | |
70 | return; | |
71 | } | |
72 | } | |
73 | ||
74 | dojo._xdNotifyLoaded(); | |
75 | }else{ | |
76 | if(resourceName == dbgQueue.currentResourceName){ | |
77 | dbgQueue.currentResourceName = dbgQueue[0].resourceName; | |
78 | var element = document.createElement("script"); | |
79 | element.type = "text/javascript"; | |
80 | element.src = dbgQueue[0].resourcePath; | |
81 | document.getElementsByTagName("head")[0].appendChild(element); | |
82 | } | |
83 | } | |
2f01fe57 | 84 | } |
a089699c | 85 | |
2f01fe57 | 86 | } |