| 1 |
|
| 2 |
/** |
| 3 |
* almond dev0.2 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. |
| 4 |
* Available via the MIT or new BSD license. |
| 5 |
* see: http://github.com/jrburke/almond for details |
| 6 |
*/ |
| 7 |
//Going sloppy to avoid 'use strict' string cost, but strict practices should |
| 8 |
//be followed. |
| 9 |
/*jslint sloppy: true */ |
| 10 |
/*global setTimeout: false */ |
| 11 |
|
| 12 |
var requirejs, require, define; |
| 13 |
(function (undef) { |
| 14 |
var main, req, makeMap, |
| 15 |
defined = {}, |
| 16 |
waiting = {}, |
| 17 |
config = {}, |
| 18 |
defining = {}, |
| 19 |
aps = [].slice; |
| 20 |
|
| 21 |
/** |
| 22 |
* Given a relative module name, like ./something, normalize it to |
| 23 |
* a real name that can be mapped to a path. |
| 24 |
* @param {String} name the relative name |
| 25 |
* @param {String} baseName a real name that the name arg is relative |
| 26 |
* to. |
| 27 |
* @returns {String} normalized name |
| 28 |
*/ |
| 29 |
function normalize(name, baseName) { |
| 30 |
var nameParts, nameSegment, mapValue, foundMap, |
| 31 |
foundI, foundStarMap, starI, i, j, part, |
| 32 |
baseParts = baseName && baseName.split("/"), |
| 33 |
map = config.map, |
| 34 |
starMap = (map && map['*']) || {}; |
| 35 |
|
| 36 |
//Adjust any relative paths. |
| 37 |
if (name && name.charAt(0) === ".") { |
| 38 |
//If have a base name, try to normalize against it, |
| 39 |
//otherwise, assume it is a top-level require that will |
| 40 |
//be relative to baseUrl in the end. |
| 41 |
if (baseName) { |
| 42 |
//Convert baseName to array, and lop off the last part, |
| 43 |
//so that . matches that "directory" and not name of the baseName's |
| 44 |
//module. For instance, baseName of "one/two/three", maps to |
| 45 |
//"one/two/three.js", but we want the directory, "one/two" for |
| 46 |
//this normalization. |
| 47 |
baseParts = baseParts.slice(0, baseParts.length - 1); |
| 48 |
|
| 49 |
name = baseParts.concat(name.split("/")); |
| 50 |
|
| 51 |
//start trimDots |
| 52 |
for (i = 0; i < name.length; i += 1) { |
| 53 |
part = name[i]; |
| 54 |
if (part === ".") { |
| 55 |
name.splice(i, 1); |
| 56 |
i -= 1; |
| 57 |
} else if (part === "..") { |
| 58 |
if (i === 1 && (name[2] === '..' || name[0] === '..')) { |
| 59 |
//End of the line. Keep at least one non-dot |
| 60 |
//path segment at the front so it can be mapped |
| 61 |
//correctly to disk. Otherwise, there is likely |
| 62 |
//no path mapping for a path starting with '..'. |
| 63 |
//This can still fail, but catches the most reasonable |
| 64 |
//uses of .. |
| 65 |
break; |
| 66 |
} else if (i > 0) { |
| 67 |
name.splice(i - 1, 2); |
| 68 |
i -= 2; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
//end trimDots |
| 73 |
|
| 74 |
name = name.join("/"); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
//Apply map config if available. |
| 79 |
if ((baseParts || starMap) && map) { |
| 80 |
nameParts = name.split('/'); |
| 81 |
|
| 82 |
for (i = nameParts.length; i > 0; i -= 1) { |
| 83 |
nameSegment = nameParts.slice(0, i).join("/"); |
| 84 |
|
| 85 |
if (baseParts) { |
| 86 |
//Find the longest baseName segment match in the config. |
| 87 |
//So, do joins on the biggest to smallest lengths of baseParts. |
| 88 |
for (j = baseParts.length; j > 0; j -= 1) { |
| 89 |
mapValue = map[baseParts.slice(0, j).join('/')]; |
| 90 |
|
| 91 |
//baseName segment has config, find if it has one for |
| 92 |
//this name. |
| 93 |
if (mapValue) { |
| 94 |
mapValue = mapValue[nameSegment]; |
| 95 |
if (mapValue) { |
| 96 |
//Match, update name to the new value. |
| 97 |
foundMap = mapValue; |
| 98 |
foundI = i; |
| 99 |
break; |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
if (foundMap) { |
| 106 |
break; |
| 107 |
} |
| 108 |
|
| 109 |
//Check for a star map match, but just hold on to it, |
| 110 |
//if there is a shorter segment match later in a matching |
| 111 |
//config, then favor over this star map. |
| 112 |
if (!foundStarMap && starMap && starMap[nameSegment]) { |
| 113 |
foundStarMap = starMap[nameSegment]; |
| 114 |
starI = i; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
if (!foundMap && foundStarMap) { |
| 119 |
foundMap = foundStarMap; |
| 120 |
foundI = starI; |
| 121 |
} |
| 122 |
|
| 123 |
if (foundMap) { |
| 124 |
nameParts.splice(0, foundI, foundMap); |
| 125 |
name = nameParts.join('/'); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
return name; |
| 130 |
} |
| 131 |
|
| 132 |
function makeRequire(relName, forceSync) { |
| 133 |
return function () { |
| 134 |
//A version of a require function that passes a moduleName |
| 135 |
//value for items that may need to |
| 136 |
//look up paths relative to the moduleName |
| 137 |
return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync])); |
| 138 |
}; |
| 139 |
} |
| 140 |
|
| 141 |
function makeNormalize(relName) { |
| 142 |
return function (name) { |
| 143 |
return normalize(name, relName); |
| 144 |
}; |
| 145 |
} |
| 146 |
|
| 147 |
function makeLoad(depName) { |
| 148 |
return function (value) { |
| 149 |
defined[depName] = value; |
| 150 |
}; |
| 151 |
} |
| 152 |
|
| 153 |
function callDep(name) { |
| 154 |
if (waiting.hasOwnProperty(name)) { |
| 155 |
var args = waiting[name]; |
| 156 |
delete waiting[name]; |
| 157 |
defining[name] = true; |
| 158 |
main.apply(undef, args); |
| 159 |
} |
| 160 |
|
| 161 |
if (!defined.hasOwnProperty(name)) { |
| 162 |
throw new Error('No ' + name); |
| 163 |
} |
| 164 |
return defined[name]; |
| 165 |
} |
| 166 |
|
| 167 |
//Turns a plugin!resource to [plugin, resource] |
| 168 |
//with the plugin being undefined if the name |
| 169 |
//did not have a plugin prefix. |
| 170 |
function splitPrefix(name) { |
| 171 |
var prefix, |
| 172 |
index = name ? name.indexOf('!') : -1; |
| 173 |
if (index > -1) { |
| 174 |
prefix = name.substring(0, index); |
| 175 |
name = name.substring(index + 1, name.length); |
| 176 |
} |
| 177 |
return [prefix, name]; |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Makes a name map, normalizing the name, and using a plugin |
| 182 |
* for normalization if necessary. Grabs a ref to plugin |
| 183 |
* too, as an optimization. |
| 184 |
*/ |
| 185 |
makeMap = function (name, relName) { |
| 186 |
var plugin, |
| 187 |
parts = splitPrefix(name), |
| 188 |
prefix = parts[0]; |
| 189 |
|
| 190 |
name = parts[1]; |
| 191 |
|
| 192 |
if (prefix) { |
| 193 |
prefix = normalize(prefix, relName); |
| 194 |
plugin = callDep(prefix); |
| 195 |
} |
| 196 |
|
| 197 |
//Normalize according |
| 198 |
if (prefix) { |
| 199 |
if (plugin && plugin.normalize) { |
| 200 |
name = plugin.normalize(name, makeNormalize(relName)); |
| 201 |
} else { |
| 202 |
name = normalize(name, relName); |
| 203 |
} |
| 204 |
} else { |
| 205 |
name = normalize(name, relName); |
| 206 |
parts = splitPrefix(name); |
| 207 |
prefix = parts[0]; |
| 208 |
name = parts[1]; |
| 209 |
if (prefix) { |
| 210 |
plugin = callDep(prefix); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
//Using ridiculous property names for space reasons |
| 215 |
return { |
| 216 |
f: prefix ? prefix + '!' + name : name, //fullName |
| 217 |
n: name, |
| 218 |
pr: prefix, |
| 219 |
p: plugin |
| 220 |
}; |
| 221 |
}; |
| 222 |
|
| 223 |
function makeConfig(name) { |
| 224 |
return function () { |
| 225 |
return (config && config.config && config.config[name]) || {}; |
| 226 |
}; |
| 227 |
} |
| 228 |
|
| 229 |
main = function (name, deps, callback, relName) { |
| 230 |
var cjsModule, depName, ret, map, i, |
| 231 |
args = [], |
| 232 |
usingExports; |
| 233 |
|
| 234 |
//Use name if no relName |
| 235 |
relName = relName || name; |
| 236 |
|
| 237 |
//Call the callback to define the module, if necessary. |
| 238 |
if (typeof callback === 'function') { |
| 239 |
|
| 240 |
//Pull out the defined dependencies and pass the ordered |
| 241 |
//values to the callback. |
| 242 |
//Default to [require, exports, module] if no deps |
| 243 |
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; |
| 244 |
for (i = 0; i < deps.length; i += 1) { |
| 245 |
map = makeMap(deps[i], relName); |
| 246 |
depName = map.f; |
| 247 |
|
| 248 |
//Fast path CommonJS standard dependencies. |
| 249 |
if (depName === "require") { |
| 250 |
args[i] = makeRequire(name); |
| 251 |
} else if (depName === "exports") { |
| 252 |
//CommonJS module spec 1.1 |
| 253 |
args[i] = defined[name] = {}; |
| 254 |
usingExports = true; |
| 255 |
} else if (depName === "module") { |
| 256 |
//CommonJS module spec 1.1 |
| 257 |
cjsModule = args[i] = { |
| 258 |
id: name, |
| 259 |
uri: '', |
| 260 |
exports: defined[name], |
| 261 |
config: makeConfig(name) |
| 262 |
}; |
| 263 |
} else if (defined.hasOwnProperty(depName) || waiting.hasOwnProperty(depName)) { |
| 264 |
args[i] = callDep(depName); |
| 265 |
} else if (map.p) { |
| 266 |
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); |
| 267 |
args[i] = defined[depName]; |
| 268 |
} else if (!defining[depName]) { |
| 269 |
throw new Error(name + ' missing ' + depName); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
ret = callback.apply(defined[name], args); |
| 274 |
|
| 275 |
if (name) { |
| 276 |
//If setting exports via "module" is in play, |
| 277 |
//favor that over return value and exports. After that, |
| 278 |
//favor a non-undefined return value over exports use. |
| 279 |
if (cjsModule && cjsModule.exports !== undef && |
| 280 |
cjsModule.exports !== defined[name]) { |
| 281 |
defined[name] = cjsModule.exports; |
| 282 |
} else if (ret !== undef || !usingExports) { |
| 283 |
//Use the return value from the function. |
| 284 |
defined[name] = ret; |
| 285 |
} |
| 286 |
} |
| 287 |
} else if (name) { |
| 288 |
//May just be an object definition for the module. Only |
| 289 |
//worry about defining if have a module name. |
| 290 |
defined[name] = callback; |
| 291 |
} |
| 292 |
}; |
| 293 |
|
| 294 |
requirejs = require = req = function (deps, callback, relName, forceSync, alt) { |
| 295 |
if (typeof deps === "string") { |
| 296 |
//Just return the module wanted. In this scenario, the |
| 297 |
//deps arg is the module name, and second arg (if passed) |
| 298 |
//is just the relName. |
| 299 |
//Normalize module name, if it contains . or .. |
| 300 |
return callDep(makeMap(deps, callback).f); |
| 301 |
} else if (!deps.splice) { |
| 302 |
//deps is a config object, not an array. |
| 303 |
config = deps; |
| 304 |
if (callback.splice) { |
| 305 |
//callback is an array, which means it is a dependency list. |
| 306 |
//Adjust args if there are dependencies |
| 307 |
deps = callback; |
| 308 |
callback = relName; |
| 309 |
relName = null; |
| 310 |
} else { |
| 311 |
deps = undef; |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
//Support require(['a']) |
| 316 |
callback = callback || function () {}; |
| 317 |
|
| 318 |
//If relName is a function, it is an errback handler, |
| 319 |
//so remove it. |
| 320 |
if (typeof relName === 'function') { |
| 321 |
relName = forceSync; |
| 322 |
forceSync = alt; |
| 323 |
} |
| 324 |
|
| 325 |
//Simulate async callback; |
| 326 |
if (forceSync) { |
| 327 |
main(undef, deps, callback, relName); |
| 328 |
} else { |
| 329 |
setTimeout(function () { |
| 330 |
main(undef, deps, callback, relName); |
| 331 |
}, 15); |
| 332 |
} |
| 333 |
|
| 334 |
return req; |
| 335 |
}; |
| 336 |
|
| 337 |
/** |
| 338 |
* Just drops the config on the floor, but returns req in case |
| 339 |
* the config return value is used. |
| 340 |
*/ |
| 341 |
req.config = function (cfg) { |
| 342 |
config = cfg; |
| 343 |
return req; |
| 344 |
}; |
| 345 |
|
| 346 |
define = function (name, deps, callback) { |
| 347 |
|
| 348 |
//This module may not have dependencies |
| 349 |
if (!deps.splice) { |
| 350 |
//deps is not an array, so probably means |
| 351 |
//an object literal or factory function for |
| 352 |
//the value. Adjust args. |
| 353 |
callback = deps; |
| 354 |
deps = []; |
| 355 |
} |
| 356 |
|
| 357 |
waiting[name] = [name, deps, callback]; |
| 358 |
}; |
| 359 |
|
| 360 |
define.amd = { |
| 361 |
jQuery: true |
| 362 |
}; |
| 363 |
}()); |
| 364 |
|
| 365 |
define("../../../almond", function(){}); |
| 366 |
|
| 367 |
/** |
| 368 |
* @license RequireJS order 1.0.5 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. |
| 369 |
* Available via the MIT or new BSD license. |
| 370 |
* see: http://github.com/jrburke/requirejs for details |
| 371 |
*/ |
| 372 |
/*jslint nomen: false, plusplus: false, strict: false */ |
| 373 |
/*global require: false, define: false, window: false, document: false, |
| 374 |
setTimeout: false */ |
| 375 |
|
| 376 |
//Specify that requirejs optimizer should wrap this code in a closure that |
| 377 |
//maps the namespaced requirejs API to non-namespaced local variables. |
| 378 |
/*requirejs namespace: true */ |
| 379 |
|
| 380 |
(function () { |
| 381 |
|
| 382 |
//Sadly necessary browser inference due to differences in the way |
| 383 |
//that browsers load and execute dynamically inserted javascript |
| 384 |
//and whether the script/cache method works when ordered execution is |
| 385 |
//desired. Currently, Gecko and Opera do not load/fire onload for scripts with |
| 386 |
//type="script/cache" but they execute injected scripts in order |
| 387 |
//unless the 'async' flag is present. |
| 388 |
//However, this is all changing in latest browsers implementing HTML5 |
| 389 |
//spec. With compliant browsers .async true by default, and |
| 390 |
//if false, then it will execute in order. Favor that test first for forward |
| 391 |
//compatibility. |
| 392 |
var testScript = typeof document !== "undefined" && |
| 393 |
typeof window !== "undefined" && |
| 394 |
document.createElement("script"), |
| 395 |
|
| 396 |
supportsInOrderExecution = testScript && (testScript.async || |
| 397 |
((window.opera && |
| 398 |
Object.prototype.toString.call(window.opera) === "[object Opera]") || |
| 399 |
//If Firefox 2 does not have to be supported, then |
| 400 |
//a better check may be: |
| 401 |
//('mozIsLocallyAvailable' in window.navigator) |
| 402 |
("MozAppearance" in document.documentElement.style))), |
| 403 |
|
| 404 |
//This test is true for IE browsers, which will load scripts but only |
| 405 |
//execute them once the script is added to the DOM. |
| 406 |
supportsLoadSeparateFromExecute = testScript && |
| 407 |
testScript.readyState === 'uninitialized', |
| 408 |
|
| 409 |
readyRegExp = /^(complete|loaded)$/, |
| 410 |
cacheWaiting = [], |
| 411 |
cached = {}, |
| 412 |
scriptNodes = {}, |
| 413 |
scriptWaiting = []; |
| 414 |
|
| 415 |
//Done with the test script. |
| 416 |
testScript = null; |
| 417 |
|
| 418 |
//Callback used by the type="script/cache" callback that indicates a script |
| 419 |
//has finished downloading. |
| 420 |
function scriptCacheCallback(evt) { |
| 421 |
var node = evt.currentTarget || evt.srcElement, i, |
| 422 |
moduleName, resource; |
| 423 |
|
| 424 |
if (evt.type === "load" || readyRegExp.test(node.readyState)) { |
| 425 |
//Pull out the name of the module and the context. |
| 426 |
moduleName = node.getAttribute("data-requiremodule"); |
| 427 |
|
| 428 |
//Mark this cache request as loaded |
| 429 |
cached[moduleName] = true; |
| 430 |
|
| 431 |
//Find out how many ordered modules have loaded |
| 432 |
for (i = 0; (resource = cacheWaiting[i]); i++) { |
| 433 |
if (cached[resource.name]) { |
| 434 |
resource.req([resource.name], resource.onLoad); |
| 435 |
} else { |
| 436 |
//Something in the ordered list is not loaded, |
| 437 |
//so wait. |
| 438 |
break; |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
//If just loaded some items, remove them from cacheWaiting. |
| 443 |
if (i > 0) { |
| 444 |
cacheWaiting.splice(0, i); |
| 445 |
} |
| 446 |
|
| 447 |
//Remove this script tag from the DOM |
| 448 |
//Use a setTimeout for cleanup because some older IE versions vomit |
| 449 |
//if removing a script node while it is being evaluated. |
| 450 |
setTimeout(function () { |
| 451 |
node.parentNode.removeChild(node); |
| 452 |
}, 15); |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
/** |
| 457 |
* Used for the IE case, where fetching is done by creating script element |
| 458 |
* but not attaching it to the DOM. This function will be called when that |
| 459 |
* happens so it can be determined when the node can be attached to the |
| 460 |
* DOM to trigger its execution. |
| 461 |
*/ |
| 462 |
function onFetchOnly(node) { |
| 463 |
var i, loadedNode, resourceName; |
| 464 |
|
| 465 |
//Mark this script as loaded. |
| 466 |
node.setAttribute('data-orderloaded', 'loaded'); |
| 467 |
|
| 468 |
//Cycle through waiting scripts. If the matching node for them |
| 469 |
//is loaded, and is in the right order, add it to the DOM |
| 470 |
//to execute the script. |
| 471 |
for (i = 0; (resourceName = scriptWaiting[i]); i++) { |
| 472 |
loadedNode = scriptNodes[resourceName]; |
| 473 |
if (loadedNode && |
| 474 |
loadedNode.getAttribute('data-orderloaded') === 'loaded') { |
| 475 |
delete scriptNodes[resourceName]; |
| 476 |
require.addScriptToDom(loadedNode); |
| 477 |
} else { |
| 478 |
break; |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
//If just loaded some items, remove them from waiting. |
| 483 |
if (i > 0) { |
| 484 |
scriptWaiting.splice(0, i); |
| 485 |
} |
| 486 |
} |
| 487 |
|
| 488 |
define('order',{ |
| 489 |
version: '1.0.5', |
| 490 |
|
| 491 |
load: function (name, req, onLoad, config) { |
| 492 |
var hasToUrl = !!req.nameToUrl, |
| 493 |
url, node, context; |
| 494 |
|
| 495 |
//If no nameToUrl, then probably a build with a loader that |
| 496 |
//does not support it, and all modules are inlined. |
| 497 |
if (!hasToUrl) { |
| 498 |
req([name], onLoad); |
| 499 |
return; |
| 500 |
} |
| 501 |
|
| 502 |
url = req.nameToUrl(name, null); |
| 503 |
|
| 504 |
//Make sure the async attribute is not set for any pathway involving |
| 505 |
//this script. |
| 506 |
require.s.skipAsync[url] = true; |
| 507 |
if (supportsInOrderExecution || config.isBuild) { |
| 508 |
//Just a normal script tag append, but without async attribute |
| 509 |
//on the script. |
| 510 |
req([name], onLoad); |
| 511 |
} else if (supportsLoadSeparateFromExecute) { |
| 512 |
//Just fetch the URL, but do not execute it yet. The |
| 513 |
//non-standards IE case. Really not so nice because it is |
| 514 |
//assuming and touching requrejs internals. OK though since |
| 515 |
//ordered execution should go away after a long while. |
| 516 |
context = require.s.contexts._; |
| 517 |
|
| 518 |
if (!context.urlFetched[url] && !context.loaded[name]) { |
| 519 |
//Indicate the script is being fetched. |
| 520 |
context.urlFetched[url] = true; |
| 521 |
|
| 522 |
//Stuff from require.load |
| 523 |
require.resourcesReady(false); |
| 524 |
context.scriptCount += 1; |
| 525 |
|
| 526 |
//Fetch the script now, remember it. |
| 527 |
node = require.attach(url, context, name, null, null, onFetchOnly); |
| 528 |
scriptNodes[name] = node; |
| 529 |
scriptWaiting.push(name); |
| 530 |
} |
| 531 |
|
| 532 |
//Do a normal require for it, once it loads, use it as return |
| 533 |
//value. |
| 534 |
req([name], onLoad); |
| 535 |
} else { |
| 536 |
//Credit to LABjs author Kyle Simpson for finding that scripts |
| 537 |
//with type="script/cache" allow scripts to be downloaded into |
| 538 |
//browser cache but not executed. Use that |
| 539 |
//so that subsequent addition of a real type="text/javascript" |
| 540 |
//tag will cause the scripts to be executed immediately in the |
| 541 |
//correct order. |
| 542 |
if (req.specified(name)) { |
| 543 |
req([name], onLoad); |
| 544 |
} else { |
| 545 |
cacheWaiting.push({ |
| 546 |
name: name, |
| 547 |
req: req, |
| 548 |
onLoad: onLoad |
| 549 |
}); |
| 550 |
require.attach(url, null, name, scriptCacheCallback, "script/cache"); |
| 551 |
} |
| 552 |
} |
| 553 |
} |
| 554 |
}); |
| 555 |
}()); |
| 556 |
|
| 557 |
var one = { |
| 558 |
name: 'one' |
| 559 |
}; |
| 560 |
|
| 561 |
define("one", function(){}); |
| 562 |
|
| 563 |
var two = { |
| 564 |
name: 'two', |
| 565 |
oneName: one.name |
| 566 |
}; |
| 567 |
|
| 568 |
define("two", function(){}); |