1 /** vim: et:ts=4:sw=4:sts=4 |
1 /** vim: et:ts=4:sw=4:sts=4 |
2 * @license RequireJS 2.1.18 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. |
2 * @license RequireJS 2.1.20 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. |
3 * Available via the MIT or new BSD license. |
3 * Available via the MIT or new BSD license. |
4 * see: http://github.com/jrburke/requirejs for details |
4 * see: http://github.com/jrburke/requirejs for details |
5 */ |
5 */ |
6 //Not using strict: uneven strict support in browsers, #392, and causes |
6 //Not using strict: uneven strict support in browsers, #392, and causes |
7 //problems with requirejs.exec()/transpiler plugins that may not be strict. |
7 //problems with requirejs.exec()/transpiler plugins that may not be strict. |
10 |
10 |
11 var requirejs, require, define; |
11 var requirejs, require, define; |
12 (function (global) { |
12 (function (global) { |
13 var req, s, head, baseElement, dataMain, src, |
13 var req, s, head, baseElement, dataMain, src, |
14 interactiveScript, currentlyAddingScript, mainScript, subPath, |
14 interactiveScript, currentlyAddingScript, mainScript, subPath, |
15 version = '2.1.18', |
15 version = '2.1.20', |
16 commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, |
16 commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, |
17 cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, |
17 cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, |
18 jsSuffixRegExp = /\.js$/, |
18 jsSuffixRegExp = /\.js$/, |
19 currDirRegExp = /^\.\//, |
19 currDirRegExp = /^\.\//, |
20 op = Object.prototype, |
20 op = Object.prototype, |
21 ostring = op.toString, |
21 ostring = op.toString, |
22 hasOwn = op.hasOwnProperty, |
22 hasOwn = op.hasOwnProperty, |
23 ap = Array.prototype, |
23 ap = Array.prototype, |
24 apsp = ap.splice, |
|
25 isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), |
24 isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), |
26 isWebWorker = !isBrowser && typeof importScripts !== 'undefined', |
25 isWebWorker = !isBrowser && typeof importScripts !== 'undefined', |
27 //PS3 indicates loaded and complete, but need to wait for complete |
26 //PS3 indicates loaded and complete, but need to wait for complete |
28 //specifically. Sequence is 'loading', 'loaded', execution, |
27 //specifically. Sequence is 'loading', 'loaded', execution, |
29 // then 'complete'. The UA check is unfortunate, but not sure how |
28 // then 'complete'. The UA check is unfortunate, but not sure how |
552 * defQueue. |
551 * defQueue. |
553 */ |
552 */ |
554 function takeGlobalQueue() { |
553 function takeGlobalQueue() { |
555 //Push all the globalDefQueue items into the context's defQueue |
554 //Push all the globalDefQueue items into the context's defQueue |
556 if (globalDefQueue.length) { |
555 if (globalDefQueue.length) { |
557 //Array splice in the values since the context code has a |
556 each(globalDefQueue, function(queueItem) { |
558 //local var ref to defQueue, so cannot just reassign the one |
557 var id = queueItem[0]; |
559 //on context. |
558 if (typeof id === 'string') { |
560 apsp.apply(defQueue, |
559 context.defQueueMap[id] = true; |
561 [defQueue.length, 0].concat(globalDefQueue)); |
560 } |
|
561 defQueue.push(queueItem); |
|
562 }); |
562 globalDefQueue = []; |
563 globalDefQueue = []; |
563 } |
564 } |
564 } |
565 } |
565 |
566 |
566 handlers = { |
567 handlers = { |
843 depExports = this.depExports, |
844 depExports = this.depExports, |
844 exports = this.exports, |
845 exports = this.exports, |
845 factory = this.factory; |
846 factory = this.factory; |
846 |
847 |
847 if (!this.inited) { |
848 if (!this.inited) { |
848 this.fetch(); |
849 // Only fetch if not already in the defQueue. |
|
850 if (!hasProp(context.defQueueMap, id)) { |
|
851 this.fetch(); |
|
852 } |
849 } else if (this.error) { |
853 } else if (this.error) { |
850 this.emit('error', this.error); |
854 this.emit('error', this.error); |
851 } else if (!this.defining) { |
855 } else if (!this.defining) { |
852 //The factory could trigger another require call |
856 //The factory could trigger another require call |
853 //that would result in checking this module to |
857 //that would result in checking this module to |
1242 //args are id, deps, factory. Should be normalized by the |
1246 //args are id, deps, factory. Should be normalized by the |
1243 //define() function. |
1247 //define() function. |
1244 callGetModule(args); |
1248 callGetModule(args); |
1245 } |
1249 } |
1246 } |
1250 } |
|
1251 context.defQueueMap = {}; |
1247 } |
1252 } |
1248 |
1253 |
1249 context = { |
1254 context = { |
1250 config: config, |
1255 config: config, |
1251 contextName: contextName, |
1256 contextName: contextName, |
1252 registry: registry, |
1257 registry: registry, |
1253 defined: defined, |
1258 defined: defined, |
1254 urlFetched: urlFetched, |
1259 urlFetched: urlFetched, |
1255 defQueue: defQueue, |
1260 defQueue: defQueue, |
|
1261 defQueueMap: {}, |
1256 Module: Module, |
1262 Module: Module, |
1257 makeModuleMap: makeModuleMap, |
1263 makeModuleMap: makeModuleMap, |
1258 nextTick: req.nextTick, |
1264 nextTick: req.nextTick, |
1259 onError: onError, |
1265 onError: onError, |
1260 |
1266 |
1500 eachReverse(defQueue, function(args, i) { |
1506 eachReverse(defQueue, function(args, i) { |
1501 if (args[0] === id) { |
1507 if (args[0] === id) { |
1502 defQueue.splice(i, 1); |
1508 defQueue.splice(i, 1); |
1503 } |
1509 } |
1504 }); |
1510 }); |
|
1511 delete context.defQueueMap[id]; |
1505 |
1512 |
1506 if (mod) { |
1513 if (mod) { |
1507 //Hold on to listeners in case the |
1514 //Hold on to listeners in case the |
1508 //module will be attempted to be reloaded |
1515 //module will be attempted to be reloaded |
1509 //using a different config. |
1516 //using a different config. |
1855 var config = (context && context.config) || {}, |
1863 var config = (context && context.config) || {}, |
1856 node; |
1864 node; |
1857 if (isBrowser) { |
1865 if (isBrowser) { |
1858 //In the browser so use a script tag |
1866 //In the browser so use a script tag |
1859 node = req.createNode(config, moduleName, url); |
1867 node = req.createNode(config, moduleName, url); |
|
1868 if (config.onNodeCreated) { |
|
1869 config.onNodeCreated(node, config, moduleName, url); |
|
1870 } |
1860 |
1871 |
1861 node.setAttribute('data-requirecontext', context.contextName); |
1872 node.setAttribute('data-requirecontext', context.contextName); |
1862 node.setAttribute('data-requiremodule', moduleName); |
1873 node.setAttribute('data-requiremodule', moduleName); |
1863 |
1874 |
1864 //Set up load listener. Test attachEvent first because IE9 has |
1875 //Set up load listener. Test attachEvent first because IE9 has |
2062 //This allows multiple modules to be in a file without prematurely |
2073 //This allows multiple modules to be in a file without prematurely |
2063 //tracing dependencies, and allows for anonymous module support, |
2074 //tracing dependencies, and allows for anonymous module support, |
2064 //where the module name is not known until the script onload event |
2075 //where the module name is not known until the script onload event |
2065 //occurs. If no context, use the global queue, and get it processed |
2076 //occurs. If no context, use the global queue, and get it processed |
2066 //in the onscript load callback. |
2077 //in the onscript load callback. |
2067 (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); |
2078 if (context) { |
|
2079 context.defQueue.push([name, deps, callback]); |
|
2080 context.defQueueMap[name] = true; |
|
2081 } else { |
|
2082 globalDefQueue.push([name, deps, callback]); |
|
2083 } |
2068 }; |
2084 }; |
2069 |
2085 |
2070 define.amd = { |
2086 define.amd = { |
2071 jQuery: true |
2087 jQuery: true |
2072 }; |
2088 }; |