/** vim: et:ts=4:sw=4:sts=41* @license RequireJS 2.1.10 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.2* Available via the MIT or new BSD license.3* see: http://github.com/jrburke/requirejs for details4*/5//Not using strict: uneven strict support in browsers, #392, and causes6//problems with requirejs.exec()/transpiler plugins that may not be strict.7/*jslint regexp: true, nomen: true, sloppy: true */8/*global window, navigator, document, importScripts, setTimeout, opera */910var requirejs, require, define;11(function (global) {12var req, s, head, baseElement, dataMain, src,13interactiveScript, currentlyAddingScript, mainScript, subPath,14version = '2.1.10',15commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,16cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,17jsSuffixRegExp = /\.js$/,18currDirRegExp = /^\.\//,19op = Object.prototype,20ostring = op.toString,21hasOwn = op.hasOwnProperty,22ap = Array.prototype,23apsp = ap.splice,24isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),25isWebWorker = !isBrowser && typeof importScripts !== 'undefined',26//PS3 indicates loaded and complete, but need to wait for complete27//specifically. Sequence is 'loading', 'loaded', execution,28// then 'complete'. The UA check is unfortunate, but not sure how29//to feature test w/o causing perf issues.30readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?31/^complete$/ : /^(complete|loaded)$/,32defContextName = '_',33//Oh the tragedy, detecting opera. See the usage of isOpera for reason.34isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',35contexts = {},36cfg = {},37globalDefQueue = [],38useInteractive = false;3940function isFunction(it) {41return ostring.call(it) === '[object Function]';42}4344function isArray(it) {45return ostring.call(it) === '[object Array]';46}4748/**49* Helper function for iterating over an array. If the func returns50* a true value, it will break out of the loop.51*/52function each(ary, func) {53if (ary) {54var i;55for (i = 0; i < ary.length; i += 1) {56if (ary[i] && func(ary[i], i, ary)) {57break;58}59}60}61}6263/**64* Helper function for iterating over an array backwards. If the func65* returns a true value, it will break out of the loop.66*/67function eachReverse(ary, func) {68if (ary) {69var i;70for (i = ary.length - 1; i > -1; i -= 1) {71if (ary[i] && func(ary[i], i, ary)) {72break;73}74}75}76}7778function hasProp(obj, prop) {79return hasOwn.call(obj, prop);80}8182function getOwn(obj, prop) {83return hasProp(obj, prop) && obj[prop];84}8586/**87* Cycles over properties in an object and calls a function for each88* property value. If the function returns a truthy value, then the89* iteration is stopped.90*/91function eachProp(obj, func) {92var prop;93for (prop in obj) {94if (hasProp(obj, prop)) {95if (func(obj[prop], prop)) {96break;97}98}99}100}101102/**103* Simple function to mix in properties from source into target,104* but only if target does not already have a property of the same name.105*/106function mixin(target, source, force, deepStringMixin) {107if (source) {108eachProp(source, function (value, prop) {109if (force || !hasProp(target, prop)) {110if (deepStringMixin && typeof value === 'object' && value &&111!isArray(value) && !isFunction(value) &&112!(value instanceof RegExp)) {113114if (!target[prop]) {115target[prop] = {};116}117mixin(target[prop], value, force, deepStringMixin);118} else {119target[prop] = value;120}121}122});123}124return target;125}126127//Similar to Function.prototype.bind, but the 'this' object is specified128//first, since it is easier to read/figure out what 'this' will be.129function bind(obj, fn) {130return function () {131return fn.apply(obj, arguments);132};133}134135function scripts() {136return document.getElementsByTagName('script');137}138139function defaultOnError(err) {140throw err;141}142143//Allow getting a global that expressed in144//dot notation, like 'a.b.c'.145function getGlobal(value) {146if (!value) {147return value;148}149var g = global;150each(value.split('.'), function (part) {151g = g[part];152});153return g;154}155156/**157* Constructs an error with a pointer to an URL with more information.158* @param {String} id the error ID that maps to an ID on a web page.159* @param {String} message human readable error.160* @param {Error} [err] the original error, if there is one.161*162* @returns {Error}163*/164function makeError(id, msg, err, requireModules) {165var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);166e.requireType = id;167e.requireModules = requireModules;168if (err) {169e.originalError = err;170}171return e;172}173174if (typeof define !== 'undefined') {175//If a define is already in play via another AMD loader,176//do not overwrite.177return;178}179180if (typeof requirejs !== 'undefined') {181if (isFunction(requirejs)) {182//Do not overwrite and existing requirejs instance.183return;184}185cfg = requirejs;186requirejs = undefined;187}188189//Allow for a require config object190if (typeof require !== 'undefined' && !isFunction(require)) {191//assume it is a config object.192cfg = require;193require = undefined;194}195196function newContext(contextName) {197var inCheckLoaded, Module, context, handlers,198checkLoadedTimeoutId,199config = {200//Defaults. Do not set a default for map201//config to speed up normalize(), which202//will run faster if there is no default.203waitSeconds: 7,204baseUrl: './',205paths: {},206bundles: {},207pkgs: {},208shim: {},209config: {}210},211registry = {},212//registry of just enabled modules, to speed213//cycle breaking code when lots of modules214//are registered, but not activated.215enabledRegistry = {},216undefEvents = {},217defQueue = [],218defined = {},219urlFetched = {},220bundlesMap = {},221requireCounter = 1,222unnormalizedCounter = 1;223224/**225* Trims the . and .. from an array of path segments.226* It will keep a leading path segment if a .. will become227* the first path segment, to help with module name lookups,228* which act like paths, but can be remapped. But the end result,229* all paths that use this function should look normalized.230* NOTE: this method MODIFIES the input array.231* @param {Array} ary the array of path segments.232*/233function trimDots(ary) {234var i, part, length = ary.length;235for (i = 0; i < length; i++) {236part = ary[i];237if (part === '.') {238ary.splice(i, 1);239i -= 1;240} else if (part === '..') {241if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {242//End of the line. Keep at least one non-dot243//path segment at the front so it can be mapped244//correctly to disk. Otherwise, there is likely245//no path mapping for a path starting with '..'.246//This can still fail, but catches the most reasonable247//uses of ..248break;249} else if (i > 0) {250ary.splice(i - 1, 2);251i -= 2;252}253}254}255}256257/**258* Given a relative module name, like ./something, normalize it to259* a real name that can be mapped to a path.260* @param {String} name the relative name261* @param {String} baseName a real name that the name arg is relative262* to.263* @param {Boolean} applyMap apply the map config to the value. Should264* only be done if this normalization is for a dependency ID.265* @returns {String} normalized name266*/267function normalize(name, baseName, applyMap) {268var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,269foundMap, foundI, foundStarMap, starI,270baseParts = baseName && baseName.split('/'),271normalizedBaseParts = baseParts,272map = config.map,273starMap = map && map['*'];274275//Adjust any relative paths.276if (name && name.charAt(0) === '.') {277//If have a base name, try to normalize against it,278//otherwise, assume it is a top-level require that will279//be relative to baseUrl in the end.280if (baseName) {281//Convert baseName to array, and lop off the last part,282//so that . matches that 'directory' and not name of the baseName's283//module. For instance, baseName of 'one/two/three', maps to284//'one/two/three.js', but we want the directory, 'one/two' for285//this normalization.286normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);287name = name.split('/');288lastIndex = name.length - 1;289290// If wanting node ID compatibility, strip .js from end291// of IDs. Have to do this here, and not in nameToUrl292// because node allows either .js or non .js to map293// to same file.294if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {295name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');296}297298name = normalizedBaseParts.concat(name);299trimDots(name);300name = name.join('/');301} else if (name.indexOf('./') === 0) {302// No baseName, so this is ID is resolved relative303// to baseUrl, pull off the leading dot.304name = name.substring(2);305}306}307308//Apply map config if available.309if (applyMap && map && (baseParts || starMap)) {310nameParts = name.split('/');311312outerLoop: for (i = nameParts.length; i > 0; i -= 1) {313nameSegment = nameParts.slice(0, i).join('/');314315if (baseParts) {316//Find the longest baseName segment match in the config.317//So, do joins on the biggest to smallest lengths of baseParts.318for (j = baseParts.length; j > 0; j -= 1) {319mapValue = getOwn(map, baseParts.slice(0, j).join('/'));320321//baseName segment has config, find if it has one for322//this name.323if (mapValue) {324mapValue = getOwn(mapValue, nameSegment);325if (mapValue) {326//Match, update name to the new value.327foundMap = mapValue;328foundI = i;329break outerLoop;330}331}332}333}334335//Check for a star map match, but just hold on to it,336//if there is a shorter segment match later in a matching337//config, then favor over this star map.338if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {339foundStarMap = getOwn(starMap, nameSegment);340starI = i;341}342}343344if (!foundMap && foundStarMap) {345foundMap = foundStarMap;346foundI = starI;347}348349if (foundMap) {350nameParts.splice(0, foundI, foundMap);351name = nameParts.join('/');352}353}354355// If the name points to a package's name, use356// the package main instead.357pkgMain = getOwn(config.pkgs, name);358359return pkgMain ? pkgMain : name;360}361362function removeScript(name) {363if (isBrowser) {364each(scripts(), function (scriptNode) {365if (scriptNode.getAttribute('data-requiremodule') === name &&366scriptNode.getAttribute('data-requirecontext') === context.contextName) {367scriptNode.parentNode.removeChild(scriptNode);368return true;369}370});371}372}373374function hasPathFallback(id) {375var pathConfig = getOwn(config.paths, id);376if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {377//Pop off the first array value, since it failed, and378//retry379pathConfig.shift();380context.require.undef(id);381context.require([id]);382return true;383}384}385386//Turns a plugin!resource to [plugin, resource]387//with the plugin being undefined if the name388//did not have a plugin prefix.389function splitPrefix(name) {390var prefix,391index = name ? name.indexOf('!') : -1;392if (index > -1) {393prefix = name.substring(0, index);394name = name.substring(index + 1, name.length);395}396return [prefix, name];397}398399/**400* Creates a module mapping that includes plugin prefix, module401* name, and path. If parentModuleMap is provided it will402* also normalize the name via require.normalize()403*404* @param {String} name the module name405* @param {String} [parentModuleMap] parent module map406* for the module name, used to resolve relative names.407* @param {Boolean} isNormalized: is the ID already normalized.408* This is true if this call is done for a define() module ID.409* @param {Boolean} applyMap: apply the map config to the ID.410* Should only be true if this map is for a dependency.411*412* @returns {Object}413*/414function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {415var url, pluginModule, suffix, nameParts,416prefix = null,417parentName = parentModuleMap ? parentModuleMap.name : null,418originalName = name,419isDefine = true,420normalizedName = '';421422//If no name, then it means it is a require call, generate an423//internal name.424if (!name) {425isDefine = false;426name = '_@r' + (requireCounter += 1);427}428429nameParts = splitPrefix(name);430prefix = nameParts[0];431name = nameParts[1];432433if (prefix) {434prefix = normalize(prefix, parentName, applyMap);435pluginModule = getOwn(defined, prefix);436}437438//Account for relative paths if there is a base name.439if (name) {440if (prefix) {441if (pluginModule && pluginModule.normalize) {442//Plugin is loaded, use its normalize method.443normalizedName = pluginModule.normalize(name, function (name) {444return normalize(name, parentName, applyMap);445});446} else {447normalizedName = normalize(name, parentName, applyMap);448}449} else {450//A regular module.451normalizedName = normalize(name, parentName, applyMap);452453//Normalized name may be a plugin ID due to map config454//application in normalize. The map config values must455//already be normalized, so do not need to redo that part.456nameParts = splitPrefix(normalizedName);457prefix = nameParts[0];458normalizedName = nameParts[1];459isNormalized = true;460461url = context.nameToUrl(normalizedName);462}463}464465//If the id is a plugin id that cannot be determined if it needs466//normalization, stamp it with a unique ID so two matching relative467//ids that may conflict can be separate.468suffix = prefix && !pluginModule && !isNormalized ?469'_unnormalized' + (unnormalizedCounter += 1) :470'';471472return {473prefix: prefix,474name: normalizedName,475parentMap: parentModuleMap,476unnormalized: !!suffix,477url: url,478originalName: originalName,479isDefine: isDefine,480id: (prefix ?481prefix + '!' + normalizedName :482normalizedName) + suffix483};484}485486function getModule(depMap) {487var id = depMap.id,488mod = getOwn(registry, id);489490if (!mod) {491mod = registry[id] = new context.Module(depMap);492}493494return mod;495}496497function on(depMap, name, fn) {498var id = depMap.id,499mod = getOwn(registry, id);500501if (hasProp(defined, id) &&502(!mod || mod.defineEmitComplete)) {503if (name === 'defined') {504fn(defined[id]);505}506} else {507mod = getModule(depMap);508if (mod.error && name === 'error') {509fn(mod.error);510} else {511mod.on(name, fn);512}513}514}515516function onError(err, errback) {517var ids = err.requireModules,518notified = false;519520if (errback) {521errback(err);522} else {523each(ids, function (id) {524var mod = getOwn(registry, id);525if (mod) {526//Set error on module, so it skips timeout checks.527mod.error = err;528if (mod.events.error) {529notified = true;530mod.emit('error', err);531}532}533});534535if (!notified) {536req.onError(err);537}538}539}540541/**542* Internal method to transfer globalQueue items to this context's543* defQueue.544*/545function takeGlobalQueue() {546//Push all the globalDefQueue items into the context's defQueue547if (globalDefQueue.length) {548//Array splice in the values since the context code has a549//local var ref to defQueue, so cannot just reassign the one550//on context.551apsp.apply(defQueue,552[defQueue.length, 0].concat(globalDefQueue));553globalDefQueue = [];554}555}556557handlers = {558'require': function (mod) {559if (mod.require) {560return mod.require;561} else {562return (mod.require = context.makeRequire(mod.map));563}564},565'exports': function (mod) {566mod.usingExports = true;567if (mod.map.isDefine) {568if (mod.exports) {569return mod.exports;570} else {571return (mod.exports = defined[mod.map.id] = {});572}573}574},575'module': function (mod) {576if (mod.module) {577return mod.module;578} else {579return (mod.module = {580id: mod.map.id,581uri: mod.map.url,582config: function () {583return getOwn(config.config, mod.map.id) || {};584},585exports: handlers.exports(mod)586});587}588}589};590591function cleanRegistry(id) {592//Clean up machinery used for waiting modules.593delete registry[id];594delete enabledRegistry[id];595}596597function breakCycle(mod, traced, processed) {598var id = mod.map.id;599600if (mod.error) {601mod.emit('error', mod.error);602} else {603traced[id] = true;604each(mod.depMaps, function (depMap, i) {605var depId = depMap.id,606dep = getOwn(registry, depId);607608//Only force things that have not completed609//being defined, so still in the registry,610//and only if it has not been matched up611//in the module already.612if (dep && !mod.depMatched[i] && !processed[depId]) {613if (getOwn(traced, depId)) {614mod.defineDep(i, defined[depId]);615mod.check(); //pass false?616} else {617breakCycle(dep, traced, processed);618}619}620});621processed[id] = true;622}623}624625function checkLoaded() {626var err, usingPathFallback,627waitInterval = config.waitSeconds * 1000,628//It is possible to disable the wait interval by using waitSeconds of 0.629expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),630noLoads = [],631reqCalls = [],632stillLoading = false,633needCycleCheck = true;634635//Do not bother if this call was a result of a cycle break.636if (inCheckLoaded) {637return;638}639640inCheckLoaded = true;641642//Figure out the state of all the modules.643eachProp(enabledRegistry, function (mod) {644var map = mod.map,645modId = map.id;646647//Skip things that are not enabled or in error state.648if (!mod.enabled) {649return;650}651652if (!map.isDefine) {653reqCalls.push(mod);654}655656if (!mod.error) {657//If the module should be executed, and it has not658//been inited and time is up, remember it.659if (!mod.inited && expired) {660if (hasPathFallback(modId)) {661usingPathFallback = true;662stillLoading = true;663} else {664noLoads.push(modId);665removeScript(modId);666}667} else if (!mod.inited && mod.fetched && map.isDefine) {668stillLoading = true;669if (!map.prefix) {670//No reason to keep looking for unfinished671//loading. If the only stillLoading is a672//plugin resource though, keep going,673//because it may be that a plugin resource674//is waiting on a non-plugin cycle.675return (needCycleCheck = false);676}677}678}679});680681if (expired && noLoads.length) {682//If wait time expired, throw error of unloaded modules.683err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);684err.contextName = context.contextName;685return onError(err);686}687688//Not expired, check for a cycle.689if (needCycleCheck) {690each(reqCalls, function (mod) {691breakCycle(mod, {}, {});692});693}694695//If still waiting on loads, and the waiting load is something696//other than a plugin resource, or there are still outstanding697//scripts, then just try back later.698if ((!expired || usingPathFallback) && stillLoading) {699//Something is still waiting to load. Wait for it, but only700//if a timeout is not already in effect.701if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {702checkLoadedTimeoutId = setTimeout(function () {703checkLoadedTimeoutId = 0;704checkLoaded();705}, 50);706}707}708709inCheckLoaded = false;710}711712Module = function (map) {713this.events = getOwn(undefEvents, map.id) || {};714this.map = map;715this.shim = getOwn(config.shim, map.id);716this.depExports = [];717this.depMaps = [];718this.depMatched = [];719this.pluginMaps = {};720this.depCount = 0;721722/* this.exports this.factory723this.depMaps = [],724this.enabled, this.fetched725*/726};727728Module.prototype = {729init: function (depMaps, factory, errback, options) {730options = options || {};731732//Do not do more inits if already done. Can happen if there733//are multiple define calls for the same module. That is not734//a normal, common case, but it is also not unexpected.735if (this.inited) {736return;737}738739this.factory = factory;740741if (errback) {742//Register for errors on this module.743this.on('error', errback);744} else if (this.events.error) {745//If no errback already, but there are error listeners746//on this module, set up an errback to pass to the deps.747errback = bind(this, function (err) {748this.emit('error', err);749});750}751752//Do a copy of the dependency array, so that753//source inputs are not modified. For example754//"shim" deps are passed in here directly, and755//doing a direct modification of the depMaps array756//would affect that config.757this.depMaps = depMaps && depMaps.slice(0);758759this.errback = errback;760761//Indicate this module has be initialized762this.inited = true;763764this.ignore = options.ignore;765766//Could have option to init this module in enabled mode,767//or could have been previously marked as enabled. However,768//the dependencies are not known until init is called. So769//if enabled previously, now trigger dependencies as enabled.770if (options.enabled || this.enabled) {771//Enable this module and dependencies.772//Will call this.check()773this.enable();774} else {775this.check();776}777},778779defineDep: function (i, depExports) {780//Because of cycles, defined callback for a given781//export can be called more than once.782if (!this.depMatched[i]) {783this.depMatched[i] = true;784this.depCount -= 1;785this.depExports[i] = depExports;786}787},788789fetch: function () {790if (this.fetched) {791return;792}793this.fetched = true;794795context.startTime = (new Date()).getTime();796797var map = this.map;798799//If the manager is for a plugin managed resource,800//ask the plugin to load it now.801if (this.shim) {802context.makeRequire(this.map, {803enableBuildCallback: true804})(this.shim.deps || [], bind(this, function () {805return map.prefix ? this.callPlugin() : this.load();806}));807} else {808//Regular dependency.809return map.prefix ? this.callPlugin() : this.load();810}811},812813load: function () {814var url = this.map.url;815816//Regular dependency.817if (!urlFetched[url]) {818urlFetched[url] = true;819context.load(this.map.id, url);820}821},822823/**824* Checks if the module is ready to define itself, and if so,825* define it.826*/827check: function () {828if (!this.enabled || this.enabling) {829return;830}831832var err, cjsModule,833id = this.map.id,834depExports = this.depExports,835exports = this.exports,836factory = this.factory;837838if (!this.inited) {839this.fetch();840} else if (this.error) {841this.emit('error', this.error);842} else if (!this.defining) {843//The factory could trigger another require call844//that would result in checking this module to845//define itself again. If already in the process846//of doing that, skip this work.847this.defining = true;848849if (this.depCount < 1 && !this.defined) {850if (isFunction(factory)) {851//If there is an error listener, favor passing852//to that instead of throwing an error. However,853//only do it for define()'d modules. require854//errbacks should not be called for failures in855//their callbacks (#699). However if a global856//onError is set, use that.857if ((this.events.error && this.map.isDefine) ||858req.onError !== defaultOnError) {859try {860exports = context.execCb(id, factory, depExports, exports);861} catch (e) {862err = e;863}864} else {865exports = context.execCb(id, factory, depExports, exports);866}867868// Favor return value over exports. If node/cjs in play,869// then will not have a return value anyway. Favor870// module.exports assignment over exports object.871if (this.map.isDefine && exports === undefined) {872cjsModule = this.module;873if (cjsModule) {874exports = cjsModule.exports;875} else if (this.usingExports) {876//exports already set the defined value.877exports = this.exports;878}879}880881if (err) {882err.requireMap = this.map;883err.requireModules = this.map.isDefine ? [this.map.id] : null;884err.requireType = this.map.isDefine ? 'define' : 'require';885return onError((this.error = err));886}887888} else {889//Just a literal value890exports = factory;891}892893this.exports = exports;894895if (this.map.isDefine && !this.ignore) {896defined[id] = exports;897898if (req.onResourceLoad) {899req.onResourceLoad(context, this.map, this.depMaps);900}901}902903//Clean up904cleanRegistry(id);905906this.defined = true;907}908909//Finished the define stage. Allow calling check again910//to allow define notifications below in the case of a911//cycle.912this.defining = false;913914if (this.defined && !this.defineEmitted) {915this.defineEmitted = true;916this.emit('defined', this.exports);917this.defineEmitComplete = true;918}919920}921},922923callPlugin: function () {924var map = this.map,925id = map.id,926//Map already normalized the prefix.927pluginMap = makeModuleMap(map.prefix);928929//Mark this as a dependency for this plugin, so it930//can be traced for cycles.931this.depMaps.push(pluginMap);932933on(pluginMap, 'defined', bind(this, function (plugin) {934var load, normalizedMap, normalizedMod,935bundleId = getOwn(bundlesMap, this.map.id),936name = this.map.name,937parentName = this.map.parentMap ? this.map.parentMap.name : null,938localRequire = context.makeRequire(map.parentMap, {939enableBuildCallback: true940});941942//If current map is not normalized, wait for that943//normalized name to load instead of continuing.944if (this.map.unnormalized) {945//Normalize the ID if the plugin allows it.946if (plugin.normalize) {947name = plugin.normalize(name, function (name) {948return normalize(name, parentName, true);949}) || '';950}951952//prefix and name should already be normalized, no need953//for applying map config again either.954normalizedMap = makeModuleMap(map.prefix + '!' + name,955this.map.parentMap);956on(normalizedMap,957'defined', bind(this, function (value) {958this.init([], function () { return value; }, null, {959enabled: true,960ignore: true961});962}));963964normalizedMod = getOwn(registry, normalizedMap.id);965if (normalizedMod) {966//Mark this as a dependency for this plugin, so it967//can be traced for cycles.968this.depMaps.push(normalizedMap);969970if (this.events.error) {971normalizedMod.on('error', bind(this, function (err) {972this.emit('error', err);973}));974}975normalizedMod.enable();976}977978return;979}980981//If a paths config, then just load that file instead to982//resolve the plugin, as it is built into that paths layer.983if (bundleId) {984this.map.url = context.nameToUrl(bundleId);985this.load();986return;987}988989load = bind(this, function (value) {990this.init([], function () { return value; }, null, {991enabled: true992});993});994995load.error = bind(this, function (err) {996this.inited = true;997this.error = err;998err.requireModules = [id];9991000//Remove temp unnormalized modules for this module,1001//since they will never be resolved otherwise now.1002eachProp(registry, function (mod) {1003if (mod.map.id.indexOf(id + '_unnormalized') === 0) {1004cleanRegistry(mod.map.id);1005}1006});10071008onError(err);1009});10101011//Allow plugins to load other code without having to know the1012//context or how to 'complete' the load.1013load.fromText = bind(this, function (text, textAlt) {1014/*jslint evil: true */1015var moduleName = map.name,1016moduleMap = makeModuleMap(moduleName),1017hasInteractive = useInteractive;10181019//As of 2.1.0, support just passing the text, to reinforce1020//fromText only being called once per resource. Still1021//support old style of passing moduleName but discard1022//that moduleName in favor of the internal ref.1023if (textAlt) {1024text = textAlt;1025}10261027//Turn off interactive script matching for IE for any define1028//calls in the text, then turn it back on at the end.1029if (hasInteractive) {1030useInteractive = false;1031}10321033//Prime the system by creating a module instance for1034//it.1035getModule(moduleMap);10361037//Transfer any config to this other module.1038if (hasProp(config.config, id)) {1039config.config[moduleName] = config.config[id];1040}10411042try {1043req.exec(text);1044} catch (e) {1045return onError(makeError('fromtexteval',1046'fromText eval for ' + id +1047' failed: ' + e,1048e,1049[id]));1050}10511052if (hasInteractive) {1053useInteractive = true;1054}10551056//Mark this as a dependency for the plugin1057//resource1058this.depMaps.push(moduleMap);10591060//Support anonymous modules.1061context.completeLoad(moduleName);10621063//Bind the value of that module to the value for this1064//resource ID.1065localRequire([moduleName], load);1066});10671068//Use parentName here since the plugin's name is not reliable,1069//could be some weird string with no path that actually wants to1070//reference the parentName's path.1071plugin.load(map.name, localRequire, load, config);1072}));10731074context.enable(pluginMap, this);1075this.pluginMaps[pluginMap.id] = pluginMap;1076},10771078enable: function () {1079enabledRegistry[this.map.id] = this;1080this.enabled = true;10811082//Set flag mentioning that the module is enabling,1083//so that immediate calls to the defined callbacks1084//for dependencies do not trigger inadvertent load1085//with the depCount still being zero.1086this.enabling = true;10871088//Enable each dependency1089each(this.depMaps, bind(this, function (depMap, i) {1090var id, mod, handler;10911092if (typeof depMap === 'string') {1093//Dependency needs to be converted to a depMap1094//and wired up to this module.1095depMap = makeModuleMap(depMap,1096(this.map.isDefine ? this.map : this.map.parentMap),1097false,1098!this.skipMap);1099this.depMaps[i] = depMap;11001101handler = getOwn(handlers, depMap.id);11021103if (handler) {1104this.depExports[i] = handler(this);1105return;1106}11071108this.depCount += 1;11091110on(depMap, 'defined', bind(this, function (depExports) {1111this.defineDep(i, depExports);1112this.check();1113}));11141115if (this.errback) {1116on(depMap, 'error', bind(this, this.errback));1117}1118}11191120id = depMap.id;1121mod = registry[id];11221123//Skip special modules like 'require', 'exports', 'module'1124//Also, don't call enable if it is already enabled,1125//important in circular dependency cases.1126if (!hasProp(handlers, id) && mod && !mod.enabled) {1127context.enable(depMap, this);1128}1129}));11301131//Enable each plugin that is used in1132//a dependency1133eachProp(this.pluginMaps, bind(this, function (pluginMap) {1134var mod = getOwn(registry, pluginMap.id);1135if (mod && !mod.enabled) {1136context.enable(pluginMap, this);1137}1138}));11391140this.enabling = false;11411142this.check();1143},11441145on: function (name, cb) {1146var cbs = this.events[name];1147if (!cbs) {1148cbs = this.events[name] = [];1149}1150cbs.push(cb);1151},11521153emit: function (name, evt) {1154each(this.events[name], function (cb) {1155cb(evt);1156});1157if (name === 'error') {1158//Now that the error handler was triggered, remove1159//the listeners, since this broken Module instance1160//can stay around for a while in the registry.1161delete this.events[name];1162}1163}1164};11651166function callGetModule(args) {1167//Skip modules already defined.1168if (!hasProp(defined, args[0])) {1169getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);1170}1171}11721173function removeListener(node, func, name, ieName) {1174//Favor detachEvent because of IE91175//issue, see attachEvent/addEventListener comment elsewhere1176//in this file.1177if (node.detachEvent && !isOpera) {1178//Probably IE. If not it will throw an error, which will be1179//useful to know.1180if (ieName) {1181node.detachEvent(ieName, func);1182}1183} else {1184node.removeEventListener(name, func, false);1185}1186}11871188/**1189* Given an event from a script node, get the requirejs info from it,1190* and then removes the event listeners on the node.1191* @param {Event} evt1192* @returns {Object}1193*/1194function getScriptData(evt) {1195//Using currentTarget instead of target for Firefox 2.0's sake. Not1196//all old browsers will be supported, but this one was easy enough1197//to support and still makes sense.1198var node = evt.currentTarget || evt.srcElement;11991200//Remove the listeners once here.1201removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');1202removeListener(node, context.onScriptError, 'error');12031204return {1205node: node,1206id: node && node.getAttribute('data-requiremodule')1207};1208}12091210function intakeDefines() {1211var args;12121213//Any defined modules in the global queue, intake them now.1214takeGlobalQueue();12151216//Make sure any remaining defQueue items get properly processed.1217while (defQueue.length) {1218args = defQueue.shift();1219if (args[0] === null) {1220return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));1221} else {1222//args are id, deps, factory. Should be normalized by the1223//define() function.1224callGetModule(args);1225}1226}1227}12281229context = {1230config: config,1231contextName: contextName,1232registry: registry,1233defined: defined,1234urlFetched: urlFetched,1235defQueue: defQueue,1236Module: Module,1237makeModuleMap: makeModuleMap,1238nextTick: req.nextTick,1239onError: onError,12401241/**1242* Set a configuration for the context.1243* @param {Object} cfg config object to integrate.1244*/1245configure: function (cfg) {1246//Make sure the baseUrl ends in a slash.1247if (cfg.baseUrl) {1248if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {1249cfg.baseUrl += '/';1250}1251}12521253//Save off the paths since they require special processing,1254//they are additive.1255var shim = config.shim,1256objs = {1257paths: true,1258bundles: true,1259config: true,1260map: true1261};12621263eachProp(cfg, function (value, prop) {1264if (objs[prop]) {1265if (!config[prop]) {1266config[prop] = {};1267}1268mixin(config[prop], value, true, true);1269} else {1270config[prop] = value;1271}1272});12731274//Reverse map the bundles1275if (cfg.bundles) {1276eachProp(cfg.bundles, function (value, prop) {1277each(value, function (v) {1278if (v !== prop) {1279bundlesMap[v] = prop;1280}1281});1282});1283}12841285//Merge shim1286if (cfg.shim) {1287eachProp(cfg.shim, function (value, id) {1288//Normalize the structure1289if (isArray(value)) {1290value = {1291deps: value1292};1293}1294if ((value.exports || value.init) && !value.exportsFn) {1295value.exportsFn = context.makeShimExports(value);1296}1297shim[id] = value;1298});1299config.shim = shim;1300}13011302//Adjust packages if necessary.1303if (cfg.packages) {1304each(cfg.packages, function (pkgObj) {1305var location, name;13061307pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;13081309name = pkgObj.name;1310location = pkgObj.location;1311if (location) {1312config.paths[name] = pkgObj.location;1313}13141315//Save pointer to main module ID for pkg name.1316//Remove leading dot in main, so main paths are normalized,1317//and remove any trailing .js, since different package1318//envs have different conventions: some use a module name,1319//some use a file name.1320config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')1321.replace(currDirRegExp, '')1322.replace(jsSuffixRegExp, '');1323});1324}13251326//If there are any "waiting to execute" modules in the registry,1327//update the maps for them, since their info, like URLs to load,1328//may have changed.1329eachProp(registry, function (mod, id) {1330//If module already has init called, since it is too1331//late to modify them, and ignore unnormalized ones1332//since they are transient.1333if (!mod.inited && !mod.map.unnormalized) {1334mod.map = makeModuleMap(id);1335}1336});13371338//If a deps array or a config callback is specified, then call1339//require with those args. This is useful when require is defined as a1340//config object before require.js is loaded.1341if (cfg.deps || cfg.callback) {1342context.require(cfg.deps || [], cfg.callback);1343}1344},13451346makeShimExports: function (value) {1347function fn() {1348var ret;1349if (value.init) {1350ret = value.init.apply(global, arguments);1351}1352return ret || (value.exports && getGlobal(value.exports));1353}1354return fn;1355},13561357makeRequire: function (relMap, options) {1358options = options || {};13591360function localRequire(deps, callback, errback) {1361var id, map, requireMod;13621363if (options.enableBuildCallback && callback && isFunction(callback)) {1364callback.__requireJsBuild = true;1365}13661367if (typeof deps === 'string') {1368if (isFunction(callback)) {1369//Invalid call1370return onError(makeError('requireargs', 'Invalid require call'), errback);1371}13721373//If require|exports|module are requested, get the1374//value for them from the special handlers. Caveat:1375//this only works while module is being defined.1376if (relMap && hasProp(handlers, deps)) {1377return handlers[deps](registry[relMap.id]);1378}13791380//Synchronous access to one module. If require.get is1381//available (as in the Node adapter), prefer that.1382if (req.get) {1383return req.get(context, deps, relMap, localRequire);1384}13851386//Normalize module name, if it contains . or ..1387map = makeModuleMap(deps, relMap, false, true);1388id = map.id;13891390if (!hasProp(defined, id)) {1391return onError(makeError('notloaded', 'Module name "' +1392id +1393'" has not been loaded yet for context: ' +1394contextName +1395(relMap ? '' : '. Use require([])')));1396}1397return defined[id];1398}13991400//Grab defines waiting in the global queue.1401intakeDefines();14021403//Mark all the dependencies as needing to be loaded.1404context.nextTick(function () {1405//Some defines could have been added since the1406//require call, collect them.1407intakeDefines();14081409requireMod = getModule(makeModuleMap(null, relMap));14101411//Store if map config should be applied to this require1412//call for dependencies.1413requireMod.skipMap = options.skipMap;14141415requireMod.init(deps, callback, errback, {1416enabled: true1417});14181419checkLoaded();1420});14211422return localRequire;1423}14241425mixin(localRequire, {1426isBrowser: isBrowser,14271428/**1429* Converts a module name + .extension into an URL path.1430* *Requires* the use of a module name. It does not support using1431* plain URLs like nameToUrl.1432*/1433toUrl: function (moduleNamePlusExt) {1434var ext,1435index = moduleNamePlusExt.lastIndexOf('.'),1436segment = moduleNamePlusExt.split('/')[0],1437isRelative = segment === '.' || segment === '..';14381439//Have a file extension alias, and it is not the1440//dots from a relative path.1441if (index !== -1 && (!isRelative || index > 1)) {1442ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);1443moduleNamePlusExt = moduleNamePlusExt.substring(0, index);1444}14451446return context.nameToUrl(normalize(moduleNamePlusExt,1447relMap && relMap.id, true), ext, true);1448},14491450defined: function (id) {1451return hasProp(defined, makeModuleMap(id, relMap, false, true).id);1452},14531454specified: function (id) {1455id = makeModuleMap(id, relMap, false, true).id;1456return hasProp(defined, id) || hasProp(registry, id);1457}1458});14591460//Only allow undef on top level require calls1461if (!relMap) {1462localRequire.undef = function (id) {1463//Bind any waiting define() calls to this context,1464//fix for #4081465takeGlobalQueue();14661467var map = makeModuleMap(id, relMap, true),1468mod = getOwn(registry, id);14691470removeScript(id);14711472delete defined[id];1473delete urlFetched[map.url];1474delete undefEvents[id];14751476//Clean queued defines too. Go backwards1477//in array so that the splices do not1478//mess up the iteration.1479eachReverse(defQueue, function(args, i) {1480if(args[0] === id) {1481defQueue.splice(i, 1);1482}1483});14841485if (mod) {1486//Hold on to listeners in case the1487//module will be attempted to be reloaded1488//using a different config.1489if (mod.events.defined) {1490undefEvents[id] = mod.events;1491}14921493cleanRegistry(id);1494}1495};1496}14971498return localRequire;1499},15001501/**1502* Called to enable a module if it is still in the registry1503* awaiting enablement. A second arg, parent, the parent module,1504* is passed in for context, when this method is overriden by1505* the optimizer. Not shown here to keep code compact.1506*/1507enable: function (depMap) {1508var mod = getOwn(registry, depMap.id);1509if (mod) {1510getModule(depMap).enable();1511}1512},15131514/**1515* Internal method used by environment adapters to complete a load event.1516* A load event could be a script load or just a load pass from a synchronous1517* load call.1518* @param {String} moduleName the name of the module to potentially complete.1519*/1520completeLoad: function (moduleName) {1521var found, args, mod,1522shim = getOwn(config.shim, moduleName) || {},1523shExports = shim.exports;15241525takeGlobalQueue();15261527while (defQueue.length) {1528args = defQueue.shift();1529if (args[0] === null) {1530args[0] = moduleName;1531//If already found an anonymous module and bound it1532//to this name, then this is some other anon module1533//waiting for its completeLoad to fire.1534if (found) {1535break;1536}1537found = true;1538} else if (args[0] === moduleName) {1539//Found matching define call for this script!1540found = true;1541}15421543callGetModule(args);1544}15451546//Do this after the cycle of callGetModule in case the result1547//of those calls/init calls changes the registry.1548mod = getOwn(registry, moduleName);15491550if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {1551if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {1552if (hasPathFallback(moduleName)) {1553return;1554} else {1555return onError(makeError('nodefine',1556'No define call for ' + moduleName,1557null,1558[moduleName]));1559}1560} else {1561//A script that does not call define(), so just simulate1562//the call for it.1563callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);1564}1565}15661567checkLoaded();1568},15691570/**1571* Converts a module name to a file path. Supports cases where1572* moduleName may actually be just an URL.1573* Note that it **does not** call normalize on the moduleName,1574* it is assumed to have already been normalized. This is an1575* internal API, not a public one. Use toUrl for the public API.1576*/1577nameToUrl: function (moduleName, ext, skipExt) {1578var paths, syms, i, parentModule, url,1579parentPath, bundleId,1580pkgMain = getOwn(config.pkgs, moduleName);15811582if (pkgMain) {1583moduleName = pkgMain;1584}15851586bundleId = getOwn(bundlesMap, moduleName);15871588if (bundleId) {1589return context.nameToUrl(bundleId, ext, skipExt);1590}15911592//If a colon is in the URL, it indicates a protocol is used and it is just1593//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)1594//or ends with .js, then assume the user meant to use an url and not a module id.1595//The slash is important for protocol-less URLs as well as full paths.1596if (req.jsExtRegExp.test(moduleName)) {1597//Just a plain path, not module name lookup, so just return it.1598//Add extension if it is included. This is a bit wonky, only non-.js things pass1599//an extension, this method probably needs to be reworked.1600url = moduleName + (ext || '');1601} else {1602//A module that needs to be converted to a path.1603paths = config.paths;16041605syms = moduleName.split('/');1606//For each module name segment, see if there is a path1607//registered for it. Start with most specific name1608//and work up from it.1609for (i = syms.length; i > 0; i -= 1) {1610parentModule = syms.slice(0, i).join('/');16111612parentPath = getOwn(paths, parentModule);1613if (parentPath) {1614//If an array, it means there are a few choices,1615//Choose the one that is desired1616if (isArray(parentPath)) {1617parentPath = parentPath[0];1618}1619syms.splice(0, i, parentPath);1620break;1621}1622}16231624//Join the path parts together, then figure out if baseUrl is needed.1625url = syms.join('/');1626url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));1627url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;1628}16291630return config.urlArgs ? url +1631((url.indexOf('?') === -1 ? '?' : '&') +1632config.urlArgs) : url;1633},16341635//Delegates to req.load. Broken out as a separate function to1636//allow overriding in the optimizer.1637load: function (id, url) {1638req.load(context, id, url);1639},16401641/**1642* Executes a module callback function. Broken out as a separate function1643* solely to allow the build system to sequence the files in the built1644* layer in the right sequence.1645*1646* @private1647*/1648execCb: function (name, callback, args, exports) {1649return callback.apply(exports, args);1650},16511652/**1653* callback for script loads, used to check status of loading.1654*1655* @param {Event} evt the event from the browser for the script1656* that was loaded.1657*/1658onScriptLoad: function (evt) {1659//Using currentTarget instead of target for Firefox 2.0's sake. Not1660//all old browsers will be supported, but this one was easy enough1661//to support and still makes sense.1662if (evt.type === 'load' ||1663(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {1664//Reset interactive script so a script node is not held onto for1665//to long.1666interactiveScript = null;16671668//Pull out the name of the module and the context.1669var data = getScriptData(evt);1670context.completeLoad(data.id);1671}1672},16731674/**1675* Callback for script errors.1676*/1677onScriptError: function (evt) {1678var data = getScriptData(evt);1679if (!hasPathFallback(data.id)) {1680return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id]));1681}1682}1683};16841685context.require = context.makeRequire();1686return context;1687}16881689/**1690* Main entry point.1691*1692* If the only argument to require is a string, then the module that1693* is represented by that string is fetched for the appropriate context.1694*1695* If the first argument is an array, then it will be treated as an array1696* of dependency string names to fetch. An optional function callback can1697* be specified to execute when all of those dependencies are available.1698*1699* Make a local req variable to help Caja compliance (it assumes things1700* on a require that are not standardized), and to give a short1701* name for minification/local scope use.1702*/1703req = requirejs = function (deps, callback, errback, optional) {17041705//Find the right context, use default1706var context, config,1707contextName = defContextName;17081709// Determine if have config object in the call.1710if (!isArray(deps) && typeof deps !== 'string') {1711// deps is a config object1712config = deps;1713if (isArray(callback)) {1714// Adjust args if there are dependencies1715deps = callback;1716callback = errback;1717errback = optional;1718} else {1719deps = [];1720}1721}17221723if (config && config.context) {1724contextName = config.context;1725}17261727context = getOwn(contexts, contextName);1728if (!context) {1729context = contexts[contextName] = req.s.newContext(contextName);1730}17311732if (config) {1733context.configure(config);1734}17351736return context.require(deps, callback, errback);1737};17381739/**1740* Support require.config() to make it easier to cooperate with other1741* AMD loaders on globally agreed names.1742*/1743req.config = function (config) {1744return req(config);1745};17461747/**1748* Execute something after the current tick1749* of the event loop. Override for other envs1750* that have a better solution than setTimeout.1751* @param {Function} fn function to execute later.1752*/1753req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {1754setTimeout(fn, 4);1755} : function (fn) { fn(); };17561757/**1758* Export require as a global, but only if it does not already exist.1759*/1760if (!require) {1761require = req;1762}17631764req.version = version;17651766//Used to filter out dependencies that are already paths.1767req.jsExtRegExp = /^\/|:|\?|\.js$/;1768req.isBrowser = isBrowser;1769s = req.s = {1770contexts: contexts,1771newContext: newContext1772};17731774//Create default context.1775req({});17761777//Exports some context-sensitive methods on global require.1778each([1779'toUrl',1780'undef',1781'defined',1782'specified'1783], function (prop) {1784//Reference from contexts instead of early binding to default context,1785//so that during builds, the latest instance of the default context1786//with its config gets used.1787req[prop] = function () {1788var ctx = contexts[defContextName];1789return ctx.require[prop].apply(ctx, arguments);1790};1791});17921793if (isBrowser) {1794head = s.head = document.getElementsByTagName('head')[0];1795//If BASE tag is in play, using appendChild is a problem for IE6.1796//When that browser dies, this can be removed. Details in this jQuery bug:1797//http://dev.jquery.com/ticket/27091798baseElement = document.getElementsByTagName('base')[0];1799if (baseElement) {1800head = s.head = baseElement.parentNode;1801}1802}18031804/**1805* Any errors that require explicitly generates will be passed to this1806* function. Intercept/override it if you want custom error handling.1807* @param {Error} err the error object.1808*/1809req.onError = defaultOnError;18101811/**1812* Creates the node for the load command. Only used in browser envs.1813*/1814req.createNode = function (config, moduleName, url) {1815var node = config.xhtml ?1816document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :1817document.createElement('script');1818node.type = config.scriptType || 'text/javascript';1819node.charset = 'utf-8';1820node.async = true;1821return node;1822};18231824/**1825* Does the request to load a module for the browser case.1826* Make this a separate function to allow other environments1827* to override it.1828*1829* @param {Object} context the require context to find state.1830* @param {String} moduleName the name of the module.1831* @param {Object} url the URL to the module.1832*/1833req.load = function (context, moduleName, url) {1834var config = (context && context.config) || {},1835node;1836if (isBrowser) {1837//In the browser so use a script tag1838node = req.createNode(config, moduleName, url);18391840node.setAttribute('data-requirecontext', context.contextName);1841node.setAttribute('data-requiremodule', moduleName);18421843//Set up load listener. Test attachEvent first because IE9 has1844//a subtle issue in its addEventListener and script onload firings1845//that do not match the behavior of all other browsers with1846//addEventListener support, which fire the onload event for a1847//script right after the script execution. See:1848//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution1849//UNFORTUNATELY Opera implements attachEvent but does not follow the script1850//script execution mode.1851if (node.attachEvent &&1852//Check if node.attachEvent is artificially added by custom script or1853//natively supported by browser1854//read https://github.com/jrburke/requirejs/issues/1871855//if we can NOT find [native code] then it must NOT natively supported.1856//in IE8, node.attachEvent does not have toString()1857//Note the test for "[native code" with no closing brace, see:1858//https://github.com/jrburke/requirejs/issues/2731859!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&1860!isOpera) {1861//Probably IE. IE (at least 6-8) do not fire1862//script onload right after executing the script, so1863//we cannot tie the anonymous define call to a name.1864//However, IE reports the script as being in 'interactive'1865//readyState at the time of the define call.1866useInteractive = true;18671868node.attachEvent('onreadystatechange', context.onScriptLoad);1869//It would be great to add an error handler here to catch1870//404s in IE9+. However, onreadystatechange will fire before1871//the error handler, so that does not help. If addEventListener1872//is used, then IE will fire error before load, but we cannot1873//use that pathway given the connect.microsoft.com issue1874//mentioned above about not doing the 'script execute,1875//then fire the script load event listener before execute1876//next script' that other browsers do.1877//Best hope: IE10 fixes the issues,1878//and then destroys all installs of IE 6-9.1879//node.attachEvent('onerror', context.onScriptError);1880} else {1881node.addEventListener('load', context.onScriptLoad, false);1882node.addEventListener('error', context.onScriptError, false);1883}1884node.src = url;18851886//For some cache cases in IE 6-8, the script executes before the end1887//of the appendChild execution, so to tie an anonymous define1888//call to the module name (which is stored on the node), hold on1889//to a reference to this node, but clear after the DOM insertion.1890currentlyAddingScript = node;1891if (baseElement) {1892head.insertBefore(node, baseElement);1893} else {1894head.appendChild(node);1895}1896currentlyAddingScript = null;18971898return node;1899} else if (isWebWorker) {1900try {1901//In a web worker, use importScripts. This is not a very1902//efficient use of importScripts, importScripts will block until1903//its script is downloaded and evaluated. However, if web workers1904//are in play, the expectation that a build has been done so that1905//only one script needs to be loaded anyway. This may need to be1906//reevaluated if other use cases become common.1907importScripts(url);19081909//Account for anonymous modules1910context.completeLoad(moduleName);1911} catch (e) {1912context.onError(makeError('importscripts',1913'importScripts failed for ' +1914moduleName + ' at ' + url,1915e,1916[moduleName]));1917}1918}1919};19201921function getInteractiveScript() {1922if (interactiveScript && interactiveScript.readyState === 'interactive') {1923return interactiveScript;1924}19251926eachReverse(scripts(), function (script) {1927if (script.readyState === 'interactive') {1928return (interactiveScript = script);1929}1930});1931return interactiveScript;1932}19331934//Look for a data-main script attribute, which could also adjust the baseUrl.1935if (isBrowser && !cfg.skipDataMain) {1936//Figure out baseUrl. Get it from the script tag with require.js in it.1937eachReverse(scripts(), function (script) {1938//Set the 'head' where we can append children by1939//using the script's parent.1940if (!head) {1941head = script.parentNode;1942}19431944//Look for a data-main attribute to set main script for the page1945//to load. If it is there, the path to data main becomes the1946//baseUrl, if it is not already set.1947dataMain = script.getAttribute('data-main');1948if (dataMain) {1949//Preserve dataMain in case it is a path (i.e. contains '?')1950mainScript = dataMain;19511952//Set final baseUrl if there is not already an explicit one.1953if (!cfg.baseUrl) {1954//Pull off the directory of data-main for use as the1955//baseUrl.1956src = mainScript.split('/');1957mainScript = src.pop();1958subPath = src.length ? src.join('/') + '/' : './';19591960cfg.baseUrl = subPath;1961}19621963//Strip off any trailing .js since mainScript is now1964//like a module name.1965mainScript = mainScript.replace(jsSuffixRegExp, '');19661967//If mainScript is still a path, fall back to dataMain1968if (req.jsExtRegExp.test(mainScript)) {1969mainScript = dataMain;1970}19711972//Put the data-main script in the files to load.1973cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];19741975return true;1976}1977});1978}19791980/**1981* The function that handles definitions of modules. Differs from1982* require() in that a string for the module should be the first argument,1983* and the function to execute after dependencies are loaded should1984* return a value to define the module corresponding to the first argument's1985* name.1986*/1987define = function (name, deps, callback) {1988var node, context;19891990//Allow for anonymous modules1991if (typeof name !== 'string') {1992//Adjust args appropriately1993callback = deps;1994deps = name;1995name = null;1996}19971998//This module may not have dependencies1999if (!isArray(deps)) {2000callback = deps;2001deps = null;2002}20032004//If no name, and callback is a function, then figure out if it a2005//CommonJS thing with dependencies.2006if (!deps && isFunction(callback)) {2007deps = [];2008//Remove comments from the callback string,2009//look for require calls, and pull them into the dependencies,2010//but only if there are function args.2011if (callback.length) {2012callback2013.toString()2014.replace(commentRegExp, '')2015.replace(cjsRequireRegExp, function (match, dep) {2016deps.push(dep);2017});20182019//May be a CommonJS thing even without require calls, but still2020//could use exports, and module. Avoid doing exports and module2021//work though if it just needs require.2022//REQUIRES the function to expect the CommonJS variables in the2023//order listed below.2024deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);2025}2026}20272028//If in IE 6-8 and hit an anonymous define() call, do the interactive2029//work.2030if (useInteractive) {2031node = currentlyAddingScript || getInteractiveScript();2032if (node) {2033if (!name) {2034name = node.getAttribute('data-requiremodule');2035}2036context = contexts[node.getAttribute('data-requirecontext')];2037}2038}20392040//Always save off evaluating the def call until the script onload handler.2041//This allows multiple modules to be in a file without prematurely2042//tracing dependencies, and allows for anonymous module support,2043//where the module name is not known until the script onload event2044//occurs. If no context, use the global queue, and get it processed2045//in the onscript load callback.2046(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);2047};20482049define.amd = {2050jQuery: true2051};205220532054/**2055* Executes the text. Normally just uses eval, but can be modified2056* to use a better, environment-specific call. Only used for transpiling2057* loader plugins, not for plain JS modules.2058* @param {String} text the text to execute/evaluate.2059*/2060req.exec = function (text) {2061/*jslint evil: true */2062return eval(text);2063};20642065//Set up with config info.2066req(cfg);2067}(this));206820692070