| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
var requirejs, require, define; |
| 10 |
(function (undefined) { |
| 11 |
|
| 12 |
var version = "1.0.8", |
| 13 |
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, |
| 14 |
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g, |
| 15 |
currDirRegExp = /^\.\//, |
| 16 |
jsSuffixRegExp = /\.js$/, |
| 17 |
ostring = Object.prototype.toString, |
| 18 |
ap = Array.prototype, |
| 19 |
aps = ap.slice, |
| 20 |
apsp = ap.splice, |
| 21 |
isBrowser = !!(typeof window !== "undefined" && navigator && document), |
| 22 |
isWebWorker = !isBrowser && typeof importScripts !== "undefined", |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? |
| 28 |
/^complete$/ : /^(complete|loaded)$/, |
| 29 |
defContextName = "_", |
| 30 |
|
| 31 |
isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]", |
| 32 |
empty = {}, |
| 33 |
contexts = {}, |
| 34 |
globalDefQueue = [], |
| 35 |
interactiveScript = null, |
| 36 |
checkLoadedDepth = 0, |
| 37 |
useInteractive = false, |
| 38 |
reservedDependencies = { |
| 39 |
require: true, |
| 40 |
module: true, |
| 41 |
exports: true |
| 42 |
}, |
| 43 |
req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script, |
| 44 |
src, subPath, mainScript, dataMain, globalI, ctx, jQueryCheck, checkLoadedTimeoutId; |
| 45 |
|
| 46 |
function isFunction(it) { |
| 47 |
return ostring.call(it) === "[object Function]"; |
| 48 |
} |
| 49 |
|
| 50 |
function isArray(it) { |
| 51 |
return ostring.call(it) === "[object Array]"; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
function mixin(target, source, force) { |
| 62 |
for (var prop in source) { |
| 63 |
if (!(prop in empty) && (!(prop in target) || force)) { |
| 64 |
target[prop] = source[prop]; |
| 65 |
} |
| 66 |
} |
| 67 |
return req; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
function makeError(id, msg, err) { |
| 79 |
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); |
| 80 |
if (err) { |
| 81 |
e.originalError = err; |
| 82 |
} |
| 83 |
return e; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
function configurePackageDir(pkgs, currentPackages, dir) { |
| 93 |
var i, location, pkgObj; |
| 94 |
|
| 95 |
for (i = 0; (pkgObj = currentPackages[i]); i++) { |
| 96 |
pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj; |
| 97 |
location = pkgObj.location; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) { |
| 102 |
location = dir + "/" + (location || pkgObj.name); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
pkgs[pkgObj.name] = { |
| 109 |
name: pkgObj.name, |
| 110 |
location: location || pkgObj.name, |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
main: (pkgObj.main || "main") |
| 116 |
.replace(currDirRegExp, '') |
| 117 |
.replace(jsSuffixRegExp, '') |
| 118 |
}; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
function jQueryHoldReady($, shouldHold) { |
| 129 |
if ($.holdReady) { |
| 130 |
$.holdReady(shouldHold); |
| 131 |
} else if (shouldHold) { |
| 132 |
$.readyWait += 1; |
| 133 |
} else { |
| 134 |
$.ready(true); |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
if (typeof define !== "undefined") { |
| 139 |
|
| 140 |
|
| 141 |
return; |
| 142 |
} |
| 143 |
|
| 144 |
if (typeof requirejs !== "undefined") { |
| 145 |
if (isFunction(requirejs)) { |
| 146 |
|
| 147 |
return; |
| 148 |
} else { |
| 149 |
cfg = requirejs; |
| 150 |
requirejs = undefined; |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
if (typeof require !== "undefined" && !isFunction(require)) { |
| 156 |
|
| 157 |
cfg = require; |
| 158 |
require = undefined; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
function newContext(contextName) { |
| 172 |
var context, resume, |
| 173 |
config = { |
| 174 |
waitSeconds: 7, |
| 175 |
baseUrl: "./", |
| 176 |
paths: {}, |
| 177 |
pkgs: {}, |
| 178 |
catchError: {} |
| 179 |
}, |
| 180 |
defQueue = [], |
| 181 |
specified = { |
| 182 |
"require": true, |
| 183 |
"exports": true, |
| 184 |
"module": true |
| 185 |
}, |
| 186 |
urlMap = {}, |
| 187 |
defined = {}, |
| 188 |
loaded = {}, |
| 189 |
waiting = {}, |
| 190 |
waitAry = [], |
| 191 |
urlFetched = {}, |
| 192 |
managerCounter = 0, |
| 193 |
managerCallbacks = {}, |
| 194 |
plugins = {}, |
| 195 |
|
| 196 |
|
| 197 |
needFullExec = {}, |
| 198 |
fullExec = {}, |
| 199 |
resumeDepth = 0; |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
function trimDots(ary) { |
| 211 |
var i, part; |
| 212 |
for (i = 0; (part = ary[i]); i++) { |
| 213 |
if (part === ".") { |
| 214 |
ary.splice(i, 1); |
| 215 |
i -= 1; |
| 216 |
} else if (part === "..") { |
| 217 |
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
break; |
| 225 |
} else if (i > 0) { |
| 226 |
ary.splice(i - 1, 2); |
| 227 |
i -= 2; |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
function normalize(name, baseName) { |
| 242 |
var pkgName, pkgConfig; |
| 243 |
|
| 244 |
|
| 245 |
if (name && name.charAt(0) === ".") { |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
if (baseName) { |
| 250 |
if (config.pkgs[baseName]) { |
| 251 |
|
| 252 |
|
| 253 |
baseName = [baseName]; |
| 254 |
} else { |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
baseName = baseName.split("/"); |
| 261 |
baseName = baseName.slice(0, baseName.length - 1); |
| 262 |
} |
| 263 |
|
| 264 |
name = baseName.concat(name.split("/")); |
| 265 |
trimDots(name); |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
pkgConfig = config.pkgs[(pkgName = name[0])]; |
| 270 |
name = name.join("/"); |
| 271 |
if (pkgConfig && name === pkgName + '/' + pkgConfig.main) { |
| 272 |
name = pkgName; |
| 273 |
} |
| 274 |
} else if (name.indexOf("./") === 0) { |
| 275 |
|
| 276 |
|
| 277 |
name = name.substring(2); |
| 278 |
} |
| 279 |
} |
| 280 |
return name; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
function makeModuleMap(name, parentModuleMap) { |
| 295 |
var index = name ? name.indexOf("!") : -1, |
| 296 |
prefix = null, |
| 297 |
parentName = parentModuleMap ? parentModuleMap.name : null, |
| 298 |
originalName = name, |
| 299 |
normalizedName, url, pluginModule; |
| 300 |
|
| 301 |
if (index !== -1) { |
| 302 |
prefix = name.substring(0, index); |
| 303 |
name = name.substring(index + 1, name.length); |
| 304 |
} |
| 305 |
|
| 306 |
if (prefix) { |
| 307 |
prefix = normalize(prefix, parentName); |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
if (name) { |
| 312 |
if (prefix) { |
| 313 |
pluginModule = defined[prefix]; |
| 314 |
if (pluginModule && pluginModule.normalize) { |
| 315 |
|
| 316 |
normalizedName = pluginModule.normalize(name, function (name) { |
| 317 |
return normalize(name, parentName); |
| 318 |
}); |
| 319 |
} else { |
| 320 |
normalizedName = normalize(name, parentName); |
| 321 |
} |
| 322 |
} else { |
| 323 |
|
| 324 |
normalizedName = normalize(name, parentName); |
| 325 |
|
| 326 |
url = urlMap[normalizedName]; |
| 327 |
if (!url) { |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
url = context.nameToUrl(name, null, parentModuleMap); |
| 338 |
|
| 339 |
|
| 340 |
urlMap[normalizedName] = url; |
| 341 |
} |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
return { |
| 346 |
prefix: prefix, |
| 347 |
name: normalizedName, |
| 348 |
parentMap: parentModuleMap, |
| 349 |
url: url, |
| 350 |
originalName: originalName, |
| 351 |
fullName: prefix ? prefix + "!" + (normalizedName || '') : normalizedName |
| 352 |
}; |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
function isPriorityDone() { |
| 359 |
var priorityDone = true, |
| 360 |
priorityWait = config.priorityWait, |
| 361 |
priorityName, i; |
| 362 |
if (priorityWait) { |
| 363 |
for (i = 0; (priorityName = priorityWait[i]); i++) { |
| 364 |
if (!loaded[priorityName]) { |
| 365 |
priorityDone = false; |
| 366 |
break; |
| 367 |
} |
| 368 |
} |
| 369 |
if (priorityDone) { |
| 370 |
delete config.priorityWait; |
| 371 |
} |
| 372 |
} |
| 373 |
return priorityDone; |
| 374 |
} |
| 375 |
|
| 376 |
function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) { |
| 377 |
return function () { |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
var args = aps.call(arguments, 0), lastArg; |
| 382 |
if (enableBuildCallback && |
| 383 |
isFunction((lastArg = args[args.length - 1]))) { |
| 384 |
lastArg.__requireJsBuild = true; |
| 385 |
} |
| 386 |
args.push(relModuleMap); |
| 387 |
return func.apply(null, args); |
| 388 |
}; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
function makeRequire(relModuleMap, enableBuildCallback, altRequire) { |
| 398 |
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback); |
| 399 |
|
| 400 |
mixin(modRequire, { |
| 401 |
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap), |
| 402 |
toUrl: makeContextModuleFunc(context.toUrl, relModuleMap), |
| 403 |
defined: makeContextModuleFunc(context.requireDefined, relModuleMap), |
| 404 |
specified: makeContextModuleFunc(context.requireSpecified, relModuleMap), |
| 405 |
isBrowser: req.isBrowser |
| 406 |
}); |
| 407 |
return modRequire; |
| 408 |
} |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
function queueDependency(manager) { |
| 416 |
context.paused.push(manager); |
| 417 |
} |
| 418 |
|
| 419 |
function execManager(manager) { |
| 420 |
var i, ret, err, errFile, errModuleTree, |
| 421 |
cb = manager.callback, |
| 422 |
map = manager.map, |
| 423 |
fullName = map.fullName, |
| 424 |
args = manager.deps, |
| 425 |
listeners = manager.listeners, |
| 426 |
execCb = config.requireExecCb || req.execCb, |
| 427 |
cjsModule; |
| 428 |
|
| 429 |
|
| 430 |
if (cb && isFunction(cb)) { |
| 431 |
if (config.catchError.define) { |
| 432 |
try { |
| 433 |
ret = execCb(fullName, manager.callback, args, defined[fullName]); |
| 434 |
} catch (e) { |
| 435 |
err = e; |
| 436 |
} |
| 437 |
} else { |
| 438 |
ret = execCb(fullName, manager.callback, args, defined[fullName]); |
| 439 |
} |
| 440 |
|
| 441 |
if (fullName) { |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
cjsModule = manager.cjsModule; |
| 446 |
if (cjsModule && |
| 447 |
cjsModule.exports !== undefined && |
| 448 |
|
| 449 |
cjsModule.exports !== defined[fullName]) { |
| 450 |
ret = defined[fullName] = manager.cjsModule.exports; |
| 451 |
} else if (ret === undefined && manager.usingExports) { |
| 452 |
|
| 453 |
ret = defined[fullName]; |
| 454 |
} else { |
| 455 |
|
| 456 |
defined[fullName] = ret; |
| 457 |
|
| 458 |
|
| 459 |
if (needFullExec[fullName]) { |
| 460 |
fullExec[fullName] = true; |
| 461 |
} |
| 462 |
} |
| 463 |
} |
| 464 |
} else if (fullName) { |
| 465 |
|
| 466 |
|
| 467 |
ret = defined[fullName] = cb; |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
if (needFullExec[fullName]) { |
| 472 |
fullExec[fullName] = true; |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
if (waiting[manager.id]) { |
| 482 |
delete waiting[manager.id]; |
| 483 |
manager.isDone = true; |
| 484 |
context.waitCount -= 1; |
| 485 |
if (context.waitCount === 0) { |
| 486 |
|
| 487 |
waitAry = []; |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
delete managerCallbacks[fullName]; |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
if (req.onResourceLoad && !manager.placeholder) { |
| 497 |
req.onResourceLoad(context, map, manager.depArray); |
| 498 |
} |
| 499 |
|
| 500 |
if (err) { |
| 501 |
errFile = (fullName ? makeModuleMap(fullName).url : '') || |
| 502 |
err.fileName || err.sourceURL; |
| 503 |
errModuleTree = err.moduleTree; |
| 504 |
err = makeError('defineerror', 'Error evaluating ' + |
| 505 |
'module "' + fullName + '" at location "' + |
| 506 |
errFile + '":\n' + |
| 507 |
err + '\nfileName:' + errFile + |
| 508 |
'\nlineNumber: ' + (err.lineNumber || err.line), err); |
| 509 |
err.moduleName = fullName; |
| 510 |
err.moduleTree = errModuleTree; |
| 511 |
return req.onError(err); |
| 512 |
} |
| 513 |
|
| 514 |
|
| 515 |
for (i = 0; (cb = listeners[i]); i++) { |
| 516 |
cb(ret); |
| 517 |
} |
| 518 |
|
| 519 |
return undefined; |
| 520 |
} |
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
function makeArgCallback(manager, i) { |
| 528 |
return function (value) { |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
if (!manager.depDone[i]) { |
| 534 |
manager.depDone[i] = true; |
| 535 |
manager.deps[i] = value; |
| 536 |
manager.depCount -= 1; |
| 537 |
if (!manager.depCount) { |
| 538 |
|
| 539 |
execManager(manager); |
| 540 |
} |
| 541 |
} |
| 542 |
}; |
| 543 |
} |
| 544 |
|
| 545 |
function callPlugin(pluginName, depManager) { |
| 546 |
var map = depManager.map, |
| 547 |
fullName = map.fullName, |
| 548 |
name = map.name, |
| 549 |
plugin = plugins[pluginName] || |
| 550 |
(plugins[pluginName] = defined[pluginName]), |
| 551 |
load; |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
if (depManager.loading) { |
| 556 |
return; |
| 557 |
} |
| 558 |
depManager.loading = true; |
| 559 |
|
| 560 |
load = function (ret) { |
| 561 |
depManager.callback = function () { |
| 562 |
return ret; |
| 563 |
}; |
| 564 |
execManager(depManager); |
| 565 |
|
| 566 |
loaded[depManager.id] = true; |
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
resume(); |
| 574 |
}; |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
load.fromText = function (moduleName, text) { |
| 579 |
|
| 580 |
var hasInteractive = useInteractive; |
| 581 |
|
| 582 |
|
| 583 |
loaded[moduleName] = false; |
| 584 |
context.scriptCount += 1; |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
context.fake[moduleName] = true; |
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
if (hasInteractive) { |
| 593 |
useInteractive = false; |
| 594 |
} |
| 595 |
|
| 596 |
req.exec(text); |
| 597 |
|
| 598 |
if (hasInteractive) { |
| 599 |
useInteractive = true; |
| 600 |
} |
| 601 |
|
| 602 |
|
| 603 |
context.completeLoad(moduleName); |
| 604 |
}; |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
if (fullName in defined) { |
| 609 |
load(defined[fullName]); |
| 610 |
} else { |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
plugin.load(name, makeRequire(map.parentMap, true, function (deps, cb) { |
| 615 |
var moduleDeps = [], |
| 616 |
i, dep, depMap; |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
for (i = 0; (dep = deps[i]); i++) { |
| 621 |
depMap = makeModuleMap(dep, map.parentMap); |
| 622 |
deps[i] = depMap.fullName; |
| 623 |
if (!depMap.prefix) { |
| 624 |
moduleDeps.push(deps[i]); |
| 625 |
} |
| 626 |
} |
| 627 |
depManager.moduleDeps = (depManager.moduleDeps || []).concat(moduleDeps); |
| 628 |
return context.require(deps, cb); |
| 629 |
}), load, config); |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
function addWait(manager) { |
| 638 |
if (!waiting[manager.id]) { |
| 639 |
waiting[manager.id] = manager; |
| 640 |
waitAry.push(manager); |
| 641 |
context.waitCount += 1; |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
function managerAdd(cb) { |
| 650 |
this.listeners.push(cb); |
| 651 |
} |
| 652 |
|
| 653 |
function getManager(map, shouldQueue) { |
| 654 |
var fullName = map.fullName, |
| 655 |
prefix = map.prefix, |
| 656 |
plugin = prefix ? plugins[prefix] || |
| 657 |
(plugins[prefix] = defined[prefix]) : null, |
| 658 |
manager, created, pluginManager, prefixMap; |
| 659 |
|
| 660 |
if (fullName) { |
| 661 |
manager = managerCallbacks[fullName]; |
| 662 |
} |
| 663 |
|
| 664 |
if (!manager) { |
| 665 |
created = true; |
| 666 |
manager = { |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
id: (prefix && !plugin ? |
| 671 |
(managerCounter++) + '__p@:' : '') + |
| 672 |
(fullName || '__r@' + (managerCounter++)), |
| 673 |
map: map, |
| 674 |
depCount: 0, |
| 675 |
depDone: [], |
| 676 |
depCallbacks: [], |
| 677 |
deps: [], |
| 678 |
listeners: [], |
| 679 |
add: managerAdd |
| 680 |
}; |
| 681 |
|
| 682 |
specified[manager.id] = true; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
if (fullName && (!prefix || plugins[prefix])) { |
| 689 |
managerCallbacks[fullName] = manager; |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
if (prefix && !plugin) { |
| 696 |
prefixMap = makeModuleMap(prefix); |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
if (prefix in defined && !defined[prefix]) { |
| 703 |
delete defined[prefix]; |
| 704 |
delete urlFetched[prefixMap.url]; |
| 705 |
} |
| 706 |
|
| 707 |
pluginManager = getManager(prefixMap, true); |
| 708 |
pluginManager.add(function (plugin) { |
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
var newMap = makeModuleMap(map.originalName, map.parentMap), |
| 713 |
normalizedManager = getManager(newMap, true); |
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
manager.placeholder = true; |
| 719 |
|
| 720 |
normalizedManager.add(function (resource) { |
| 721 |
manager.callback = function () { |
| 722 |
return resource; |
| 723 |
}; |
| 724 |
execManager(manager); |
| 725 |
}); |
| 726 |
}); |
| 727 |
} else if (created && shouldQueue) { |
| 728 |
|
| 729 |
|
| 730 |
loaded[manager.id] = false; |
| 731 |
queueDependency(manager); |
| 732 |
addWait(manager); |
| 733 |
} |
| 734 |
|
| 735 |
return manager; |
| 736 |
} |
| 737 |
|
| 738 |
function main(inName, depArray, callback, relModuleMap) { |
| 739 |
var moduleMap = makeModuleMap(inName, relModuleMap), |
| 740 |
name = moduleMap.name, |
| 741 |
fullName = moduleMap.fullName, |
| 742 |
manager = getManager(moduleMap), |
| 743 |
id = manager.id, |
| 744 |
deps = manager.deps, |
| 745 |
i, depArg, depName, depPrefix, cjsMod; |
| 746 |
|
| 747 |
if (fullName) { |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
if (fullName in defined || loaded[id] === true || |
| 752 |
(fullName === "jquery" && config.jQuery && |
| 753 |
config.jQuery !== callback().fn.jquery)) { |
| 754 |
return; |
| 755 |
} |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
specified[id] = true; |
| 762 |
loaded[id] = true; |
| 763 |
|
| 764 |
|
| 765 |
if (fullName === "jquery" && callback) { |
| 766 |
jQueryCheck(callback()); |
| 767 |
} |
| 768 |
} |
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
manager.depArray = depArray; |
| 775 |
manager.callback = callback; |
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
for (i = 0; i < depArray.length; i++) { |
| 780 |
depArg = depArray[i]; |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
if (depArg) { |
| 785 |
|
| 786 |
depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap)); |
| 787 |
depName = depArg.fullName; |
| 788 |
depPrefix = depArg.prefix; |
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
depArray[i] = depName; |
| 793 |
|
| 794 |
|
| 795 |
if (depName === "require") { |
| 796 |
deps[i] = makeRequire(moduleMap); |
| 797 |
} else if (depName === "exports") { |
| 798 |
|
| 799 |
deps[i] = defined[fullName] = {}; |
| 800 |
manager.usingExports = true; |
| 801 |
} else if (depName === "module") { |
| 802 |
|
| 803 |
manager.cjsModule = cjsMod = deps[i] = { |
| 804 |
id: name, |
| 805 |
uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined, |
| 806 |
exports: defined[fullName] |
| 807 |
}; |
| 808 |
} else if (depName in defined && !(depName in waiting) && |
| 809 |
(!(fullName in needFullExec) || |
| 810 |
(fullName in needFullExec && fullExec[depName]))) { |
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
deps[i] = defined[depName]; |
| 817 |
} else { |
| 818 |
|
| 819 |
|
| 820 |
if (fullName in needFullExec) { |
| 821 |
needFullExec[depName] = true; |
| 822 |
|
| 823 |
|
| 824 |
delete defined[depName]; |
| 825 |
urlFetched[depArg.url] = false; |
| 826 |
} |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
manager.depCount += 1; |
| 832 |
manager.depCallbacks[i] = makeArgCallback(manager, i); |
| 833 |
getManager(depArg, true).add(manager.depCallbacks[i]); |
| 834 |
} |
| 835 |
} |
| 836 |
} |
| 837 |
|
| 838 |
|
| 839 |
if (!manager.depCount) { |
| 840 |
|
| 841 |
execManager(manager); |
| 842 |
} else { |
| 843 |
addWait(manager); |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
function callDefMain(args) { |
| 852 |
main.apply(null, args); |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
jQueryCheck = function (jqCandidate) { |
| 865 |
if (!context.jQuery) { |
| 866 |
var $ = jqCandidate || (typeof jQuery !== "undefined" ? jQuery : null); |
| 867 |
|
| 868 |
if ($) { |
| 869 |
|
| 870 |
|
| 871 |
if (config.jQuery && $.fn.jquery !== config.jQuery) { |
| 872 |
return; |
| 873 |
} |
| 874 |
|
| 875 |
if ("holdReady" in $ || "readyWait" in $) { |
| 876 |
context.jQuery = $; |
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
callDefMain(["jquery", [], function () { |
| 883 |
return jQuery; |
| 884 |
}]); |
| 885 |
|
| 886 |
|
| 887 |
if (context.scriptCount) { |
| 888 |
jQueryHoldReady($, true); |
| 889 |
context.jQueryIncremented = true; |
| 890 |
} |
| 891 |
} |
| 892 |
} |
| 893 |
} |
| 894 |
}; |
| 895 |
|
| 896 |
function findCycle(manager, traced) { |
| 897 |
var fullName = manager.map.fullName, |
| 898 |
depArray = manager.depArray, |
| 899 |
fullyLoaded = true, |
| 900 |
i, depName, depManager, result; |
| 901 |
|
| 902 |
if (manager.isDone || !fullName || !loaded[fullName]) { |
| 903 |
return result; |
| 904 |
} |
| 905 |
|
| 906 |
|
| 907 |
if (traced[fullName]) { |
| 908 |
return manager; |
| 909 |
} |
| 910 |
|
| 911 |
traced[fullName] = true; |
| 912 |
|
| 913 |
|
| 914 |
if (depArray) { |
| 915 |
for (i = 0; i < depArray.length; i++) { |
| 916 |
|
| 917 |
|
| 918 |
depName = depArray[i]; |
| 919 |
if (!loaded[depName] && !reservedDependencies[depName]) { |
| 920 |
fullyLoaded = false; |
| 921 |
break; |
| 922 |
} |
| 923 |
depManager = waiting[depName]; |
| 924 |
if (depManager && !depManager.isDone && loaded[depName]) { |
| 925 |
result = findCycle(depManager, traced); |
| 926 |
if (result) { |
| 927 |
break; |
| 928 |
} |
| 929 |
} |
| 930 |
} |
| 931 |
if (!fullyLoaded) { |
| 932 |
|
| 933 |
|
| 934 |
result = undefined; |
| 935 |
delete traced[fullName]; |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
return result; |
| 940 |
} |
| 941 |
|
| 942 |
function forceExec(manager, traced) { |
| 943 |
var fullName = manager.map.fullName, |
| 944 |
depArray = manager.depArray, |
| 945 |
i, depName, depManager, prefix, prefixManager, value; |
| 946 |
|
| 947 |
|
| 948 |
if (manager.isDone || !fullName || !loaded[fullName]) { |
| 949 |
return undefined; |
| 950 |
} |
| 951 |
|
| 952 |
if (fullName) { |
| 953 |
if (traced[fullName]) { |
| 954 |
return defined[fullName]; |
| 955 |
} |
| 956 |
|
| 957 |
traced[fullName] = true; |
| 958 |
} |
| 959 |
|
| 960 |
|
| 961 |
if (depArray) { |
| 962 |
for (i = 0; i < depArray.length; i++) { |
| 963 |
|
| 964 |
|
| 965 |
depName = depArray[i]; |
| 966 |
if (depName) { |
| 967 |
|
| 968 |
|
| 969 |
prefix = makeModuleMap(depName).prefix; |
| 970 |
if (prefix && (prefixManager = waiting[prefix])) { |
| 971 |
forceExec(prefixManager, traced); |
| 972 |
} |
| 973 |
depManager = waiting[depName]; |
| 974 |
if (depManager && !depManager.isDone && loaded[depName]) { |
| 975 |
value = forceExec(depManager, traced); |
| 976 |
manager.depCallbacks[i](value); |
| 977 |
} |
| 978 |
} |
| 979 |
} |
| 980 |
} |
| 981 |
|
| 982 |
return defined[fullName]; |
| 983 |
} |
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
function checkLoaded() { |
| 992 |
var waitInterval = config.waitSeconds * 1000, |
| 993 |
|
| 994 |
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), |
| 995 |
noLoads = "", hasLoadedProp = false, stillLoading = false, |
| 996 |
cycleDeps = [], |
| 997 |
i, prop, err, manager, cycleManager, moduleDeps; |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
if (context.pausedCount > 0) { |
| 1003 |
return undefined; |
| 1004 |
} |
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
if (config.priorityWait) { |
| 1009 |
if (isPriorityDone()) { |
| 1010 |
|
| 1011 |
|
| 1012 |
resume(); |
| 1013 |
} else { |
| 1014 |
return undefined; |
| 1015 |
} |
| 1016 |
} |
| 1017 |
|
| 1018 |
|
| 1019 |
for (prop in loaded) { |
| 1020 |
if (!(prop in empty)) { |
| 1021 |
hasLoadedProp = true; |
| 1022 |
if (!loaded[prop]) { |
| 1023 |
if (expired) { |
| 1024 |
noLoads += prop + " "; |
| 1025 |
} else { |
| 1026 |
stillLoading = true; |
| 1027 |
if (prop.indexOf('!') === -1) { |
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
cycleDeps = []; |
| 1034 |
break; |
| 1035 |
} else { |
| 1036 |
moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps; |
| 1037 |
if (moduleDeps) { |
| 1038 |
cycleDeps.push.apply(cycleDeps, moduleDeps); |
| 1039 |
} |
| 1040 |
} |
| 1041 |
} |
| 1042 |
} |
| 1043 |
} |
| 1044 |
} |
| 1045 |
|
| 1046 |
|
| 1047 |
if (!hasLoadedProp && !context.waitCount) { |
| 1048 |
|
| 1049 |
|
| 1050 |
return undefined; |
| 1051 |
} |
| 1052 |
if (expired && noLoads) { |
| 1053 |
|
| 1054 |
err = makeError("timeout", "Load timeout for modules: " + noLoads); |
| 1055 |
err.requireType = "timeout"; |
| 1056 |
err.requireModules = noLoads; |
| 1057 |
err.contextName = context.contextName; |
| 1058 |
return req.onError(err); |
| 1059 |
} |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
if (stillLoading && cycleDeps.length) { |
| 1064 |
for (i = 0; (manager = waiting[cycleDeps[i]]); i++) { |
| 1065 |
if ((cycleManager = findCycle(manager, {}))) { |
| 1066 |
forceExec(cycleManager, {}); |
| 1067 |
break; |
| 1068 |
} |
| 1069 |
} |
| 1070 |
|
| 1071 |
} |
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
if (!expired && (stillLoading || context.scriptCount)) { |
| 1077 |
|
| 1078 |
|
| 1079 |
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { |
| 1080 |
checkLoadedTimeoutId = setTimeout(function () { |
| 1081 |
checkLoadedTimeoutId = 0; |
| 1082 |
checkLoaded(); |
| 1083 |
}, 50); |
| 1084 |
} |
| 1085 |
return undefined; |
| 1086 |
} |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
if (context.waitCount) { |
| 1097 |
|
| 1098 |
for (i = 0; (manager = waitAry[i]); i++) { |
| 1099 |
forceExec(manager, {}); |
| 1100 |
} |
| 1101 |
|
| 1102 |
|
| 1103 |
if (context.paused.length) { |
| 1104 |
resume(); |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
if (checkLoadedDepth < 5) { |
| 1115 |
checkLoadedDepth += 1; |
| 1116 |
checkLoaded(); |
| 1117 |
} |
| 1118 |
} |
| 1119 |
|
| 1120 |
checkLoadedDepth = 0; |
| 1121 |
|
| 1122 |
|
| 1123 |
req.checkReadyState(); |
| 1124 |
|
| 1125 |
return undefined; |
| 1126 |
} |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
resume = function () { |
| 1132 |
var manager, map, url, i, p, args, fullName; |
| 1133 |
|
| 1134 |
|
| 1135 |
context.takeGlobalQueue(); |
| 1136 |
|
| 1137 |
resumeDepth += 1; |
| 1138 |
|
| 1139 |
if (context.scriptCount <= 0) { |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
context.scriptCount = 0; |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
while (defQueue.length) { |
| 1149 |
args = defQueue.shift(); |
| 1150 |
if (args[0] === null) { |
| 1151 |
return req.onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); |
| 1152 |
} else { |
| 1153 |
callDefMain(args); |
| 1154 |
} |
| 1155 |
} |
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
if (!config.priorityWait || isPriorityDone()) { |
| 1160 |
while (context.paused.length) { |
| 1161 |
p = context.paused; |
| 1162 |
context.pausedCount += p.length; |
| 1163 |
|
| 1164 |
context.paused = []; |
| 1165 |
|
| 1166 |
for (i = 0; (manager = p[i]); i++) { |
| 1167 |
map = manager.map; |
| 1168 |
url = map.url; |
| 1169 |
fullName = map.fullName; |
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
if (map.prefix) { |
| 1174 |
callPlugin(map.prefix, manager); |
| 1175 |
} else { |
| 1176 |
|
| 1177 |
if (!urlFetched[url] && !loaded[fullName]) { |
| 1178 |
(config.requireLoad || req.load)(context, fullName, url); |
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
if (url.indexOf('empty:') !== 0) { |
| 1187 |
urlFetched[url] = true; |
| 1188 |
} |
| 1189 |
} |
| 1190 |
} |
| 1191 |
} |
| 1192 |
|
| 1193 |
|
| 1194 |
context.startTime = (new Date()).getTime(); |
| 1195 |
context.pausedCount -= p.length; |
| 1196 |
} |
| 1197 |
} |
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
if (resumeDepth === 1) { |
| 1205 |
checkLoaded(); |
| 1206 |
} |
| 1207 |
|
| 1208 |
resumeDepth -= 1; |
| 1209 |
|
| 1210 |
return undefined; |
| 1211 |
}; |
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
context = { |
| 1216 |
contextName: contextName, |
| 1217 |
config: config, |
| 1218 |
defQueue: defQueue, |
| 1219 |
waiting: waiting, |
| 1220 |
waitCount: 0, |
| 1221 |
specified: specified, |
| 1222 |
loaded: loaded, |
| 1223 |
urlMap: urlMap, |
| 1224 |
urlFetched: urlFetched, |
| 1225 |
scriptCount: 0, |
| 1226 |
defined: defined, |
| 1227 |
paused: [], |
| 1228 |
pausedCount: 0, |
| 1229 |
plugins: plugins, |
| 1230 |
needFullExec: needFullExec, |
| 1231 |
fake: {}, |
| 1232 |
fullExec: fullExec, |
| 1233 |
managerCallbacks: managerCallbacks, |
| 1234 |
makeModuleMap: makeModuleMap, |
| 1235 |
normalize: normalize, |
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
configure: function (cfg) { |
| 1241 |
var paths, prop, packages, pkgs, packagePaths, requireWait; |
| 1242 |
|
| 1243 |
|
| 1244 |
if (cfg.baseUrl) { |
| 1245 |
if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== "/") { |
| 1246 |
cfg.baseUrl += "/"; |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
paths = config.paths; |
| 1253 |
packages = config.packages; |
| 1254 |
pkgs = config.pkgs; |
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
mixin(config, cfg, true); |
| 1259 |
|
| 1260 |
|
| 1261 |
if (cfg.paths) { |
| 1262 |
for (prop in cfg.paths) { |
| 1263 |
if (!(prop in empty)) { |
| 1264 |
paths[prop] = cfg.paths[prop]; |
| 1265 |
} |
| 1266 |
} |
| 1267 |
config.paths = paths; |
| 1268 |
} |
| 1269 |
|
| 1270 |
packagePaths = cfg.packagePaths; |
| 1271 |
if (packagePaths || cfg.packages) { |
| 1272 |
|
| 1273 |
if (packagePaths) { |
| 1274 |
for (prop in packagePaths) { |
| 1275 |
if (!(prop in empty)) { |
| 1276 |
configurePackageDir(pkgs, packagePaths[prop], prop); |
| 1277 |
} |
| 1278 |
} |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
if (cfg.packages) { |
| 1283 |
configurePackageDir(pkgs, cfg.packages); |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
config.pkgs = pkgs; |
| 1288 |
} |
| 1289 |
|
| 1290 |
|
| 1291 |
if (cfg.priority) { |
| 1292 |
|
| 1293 |
requireWait = context.requireWait; |
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
context.requireWait = false; |
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
resume(); |
| 1302 |
|
| 1303 |
context.require(cfg.priority); |
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
resume(); |
| 1311 |
|
| 1312 |
|
| 1313 |
context.requireWait = requireWait; |
| 1314 |
config.priorityWait = cfg.priority; |
| 1315 |
} |
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
if (cfg.deps || cfg.callback) { |
| 1321 |
context.require(cfg.deps || [], cfg.callback); |
| 1322 |
} |
| 1323 |
}, |
| 1324 |
|
| 1325 |
requireDefined: function (moduleName, relModuleMap) { |
| 1326 |
return makeModuleMap(moduleName, relModuleMap).fullName in defined; |
| 1327 |
}, |
| 1328 |
|
| 1329 |
requireSpecified: function (moduleName, relModuleMap) { |
| 1330 |
return makeModuleMap(moduleName, relModuleMap).fullName in specified; |
| 1331 |
}, |
| 1332 |
|
| 1333 |
require: function (deps, callback, relModuleMap) { |
| 1334 |
var moduleName, fullName, moduleMap; |
| 1335 |
if (typeof deps === "string") { |
| 1336 |
if (isFunction(callback)) { |
| 1337 |
|
| 1338 |
return req.onError(makeError("requireargs", "Invalid require call")); |
| 1339 |
} |
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
if (req.get) { |
| 1346 |
return req.get(context, deps, callback); |
| 1347 |
} |
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
moduleName = deps; |
| 1352 |
relModuleMap = callback; |
| 1353 |
|
| 1354 |
|
| 1355 |
moduleMap = makeModuleMap(moduleName, relModuleMap); |
| 1356 |
fullName = moduleMap.fullName; |
| 1357 |
|
| 1358 |
if (!(fullName in defined)) { |
| 1359 |
return req.onError(makeError("notloaded", "Module name '" + |
| 1360 |
moduleMap.fullName + |
| 1361 |
"' has not been loaded yet for context: " + |
| 1362 |
contextName)); |
| 1363 |
} |
| 1364 |
return defined[fullName]; |
| 1365 |
} |
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
if (deps && deps.length || callback) { |
| 1370 |
main(null, deps, callback, relModuleMap); |
| 1371 |
} |
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
if (!context.requireWait) { |
| 1376 |
while (!context.scriptCount && context.paused.length) { |
| 1377 |
resume(); |
| 1378 |
} |
| 1379 |
} |
| 1380 |
return context.require; |
| 1381 |
}, |
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
takeGlobalQueue: function () { |
| 1388 |
|
| 1389 |
if (globalDefQueue.length) { |
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
apsp.apply(context.defQueue, |
| 1394 |
[context.defQueue.length - 1, 0].concat(globalDefQueue)); |
| 1395 |
globalDefQueue = []; |
| 1396 |
} |
| 1397 |
}, |
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
completeLoad: function (moduleName) { |
| 1406 |
var args; |
| 1407 |
|
| 1408 |
context.takeGlobalQueue(); |
| 1409 |
|
| 1410 |
while (defQueue.length) { |
| 1411 |
args = defQueue.shift(); |
| 1412 |
|
| 1413 |
if (args[0] === null) { |
| 1414 |
args[0] = moduleName; |
| 1415 |
break; |
| 1416 |
} else if (args[0] === moduleName) { |
| 1417 |
|
| 1418 |
break; |
| 1419 |
} else { |
| 1420 |
|
| 1421 |
|
| 1422 |
callDefMain(args); |
| 1423 |
args = null; |
| 1424 |
} |
| 1425 |
} |
| 1426 |
if (args) { |
| 1427 |
callDefMain(args); |
| 1428 |
} else { |
| 1429 |
|
| 1430 |
|
| 1431 |
callDefMain([moduleName, [], |
| 1432 |
moduleName === "jquery" && typeof jQuery !== "undefined" ? |
| 1433 |
function () { |
| 1434 |
return jQuery; |
| 1435 |
} : null]); |
| 1436 |
} |
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
if (req.isAsync) { |
| 1445 |
context.scriptCount -= 1; |
| 1446 |
} |
| 1447 |
resume(); |
| 1448 |
if (!req.isAsync) { |
| 1449 |
context.scriptCount -= 1; |
| 1450 |
} |
| 1451 |
}, |
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
toUrl: function (moduleNamePlusExt, relModuleMap) { |
| 1459 |
var index = moduleNamePlusExt.lastIndexOf("."), |
| 1460 |
ext = null; |
| 1461 |
|
| 1462 |
if (index !== -1) { |
| 1463 |
ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); |
| 1464 |
moduleNamePlusExt = moduleNamePlusExt.substring(0, index); |
| 1465 |
} |
| 1466 |
|
| 1467 |
return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap); |
| 1468 |
}, |
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
nameToUrl: function (moduleName, ext, relModuleMap) { |
| 1475 |
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, |
| 1476 |
config = context.config; |
| 1477 |
|
| 1478 |
|
| 1479 |
moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName); |
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
if (req.jsExtRegExp.test(moduleName)) { |
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
url = moduleName + (ext ? ext : ""); |
| 1490 |
} else { |
| 1491 |
|
| 1492 |
paths = config.paths; |
| 1493 |
pkgs = config.pkgs; |
| 1494 |
|
| 1495 |
syms = moduleName.split("/"); |
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
for (i = syms.length; i > 0; i--) { |
| 1500 |
parentModule = syms.slice(0, i).join("/"); |
| 1501 |
if (paths[parentModule]) { |
| 1502 |
syms.splice(0, i, paths[parentModule]); |
| 1503 |
break; |
| 1504 |
} else if ((pkg = pkgs[parentModule])) { |
| 1505 |
|
| 1506 |
|
| 1507 |
if (moduleName === pkg.name) { |
| 1508 |
pkgPath = pkg.location + '/' + pkg.main; |
| 1509 |
} else { |
| 1510 |
pkgPath = pkg.location; |
| 1511 |
} |
| 1512 |
syms.splice(0, i, pkgPath); |
| 1513 |
break; |
| 1514 |
} |
| 1515 |
} |
| 1516 |
|
| 1517 |
|
| 1518 |
url = syms.join("/") + (ext || ".js"); |
| 1519 |
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? "" : config.baseUrl) + url; |
| 1520 |
} |
| 1521 |
|
| 1522 |
return config.urlArgs ? url + |
| 1523 |
((url.indexOf('?') === -1 ? '?' : '&') + |
| 1524 |
config.urlArgs) : url; |
| 1525 |
} |
| 1526 |
}; |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
context.jQueryCheck = jQueryCheck; |
| 1531 |
context.resume = resume; |
| 1532 |
|
| 1533 |
return context; |
| 1534 |
} |
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
req = requirejs = function (deps, callback) { |
| 1551 |
|
| 1552 |
|
| 1553 |
var contextName = defContextName, |
| 1554 |
context, config; |
| 1555 |
|
| 1556 |
|
| 1557 |
if (!isArray(deps) && typeof deps !== "string") { |
| 1558 |
|
| 1559 |
config = deps; |
| 1560 |
if (isArray(callback)) { |
| 1561 |
|
| 1562 |
deps = callback; |
| 1563 |
callback = arguments[2]; |
| 1564 |
} else { |
| 1565 |
deps = []; |
| 1566 |
} |
| 1567 |
} |
| 1568 |
|
| 1569 |
if (config && config.context) { |
| 1570 |
contextName = config.context; |
| 1571 |
} |
| 1572 |
|
| 1573 |
context = contexts[contextName] || |
| 1574 |
(contexts[contextName] = newContext(contextName)); |
| 1575 |
|
| 1576 |
if (config) { |
| 1577 |
context.configure(config); |
| 1578 |
} |
| 1579 |
|
| 1580 |
return context.require(deps, callback); |
| 1581 |
}; |
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
req.config = function (config) { |
| 1588 |
return req(config); |
| 1589 |
}; |
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
if (!require) { |
| 1595 |
require = req; |
| 1596 |
} |
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
req.toUrl = function (moduleNamePlusExt) { |
| 1603 |
return contexts[defContextName].toUrl(moduleNamePlusExt); |
| 1604 |
}; |
| 1605 |
|
| 1606 |
req.version = version; |
| 1607 |
|
| 1608 |
|
| 1609 |
req.jsExtRegExp = /^\/|:|\?|\.js$/; |
| 1610 |
s = req.s = { |
| 1611 |
contexts: contexts, |
| 1612 |
|
| 1613 |
skipAsync: {} |
| 1614 |
}; |
| 1615 |
|
| 1616 |
req.isAsync = req.isBrowser = isBrowser; |
| 1617 |
if (isBrowser) { |
| 1618 |
head = s.head = document.getElementsByTagName("head")[0]; |
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
baseElement = document.getElementsByTagName("base")[0]; |
| 1623 |
if (baseElement) { |
| 1624 |
head = s.head = baseElement.parentNode; |
| 1625 |
} |
| 1626 |
} |
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
req.onError = function (err) { |
| 1634 |
throw err; |
| 1635 |
}; |
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
req.load = function (context, moduleName, url) { |
| 1647 |
req.resourcesReady(false); |
| 1648 |
|
| 1649 |
context.scriptCount += 1; |
| 1650 |
req.attach(url, context, moduleName); |
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
if (context.jQuery && !context.jQueryIncremented) { |
| 1656 |
jQueryHoldReady(context.jQuery, true); |
| 1657 |
context.jQueryIncremented = true; |
| 1658 |
} |
| 1659 |
}; |
| 1660 |
|
| 1661 |
function getInteractiveScript() { |
| 1662 |
var scripts, i, script; |
| 1663 |
if (interactiveScript && interactiveScript.readyState === 'interactive') { |
| 1664 |
return interactiveScript; |
| 1665 |
} |
| 1666 |
|
| 1667 |
scripts = document.getElementsByTagName('script'); |
| 1668 |
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) { |
| 1669 |
if (script.readyState === 'interactive') { |
| 1670 |
return (interactiveScript = script); |
| 1671 |
} |
| 1672 |
} |
| 1673 |
|
| 1674 |
return null; |
| 1675 |
} |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
define = function (name, deps, callback) { |
| 1685 |
var node, context; |
| 1686 |
|
| 1687 |
|
| 1688 |
if (typeof name !== 'string') { |
| 1689 |
|
| 1690 |
callback = deps; |
| 1691 |
deps = name; |
| 1692 |
name = null; |
| 1693 |
} |
| 1694 |
|
| 1695 |
|
| 1696 |
if (!isArray(deps)) { |
| 1697 |
callback = deps; |
| 1698 |
deps = []; |
| 1699 |
} |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
if (!deps.length && isFunction(callback)) { |
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
if (callback.length) { |
| 1708 |
callback |
| 1709 |
.toString() |
| 1710 |
.replace(commentRegExp, "") |
| 1711 |
.replace(cjsRequireRegExp, function (match, dep) { |
| 1712 |
deps.push(dep); |
| 1713 |
}); |
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
deps = (callback.length === 1 ? ["require"] : ["require", "exports", "module"]).concat(deps); |
| 1721 |
} |
| 1722 |
} |
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
if (useInteractive) { |
| 1727 |
node = currentlyAddingScript || getInteractiveScript(); |
| 1728 |
if (node) { |
| 1729 |
if (!name) { |
| 1730 |
name = node.getAttribute("data-requiremodule"); |
| 1731 |
} |
| 1732 |
context = contexts[node.getAttribute("data-requirecontext")]; |
| 1733 |
} |
| 1734 |
} |
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]); |
| 1743 |
|
| 1744 |
return undefined; |
| 1745 |
}; |
| 1746 |
|
| 1747 |
define.amd = { |
| 1748 |
multiversion: true, |
| 1749 |
plugins: true, |
| 1750 |
jQuery: true |
| 1751 |
}; |
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
req.exec = function (text) { |
| 1759 |
return eval(text); |
| 1760 |
}; |
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
req.execCb = function (name, callback, args, exports) { |
| 1770 |
return callback.apply(exports, args); |
| 1771 |
}; |
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
req.addScriptToDom = function (node) { |
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
currentlyAddingScript = node; |
| 1784 |
if (baseElement) { |
| 1785 |
head.insertBefore(node, baseElement); |
| 1786 |
} else { |
| 1787 |
head.appendChild(node); |
| 1788 |
} |
| 1789 |
currentlyAddingScript = null; |
| 1790 |
}; |
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
req.onScriptLoad = function (evt) { |
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
var node = evt.currentTarget || evt.srcElement, contextName, moduleName, |
| 1805 |
context; |
| 1806 |
|
| 1807 |
if (evt.type === "load" || (node && readyRegExp.test(node.readyState))) { |
| 1808 |
|
| 1809 |
|
| 1810 |
interactiveScript = null; |
| 1811 |
|
| 1812 |
|
| 1813 |
contextName = node.getAttribute("data-requirecontext"); |
| 1814 |
moduleName = node.getAttribute("data-requiremodule"); |
| 1815 |
context = contexts[contextName]; |
| 1816 |
|
| 1817 |
contexts[contextName].completeLoad(moduleName); |
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
if (node.detachEvent && !isOpera) { |
| 1823 |
|
| 1824 |
|
| 1825 |
node.detachEvent("onreadystatechange", req.onScriptLoad); |
| 1826 |
} else { |
| 1827 |
node.removeEventListener("load", req.onScriptLoad, false); |
| 1828 |
} |
| 1829 |
} |
| 1830 |
}; |
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
req.attach = function (url, context, moduleName, callback, type, fetchOnlyFunction) { |
| 1848 |
var node; |
| 1849 |
if (isBrowser) { |
| 1850 |
|
| 1851 |
callback = callback || req.onScriptLoad; |
| 1852 |
node = context && context.config && context.config.xhtml ? |
| 1853 |
document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") : |
| 1854 |
document.createElement("script"); |
| 1855 |
node.type = type || (context && context.config.scriptType) || |
| 1856 |
"text/javascript"; |
| 1857 |
node.charset = "utf-8"; |
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
node.async = !s.skipAsync[url]; |
| 1869 |
|
| 1870 |
if (context) { |
| 1871 |
node.setAttribute("data-requirecontext", context.contextName); |
| 1872 |
} |
| 1873 |
node.setAttribute("data-requiremodule", moduleName); |
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
if (node.attachEvent && |
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code]') < 0) && |
| 1891 |
!isOpera) { |
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
useInteractive = true; |
| 1898 |
|
| 1899 |
|
| 1900 |
if (fetchOnlyFunction) { |
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
|
| 1905 |
node.onreadystatechange = function (evt) { |
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
if (node.readyState === 'loaded') { |
| 1910 |
node.onreadystatechange = null; |
| 1911 |
node.attachEvent("onreadystatechange", callback); |
| 1912 |
fetchOnlyFunction(node); |
| 1913 |
} |
| 1914 |
}; |
| 1915 |
} else { |
| 1916 |
node.attachEvent("onreadystatechange", callback); |
| 1917 |
} |
| 1918 |
} else { |
| 1919 |
node.addEventListener("load", callback, false); |
| 1920 |
} |
| 1921 |
node.src = url; |
| 1922 |
|
| 1923 |
|
| 1924 |
if (!fetchOnlyFunction) { |
| 1925 |
req.addScriptToDom(node); |
| 1926 |
} |
| 1927 |
|
| 1928 |
return node; |
| 1929 |
} else if (isWebWorker) { |
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
importScripts(url); |
| 1937 |
|
| 1938 |
|
| 1939 |
context.completeLoad(moduleName); |
| 1940 |
} |
| 1941 |
return null; |
| 1942 |
}; |
| 1943 |
|
| 1944 |
|
| 1945 |
if (isBrowser) { |
| 1946 |
|
| 1947 |
scripts = document.getElementsByTagName("script"); |
| 1948 |
|
| 1949 |
for (globalI = scripts.length - 1; globalI > -1 && (script = scripts[globalI]); globalI--) { |
| 1950 |
|
| 1951 |
|
| 1952 |
if (!head) { |
| 1953 |
head = script.parentNode; |
| 1954 |
} |
| 1955 |
|
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
if ((dataMain = script.getAttribute('data-main'))) { |
| 1960 |
if (!cfg.baseUrl) { |
| 1961 |
|
| 1962 |
|
| 1963 |
src = dataMain.split('/'); |
| 1964 |
mainScript = src.pop(); |
| 1965 |
subPath = src.length ? src.join('/') + '/' : './'; |
| 1966 |
|
| 1967 |
|
| 1968 |
cfg.baseUrl = subPath; |
| 1969 |
|
| 1970 |
|
| 1971 |
dataMain = mainScript.replace(jsSuffixRegExp, ''); |
| 1972 |
} |
| 1973 |
|
| 1974 |
|
| 1975 |
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; |
| 1976 |
|
| 1977 |
break; |
| 1978 |
} |
| 1979 |
} |
| 1980 |
} |
| 1981 |
|
| 1982 |
|
| 1983 |
|
| 1984 |
req.checkReadyState = function () { |
| 1985 |
var contexts = s.contexts, prop; |
| 1986 |
for (prop in contexts) { |
| 1987 |
if (!(prop in empty)) { |
| 1988 |
if (contexts[prop].waitCount) { |
| 1989 |
return; |
| 1990 |
} |
| 1991 |
} |
| 1992 |
} |
| 1993 |
req.resourcesReady(true); |
| 1994 |
}; |
| 1995 |
|
| 1996 |
|
| 1997 |
|
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
req.resourcesReady = function (isReady) { |
| 2003 |
var contexts, context, prop; |
| 2004 |
|
| 2005 |
|
| 2006 |
req.resourcesDone = isReady; |
| 2007 |
|
| 2008 |
if (req.resourcesDone) { |
| 2009 |
|
| 2010 |
contexts = s.contexts; |
| 2011 |
for (prop in contexts) { |
| 2012 |
if (!(prop in empty)) { |
| 2013 |
context = contexts[prop]; |
| 2014 |
if (context.jQueryIncremented) { |
| 2015 |
jQueryHoldReady(context.jQuery, false); |
| 2016 |
context.jQueryIncremented = false; |
| 2017 |
} |
| 2018 |
} |
| 2019 |
} |
| 2020 |
} |
| 2021 |
}; |
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
req.pageLoaded = function () { |
| 2028 |
if (document.readyState !== "complete") { |
| 2029 |
document.readyState = "complete"; |
| 2030 |
} |
| 2031 |
}; |
| 2032 |
if (isBrowser) { |
| 2033 |
if (document.addEventListener) { |
| 2034 |
if (!document.readyState) { |
| 2035 |
document.readyState = "loading"; |
| 2036 |
window.addEventListener("load", req.pageLoaded, false); |
| 2037 |
} |
| 2038 |
} |
| 2039 |
} |
| 2040 |
|
| 2041 |
|
| 2042 |
req(cfg); |
| 2043 |
|
| 2044 |
|
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
if (req.isAsync && typeof setTimeout !== "undefined") { |
| 2049 |
ctx = s.contexts[(cfg.context || defContextName)]; |
| 2050 |
|
| 2051 |
|
| 2052 |
|
| 2053 |
ctx.requireWait = true; |
| 2054 |
setTimeout(function () { |
| 2055 |
ctx.requireWait = false; |
| 2056 |
|
| 2057 |
if (!ctx.scriptCount) { |
| 2058 |
ctx.resume(); |
| 2059 |
} |
| 2060 |
req.checkReadyState(); |
| 2061 |
}, 0); |
| 2062 |
} |
| 2063 |
}()); |