{"version":3,"names":[],"mappings":"","sources":["require.js"],"sourcesContent":["/** vim: et:ts=4:sw=4:sts=4\r\n * @license RequireJS 2.2.0 Copyright jQuery Foundation and other contributors.\r\n * Released under MIT license, http://github.com/requirejs/requirejs/LICENSE\r\n */\r\n//Not using strict: uneven strict support in browsers, #392, and causes\r\n//problems with requirejs.exec()/transpiler plugins that may not be strict.\r\n/*jslint regexp: true, nomen: true, sloppy: true */\r\n/*global window, navigator, document, importScripts, setTimeout, opera */\r\n\r\nvar requirejs, require, define;\r\n(function (global) {\r\n var req, s, head, baseElement, dataMain, src,\r\n interactiveScript, currentlyAddingScript, mainScript, subPath,\r\n version = '2.2.0',\r\n commentRegExp = /(\\/\\*([\\s\\S]*?)\\*\\/|([^:]|^)\\/\\/(.*)$)/mg,\r\n cjsRequireRegExp = /[^.]\\s*require\\s*\\(\\s*[\"']([^'\"\\s]+)[\"']\\s*\\)/g,\r\n jsSuffixRegExp = /\\.js$/,\r\n currDirRegExp = /^\\.\\//,\r\n op = Object.prototype,\r\n ostring = op.toString,\r\n hasOwn = op.hasOwnProperty,\r\n isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),\r\n isWebWorker = !isBrowser && typeof importScripts !== 'undefined',\r\n //PS3 indicates loaded and complete, but need to wait for complete\r\n //specifically. Sequence is 'loading', 'loaded', execution,\r\n // then 'complete'. The UA check is unfortunate, but not sure how\r\n //to feature test w/o causing perf issues.\r\n readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?\r\n /^complete$/ : /^(complete|loaded)$/,\r\n defContextName = '_',\r\n //Oh the tragedy, detecting opera. See the usage of isOpera for reason.\r\n isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',\r\n contexts = {},\r\n cfg = {},\r\n globalDefQueue = [],\r\n useInteractive = false;\r\n\r\n //Could match something like ')//comment', do not lose the prefix to comment.\r\n function commentReplace(match, multi, multiText, singlePrefix) {\r\n return singlePrefix || '';\r\n }\r\n\r\n function isFunction(it) {\r\n return ostring.call(it) === '[object Function]';\r\n }\r\n\r\n function isArray(it) {\r\n return ostring.call(it) === '[object Array]';\r\n }\r\n\r\n /**\r\n * Helper function for iterating over an array. If the func returns\r\n * a true value, it will break out of the loop.\r\n */\r\n function each(ary, func) {\r\n if (ary) {\r\n var i;\r\n for (i = 0; i < ary.length; i += 1) {\r\n if (ary[i] && func(ary[i], i, ary)) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Helper function for iterating over an array backwards. If the func\r\n * returns a true value, it will break out of the loop.\r\n */\r\n function eachReverse(ary, func) {\r\n if (ary) {\r\n var i;\r\n for (i = ary.length - 1; i > -1; i -= 1) {\r\n if (ary[i] && func(ary[i], i, ary)) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n function hasProp(obj, prop) {\r\n return hasOwn.call(obj, prop);\r\n }\r\n\r\n function getOwn(obj, prop) {\r\n return hasProp(obj, prop) && obj[prop];\r\n }\r\n\r\n /**\r\n * Cycles over properties in an object and calls a function for each\r\n * property value. If the function returns a truthy value, then the\r\n * iteration is stopped.\r\n */\r\n function eachProp(obj, func) {\r\n var prop;\r\n for (prop in obj) {\r\n if (hasProp(obj, prop)) {\r\n if (func(obj[prop], prop)) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Simple function to mix in properties from source into target,\r\n * but only if target does not already have a property of the same name.\r\n */\r\n function mixin(target, source, force, deepStringMixin) {\r\n if (source) {\r\n eachProp(source, function (value, prop) {\r\n if (force || !hasProp(target, prop)) {\r\n if (deepStringMixin && typeof value === 'object' && value &&\r\n !isArray(value) && !isFunction(value) &&\r\n !(value instanceof RegExp)) {\r\n\r\n if (!target[prop]) {\r\n target[prop] = {};\r\n }\r\n mixin(target[prop], value, force, deepStringMixin);\r\n } else {\r\n target[prop] = value;\r\n }\r\n }\r\n });\r\n }\r\n return target;\r\n }\r\n\r\n //Similar to Function.prototype.bind, but the 'this' object is specified\r\n //first, since it is easier to read/figure out what 'this' will be.\r\n function bind(obj, fn) {\r\n return function () {\r\n return fn.apply(obj, arguments);\r\n };\r\n }\r\n\r\n function scripts() {\r\n return document.getElementsByTagName('script');\r\n }\r\n\r\n function defaultOnError(err) {\r\n throw err;\r\n }\r\n\r\n //Allow getting a global that is expressed in\r\n //dot notation, like 'a.b.c'.\r\n function getGlobal(value) {\r\n if (!value) {\r\n return value;\r\n }\r\n var g = global;\r\n each(value.split('.'), function (part) {\r\n g = g[part];\r\n });\r\n return g;\r\n }\r\n\r\n /**\r\n * Constructs an error with a pointer to an URL with more information.\r\n * @param {String} id the error ID that maps to an ID on a web page.\r\n * @param {String} message human readable error.\r\n * @param {Error} [err] the original error, if there is one.\r\n *\r\n * @returns {Error}\r\n */\r\n function makeError(id, msg, err, requireModules) {\r\n var e = new Error(msg + '\\nhttp://requirejs.org/docs/errors.html#' + id);\r\n e.requireType = id;\r\n e.requireModules = requireModules;\r\n if (err) {\r\n e.originalError = err;\r\n }\r\n return e;\r\n }\r\n\r\n if (typeof define !== 'undefined') {\r\n //If a define is already in play via another AMD loader,\r\n //do not overwrite.\r\n return;\r\n }\r\n\r\n if (typeof requirejs !== 'undefined') {\r\n if (isFunction(requirejs)) {\r\n //Do not overwrite an existing requirejs instance.\r\n return;\r\n }\r\n cfg = requirejs;\r\n requirejs = undefined;\r\n }\r\n\r\n //Allow for a require config object\r\n if (typeof require !== 'undefined' && !isFunction(require)) {\r\n //assume it is a config object.\r\n cfg = require;\r\n require = undefined;\r\n }\r\n\r\n function newContext(contextName) {\r\n var inCheckLoaded, Module, context, handlers,\r\n checkLoadedTimeoutId,\r\n config = {\r\n //Defaults. Do not set a default for map\r\n //config to speed up normalize(), which\r\n //will run faster if there is no default.\r\n waitSeconds: 7,\r\n baseUrl: './',\r\n paths: {},\r\n bundles: {},\r\n pkgs: {},\r\n shim: {},\r\n config: {}\r\n },\r\n registry = {},\r\n //registry of just enabled modules, to speed\r\n //cycle breaking code when lots of modules\r\n //are registered, but not activated.\r\n enabledRegistry = {},\r\n undefEvents = {},\r\n defQueue = [],\r\n defined = {},\r\n urlFetched = {},\r\n bundlesMap = {},\r\n requireCounter = 1,\r\n unnormalizedCounter = 1;\r\n\r\n /**\r\n * Trims the . and .. from an array of path segments.\r\n * It will keep a leading path segment if a .. will become\r\n * the first path segment, to help with module name lookups,\r\n * which act like paths, but can be remapped. But the end result,\r\n * all paths that use this function should look normalized.\r\n * NOTE: this method MODIFIES the input array.\r\n * @param {Array} ary the array of path segments.\r\n */\r\n function trimDots(ary) {\r\n var i, part;\r\n for (i = 0; i < ary.length; i++) {\r\n part = ary[i];\r\n if (part === '.') {\r\n ary.splice(i, 1);\r\n i -= 1;\r\n } else if (part === '..') {\r\n // If at the start, or previous value is still ..,\r\n // keep them so that when converted to a path it may\r\n // still work when converted to a path, even though\r\n // as an ID it is less than ideal. In larger point\r\n // releases, may be better to just kick out an error.\r\n if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {\r\n continue;\r\n } else if (i > 0) {\r\n ary.splice(i - 1, 2);\r\n i -= 2;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a relative module name, like ./something, normalize it to\r\n * a real name that can be mapped to a path.\r\n * @param {String} name the relative name\r\n * @param {String} baseName a real name that the name arg is relative\r\n * to.\r\n * @param {Boolean} applyMap apply the map config to the value. Should\r\n * only be done if this normalization is for a dependency ID.\r\n * @returns {String} normalized name\r\n */\r\n function normalize(name, baseName, applyMap) {\r\n var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,\r\n foundMap, foundI, foundStarMap, starI, normalizedBaseParts,\r\n baseParts = (baseName && baseName.split('/')),\r\n map = config.map,\r\n starMap = map && map['*'];\r\n\r\n //Adjust any relative paths.\r\n if (name) {\r\n name = name.split('/');\r\n lastIndex = name.length - 1;\r\n\r\n // If wanting node ID compatibility, strip .js from end\r\n // of IDs. Have to do this here, and not in nameToUrl\r\n // because node allows either .js or non .js to map\r\n // to same file.\r\n if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {\r\n name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');\r\n }\r\n\r\n // Starts with a '.' so need the baseName\r\n if (name[0].charAt(0) === '.' && baseParts) {\r\n //Convert baseName to array, and lop off the last part,\r\n //so that . matches that 'directory' and not name of the baseName's\r\n //module. For instance, baseName of 'one/two/three', maps to\r\n //'one/two/three.js', but we want the directory, 'one/two' for\r\n //this normalization.\r\n normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);\r\n name = normalizedBaseParts.concat(name);\r\n }\r\n\r\n trimDots(name);\r\n name = name.join('/');\r\n }\r\n\r\n //Apply map config if available.\r\n if (applyMap && map && (baseParts || starMap)) {\r\n nameParts = name.split('/');\r\n\r\n outerLoop: for (i = nameParts.length; i > 0; i -= 1) {\r\n nameSegment = nameParts.slice(0, i).join('/');\r\n\r\n if (baseParts) {\r\n //Find the longest baseName segment match in the config.\r\n //So, do joins on the biggest to smallest lengths of baseParts.\r\n for (j = baseParts.length; j > 0; j -= 1) {\r\n mapValue = getOwn(map, baseParts.slice(0, j).join('/'));\r\n\r\n //baseName segment has config, find if it has one for\r\n //this name.\r\n if (mapValue) {\r\n mapValue = getOwn(mapValue, nameSegment);\r\n if (mapValue) {\r\n //Match, update name to the new value.\r\n foundMap = mapValue;\r\n foundI = i;\r\n break outerLoop;\r\n }\r\n }\r\n }\r\n }\r\n\r\n //Check for a star map match, but just hold on to it,\r\n //if there is a shorter segment match later in a matching\r\n //config, then favor over this star map.\r\n if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {\r\n foundStarMap = getOwn(starMap, nameSegment);\r\n starI = i;\r\n }\r\n }\r\n\r\n if (!foundMap && foundStarMap) {\r\n foundMap = foundStarMap;\r\n foundI = starI;\r\n }\r\n\r\n if (foundMap) {\r\n nameParts.splice(0, foundI, foundMap);\r\n name = nameParts.join('/');\r\n }\r\n }\r\n\r\n // If the name points to a package's name, use\r\n // the package main instead.\r\n pkgMain = getOwn(config.pkgs, name);\r\n\r\n return pkgMain ? pkgMain : name;\r\n }\r\n\r\n function removeScript(name) {\r\n if (isBrowser) {\r\n each(scripts(), function (scriptNode) {\r\n if (scriptNode.getAttribute('data-requiremodule') === name &&\r\n scriptNode.getAttribute('data-requirecontext') === context.contextName) {\r\n scriptNode.parentNode.removeChild(scriptNode);\r\n return true;\r\n }\r\n });\r\n }\r\n }\r\n\r\n function hasPathFallback(id) {\r\n var pathConfig = getOwn(config.paths, id);\r\n if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {\r\n //Pop off the first array value, since it failed, and\r\n //retry\r\n pathConfig.shift();\r\n context.require.undef(id);\r\n\r\n //Custom require that does not do map translation, since\r\n //ID is \"absolute\", already mapped/resolved.\r\n context.makeRequire(null, {\r\n skipMap: true\r\n })([id]);\r\n\r\n return true;\r\n }\r\n }\r\n\r\n //Turns a plugin!resource to [plugin, resource]\r\n //with the plugin being undefined if the name\r\n //did not have a plugin prefix.\r\n function splitPrefix(name) {\r\n var prefix,\r\n index = name ? name.indexOf('!') : -1;\r\n if (index > -1) {\r\n prefix = name.substring(0, index);\r\n name = name.substring(index + 1, name.length);\r\n }\r\n return [prefix, name];\r\n }\r\n\r\n /**\r\n * Creates a module mapping that includes plugin prefix, module\r\n * name, and path. If parentModuleMap is provided it will\r\n * also normalize the name via require.normalize()\r\n *\r\n * @param {String} name the module name\r\n * @param {String} [parentModuleMap] parent module map\r\n * for the module name, used to resolve relative names.\r\n * @param {Boolean} isNormalized: is the ID already normalized.\r\n * This is true if this call is done for a define() module ID.\r\n * @param {Boolean} applyMap: apply the map config to the ID.\r\n * Should only be true if this map is for a dependency.\r\n *\r\n * @returns {Object}\r\n */\r\n function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {\r\n var url, pluginModule, suffix, nameParts,\r\n prefix = null,\r\n parentName = parentModuleMap ? parentModuleMap.name : null,\r\n originalName = name,\r\n isDefine = true,\r\n normalizedName = '';\r\n\r\n //If no name, then it means it is a require call, generate an\r\n //internal name.\r\n if (!name) {\r\n isDefine = false;\r\n name = '_@r' + (requireCounter += 1);\r\n }\r\n\r\n nameParts = splitPrefix(name);\r\n prefix = nameParts[0];\r\n name = nameParts[1];\r\n\r\n if (prefix) {\r\n prefix = normalize(prefix, parentName, applyMap);\r\n pluginModule = getOwn(defined, prefix);\r\n }\r\n\r\n //Account for relative paths if there is a base name.\r\n if (name) {\r\n if (prefix) {\r\n if (pluginModule && pluginModule.normalize) {\r\n //Plugin is loaded, use its normalize method.\r\n normalizedName = pluginModule.normalize(name, function (name) {\r\n return normalize(name, parentName, applyMap);\r\n });\r\n } else {\r\n // If nested plugin references, then do not try to\r\n // normalize, as it will not normalize correctly. This\r\n // places a restriction on resourceIds, and the longer\r\n // term solution is not to normalize until plugins are\r\n // loaded and all normalizations to allow for async\r\n // loading of a loader plugin. But for now, fixes the\r\n // common uses. Details in #1131\r\n normalizedName = name.indexOf('!') === -1 ?\r\n normalize(name, parentName, applyMap) :\r\n name;\r\n }\r\n } else {\r\n //A regular module.\r\n normalizedName = normalize(name, parentName, applyMap);\r\n\r\n //Normalized name may be a plugin ID due to map config\r\n //application in normalize. The map config values must\r\n //already be normalized, so do not need to redo that part.\r\n nameParts = splitPrefix(normalizedName);\r\n prefix = nameParts[0];\r\n normalizedName = nameParts[1];\r\n isNormalized = true;\r\n\r\n url = context.nameToUrl(normalizedName);\r\n }\r\n }\r\n\r\n //If the id is a plugin id that cannot be determined if it needs\r\n //normalization, stamp it with a unique ID so two matching relative\r\n //ids that may conflict can be separate.\r\n suffix = prefix && !pluginModule && !isNormalized ?\r\n '_unnormalized' + (unnormalizedCounter += 1) :\r\n '';\r\n\r\n return {\r\n prefix: prefix,\r\n name: normalizedName,\r\n parentMap: parentModuleMap,\r\n unnormalized: !!suffix,\r\n url: url,\r\n originalName: originalName,\r\n isDefine: isDefine,\r\n id: (prefix ?\r\n prefix + '!' + normalizedName :\r\n normalizedName) + suffix\r\n };\r\n }\r\n\r\n function getModule(depMap) {\r\n var id = depMap.id,\r\n mod = getOwn(registry, id);\r\n\r\n if (!mod) {\r\n mod = registry[id] = new context.Module(depMap);\r\n }\r\n\r\n return mod;\r\n }\r\n\r\n function on(depMap, name, fn) {\r\n var id = depMap.id,\r\n mod = getOwn(registry, id);\r\n\r\n if (hasProp(defined, id) &&\r\n (!mod || mod.defineEmitComplete)) {\r\n if (name === 'defined') {\r\n fn(defined[id]);\r\n }\r\n } else {\r\n mod = getModule(depMap);\r\n if (mod.error && name === 'error') {\r\n fn(mod.error);\r\n } else {\r\n mod.on(name, fn);\r\n }\r\n }\r\n }\r\n\r\n function onError(err, errback) {\r\n var ids = err.requireModules,\r\n notified = false;\r\n\r\n if (errback) {\r\n errback(err);\r\n } else {\r\n each(ids, function (id) {\r\n var mod = getOwn(registry, id);\r\n if (mod) {\r\n //Set error on module, so it skips timeout checks.\r\n mod.error = err;\r\n if (mod.events.error) {\r\n notified = true;\r\n mod.emit('error', err);\r\n }\r\n }\r\n });\r\n\r\n if (!notified) {\r\n req.onError(err);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Internal method to transfer globalQueue items to this context's\r\n * defQueue.\r\n */\r\n function takeGlobalQueue() {\r\n //Push all the globalDefQueue items into the context's defQueue\r\n if (globalDefQueue.length) {\r\n each(globalDefQueue, function(queueItem) {\r\n var id = queueItem[0];\r\n if (typeof id === 'string') {\r\n context.defQueueMap[id] = true;\r\n }\r\n defQueue.push(queueItem);\r\n });\r\n globalDefQueue = [];\r\n }\r\n }\r\n\r\n handlers = {\r\n 'require': function (mod) {\r\n if (mod.require) {\r\n return mod.require;\r\n } else {\r\n return (mod.require = context.makeRequire(mod.map));\r\n }\r\n },\r\n 'exports': function (mod) {\r\n mod.usingExports = true;\r\n if (mod.map.isDefine) {\r\n if (mod.exports) {\r\n return (defined[mod.map.id] = mod.exports);\r\n } else {\r\n return (mod.exports = defined[mod.map.id] = {});\r\n }\r\n }\r\n },\r\n 'module': function (mod) {\r\n if (mod.module) {\r\n return mod.module;\r\n } else {\r\n return (mod.module = {\r\n id: mod.map.id,\r\n uri: mod.map.url,\r\n config: function () {\r\n return getOwn(config.config, mod.map.id) || {};\r\n },\r\n exports: mod.exports || (mod.exports = {})\r\n });\r\n }\r\n }\r\n };\r\n\r\n function cleanRegistry(id) {\r\n //Clean up machinery used for waiting modules.\r\n delete registry[id];\r\n delete enabledRegistry[id];\r\n }\r\n\r\n function breakCycle(mod, traced, processed) {\r\n var id = mod.map.id;\r\n\r\n if (mod.error) {\r\n mod.emit('error', mod.error);\r\n } else {\r\n traced[id] = true;\r\n each(mod.depMaps, function (depMap, i) {\r\n var depId = depMap.id,\r\n dep = getOwn(registry, depId);\r\n\r\n //Only force things that have not completed\r\n //being defined, so still in the registry,\r\n //and only if it has not been matched up\r\n //in the module already.\r\n if (dep && !mod.depMatched[i] && !processed[depId]) {\r\n if (getOwn(traced, depId)) {\r\n mod.defineDep(i, defined[depId]);\r\n mod.check(); //pass false?\r\n } else {\r\n breakCycle(dep, traced, processed);\r\n }\r\n }\r\n });\r\n processed[id] = true;\r\n }\r\n }\r\n\r\n function checkLoaded() {\r\n var err, usingPathFallback,\r\n waitInterval = config.waitSeconds * 1000,\r\n //It is possible to disable the wait interval by using waitSeconds of 0.\r\n expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),\r\n noLoads = [],\r\n reqCalls = [],\r\n stillLoading = false,\r\n needCycleCheck = true;\r\n\r\n //Do not bother if this call was a result of a cycle break.\r\n if (inCheckLoaded) {\r\n return;\r\n }\r\n\r\n inCheckLoaded = true;\r\n\r\n //Figure out the state of all the modules.\r\n eachProp(enabledRegistry, function (mod) {\r\n var map = mod.map,\r\n modId = map.id;\r\n\r\n //Skip things that are not enabled or in error state.\r\n if (!mod.enabled) {\r\n return;\r\n }\r\n\r\n if (!map.isDefine) {\r\n reqCalls.push(mod);\r\n }\r\n\r\n if (!mod.error) {\r\n //If the module should be executed, and it has not\r\n //been inited and time is up, remember it.\r\n if (!mod.inited && expired) {\r\n if (hasPathFallback(modId)) {\r\n usingPathFallback = true;\r\n stillLoading = true;\r\n } else {\r\n noLoads.push(modId);\r\n removeScript(modId);\r\n }\r\n } else if (!mod.inited && mod.fetched && map.isDefine) {\r\n stillLoading = true;\r\n if (!map.prefix) {\r\n //No reason to keep looking for unfinished\r\n //loading. If the only stillLoading is a\r\n //plugin resource though, keep going,\r\n //because it may be that a plugin resource\r\n //is waiting on a non-plugin cycle.\r\n return (needCycleCheck = false);\r\n }\r\n }\r\n }\r\n });\r\n\r\n if (expired && noLoads.length) {\r\n //If wait time expired, throw error of unloaded modules.\r\n err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);\r\n err.contextName = context.contextName;\r\n return onError(err);\r\n }\r\n\r\n //Not expired, check for a cycle.\r\n if (needCycleCheck) {\r\n each(reqCalls, function (mod) {\r\n breakCycle(mod, {}, {});\r\n });\r\n }\r\n\r\n //If still waiting on loads, and the waiting load is something\r\n //other than a plugin resource, or there are still outstanding\r\n //scripts, then just try back later.\r\n if ((!expired || usingPathFallback) && stillLoading) {\r\n //Something is still waiting to load. Wait for it, but only\r\n //if a timeout is not already in effect.\r\n if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {\r\n checkLoadedTimeoutId = setTimeout(function () {\r\n checkLoadedTimeoutId = 0;\r\n checkLoaded();\r\n }, 50);\r\n }\r\n }\r\n\r\n inCheckLoaded = false;\r\n }\r\n\r\n Module = function (map) {\r\n this.events = getOwn(undefEvents, map.id) || {};\r\n this.map = map;\r\n this.shim = getOwn(config.shim, map.id);\r\n this.depExports = [];\r\n this.depMaps = [];\r\n this.depMatched = [];\r\n this.pluginMaps = {};\r\n this.depCount = 0;\r\n\r\n /* this.exports this.factory\r\n this.depMaps = [],\r\n this.enabled, this.fetched\r\n */\r\n };\r\n\r\n Module.prototype = {\r\n init: function (depMaps, factory, errback, options) {\r\n options = options || {};\r\n\r\n //Do not do more inits if already done. Can happen if there\r\n //are multiple define calls for the same module. That is not\r\n //a normal, common case, but it is also not unexpected.\r\n if (this.inited) {\r\n return;\r\n }\r\n\r\n this.factory = factory;\r\n\r\n if (errback) {\r\n //Register for errors on this module.\r\n this.on('error', errback);\r\n } else if (this.events.error) {\r\n //If no errback already, but there are error listeners\r\n //on this module, set up an errback to pass to the deps.\r\n errback = bind(this, function (err) {\r\n this.emit('error', err);\r\n });\r\n }\r\n\r\n //Do a copy of the dependency array, so that\r\n //source inputs are not modified. For example\r\n //\"shim\" deps are passed in here directly, and\r\n //doing a direct modification of the depMaps array\r\n //would affect that config.\r\n this.depMaps = depMaps && depMaps.slice(0);\r\n\r\n this.errback = errback;\r\n\r\n //Indicate this module has be initialized\r\n this.inited = true;\r\n\r\n this.ignore = options.ignore;\r\n\r\n //Could have option to init this module in enabled mode,\r\n //or could have been previously marked as enabled. However,\r\n //the dependencies are not known until init is called. So\r\n //if enabled previously, now trigger dependencies as enabled.\r\n if (options.enabled || this.enabled) {\r\n //Enable this module and dependencies.\r\n //Will call this.check()\r\n this.enable();\r\n } else {\r\n this.check();\r\n }\r\n },\r\n\r\n defineDep: function (i, depExports) {\r\n //Because of cycles, defined callback for a given\r\n //export can be called more than once.\r\n if (!this.depMatched[i]) {\r\n this.depMatched[i] = true;\r\n this.depCount -= 1;\r\n this.depExports[i] = depExports;\r\n }\r\n },\r\n\r\n fetch: function () {\r\n if (this.fetched) {\r\n return;\r\n }\r\n this.fetched = true;\r\n\r\n context.startTime = (new Date()).getTime();\r\n\r\n var map = this.map;\r\n\r\n //If the manager is for a plugin managed resource,\r\n //ask the plugin to load it now.\r\n if (this.shim) {\r\n context.makeRequire(this.map, {\r\n enableBuildCallback: true\r\n })(this.shim.deps || [], bind(this, function () {\r\n return map.prefix ? this.callPlugin() : this.load();\r\n }));\r\n } else {\r\n //Regular dependency.\r\n return map.prefix ? this.callPlugin() : this.load();\r\n }\r\n },\r\n\r\n load: function () {\r\n var url = this.map.url;\r\n\r\n //Regular dependency.\r\n if (!urlFetched[url]) {\r\n urlFetched[url] = true;\r\n context.load(this.map.id, url);\r\n }\r\n },\r\n\r\n /**\r\n * Checks if the module is ready to define itself, and if so,\r\n * define it.\r\n */\r\n check: function () {\r\n if (!this.enabled || this.enabling) {\r\n return;\r\n }\r\n\r\n var err, cjsModule,\r\n id = this.map.id,\r\n depExports = this.depExports,\r\n exports = this.exports,\r\n factory = this.factory;\r\n\r\n if (!this.inited) {\r\n // Only fetch if not already in the defQueue.\r\n if (!hasProp(context.defQueueMap, id)) {\r\n this.fetch();\r\n }\r\n } else if (this.error) {\r\n this.emit('error', this.error);\r\n } else if (!this.defining) {\r\n //The factory could trigger another require call\r\n //that would result in checking this module to\r\n //define itself again. If already in the process\r\n //of doing that, skip this work.\r\n this.defining = true;\r\n\r\n if (this.depCount < 1 && !this.defined) {\r\n if (isFunction(factory)) {\r\n //If there is an error listener, favor passing\r\n //to that instead of throwing an error. However,\r\n //only do it for define()'d modules. require\r\n //errbacks should not be called for failures in\r\n //their callbacks (#699). However if a global\r\n //onError is set, use that.\r\n if ((this.events.error && this.map.isDefine) ||\r\n req.onError !== defaultOnError) {\r\n try {\r\n exports = context.execCb(id, factory, depExports, exports);\r\n } catch (e) {\r\n err = e;\r\n }\r\n } else {\r\n exports = context.execCb(id, factory, depExports, exports);\r\n }\r\n\r\n // Favor return value over exports. If node/cjs in play,\r\n // then will not have a return value anyway. Favor\r\n // module.exports assignment over exports object.\r\n if (this.map.isDefine && exports === undefined) {\r\n cjsModule = this.module;\r\n if (cjsModule) {\r\n exports = cjsModule.exports;\r\n } else if (this.usingExports) {\r\n //exports already set the defined value.\r\n exports = this.exports;\r\n }\r\n }\r\n\r\n if (err) {\r\n err.requireMap = this.map;\r\n err.requireModules = this.map.isDefine ? [this.map.id] : null;\r\n err.requireType = this.map.isDefine ? 'define' : 'require';\r\n return onError((this.error = err));\r\n }\r\n\r\n } else {\r\n //Just a literal value\r\n exports = factory;\r\n }\r\n\r\n this.exports = exports;\r\n\r\n if (this.map.isDefine && !this.ignore) {\r\n defined[id] = exports;\r\n\r\n if (req.onResourceLoad) {\r\n var resLoadMaps = [];\r\n each(this.depMaps, function (depMap) {\r\n resLoadMaps.push(depMap.normalizedMap || depMap);\r\n });\r\n req.onResourceLoad(context, this.map, resLoadMaps);\r\n }\r\n }\r\n\r\n //Clean up\r\n cleanRegistry(id);\r\n\r\n this.defined = true;\r\n }\r\n\r\n //Finished the define stage. Allow calling check again\r\n //to allow define notifications below in the case of a\r\n //cycle.\r\n this.defining = false;\r\n\r\n if (this.defined && !this.defineEmitted) {\r\n this.defineEmitted = true;\r\n this.emit('defined', this.exports);\r\n this.defineEmitComplete = true;\r\n }\r\n\r\n }\r\n },\r\n\r\n callPlugin: function () {\r\n var map = this.map,\r\n id = map.id,\r\n //Map already normalized the prefix.\r\n pluginMap = makeModuleMap(map.prefix);\r\n\r\n //Mark this as a dependency for this plugin, so it\r\n //can be traced for cycles.\r\n this.depMaps.push(pluginMap);\r\n\r\n on(pluginMap, 'defined', bind(this, function (plugin) {\r\n var load, normalizedMap, normalizedMod,\r\n bundleId = getOwn(bundlesMap, this.map.id),\r\n name = this.map.name,\r\n parentName = this.map.parentMap ? this.map.parentMap.name : null,\r\n localRequire = context.makeRequire(map.parentMap, {\r\n enableBuildCallback: true\r\n });\r\n\r\n //If current map is not normalized, wait for that\r\n //normalized name to load instead of continuing.\r\n if (this.map.unnormalized) {\r\n //Normalize the ID if the plugin allows it.\r\n if (plugin.normalize) {\r\n name = plugin.normalize(name, function (name) {\r\n return normalize(name, parentName, true);\r\n }) || '';\r\n }\r\n\r\n //prefix and name should already be normalized, no need\r\n //for applying map config again either.\r\n normalizedMap = makeModuleMap(map.prefix + '!' + name,\r\n this.map.parentMap);\r\n on(normalizedMap,\r\n 'defined', bind(this, function (value) {\r\n this.map.normalizedMap = normalizedMap;\r\n this.init([], function () { return value; }, null, {\r\n enabled: true,\r\n ignore: true\r\n });\r\n }));\r\n\r\n normalizedMod = getOwn(registry, normalizedMap.id);\r\n if (normalizedMod) {\r\n //Mark this as a dependency for this plugin, so it\r\n //can be traced for cycles.\r\n this.depMaps.push(normalizedMap);\r\n\r\n if (this.events.error) {\r\n normalizedMod.on('error', bind(this, function (err) {\r\n this.emit('error', err);\r\n }));\r\n }\r\n normalizedMod.enable();\r\n }\r\n\r\n return;\r\n }\r\n\r\n //If a paths config, then just load that file instead to\r\n //resolve the plugin, as it is built into that paths layer.\r\n if (bundleId) {\r\n this.map.url = context.nameToUrl(bundleId);\r\n this.load();\r\n return;\r\n }\r\n\r\n load = bind(this, function (value) {\r\n this.init([], function () { return value; }, null, {\r\n enabled: true\r\n });\r\n });\r\n\r\n load.error = bind(this, function (err) {\r\n this.inited = true;\r\n this.error = err;\r\n err.requireModules = [id];\r\n\r\n //Remove temp unnormalized modules for this module,\r\n //since they will never be resolved otherwise now.\r\n eachProp(registry, function (mod) {\r\n if (mod.map.id.indexOf(id + '_unnormalized') === 0) {\r\n cleanRegistry(mod.map.id);\r\n }\r\n });\r\n\r\n onError(err);\r\n });\r\n\r\n //Allow plugins to load other code without having to know the\r\n //context or how to 'complete' the load.\r\n load.fromText = bind(this, function (text, textAlt) {\r\n /*jslint evil: true */\r\n var moduleName = map.name,\r\n moduleMap = makeModuleMap(moduleName),\r\n hasInteractive = useInteractive;\r\n\r\n //As of 2.1.0, support just passing the text, to reinforce\r\n //fromText only being called once per resource. Still\r\n //support old style of passing moduleName but discard\r\n //that moduleName in favor of the internal ref.\r\n if (textAlt) {\r\n text = textAlt;\r\n }\r\n\r\n //Turn off interactive script matching for IE for any define\r\n //calls in the text, then turn it back on at the end.\r\n if (hasInteractive) {\r\n useInteractive = false;\r\n }\r\n\r\n //Prime the system by creating a module instance for\r\n //it.\r\n getModule(moduleMap);\r\n\r\n //Transfer any config to this other module.\r\n if (hasProp(config.config, id)) {\r\n config.config[moduleName] = config.config[id];\r\n }\r\n\r\n try {\r\n req.exec(text);\r\n } catch (e) {\r\n return onError(makeError('fromtexteval',\r\n 'fromText eval for ' + id +\r\n ' failed: ' + e,\r\n e,\r\n [id]));\r\n }\r\n\r\n if (hasInteractive) {\r\n useInteractive = true;\r\n }\r\n\r\n //Mark this as a dependency for the plugin\r\n //resource\r\n this.depMaps.push(moduleMap);\r\n\r\n //Support anonymous modules.\r\n context.completeLoad(moduleName);\r\n\r\n //Bind the value of that module to the value for this\r\n //resource ID.\r\n localRequire([moduleName], load);\r\n });\r\n\r\n //Use parentName here since the plugin's name is not reliable,\r\n //could be some weird string with no path that actually wants to\r\n //reference the parentName's path.\r\n plugin.load(map.name, localRequire, load, config);\r\n }));\r\n\r\n context.enable(pluginMap, this);\r\n this.pluginMaps[pluginMap.id] = pluginMap;\r\n },\r\n\r\n enable: function () {\r\n enabledRegistry[this.map.id] = this;\r\n this.enabled = true;\r\n\r\n //Set flag mentioning that the module is enabling,\r\n //so that immediate calls to the defined callbacks\r\n //for dependencies do not trigger inadvertent load\r\n //with the depCount still being zero.\r\n this.enabling = true;\r\n\r\n //Enable each dependency\r\n each(this.depMaps, bind(this, function (depMap, i) {\r\n var id, mod, handler;\r\n\r\n if (typeof depMap === 'string') {\r\n //Dependency needs to be converted to a depMap\r\n //and wired up to this module.\r\n depMap = makeModuleMap(depMap,\r\n (this.map.isDefine ? this.map : this.map.parentMap),\r\n false,\r\n !this.skipMap);\r\n this.depMaps[i] = depMap;\r\n\r\n handler = getOwn(handlers, depMap.id);\r\n\r\n if (handler) {\r\n this.depExports[i] = handler(this);\r\n return;\r\n }\r\n\r\n this.depCount += 1;\r\n\r\n on(depMap, 'defined', bind(this, function (depExports) {\r\n if (this.undefed) {\r\n return;\r\n }\r\n this.defineDep(i, depExports);\r\n this.check();\r\n }));\r\n\r\n if (this.errback) {\r\n on(depMap, 'error', bind(this, this.errback));\r\n } else if (this.events.error) {\r\n // No direct errback on this module, but something\r\n // else is listening for errors, so be sure to\r\n // propagate the error correctly.\r\n on(depMap, 'error', bind(this, function(err) {\r\n this.emit('error', err);\r\n }));\r\n }\r\n }\r\n\r\n id = depMap.id;\r\n mod = registry[id];\r\n\r\n //Skip special modules like 'require', 'exports', 'module'\r\n //Also, don't call enable if it is already enabled,\r\n //important in circular dependency cases.\r\n if (!hasProp(handlers, id) && mod && !mod.enabled) {\r\n context.enable(depMap, this);\r\n }\r\n }));\r\n\r\n //Enable each plugin that is used in\r\n //a dependency\r\n eachProp(this.pluginMaps, bind(this, function (pluginMap) {\r\n var mod = getOwn(registry, pluginMap.id);\r\n if (mod && !mod.enabled) {\r\n context.enable(pluginMap, this);\r\n }\r\n }));\r\n\r\n this.enabling = false;\r\n\r\n this.check();\r\n },\r\n\r\n on: function (name, cb) {\r\n var cbs = this.events[name];\r\n if (!cbs) {\r\n cbs = this.events[name] = [];\r\n }\r\n cbs.push(cb);\r\n },\r\n\r\n emit: function (name, evt) {\r\n each(this.events[name], function (cb) {\r\n cb(evt);\r\n });\r\n if (name === 'error') {\r\n //Now that the error handler was triggered, remove\r\n //the listeners, since this broken Module instance\r\n //can stay around for a while in the registry.\r\n delete this.events[name];\r\n }\r\n }\r\n };\r\n\r\n function callGetModule(args) {\r\n //Skip modules already defined.\r\n if (!hasProp(defined, args[0])) {\r\n getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);\r\n }\r\n }\r\n\r\n function removeListener(node, func, name, ieName) {\r\n //Favor detachEvent because of IE9\r\n //issue, see attachEvent/addEventListener comment elsewhere\r\n //in this file.\r\n if (node.detachEvent && !isOpera) {\r\n //Probably IE. If not it will throw an error, which will be\r\n //useful to know.\r\n if (ieName) {\r\n node.detachEvent(ieName, func);\r\n }\r\n } else {\r\n node.removeEventListener(name, func, false);\r\n }\r\n }\r\n\r\n /**\r\n * Given an event from a script node, get the requirejs info from it,\r\n * and then removes the event listeners on the node.\r\n * @param {Event} evt\r\n * @returns {Object}\r\n */\r\n function getScriptData(evt) {\r\n //Using currentTarget instead of target for Firefox 2.0's sake. Not\r\n //all old browsers will be supported, but this one was easy enough\r\n //to support and still makes sense.\r\n var node = evt.currentTarget || evt.srcElement;\r\n\r\n //Remove the listeners once here.\r\n removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');\r\n removeListener(node, context.onScriptError, 'error');\r\n\r\n return {\r\n node: node,\r\n id: node && node.getAttribute('data-requiremodule')\r\n };\r\n }\r\n\r\n function intakeDefines() {\r\n var args;\r\n\r\n //Any defined modules in the global queue, intake them now.\r\n takeGlobalQueue();\r\n\r\n //Make sure any remaining defQueue items get properly processed.\r\n while (defQueue.length) {\r\n args = defQueue.shift();\r\n if (args[0] === null) {\r\n return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +\r\n args[args.length - 1]));\r\n } else {\r\n //args are id, deps, factory. Should be normalized by the\r\n //define() function.\r\n callGetModule(args);\r\n }\r\n }\r\n context.defQueueMap = {};\r\n }\r\n\r\n context = {\r\n config: config,\r\n contextName: contextName,\r\n registry: registry,\r\n defined: defined,\r\n urlFetched: urlFetched,\r\n defQueue: defQueue,\r\n defQueueMap: {},\r\n Module: Module,\r\n makeModuleMap: makeModuleMap,\r\n nextTick: req.nextTick,\r\n onError: onError,\r\n\r\n /**\r\n * Set a configuration for the context.\r\n * @param {Object} cfg config object to integrate.\r\n */\r\n configure: function (cfg) {\r\n //Make sure the baseUrl ends in a slash.\r\n if (cfg.baseUrl) {\r\n if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {\r\n cfg.baseUrl += '/';\r\n }\r\n }\r\n\r\n // Convert old style urlArgs string to a function.\r\n if (typeof cfg.urlArgs === 'string') {\r\n var urlArgs = cfg.urlArgs;\r\n cfg.urlArgs = function(id, url) {\r\n return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;\r\n };\r\n }\r\n\r\n //Save off the paths since they require special processing,\r\n //they are additive.\r\n var shim = config.shim,\r\n objs = {\r\n paths: true,\r\n bundles: true,\r\n config: true,\r\n map: true\r\n };\r\n\r\n eachProp(cfg, function (value, prop) {\r\n if (objs[prop]) {\r\n if (!config[prop]) {\r\n config[prop] = {};\r\n }\r\n mixin(config[prop], value, true, true);\r\n } else {\r\n config[prop] = value;\r\n }\r\n });\r\n\r\n //Reverse map the bundles\r\n if (cfg.bundles) {\r\n eachProp(cfg.bundles, function (value, prop) {\r\n each(value, function (v) {\r\n if (v !== prop) {\r\n bundlesMap[v] = prop;\r\n }\r\n });\r\n });\r\n }\r\n\r\n //Merge shim\r\n if (cfg.shim) {\r\n eachProp(cfg.shim, function (value, id) {\r\n //Normalize the structure\r\n if (isArray(value)) {\r\n value = {\r\n deps: value\r\n };\r\n }\r\n if ((value.exports || value.init) && !value.exportsFn) {\r\n value.exportsFn = context.makeShimExports(value);\r\n }\r\n shim[id] = value;\r\n });\r\n config.shim = shim;\r\n }\r\n\r\n //Adjust packages if necessary.\r\n if (cfg.packages) {\r\n each(cfg.packages, function (pkgObj) {\r\n var location, name;\r\n\r\n pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;\r\n\r\n name = pkgObj.name;\r\n location = pkgObj.location;\r\n if (location) {\r\n config.paths[name] = pkgObj.location;\r\n }\r\n\r\n //Save pointer to main module ID for pkg name.\r\n //Remove leading dot in main, so main paths are normalized,\r\n //and remove any trailing .js, since different package\r\n //envs have different conventions: some use a module name,\r\n //some use a file name.\r\n config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')\r\n .replace(currDirRegExp, '')\r\n .replace(jsSuffixRegExp, '');\r\n });\r\n }\r\n\r\n //If there are any \"waiting to execute\" modules in the registry,\r\n //update the maps for them, since their info, like URLs to load,\r\n //may have changed.\r\n eachProp(registry, function (mod, id) {\r\n //If module already has init called, since it is too\r\n //late to modify them, and ignore unnormalized ones\r\n //since they are transient.\r\n if (!mod.inited && !mod.map.unnormalized) {\r\n mod.map = makeModuleMap(id, null, true);\r\n }\r\n });\r\n\r\n //If a deps array or a config callback is specified, then call\r\n //require with those args. This is useful when require is defined as a\r\n //config object before require.js is loaded.\r\n if (cfg.deps || cfg.callback) {\r\n context.require(cfg.deps || [], cfg.callback);\r\n }\r\n },\r\n\r\n makeShimExports: function (value) {\r\n function fn() {\r\n var ret;\r\n if (value.init) {\r\n ret = value.init.apply(global, arguments);\r\n }\r\n return ret || (value.exports && getGlobal(value.exports));\r\n }\r\n return fn;\r\n },\r\n\r\n makeRequire: function (relMap, options) {\r\n options = options || {};\r\n\r\n function localRequire(deps, callback, errback) {\r\n var id, map, requireMod;\r\n\r\n if (options.enableBuildCallback && callback && isFunction(callback)) {\r\n callback.__requireJsBuild = true;\r\n }\r\n\r\n if (typeof deps === 'string') {\r\n if (isFunction(callback)) {\r\n //Invalid call\r\n return onError(makeError('requireargs', 'Invalid require call'), errback);\r\n }\r\n\r\n //If require|exports|module are requested, get the\r\n //value for them from the special handlers. Caveat:\r\n //this only works while module is being defined.\r\n if (relMap && hasProp(handlers, deps)) {\r\n return handlers[deps](registry[relMap.id]);\r\n }\r\n\r\n //Synchronous access to one module. If require.get is\r\n //available (as in the Node adapter), prefer that.\r\n if (req.get) {\r\n return req.get(context, deps, relMap, localRequire);\r\n }\r\n\r\n //Normalize module name, if it contains . or ..\r\n map = makeModuleMap(deps, relMap, false, true);\r\n id = map.id;\r\n\r\n if (!hasProp(defined, id)) {\r\n return onError(makeError('notloaded', 'Module name \"' +\r\n id +\r\n '\" has not been loaded yet for context: ' +\r\n contextName +\r\n (relMap ? '' : '. Use require([])')));\r\n }\r\n return defined[id];\r\n }\r\n\r\n //Grab defines waiting in the global queue.\r\n intakeDefines();\r\n\r\n //Mark all the dependencies as needing to be loaded.\r\n context.nextTick(function () {\r\n //Some defines could have been added since the\r\n //require call, collect them.\r\n intakeDefines();\r\n\r\n requireMod = getModule(makeModuleMap(null, relMap));\r\n\r\n //Store if map config should be applied to this require\r\n //call for dependencies.\r\n requireMod.skipMap = options.skipMap;\r\n\r\n requireMod.init(deps, callback, errback, {\r\n enabled: true\r\n });\r\n\r\n checkLoaded();\r\n });\r\n\r\n return localRequire;\r\n }\r\n\r\n mixin(localRequire, {\r\n isBrowser: isBrowser,\r\n\r\n /**\r\n * Converts a module name + .extension into an URL path.\r\n * *Requires* the use of a module name. It does not support using\r\n * plain URLs like nameToUrl.\r\n */\r\n toUrl: function (moduleNamePlusExt) {\r\n var ext,\r\n index = moduleNamePlusExt.lastIndexOf('.'),\r\n segment = moduleNamePlusExt.split('/')[0],\r\n isRelative = segment === '.' || segment === '..';\r\n\r\n //Have a file extension alias, and it is not the\r\n //dots from a relative path.\r\n if (index !== -1 && (!isRelative || index > 1)) {\r\n ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);\r\n moduleNamePlusExt = moduleNamePlusExt.substring(0, index);\r\n }\r\n\r\n return context.nameToUrl(normalize(moduleNamePlusExt,\r\n relMap && relMap.id, true), ext, true);\r\n },\r\n\r\n defined: function (id) {\r\n return hasProp(defined, makeModuleMap(id, relMap, false, true).id);\r\n },\r\n\r\n specified: function (id) {\r\n id = makeModuleMap(id, relMap, false, true).id;\r\n return hasProp(defined, id) || hasProp(registry, id);\r\n }\r\n });\r\n\r\n //Only allow undef on top level require calls\r\n if (!relMap) {\r\n localRequire.undef = function (id) {\r\n //Bind any waiting define() calls to this context,\r\n //fix for #408\r\n takeGlobalQueue();\r\n\r\n var map = makeModuleMap(id, relMap, true),\r\n mod = getOwn(registry, id);\r\n\r\n mod.undefed = true;\r\n removeScript(id);\r\n\r\n delete defined[id];\r\n delete urlFetched[map.url];\r\n delete undefEvents[id];\r\n\r\n //Clean queued defines too. Go backwards\r\n //in array so that the splices do not\r\n //mess up the iteration.\r\n eachReverse(defQueue, function(args, i) {\r\n if (args[0] === id) {\r\n defQueue.splice(i, 1);\r\n }\r\n });\r\n delete context.defQueueMap[id];\r\n\r\n if (mod) {\r\n //Hold on to listeners in case the\r\n //module will be attempted to be reloaded\r\n //using a different config.\r\n if (mod.events.defined) {\r\n undefEvents[id] = mod.events;\r\n }\r\n\r\n cleanRegistry(id);\r\n }\r\n };\r\n }\r\n\r\n return localRequire;\r\n },\r\n\r\n /**\r\n * Called to enable a module if it is still in the registry\r\n * awaiting enablement. A second arg, parent, the parent module,\r\n * is passed in for context, when this method is overridden by\r\n * the optimizer. Not shown here to keep code compact.\r\n */\r\n enable: function (depMap) {\r\n var mod = getOwn(registry, depMap.id);\r\n if (mod) {\r\n getModule(depMap).enable();\r\n }\r\n },\r\n\r\n /**\r\n * Internal method used by environment adapters to complete a load event.\r\n * A load event could be a script load or just a load pass from a synchronous\r\n * load call.\r\n * @param {String} moduleName the name of the module to potentially complete.\r\n */\r\n completeLoad: function (moduleName) {\r\n var found, args, mod,\r\n shim = getOwn(config.shim, moduleName) || {},\r\n shExports = shim.exports;\r\n\r\n takeGlobalQueue();\r\n\r\n while (defQueue.length) {\r\n args = defQueue.shift();\r\n if (args[0] === null) {\r\n args[0] = moduleName;\r\n //If already found an anonymous module and bound it\r\n //to this name, then this is some other anon module\r\n //waiting for its completeLoad to fire.\r\n if (found) {\r\n break;\r\n }\r\n found = true;\r\n } else if (args[0] === moduleName) {\r\n //Found matching define call for this script!\r\n found = true;\r\n }\r\n\r\n callGetModule(args);\r\n }\r\n context.defQueueMap = {};\r\n\r\n //Do this after the cycle of callGetModule in case the result\r\n //of those calls/init calls changes the registry.\r\n mod = getOwn(registry, moduleName);\r\n\r\n if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {\r\n if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {\r\n if (hasPathFallback(moduleName)) {\r\n return;\r\n } else {\r\n return onError(makeError('nodefine',\r\n 'No define call for ' + moduleName,\r\n null,\r\n [moduleName]));\r\n }\r\n } else {\r\n //A script that does not call define(), so just simulate\r\n //the call for it.\r\n callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);\r\n }\r\n }\r\n\r\n checkLoaded();\r\n },\r\n\r\n /**\r\n * Converts a module name to a file path. Supports cases where\r\n * moduleName may actually be just an URL.\r\n * Note that it **does not** call normalize on the moduleName,\r\n * it is assumed to have already been normalized. This is an\r\n * internal API, not a public one. Use toUrl for the public API.\r\n */\r\n nameToUrl: function (moduleName, ext, skipExt) {\r\n var paths, syms, i, parentModule, url,\r\n parentPath, bundleId,\r\n pkgMain = getOwn(config.pkgs, moduleName);\r\n\r\n if (pkgMain) {\r\n moduleName = pkgMain;\r\n }\r\n\r\n bundleId = getOwn(bundlesMap, moduleName);\r\n\r\n if (bundleId) {\r\n return context.nameToUrl(bundleId, ext, skipExt);\r\n }\r\n\r\n //If a colon is in the URL, it indicates a protocol is used and it is just\r\n //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)\r\n //or ends with .js, then assume the user meant to use an url and not a module id.\r\n //The slash is important for protocol-less URLs as well as full paths.\r\n if (req.jsExtRegExp.test(moduleName)) {\r\n //Just a plain path, not module name lookup, so just return it.\r\n //Add extension if it is included. This is a bit wonky, only non-.js things pass\r\n //an extension, this method probably needs to be reworked.\r\n url = moduleName + (ext || '');\r\n } else {\r\n //A module that needs to be converted to a path.\r\n paths = config.paths;\r\n\r\n syms = moduleName.split('/');\r\n //For each module name segment, see if there is a path\r\n //registered for it. Start with most specific name\r\n //and work up from it.\r\n for (i = syms.length; i > 0; i -= 1) {\r\n parentModule = syms.slice(0, i).join('/');\r\n\r\n parentPath = getOwn(paths, parentModule);\r\n if (parentPath) {\r\n //If an array, it means there are a few choices,\r\n //Choose the one that is desired\r\n if (isArray(parentPath)) {\r\n parentPath = parentPath[0];\r\n }\r\n syms.splice(0, i, parentPath);\r\n break;\r\n }\r\n }\r\n\r\n //Join the path parts together, then figure out if baseUrl is needed.\r\n url = syms.join('/');\r\n url += (ext || (/^data\\:|^blob\\:|\\?/.test(url) || skipExt ? '' : '.js'));\r\n url = (url.charAt(0) === '/' || url.match(/^[\\w\\+\\.\\-]+:/) ? '' : config.baseUrl) + url;\r\n }\r\n\r\n return config.urlArgs && !/^blob\\:/.test(url) ?\r\n url + config.urlArgs(moduleName, url) : url;\r\n },\r\n\r\n //Delegates to req.load. Broken out as a separate function to\r\n //allow overriding in the optimizer.\r\n load: function (id, url) {\r\n req.load(context, id, url);\r\n },\r\n\r\n /**\r\n * Executes a module callback function. Broken out as a separate function\r\n * solely to allow the build system to sequence the files in the built\r\n * layer in the right sequence.\r\n *\r\n * @private\r\n */\r\n execCb: function (name, callback, args, exports) {\r\n return callback.apply(exports, args);\r\n },\r\n\r\n /**\r\n * callback for script loads, used to check status of loading.\r\n *\r\n * @param {Event} evt the event from the browser for the script\r\n * that was loaded.\r\n */\r\n onScriptLoad: function (evt) {\r\n //Using currentTarget instead of target for Firefox 2.0's sake. Not\r\n //all old browsers will be supported, but this one was easy enough\r\n //to support and still makes sense.\r\n if (evt.type === 'load' ||\r\n (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {\r\n //Reset interactive script so a script node is not held onto for\r\n //to long.\r\n interactiveScript = null;\r\n\r\n //Pull out the name of the module and the context.\r\n var data = getScriptData(evt);\r\n context.completeLoad(data.id);\r\n }\r\n },\r\n\r\n /**\r\n * Callback for script errors.\r\n */\r\n onScriptError: function (evt) {\r\n var data = getScriptData(evt);\r\n if (!hasPathFallback(data.id)) {\r\n var parents = [];\r\n eachProp(registry, function(value, key) {\r\n if (key.indexOf('_@r') !== 0) {\r\n each(value.depMaps, function(depMap) {\r\n if (depMap.id === data.id) {\r\n parents.push(key);\r\n return true;\r\n }\r\n });\r\n }\r\n });\r\n return onError(makeError('scripterror', 'Script error for \"' + data.id +\r\n (parents.length ?\r\n '\", needed by: ' + parents.join(', ') :\r\n '\"'), evt, [data.id]));\r\n }\r\n }\r\n };\r\n\r\n context.require = context.makeRequire();\r\n return context;\r\n }\r\n\r\n /**\r\n * Main entry point.\r\n *\r\n * If the only argument to require is a string, then the module that\r\n * is represented by that string is fetched for the appropriate context.\r\n *\r\n * If the first argument is an array, then it will be treated as an array\r\n * of dependency string names to fetch. An optional function callback can\r\n * be specified to execute when all of those dependencies are available.\r\n *\r\n * Make a local req variable to help Caja compliance (it assumes things\r\n * on a require that are not standardized), and to give a short\r\n * name for minification/local scope use.\r\n */\r\n req = requirejs = function (deps, callback, errback, optional) {\r\n\r\n //Find the right context, use default\r\n var context, config,\r\n contextName = defContextName;\r\n\r\n // Determine if have config object in the call.\r\n if (!isArray(deps) && typeof deps !== 'string') {\r\n // deps is a config object\r\n config = deps;\r\n if (isArray(callback)) {\r\n // Adjust args if there are dependencies\r\n deps = callback;\r\n callback = errback;\r\n errback = optional;\r\n } else {\r\n deps = [];\r\n }\r\n }\r\n\r\n if (config && config.context) {\r\n contextName = config.context;\r\n }\r\n\r\n context = getOwn(contexts, contextName);\r\n if (!context) {\r\n context = contexts[contextName] = req.s.newContext(contextName);\r\n }\r\n\r\n if (config) {\r\n context.configure(config);\r\n }\r\n\r\n return context.require(deps, callback, errback);\r\n };\r\n\r\n /**\r\n * Support require.config() to make it easier to cooperate with other\r\n * AMD loaders on globally agreed names.\r\n */\r\n req.config = function (config) {\r\n return req(config);\r\n };\r\n\r\n /**\r\n * Execute something after the current tick\r\n * of the event loop. Override for other envs\r\n * that have a better solution than setTimeout.\r\n * @param {Function} fn function to execute later.\r\n */\r\n req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {\r\n setTimeout(fn, 4);\r\n } : function (fn) { fn(); };\r\n\r\n /**\r\n * Export require as a global, but only if it does not already exist.\r\n */\r\n if (!require) {\r\n require = req;\r\n }\r\n\r\n req.version = version;\r\n\r\n //Used to filter out dependencies that are already paths.\r\n req.jsExtRegExp = /^\\/|:|\\?|\\.js$/;\r\n req.isBrowser = isBrowser;\r\n s = req.s = {\r\n contexts: contexts,\r\n newContext: newContext\r\n };\r\n\r\n //Create default context.\r\n req({});\r\n\r\n //Exports some context-sensitive methods on global require.\r\n each([\r\n 'toUrl',\r\n 'undef',\r\n 'defined',\r\n 'specified'\r\n ], function (prop) {\r\n //Reference from contexts instead of early binding to default context,\r\n //so that during builds, the latest instance of the default context\r\n //with its config gets used.\r\n req[prop] = function () {\r\n var ctx = contexts[defContextName];\r\n return ctx.require[prop].apply(ctx, arguments);\r\n };\r\n });\r\n\r\n if (isBrowser) {\r\n head = s.head = document.getElementsByTagName('head')[0];\r\n //If BASE tag is in play, using appendChild is a problem for IE6.\r\n //When that browser dies, this can be removed. Details in this jQuery bug:\r\n //http://dev.jquery.com/ticket/2709\r\n baseElement = document.getElementsByTagName('base')[0];\r\n if (baseElement) {\r\n head = s.head = baseElement.parentNode;\r\n }\r\n }\r\n\r\n /**\r\n * Any errors that require explicitly generates will be passed to this\r\n * function. Intercept/override it if you want custom error handling.\r\n * @param {Error} err the error object.\r\n */\r\n req.onError = defaultOnError;\r\n\r\n /**\r\n * Creates the node for the load command. Only used in browser envs.\r\n */\r\n req.createNode = function (config, moduleName, url) {\r\n var node = config.xhtml ?\r\n document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :\r\n document.createElement('script');\r\n node.type = config.scriptType || 'text/javascript';\r\n node.charset = 'utf-8';\r\n node.async = true;\r\n return node;\r\n };\r\n\r\n /**\r\n * Does the request to load a module for the browser case.\r\n * Make this a separate function to allow other environments\r\n * to override it.\r\n *\r\n * @param {Object} context the require context to find state.\r\n * @param {String} moduleName the name of the module.\r\n * @param {Object} url the URL to the module.\r\n */\r\n req.load = function (context, moduleName, url) {\r\n var config = (context && context.config) || {},\r\n node;\r\n if (isBrowser) {\r\n //In the browser so use a script tag\r\n node = req.createNode(config, moduleName, url);\r\n\r\n node.setAttribute('data-requirecontext', context.contextName);\r\n node.setAttribute('data-requiremodule', moduleName);\r\n\r\n //Set up load listener. Test attachEvent first because IE9 has\r\n //a subtle issue in its addEventListener and script onload firings\r\n //that do not match the behavior of all other browsers with\r\n //addEventListener support, which fire the onload event for a\r\n //script right after the script execution. See:\r\n //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution\r\n //UNFORTUNATELY Opera implements attachEvent but does not follow the script\r\n //script execution mode.\r\n if (node.attachEvent &&\r\n //Check if node.attachEvent is artificially added by custom script or\r\n //natively supported by browser\r\n //read https://github.com/requirejs/requirejs/issues/187\r\n //if we can NOT find [native code] then it must NOT natively supported.\r\n //in IE8, node.attachEvent does not have toString()\r\n //Note the test for \"[native code\" with no closing brace, see:\r\n //https://github.com/requirejs/requirejs/issues/273\r\n !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&\r\n !isOpera) {\r\n //Probably IE. IE (at least 6-8) do not fire\r\n //script onload right after executing the script, so\r\n //we cannot tie the anonymous define call to a name.\r\n //However, IE reports the script as being in 'interactive'\r\n //readyState at the time of the define call.\r\n useInteractive = true;\r\n\r\n node.attachEvent('onreadystatechange', context.onScriptLoad);\r\n //It would be great to add an error handler here to catch\r\n //404s in IE9+. However, onreadystatechange will fire before\r\n //the error handler, so that does not help. If addEventListener\r\n //is used, then IE will fire error before load, but we cannot\r\n //use that pathway given the connect.microsoft.com issue\r\n //mentioned above about not doing the 'script execute,\r\n //then fire the script load event listener before execute\r\n //next script' that other browsers do.\r\n //Best hope: IE10 fixes the issues,\r\n //and then destroys all installs of IE 6-9.\r\n //node.attachEvent('onerror', context.onScriptError);\r\n } else {\r\n node.addEventListener('load', context.onScriptLoad, false);\r\n node.addEventListener('error', context.onScriptError, false);\r\n }\r\n node.src = url;\r\n\r\n //Calling onNodeCreated after all properties on the node have been\r\n //set, but before it is placed in the DOM.\r\n if (config.onNodeCreated) {\r\n config.onNodeCreated(node, config, moduleName, url);\r\n }\r\n\r\n //For some cache cases in IE 6-8, the script executes before the end\r\n //of the appendChild execution, so to tie an anonymous define\r\n //call to the module name (which is stored on the node), hold on\r\n //to a reference to this node, but clear after the DOM insertion.\r\n currentlyAddingScript = node;\r\n if (baseElement) {\r\n head.insertBefore(node, baseElement);\r\n } else {\r\n head.appendChild(node);\r\n }\r\n currentlyAddingScript = null;\r\n\r\n return node;\r\n } else if (isWebWorker) {\r\n try {\r\n //In a web worker, use importScripts. This is not a very\r\n //efficient use of importScripts, importScripts will block until\r\n //its script is downloaded and evaluated. However, if web workers\r\n //are in play, the expectation is that a build has been done so\r\n //that only one script needs to be loaded anyway. This may need\r\n //to be reevaluated if other use cases become common.\r\n\r\n // Post a task to the event loop to work around a bug in WebKit\r\n // where the worker gets garbage-collected after calling\r\n // importScripts(): https://webkit.org/b/153317\r\n setTimeout(function() {}, 0);\r\n importScripts(url);\r\n\r\n //Account for anonymous modules\r\n context.completeLoad(moduleName);\r\n } catch (e) {\r\n context.onError(makeError('importscripts',\r\n 'importScripts failed for ' +\r\n moduleName + ' at ' + url,\r\n e,\r\n [moduleName]));\r\n }\r\n }\r\n };\r\n\r\n function getInteractiveScript() {\r\n if (interactiveScript && interactiveScript.readyState === 'interactive') {\r\n return interactiveScript;\r\n }\r\n\r\n eachReverse(scripts(), function (script) {\r\n if (script.readyState === 'interactive') {\r\n return (interactiveScript = script);\r\n }\r\n });\r\n return interactiveScript;\r\n }\r\n\r\n //Look for a data-main script attribute, which could also adjust the baseUrl.\r\n if (isBrowser && !cfg.skipDataMain) {\r\n //Figure out baseUrl. Get it from the script tag with require.js in it.\r\n eachReverse(scripts(), function (script) {\r\n //Set the 'head' where we can append children by\r\n //using the script's parent.\r\n if (!head) {\r\n head = script.parentNode;\r\n }\r\n\r\n //Look for a data-main attribute to set main script for the page\r\n //to load. If it is there, the path to data main becomes the\r\n //baseUrl, if it is not already set.\r\n dataMain = script.getAttribute('data-main');\r\n if (dataMain) {\r\n //Preserve dataMain in case it is a path (i.e. contains '?')\r\n mainScript = dataMain;\r\n\r\n //Set final baseUrl if there is not already an explicit one,\r\n //but only do so if the data-main value is not a loader plugin\r\n //module ID.\r\n if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {\r\n //Pull off the directory of data-main for use as the\r\n //baseUrl.\r\n src = mainScript.split('/');\r\n mainScript = src.pop();\r\n subPath = src.length ? src.join('/') + '/' : './';\r\n\r\n cfg.baseUrl = subPath;\r\n }\r\n\r\n //Strip off any trailing .js since mainScript is now\r\n //like a module name.\r\n mainScript = mainScript.replace(jsSuffixRegExp, '');\r\n\r\n //If mainScript is still a path, fall back to dataMain\r\n if (req.jsExtRegExp.test(mainScript)) {\r\n mainScript = dataMain;\r\n }\r\n\r\n //Put the data-main script in the files to load.\r\n cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];\r\n\r\n return true;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * The function that handles definitions of modules. Differs from\r\n * require() in that a string for the module should be the first argument,\r\n * and the function to execute after dependencies are loaded should\r\n * return a value to define the module corresponding to the first argument's\r\n * name.\r\n */\r\n define = function (name, deps, callback) {\r\n var node, context;\r\n\r\n //Allow for anonymous modules\r\n if (typeof name !== 'string') {\r\n //Adjust args appropriately\r\n callback = deps;\r\n deps = name;\r\n name = null;\r\n }\r\n\r\n //This module may not have dependencies\r\n if (!isArray(deps)) {\r\n callback = deps;\r\n deps = null;\r\n }\r\n\r\n //If no name, and callback is a function, then figure out if it a\r\n //CommonJS thing with dependencies.\r\n if (!deps && isFunction(callback)) {\r\n deps = [];\r\n //Remove comments from the callback string,\r\n //look for require calls, and pull them into the dependencies,\r\n //but only if there are function args.\r\n if (callback.length) {\r\n callback\r\n .toString()\r\n .replace(commentRegExp, commentReplace)\r\n .replace(cjsRequireRegExp, function (match, dep) {\r\n deps.push(dep);\r\n });\r\n\r\n //May be a CommonJS thing even without require calls, but still\r\n //could use exports, and module. Avoid doing exports and module\r\n //work though if it just needs require.\r\n //REQUIRES the function to expect the CommonJS variables in the\r\n //order listed below.\r\n deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);\r\n }\r\n }\r\n\r\n //If in IE 6-8 and hit an anonymous define() call, do the interactive\r\n //work.\r\n if (useInteractive) {\r\n node = currentlyAddingScript || getInteractiveScript();\r\n if (node) {\r\n if (!name) {\r\n name = node.getAttribute('data-requiremodule');\r\n }\r\n context = contexts[node.getAttribute('data-requirecontext')];\r\n }\r\n }\r\n\r\n //Always save off evaluating the def call until the script onload handler.\r\n //This allows multiple modules to be in a file without prematurely\r\n //tracing dependencies, and allows for anonymous module support,\r\n //where the module name is not known until the script onload event\r\n //occurs. If no context, use the global queue, and get it processed\r\n //in the onscript load callback.\r\n if (context) {\r\n context.defQueue.push([name, deps, callback]);\r\n context.defQueueMap[name] = true;\r\n } else {\r\n globalDefQueue.push([name, deps, callback]);\r\n }\r\n };\r\n\r\n define.amd = {\r\n jQuery: true\r\n };\r\n\r\n /**\r\n * Executes the text. Normally just uses eval, but can be modified\r\n * to use a better, environment-specific call. Only used for transpiling\r\n * loader plugins, not for plain JS modules.\r\n * @param {String} text the text to execute/evaluate.\r\n */\r\n req.exec = function (text) {\r\n /*jslint evil: true */\r\n return eval(text);\r\n };\r\n\r\n //Set up with config info.\r\n req(cfg);\r\n}(this));\r\n"],"file":"require.js","sourceRoot":"/source/"}