/** vim: et:ts=4:sw=4:sts=41* @license RequireJS 2.1.15 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.15',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 is 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 an 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;235for (i = 0; i < ary.length; i++) {236part = ary[i];237if (part === '.') {238ary.splice(i, 1);239i -= 1;240} else if (part === '..') {241// If at the start, or previous value is still ..,242// keep them so that when converted to a path it may243// still work when converted to a path, even though244// as an ID it is less than ideal. In larger point245// releases, may be better to just kick out an error.246if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') {247continue;248} else if (i > 0) {249ary.splice(i - 1, 2);250i -= 2;251}252}253}254}255256/**257* Given a relative module name, like ./something, normalize it to258* a real name that can be mapped to a path.259* @param {String} name the relative name260* @param {String} baseName a real name that the name arg is relative261* to.262* @param {Boolean} applyMap apply the map config to the value. Should263* only be done if this normalization is for a dependency ID.264* @returns {String} normalized name265*/266function normalize(name, baseName, applyMap) {267var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,268foundMap, foundI, foundStarMap, starI, normalizedBaseParts,269baseParts = (baseName && baseName.split('/')),270map = config.map,271starMap = map && map['*'];272273//Adjust any relative paths.274if (name) {275name = name.split('/');276lastIndex = name.length - 1;277278// If wanting node ID compatibility, strip .js from end279// of IDs. Have to do this here, and not in nameToUrl280// because node allows either .js or non .js to map281// to same file.282if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {283name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');284}285286// Starts with a '.' so need the baseName287if (name[0].charAt(0) === '.' && baseParts) {288//Convert baseName to array, and lop off the last part,289//so that . matches that 'directory' and not name of the baseName's290//module. For instance, baseName of 'one/two/three', maps to291//'one/two/three.js', but we want the directory, 'one/two' for292//this normalization.293normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);294name = normalizedBaseParts.concat(name);295}296297trimDots(name);298name = name.join('/');299}300301//Apply map config if available.302if (applyMap && map && (baseParts || starMap)) {303nameParts = name.split('/');304305outerLoop: for (i = nameParts.length; i > 0; i -= 1) {306nameSegment = nameParts.slice(0, i).join('/');307308if (baseParts) {309//Find the longest baseName segment match in the config.310//So, do joins on the biggest to smallest lengths of baseParts.311for (j = baseParts.length; j > 0; j -= 1) {312mapValue = getOwn(map, baseParts.slice(0, j).join('/'));313314//baseName segment has config, find if it has one for315//this name.316if (mapValue) {317mapValue = getOwn(mapValue, nameSegment);318if (mapValue) {319//Match, update name to the new value.320foundMap = mapValue;321foundI = i;322break outerLoop;323}324}325}326}327328//Check for a star map match, but just hold on to it,329//if there is a shorter segment match later in a matching330//config, then favor over this star map.331if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {332foundStarMap = getOwn(starMap, nameSegment);333starI = i;334}335}336337if (!foundMap && foundStarMap) {338foundMap = foundStarMap;339foundI = starI;340}341342if (foundMap) {343nameParts.splice(0, foundI, foundMap);344name = nameParts.join('/');345}346}347348// If the name points to a package's name, use349// the package main instead.350pkgMain = getOwn(config.pkgs, name);351352return pkgMain ? pkgMain : name;353}354355function removeScript(name) {356if (isBrowser) {357each(scripts(), function (scriptNode) {358if (scriptNode.getAttribute('data-requiremodule') === name &&359scriptNode.getAttribute('data-requirecontext') === context.contextName) {360scriptNode.parentNode.removeChild(scriptNode);361return true;362}363});364}365}366367function hasPathFallback(id) {368var pathConfig = getOwn(config.paths, id);369if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {370//Pop off the first array value, since it failed, and371//retry372pathConfig.shift();373context.require.undef(id);374375//Custom require that does not do map translation, since376//ID is "absolute", already mapped/resolved.377context.makeRequire(null, {378skipMap: true379})([id]);380381return true;382}383}384385//Turns a plugin!resource to [plugin, resource]386//with the plugin being undefined if the name387//did not have a plugin prefix.388function splitPrefix(name) {389var prefix,390index = name ? name.indexOf('!') : -1;391if (index > -1) {392prefix = name.substring(0, index);393name = name.substring(index + 1, name.length);394}395return [prefix, name];396}397398/**399* Creates a module mapping that includes plugin prefix, module400* name, and path. If parentModuleMap is provided it will401* also normalize the name via require.normalize()402*403* @param {String} name the module name404* @param {String} [parentModuleMap] parent module map405* for the module name, used to resolve relative names.406* @param {Boolean} isNormalized: is the ID already normalized.407* This is true if this call is done for a define() module ID.408* @param {Boolean} applyMap: apply the map config to the ID.409* Should only be true if this map is for a dependency.410*411* @returns {Object}412*/413function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {414var url, pluginModule, suffix, nameParts,415prefix = null,416parentName = parentModuleMap ? parentModuleMap.name : null,417originalName = name,418isDefine = true,419normalizedName = '';420421//If no name, then it means it is a require call, generate an422//internal name.423if (!name) {424isDefine = false;425name = '_@r' + (requireCounter += 1);426}427428nameParts = splitPrefix(name);429prefix = nameParts[0];430name = nameParts[1];431432if (prefix) {433prefix = normalize(prefix, parentName, applyMap);434pluginModule = getOwn(defined, prefix);435}436437//Account for relative paths if there is a base name.438if (name) {439if (prefix) {440if (pluginModule && pluginModule.normalize) {441//Plugin is loaded, use its normalize method.442normalizedName = pluginModule.normalize(name, function (name) {443return normalize(name, parentName, applyMap);444});445} else {446// If nested plugin references, then do not try to447// normalize, as it will not normalize correctly. This448// places a restriction on resourceIds, and the longer449// term solution is not to normalize until plugins are450// loaded and all normalizations to allow for async451// loading of a loader plugin. But for now, fixes the452// common uses. Details in #1131453normalizedName = name.indexOf('!') === -1 ?454normalize(name, parentName, applyMap) :455name;456}457} else {458//A regular module.459normalizedName = normalize(name, parentName, applyMap);460461//Normalized name may be a plugin ID due to map config462//application in normalize. The map config values must463//already be normalized, so do not need to redo that part.464nameParts = splitPrefix(normalizedName);465prefix = nameParts[0];466normalizedName = nameParts[1];467isNormalized = true;468469url = context.nameToUrl(normalizedName);470}471}472473//If the id is a plugin id that cannot be determined if it needs474//normalization, stamp it with a unique ID so two matching relative475//ids that may conflict can be separate.476suffix = prefix && !pluginModule && !isNormalized ?477'_unnormalized' + (unnormalizedCounter += 1) :478'';479480return {481prefix: prefix,482name: normalizedName,483parentMap: parentModuleMap,484unnormalized: !!suffix,485url: url,486originalName: originalName,487isDefine: isDefine,488id: (prefix ?489prefix + '!' + normalizedName :490normalizedName) + suffix491};492}493494function getModule(depMap) {495var id = depMap.id,496mod = getOwn(registry, id);497498if (!mod) {499mod = registry[id] = new context.Module(depMap);500}501502return mod;503}504505function on(depMap, name, fn) {506var id = depMap.id,507mod = getOwn(registry, id);508509if (hasProp(defined, id) &&510(!mod || mod.defineEmitComplete)) {511if (name === 'defined') {512fn(defined[id]);513}514} else {515mod = getModule(depMap);516if (mod.error && name === 'error') {517fn(mod.error);518} else {519mod.on(name, fn);520}521}522}523524function onError(err, errback) {525var ids = err.requireModules,526notified = false;527528if (errback) {529errback(err);530} else {531each(ids, function (id) {532var mod = getOwn(registry, id);533if (mod) {534//Set error on module, so it skips timeout checks.535mod.error = err;536if (mod.events.error) {537notified = true;538mod.emit('error', err);539}540}541});542543if (!notified) {544req.onError(err);545}546}547}548549/**550* Internal method to transfer globalQueue items to this context's551* defQueue.552*/553function takeGlobalQueue() {554//Push all the globalDefQueue items into the context's defQueue555if (globalDefQueue.length) {556//Array splice in the values since the context code has a557//local var ref to defQueue, so cannot just reassign the one558//on context.559apsp.apply(defQueue,560[defQueue.length, 0].concat(globalDefQueue));561globalDefQueue = [];562}563}564565handlers = {566'require': function (mod) {567if (mod.require) {568return mod.require;569} else {570return (mod.require = context.makeRequire(mod.map));571}572},573'exports': function (mod) {574mod.usingExports = true;575if (mod.map.isDefine) {576if (mod.exports) {577return (defined[mod.map.id] = mod.exports);578} else {579return (mod.exports = defined[mod.map.id] = {});580}581}582},583'module': function (mod) {584if (mod.module) {585return mod.module;586} else {587return (mod.module = {588id: mod.map.id,589uri: mod.map.url,590config: function () {591return getOwn(config.config, mod.map.id) || {};592},593exports: mod.exports || (mod.exports = {})594});595}596}597};598599function cleanRegistry(id) {600//Clean up machinery used for waiting modules.601delete registry[id];602delete enabledRegistry[id];603}604605function breakCycle(mod, traced, processed) {606var id = mod.map.id;607608if (mod.error) {609mod.emit('error', mod.error);610} else {611traced[id] = true;612each(mod.depMaps, function (depMap, i) {613var depId = depMap.id,614dep = getOwn(registry, depId);615616//Only force things that have not completed617//being defined, so still in the registry,618//and only if it has not been matched up619//in the module already.620if (dep && !mod.depMatched[i] && !processed[depId]) {621if (getOwn(traced, depId)) {622mod.defineDep(i, defined[depId]);623mod.check(); //pass false?624} else {625breakCycle(dep, traced, processed);626}627}628});629processed[id] = true;630}631}632633function checkLoaded() {634var err, usingPathFallback,635waitInterval = config.waitSeconds * 1000,636//It is possible to disable the wait interval by using waitSeconds of 0.637expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),638noLoads = [],639reqCalls = [],640stillLoading = false,641needCycleCheck = true;642643//Do not bother if this call was a result of a cycle break.644if (inCheckLoaded) {645return;646}647648inCheckLoaded = true;649650//Figure out the state of all the modules.651eachProp(enabledRegistry, function (mod) {652var map = mod.map,653modId = map.id;654655//Skip things that are not enabled or in error state.656if (!mod.enabled) {657return;658}659660if (!map.isDefine) {661reqCalls.push(mod);662}663664if (!mod.error) {665//If the module should be executed, and it has not666//been inited and time is up, remember it.667if (!mod.inited && expired) {668if (hasPathFallback(modId)) {669usingPathFallback = true;670stillLoading = true;671} else {672noLoads.push(modId);673removeScript(modId);674}675} else if (!mod.inited && mod.fetched && map.isDefine) {676stillLoading = true;677if (!map.prefix) {678//No reason to keep looking for unfinished679//loading. If the only stillLoading is a680//plugin resource though, keep going,681//because it may be that a plugin resource682//is waiting on a non-plugin cycle.683return (needCycleCheck = false);684}685}686}687});688689if (expired && noLoads.length) {690//If wait time expired, throw error of unloaded modules.691err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);692err.contextName = context.contextName;693return onError(err);694}695696//Not expired, check for a cycle.697if (needCycleCheck) {698each(reqCalls, function (mod) {699breakCycle(mod, {}, {});700});701}702703//If still waiting on loads, and the waiting load is something704//other than a plugin resource, or there are still outstanding705//scripts, then just try back later.706if ((!expired || usingPathFallback) && stillLoading) {707//Something is still waiting to load. Wait for it, but only708//if a timeout is not already in effect.709if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {710checkLoadedTimeoutId = setTimeout(function () {711checkLoadedTimeoutId = 0;712checkLoaded();713}, 50);714}715}716717inCheckLoaded = false;718}719720Module = function (map) {721this.events = getOwn(undefEvents, map.id) || {};722this.map = map;723this.shim = getOwn(config.shim, map.id);724this.depExports = [];725this.depMaps = [];726this.depMatched = [];727this.pluginMaps = {};728this.depCount = 0;729730/* this.exports this.factory731this.depMaps = [],732this.enabled, this.fetched733*/734};735736Module.prototype = {737init: function (depMaps, factory, errback, options) {738options = options || {};739740//Do not do more inits if already done. Can happen if there741//are multiple define calls for the same module. That is not742//a normal, common case, but it is also not unexpected.743if (this.inited) {744return;745}746747this.factory = factory;748749if (errback) {750//Register for errors on this module.751this.on('error', errback);752} else if (this.events.error) {753//If no errback already, but there are error listeners754//on this module, set up an errback to pass to the deps.755errback = bind(this, function (err) {756this.emit('error', err);757});758}759760//Do a copy of the dependency array, so that761//source inputs are not modified. For example762//"shim" deps are passed in here directly, and763//doing a direct modification of the depMaps array764//would affect that config.765this.depMaps = depMaps && depMaps.slice(0);766767this.errback = errback;768769//Indicate this module has be initialized770this.inited = true;771772this.ignore = options.ignore;773774//Could have option to init this module in enabled mode,775//or could have been previously marked as enabled. However,776//the dependencies are not known until init is called. So777//if enabled previously, now trigger dependencies as enabled.778if (options.enabled || this.enabled) {779//Enable this module and dependencies.780//Will call this.check()781this.enable();782} else {783this.check();784}785},786787defineDep: function (i, depExports) {788//Because of cycles, defined callback for a given789//export can be called more than once.790if (!this.depMatched[i]) {791this.depMatched[i] = true;792this.depCount -= 1;793this.depExports[i] = depExports;794}795},796797fetch: function () {798if (this.fetched) {799return;800}801this.fetched = true;802803context.startTime = (new Date()).getTime();804805var map = this.map;806807//If the manager is for a plugin managed resource,808//ask the plugin to load it now.809if (this.shim) {810context.makeRequire(this.map, {811enableBuildCallback: true812})(this.shim.deps || [], bind(this, function () {813return map.prefix ? this.callPlugin() : this.load();814}));815} else {816//Regular dependency.817return map.prefix ? this.callPlugin() : this.load();818}819},820821load: function () {822var url = this.map.url;823824//Regular dependency.825if (!urlFetched[url]) {826urlFetched[url] = true;827context.load(this.map.id, url);828}829},830831/**832* Checks if the module is ready to define itself, and if so,833* define it.834*/835check: function () {836if (!this.enabled || this.enabling) {837return;838}839840var err, cjsModule,841id = this.map.id,842depExports = this.depExports,843exports = this.exports,844factory = this.factory;845846if (!this.inited) {847this.fetch();848} else if (this.error) {849this.emit('error', this.error);850} else if (!this.defining) {851//The factory could trigger another require call852//that would result in checking this module to853//define itself again. If already in the process854//of doing that, skip this work.855this.defining = true;856857if (this.depCount < 1 && !this.defined) {858if (isFunction(factory)) {859//If there is an error listener, favor passing860//to that instead of throwing an error. However,861//only do it for define()'d modules. require862//errbacks should not be called for failures in863//their callbacks (#699). However if a global864//onError is set, use that.865if ((this.events.error && this.map.isDefine) ||866req.onError !== defaultOnError) {867try {868exports = context.execCb(id, factory, depExports, exports);869} catch (e) {870err = e;871}872} else {873exports = context.execCb(id, factory, depExports, exports);874}875876// Favor return value over exports. If node/cjs in play,877// then will not have a return value anyway. Favor878// module.exports assignment over exports object.879if (this.map.isDefine && exports === undefined) {880cjsModule = this.module;881if (cjsModule) {882exports = cjsModule.exports;883} else if (this.usingExports) {884//exports already set the defined value.885exports = this.exports;886}887}888889if (err) {890err.requireMap = this.map;891err.requireModules = this.map.isDefine ? [this.map.id] : null;892err.requireType = this.map.isDefine ? 'define' : 'require';893return onError((this.error = err));894}895896} else {897//Just a literal value898exports = factory;899}900901this.exports = exports;902903if (this.map.isDefine && !this.ignore) {904defined[id] = exports;905906if (req.onResourceLoad) {907req.onResourceLoad(context, this.map, this.depMaps);908}909}910911//Clean up912cleanRegistry(id);913914this.defined = true;915}916917//Finished the define stage. Allow calling check again918//to allow define notifications below in the case of a919//cycle.920this.defining = false;921922if (this.defined && !this.defineEmitted) {923this.defineEmitted = true;924this.emit('defined', this.exports);925this.defineEmitComplete = true;926}927928}929},930931callPlugin: function () {932var map = this.map,933id = map.id,934//Map already normalized the prefix.935pluginMap = makeModuleMap(map.prefix);936937//Mark this as a dependency for this plugin, so it938//can be traced for cycles.939this.depMaps.push(pluginMap);940941on(pluginMap, 'defined', bind(this, function (plugin) {942var load, normalizedMap, normalizedMod,943bundleId = getOwn(bundlesMap, this.map.id),944name = this.map.name,945parentName = this.map.parentMap ? this.map.parentMap.name : null,946localRequire = context.makeRequire(map.parentMap, {947enableBuildCallback: true948});949950//If current map is not normalized, wait for that951//normalized name to load instead of continuing.952if (this.map.unnormalized) {953//Normalize the ID if the plugin allows it.954if (plugin.normalize) {955name = plugin.normalize(name, function (name) {956return normalize(name, parentName, true);957}) || '';958}959960//prefix and name should already be normalized, no need961//for applying map config again either.962normalizedMap = makeModuleMap(map.prefix + '!' + name,963this.map.parentMap);964on(normalizedMap,965'defined', bind(this, function (value) {966this.init([], function () { return value; }, null, {967enabled: true,968ignore: true969});970}));971972normalizedMod = getOwn(registry, normalizedMap.id);973if (normalizedMod) {974//Mark this as a dependency for this plugin, so it975//can be traced for cycles.976this.depMaps.push(normalizedMap);977978if (this.events.error) {979normalizedMod.on('error', bind(this, function (err) {980this.emit('error', err);981}));982}983normalizedMod.enable();984}985986return;987}988989//If a paths config, then just load that file instead to990//resolve the plugin, as it is built into that paths layer.991if (bundleId) {992this.map.url = context.nameToUrl(bundleId);993this.load();994return;995}996997load = bind(this, function (value) {998this.init([], function () { return value; }, null, {999enabled: true1000});1001});10021003load.error = bind(this, function (err) {1004this.inited = true;1005this.error = err;1006err.requireModules = [id];10071008//Remove temp unnormalized modules for this module,1009//since they will never be resolved otherwise now.1010eachProp(registry, function (mod) {1011if (mod.map.id.indexOf(id + '_unnormalized') === 0) {1012cleanRegistry(mod.map.id);1013}1014});10151016onError(err);1017});10181019//Allow plugins to load other code without having to know the1020//context or how to 'complete' the load.1021load.fromText = bind(this, function (text, textAlt) {1022/*jslint evil: true */1023var moduleName = map.name,1024moduleMap = makeModuleMap(moduleName),1025hasInteractive = useInteractive;10261027//As of 2.1.0, support just passing the text, to reinforce1028//fromText only being called once per resource. Still1029//support old style of passing moduleName but discard1030//that moduleName in favor of the internal ref.1031if (textAlt) {1032text = textAlt;1033}10341035//Turn off interactive script matching for IE for any define1036//calls in the text, then turn it back on at the end.1037if (hasInteractive) {1038useInteractive = false;1039}10401041//Prime the system by creating a module instance for1042//it.1043getModule(moduleMap);10441045//Transfer any config to this other module.1046if (hasProp(config.config, id)) {1047config.config[moduleName] = config.config[id];1048}10491050try {1051req.exec(text);1052} catch (e) {1053return onError(makeError('fromtexteval',1054'fromText eval for ' + id +1055' failed: ' + e,1056e,1057[id]));1058}10591060if (hasInteractive) {1061useInteractive = true;1062}10631064//Mark this as a dependency for the plugin1065//resource1066this.depMaps.push(moduleMap);10671068//Support anonymous modules.1069context.completeLoad(moduleName);10701071//Bind the value of that module to the value for this1072//resource ID.1073localRequire([moduleName], load);1074});10751076//Use parentName here since the plugin's name is not reliable,1077//could be some weird string with no path that actually wants to1078//reference the parentName's path.1079plugin.load(map.name, localRequire, load, config);1080}));10811082context.enable(pluginMap, this);1083this.pluginMaps[pluginMap.id] = pluginMap;1084},10851086enable: function () {1087enabledRegistry[this.map.id] = this;1088this.enabled = true;10891090//Set flag mentioning that the module is enabling,1091//so that immediate calls to the defined callbacks1092//for dependencies do not trigger inadvertent load1093//with the depCount still being zero.1094this.enabling = true;10951096//Enable each dependency1097each(this.depMaps, bind(this, function (depMap, i) {1098var id, mod, handler;10991100if (typeof depMap === 'string') {1101//Dependency needs to be converted to a depMap1102//and wired up to this module.1103depMap = makeModuleMap(depMap,1104(this.map.isDefine ? this.map : this.map.parentMap),1105false,1106!this.skipMap);1107this.depMaps[i] = depMap;11081109handler = getOwn(handlers, depMap.id);11101111if (handler) {1112this.depExports[i] = handler(this);1113return;1114}11151116this.depCount += 1;11171118on(depMap, 'defined', bind(this, function (depExports) {1119this.defineDep(i, depExports);1120this.check();1121}));11221123if (this.errback) {1124on(depMap, 'error', bind(this, this.errback));1125}1126}11271128id = depMap.id;1129mod = registry[id];11301131//Skip special modules like 'require', 'exports', 'module'1132//Also, don't call enable if it is already enabled,1133//important in circular dependency cases.1134if (!hasProp(handlers, id) && mod && !mod.enabled) {1135context.enable(depMap, this);1136}1137}));11381139//Enable each plugin that is used in1140//a dependency1141eachProp(this.pluginMaps, bind(this, function (pluginMap) {1142var mod = getOwn(registry, pluginMap.id);1143if (mod && !mod.enabled) {1144context.enable(pluginMap, this);1145}1146}));11471148this.enabling = false;11491150this.check();1151},11521153on: function (name, cb) {1154var cbs = this.events[name];1155if (!cbs) {1156cbs = this.events[name] = [];1157}1158cbs.push(cb);1159},11601161emit: function (name, evt) {1162each(this.events[name], function (cb) {1163cb(evt);1164});1165if (name === 'error') {1166//Now that the error handler was triggered, remove1167//the listeners, since this broken Module instance1168//can stay around for a while in the registry.1169delete this.events[name];1170}1171}1172};11731174function callGetModule(args) {1175//Skip modules already defined.1176if (!hasProp(defined, args[0])) {1177getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);1178}1179}11801181function removeListener(node, func, name, ieName) {1182//Favor detachEvent because of IE91183//issue, see attachEvent/addEventListener comment elsewhere1184//in this file.1185if (node.detachEvent && !isOpera) {1186//Probably IE. If not it will throw an error, which will be1187//useful to know.1188if (ieName) {1189node.detachEvent(ieName, func);1190}1191} else {1192node.removeEventListener(name, func, false);1193}1194}11951196/**1197* Given an event from a script node, get the requirejs info from it,1198* and then removes the event listeners on the node.1199* @param {Event} evt1200* @returns {Object}1201*/1202function getScriptData(evt) {1203//Using currentTarget instead of target for Firefox 2.0's sake. Not1204//all old browsers will be supported, but this one was easy enough1205//to support and still makes sense.1206var node = evt.currentTarget || evt.srcElement;12071208//Remove the listeners once here.1209removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');1210removeListener(node, context.onScriptError, 'error');12111212return {1213node: node,1214id: node && node.getAttribute('data-requiremodule')1215};1216}12171218function intakeDefines() {1219var args;12201221//Any defined modules in the global queue, intake them now.1222takeGlobalQueue();12231224//Make sure any remaining defQueue items get properly processed.1225while (defQueue.length) {1226args = defQueue.shift();1227if (args[0] === null) {1228return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));1229} else {1230//args are id, deps, factory. Should be normalized by the1231//define() function.1232callGetModule(args);1233}1234}1235}12361237context = {1238config: config,1239contextName: contextName,1240registry: registry,1241defined: defined,1242urlFetched: urlFetched,1243defQueue: defQueue,1244Module: Module,1245makeModuleMap: makeModuleMap,1246nextTick: req.nextTick,1247onError: onError,12481249/**1250* Set a configuration for the context.1251* @param {Object} cfg config object to integrate.1252*/1253configure: function (cfg) {1254//Make sure the baseUrl ends in a slash.1255if (cfg.baseUrl) {1256if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {1257cfg.baseUrl += '/';1258}1259}12601261//Save off the paths since they require special processing,1262//they are additive.1263var shim = config.shim,1264objs = {1265paths: true,1266bundles: true,1267config: true,1268map: true1269};12701271eachProp(cfg, function (value, prop) {1272if (objs[prop]) {1273if (!config[prop]) {1274config[prop] = {};1275}1276mixin(config[prop], value, true, true);1277} else {1278config[prop] = value;1279}1280});12811282//Reverse map the bundles1283if (cfg.bundles) {1284eachProp(cfg.bundles, function (value, prop) {1285each(value, function (v) {1286if (v !== prop) {1287bundlesMap[v] = prop;1288}1289});1290});1291}12921293//Merge shim1294if (cfg.shim) {1295eachProp(cfg.shim, function (value, id) {1296//Normalize the structure1297if (isArray(value)) {1298value = {1299deps: value1300};1301}1302if ((value.exports || value.init) && !value.exportsFn) {1303value.exportsFn = context.makeShimExports(value);1304}1305shim[id] = value;1306});1307config.shim = shim;1308}13091310//Adjust packages if necessary.1311if (cfg.packages) {1312each(cfg.packages, function (pkgObj) {1313var location, name;13141315pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;13161317name = pkgObj.name;1318location = pkgObj.location;1319if (location) {1320config.paths[name] = pkgObj.location;1321}13221323//Save pointer to main module ID for pkg name.1324//Remove leading dot in main, so main paths are normalized,1325//and remove any trailing .js, since different package1326//envs have different conventions: some use a module name,1327//some use a file name.1328config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')1329.replace(currDirRegExp, '')1330.replace(jsSuffixRegExp, '');1331});1332}13331334//If there are any "waiting to execute" modules in the registry,1335//update the maps for them, since their info, like URLs to load,1336//may have changed.1337eachProp(registry, function (mod, id) {1338//If module already has init called, since it is too1339//late to modify them, and ignore unnormalized ones1340//since they are transient.1341if (!mod.inited && !mod.map.unnormalized) {1342mod.map = makeModuleMap(id);1343}1344});13451346//If a deps array or a config callback is specified, then call1347//require with those args. This is useful when require is defined as a1348//config object before require.js is loaded.1349if (cfg.deps || cfg.callback) {1350context.require(cfg.deps || [], cfg.callback);1351}1352},13531354makeShimExports: function (value) {1355function fn() {1356var ret;1357if (value.init) {1358ret = value.init.apply(global, arguments);1359}1360return ret || (value.exports && getGlobal(value.exports));1361}1362return fn;1363},13641365makeRequire: function (relMap, options) {1366options = options || {};13671368function localRequire(deps, callback, errback) {1369var id, map, requireMod;13701371if (options.enableBuildCallback && callback && isFunction(callback)) {1372callback.__requireJsBuild = true;1373}13741375if (typeof deps === 'string') {1376if (isFunction(callback)) {1377//Invalid call1378return onError(makeError('requireargs', 'Invalid require call'), errback);1379}13801381//If require|exports|module are requested, get the1382//value for them from the special handlers. Caveat:1383//this only works while module is being defined.1384if (relMap && hasProp(handlers, deps)) {1385return handlers[deps](registry[relMap.id]);1386}13871388//Synchronous access to one module. If require.get is1389//available (as in the Node adapter), prefer that.1390if (req.get) {1391return req.get(context, deps, relMap, localRequire);1392}13931394//Normalize module name, if it contains . or ..1395map = makeModuleMap(deps, relMap, false, true);1396id = map.id;13971398if (!hasProp(defined, id)) {1399return onError(makeError('notloaded', 'Module name "' +1400id +1401'" has not been loaded yet for context: ' +1402contextName +1403(relMap ? '' : '. Use require([])')));1404}1405return defined[id];1406}14071408//Grab defines waiting in the global queue.1409intakeDefines();14101411//Mark all the dependencies as needing to be loaded.1412context.nextTick(function () {1413//Some defines could have been added since the1414//require call, collect them.1415intakeDefines();14161417requireMod = getModule(makeModuleMap(null, relMap));14181419//Store if map config should be applied to this require1420//call for dependencies.1421requireMod.skipMap = options.skipMap;14221423requireMod.init(deps, callback, errback, {1424enabled: true1425});14261427checkLoaded();1428});14291430return localRequire;1431}14321433mixin(localRequire, {1434isBrowser: isBrowser,14351436/**1437* Converts a module name + .extension into an URL path.1438* *Requires* the use of a module name. It does not support using1439* plain URLs like nameToUrl.1440*/1441toUrl: function (moduleNamePlusExt) {1442var ext,1443index = moduleNamePlusExt.lastIndexOf('.'),1444segment = moduleNamePlusExt.split('/')[0],1445isRelative = segment === '.' || segment === '..';14461447//Have a file extension alias, and it is not the1448//dots from a relative path.1449if (index !== -1 && (!isRelative || index > 1)) {1450ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);1451moduleNamePlusExt = moduleNamePlusExt.substring(0, index);1452}14531454return context.nameToUrl(normalize(moduleNamePlusExt,1455relMap && relMap.id, true), ext, true);1456},14571458defined: function (id) {1459return hasProp(defined, makeModuleMap(id, relMap, false, true).id);1460},14611462specified: function (id) {1463id = makeModuleMap(id, relMap, false, true).id;1464return hasProp(defined, id) || hasProp(registry, id);1465}1466});14671468//Only allow undef on top level require calls1469if (!relMap) {1470localRequire.undef = function (id) {1471//Bind any waiting define() calls to this context,1472//fix for #4081473takeGlobalQueue();14741475var map = makeModuleMap(id, relMap, true),1476mod = getOwn(registry, id);14771478removeScript(id);14791480delete defined[id];1481delete urlFetched[map.url];1482delete undefEvents[id];14831484//Clean queued defines too. Go backwards1485//in array so that the splices do not1486//mess up the iteration.1487eachReverse(defQueue, function(args, i) {1488if(args[0] === id) {1489defQueue.splice(i, 1);1490}1491});14921493if (mod) {1494//Hold on to listeners in case the1495//module will be attempted to be reloaded1496//using a different config.1497if (mod.events.defined) {1498undefEvents[id] = mod.events;1499}15001501cleanRegistry(id);1502}1503};1504}15051506return localRequire;1507},15081509/**1510* Called to enable a module if it is still in the registry1511* awaiting enablement. A second arg, parent, the parent module,1512* is passed in for context, when this method is overridden by1513* the optimizer. Not shown here to keep code compact.1514*/1515enable: function (depMap) {1516var mod = getOwn(registry, depMap.id);1517if (mod) {1518getModule(depMap).enable();1519}1520},15211522/**1523* Internal method used by environment adapters to complete a load event.1524* A load event could be a script load or just a load pass from a synchronous1525* load call.1526* @param {String} moduleName the name of the module to potentially complete.1527*/1528completeLoad: function (moduleName) {1529var found, args, mod,1530shim = getOwn(config.shim, moduleName) || {},1531shExports = shim.exports;15321533takeGlobalQueue();15341535while (defQueue.length) {1536args = defQueue.shift();1537if (args[0] === null) {1538args[0] = moduleName;1539//If already found an anonymous module and bound it1540//to this name, then this is some other anon module1541//waiting for its completeLoad to fire.1542if (found) {1543break;1544}1545found = true;1546} else if (args[0] === moduleName) {1547//Found matching define call for this script!1548found = true;1549}15501551callGetModule(args);1552}15531554//Do this after the cycle of callGetModule in case the result1555//of those calls/init calls changes the registry.1556mod = getOwn(registry, moduleName);15571558if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {1559if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {1560if (hasPathFallback(moduleName)) {1561return;1562} else {1563return onError(makeError('nodefine',1564'No define call for ' + moduleName,1565null,1566[moduleName]));1567}1568} else {1569//A script that does not call define(), so just simulate1570//the call for it.1571callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);1572}1573}15741575checkLoaded();1576},15771578/**1579* Converts a module name to a file path. Supports cases where1580* moduleName may actually be just an URL.1581* Note that it **does not** call normalize on the moduleName,1582* it is assumed to have already been normalized. This is an1583* internal API, not a public one. Use toUrl for the public API.1584*/1585nameToUrl: function (moduleName, ext, skipExt) {1586var paths, syms, i, parentModule, url,1587parentPath, bundleId,1588pkgMain = getOwn(config.pkgs, moduleName);15891590if (pkgMain) {1591moduleName = pkgMain;1592}15931594bundleId = getOwn(bundlesMap, moduleName);15951596if (bundleId) {1597return context.nameToUrl(bundleId, ext, skipExt);1598}15991600//If a colon is in the URL, it indicates a protocol is used and it is just1601//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)1602//or ends with .js, then assume the user meant to use an url and not a module id.1603//The slash is important for protocol-less URLs as well as full paths.1604if (req.jsExtRegExp.test(moduleName)) {1605//Just a plain path, not module name lookup, so just return it.1606//Add extension if it is included. This is a bit wonky, only non-.js things pass1607//an extension, this method probably needs to be reworked.1608url = moduleName + (ext || '');1609} else {1610//A module that needs to be converted to a path.1611paths = config.paths;16121613syms = moduleName.split('/');1614//For each module name segment, see if there is a path1615//registered for it. Start with most specific name1616//and work up from it.1617for (i = syms.length; i > 0; i -= 1) {1618parentModule = syms.slice(0, i).join('/');16191620parentPath = getOwn(paths, parentModule);1621if (parentPath) {1622//If an array, it means there are a few choices,1623//Choose the one that is desired1624if (isArray(parentPath)) {1625parentPath = parentPath[0];1626}1627syms.splice(0, i, parentPath);1628break;1629}1630}16311632//Join the path parts together, then figure out if baseUrl is needed.1633url = syms.join('/');1634url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));1635url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;1636}16371638return config.urlArgs ? url +1639((url.indexOf('?') === -1 ? '?' : '&') +1640config.urlArgs) : url;1641},16421643//Delegates to req.load. Broken out as a separate function to1644//allow overriding in the optimizer.1645load: function (id, url) {1646req.load(context, id, url);1647},16481649/**1650* Executes a module callback function. Broken out as a separate function1651* solely to allow the build system to sequence the files in the built1652* layer in the right sequence.1653*1654* @private1655*/1656execCb: function (name, callback, args, exports) {1657return callback.apply(exports, args);1658},16591660/**1661* callback for script loads, used to check status of loading.1662*1663* @param {Event} evt the event from the browser for the script1664* that was loaded.1665*/1666onScriptLoad: function (evt) {1667//Using currentTarget instead of target for Firefox 2.0's sake. Not1668//all old browsers will be supported, but this one was easy enough1669//to support and still makes sense.1670if (evt.type === 'load' ||1671(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {1672//Reset interactive script so a script node is not held onto for1673//to long.1674interactiveScript = null;16751676//Pull out the name of the module and the context.1677var data = getScriptData(evt);1678context.completeLoad(data.id);1679}1680},16811682/**1683* Callback for script errors.1684*/1685onScriptError: function (evt) {1686var data = getScriptData(evt);1687if (!hasPathFallback(data.id)) {1688return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id]));1689}1690}1691};16921693context.require = context.makeRequire();1694return context;1695}16961697/**1698* Main entry point.1699*1700* If the only argument to require is a string, then the module that1701* is represented by that string is fetched for the appropriate context.1702*1703* If the first argument is an array, then it will be treated as an array1704* of dependency string names to fetch. An optional function callback can1705* be specified to execute when all of those dependencies are available.1706*1707* Make a local req variable to help Caja compliance (it assumes things1708* on a require that are not standardized), and to give a short1709* name for minification/local scope use.1710*/1711req = requirejs = function (deps, callback, errback, optional) {17121713//Find the right context, use default1714var context, config,1715contextName = defContextName;17161717// Determine if have config object in the call.1718if (!isArray(deps) && typeof deps !== 'string') {1719// deps is a config object1720config = deps;1721if (isArray(callback)) {1722// Adjust args if there are dependencies1723deps = callback;1724callback = errback;1725errback = optional;1726} else {1727deps = [];1728}1729}17301731if (config && config.context) {1732contextName = config.context;1733}17341735context = getOwn(contexts, contextName);1736if (!context) {1737context = contexts[contextName] = req.s.newContext(contextName);1738}17391740if (config) {1741context.configure(config);1742}17431744return context.require(deps, callback, errback);1745};17461747/**1748* Support require.config() to make it easier to cooperate with other1749* AMD loaders on globally agreed names.1750*/1751req.config = function (config) {1752return req(config);1753};17541755/**1756* Execute something after the current tick1757* of the event loop. Override for other envs1758* that have a better solution than setTimeout.1759* @param {Function} fn function to execute later.1760*/1761req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {1762setTimeout(fn, 4);1763} : function (fn) { fn(); };17641765/**1766* Export require as a global, but only if it does not already exist.1767*/1768if (!require) {1769require = req;1770}17711772req.version = version;17731774//Used to filter out dependencies that are already paths.1775req.jsExtRegExp = /^\/|:|\?|\.js$/;1776req.isBrowser = isBrowser;1777s = req.s = {1778contexts: contexts,1779newContext: newContext1780};17811782//Create default context.1783req({});17841785//Exports some context-sensitive methods on global require.1786each([1787'toUrl',1788'undef',1789'defined',1790'specified'1791], function (prop) {1792//Reference from contexts instead of early binding to default context,1793//so that during builds, the latest instance of the default context1794//with its config gets used.1795req[prop] = function () {1796var ctx = contexts[defContextName];1797return ctx.require[prop].apply(ctx, arguments);1798};1799});18001801if (isBrowser) {1802head = s.head = document.getElementsByTagName('head')[0];1803//If BASE tag is in play, using appendChild is a problem for IE6.1804//When that browser dies, this can be removed. Details in this jQuery bug:1805//http://dev.jquery.com/ticket/27091806baseElement = document.getElementsByTagName('base')[0];1807if (baseElement) {1808head = s.head = baseElement.parentNode;1809}1810}18111812/**1813* Any errors that require explicitly generates will be passed to this1814* function. Intercept/override it if you want custom error handling.1815* @param {Error} err the error object.1816*/1817req.onError = defaultOnError;18181819/**1820* Creates the node for the load command. Only used in browser envs.1821*/1822req.createNode = function (config, moduleName, url) {1823var node = config.xhtml ?1824document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :1825document.createElement('script');1826node.type = config.scriptType || 'text/javascript';1827node.charset = 'utf-8';1828node.async = true;1829return node;1830};18311832/**1833* Does the request to load a module for the browser case.1834* Make this a separate function to allow other environments1835* to override it.1836*1837* @param {Object} context the require context to find state.1838* @param {String} moduleName the name of the module.1839* @param {Object} url the URL to the module.1840*/1841req.load = function (context, moduleName, url) {1842var config = (context && context.config) || {},1843node;1844if (isBrowser) {1845//In the browser so use a script tag1846node = req.createNode(config, moduleName, url);18471848node.setAttribute('data-requirecontext', context.contextName);1849node.setAttribute('data-requiremodule', moduleName);18501851//Set up load listener. Test attachEvent first because IE9 has1852//a subtle issue in its addEventListener and script onload firings1853//that do not match the behavior of all other browsers with1854//addEventListener support, which fire the onload event for a1855//script right after the script execution. See:1856//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution1857//UNFORTUNATELY Opera implements attachEvent but does not follow the script1858//script execution mode.1859if (node.attachEvent &&1860//Check if node.attachEvent is artificially added by custom script or1861//natively supported by browser1862//read https://github.com/jrburke/requirejs/issues/1871863//if we can NOT find [native code] then it must NOT natively supported.1864//in IE8, node.attachEvent does not have toString()1865//Note the test for "[native code" with no closing brace, see:1866//https://github.com/jrburke/requirejs/issues/2731867!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&1868!isOpera) {1869//Probably IE. IE (at least 6-8) do not fire1870//script onload right after executing the script, so1871//we cannot tie the anonymous define call to a name.1872//However, IE reports the script as being in 'interactive'1873//readyState at the time of the define call.1874useInteractive = true;18751876node.attachEvent('onreadystatechange', context.onScriptLoad);1877//It would be great to add an error handler here to catch1878//404s in IE9+. However, onreadystatechange will fire before1879//the error handler, so that does not help. If addEventListener1880//is used, then IE will fire error before load, but we cannot1881//use that pathway given the connect.microsoft.com issue1882//mentioned above about not doing the 'script execute,1883//then fire the script load event listener before execute1884//next script' that other browsers do.1885//Best hope: IE10 fixes the issues,1886//and then destroys all installs of IE 6-9.1887//node.attachEvent('onerror', context.onScriptError);1888} else {1889node.addEventListener('load', context.onScriptLoad, false);1890node.addEventListener('error', context.onScriptError, false);1891}1892node.src = url;18931894//For some cache cases in IE 6-8, the script executes before the end1895//of the appendChild execution, so to tie an anonymous define1896//call to the module name (which is stored on the node), hold on1897//to a reference to this node, but clear after the DOM insertion.1898currentlyAddingScript = node;1899if (baseElement) {1900head.insertBefore(node, baseElement);1901} else {1902head.appendChild(node);1903}1904currentlyAddingScript = null;19051906return node;1907} else if (isWebWorker) {1908try {1909//In a web worker, use importScripts. This is not a very1910//efficient use of importScripts, importScripts will block until1911//its script is downloaded and evaluated. However, if web workers1912//are in play, the expectation that a build has been done so that1913//only one script needs to be loaded anyway. This may need to be1914//reevaluated if other use cases become common.1915importScripts(url);19161917//Account for anonymous modules1918context.completeLoad(moduleName);1919} catch (e) {1920context.onError(makeError('importscripts',1921'importScripts failed for ' +1922moduleName + ' at ' + url,1923e,1924[moduleName]));1925}1926}1927};19281929function getInteractiveScript() {1930if (interactiveScript && interactiveScript.readyState === 'interactive') {1931return interactiveScript;1932}19331934eachReverse(scripts(), function (script) {1935if (script.readyState === 'interactive') {1936return (interactiveScript = script);1937}1938});1939return interactiveScript;1940}19411942//Look for a data-main script attribute, which could also adjust the baseUrl.1943if (isBrowser && !cfg.skipDataMain) {1944//Figure out baseUrl. Get it from the script tag with require.js in it.1945eachReverse(scripts(), function (script) {1946//Set the 'head' where we can append children by1947//using the script's parent.1948if (!head) {1949head = script.parentNode;1950}19511952//Look for a data-main attribute to set main script for the page1953//to load. If it is there, the path to data main becomes the1954//baseUrl, if it is not already set.1955dataMain = script.getAttribute('data-main');1956if (dataMain) {1957//Preserve dataMain in case it is a path (i.e. contains '?')1958mainScript = dataMain;19591960//Set final baseUrl if there is not already an explicit one.1961if (!cfg.baseUrl) {1962//Pull off the directory of data-main for use as the1963//baseUrl.1964src = mainScript.split('/');1965mainScript = src.pop();1966subPath = src.length ? src.join('/') + '/' : './';19671968cfg.baseUrl = subPath;1969}19701971//Strip off any trailing .js since mainScript is now1972//like a module name.1973mainScript = mainScript.replace(jsSuffixRegExp, '');19741975//If mainScript is still a path, fall back to dataMain1976if (req.jsExtRegExp.test(mainScript)) {1977mainScript = dataMain;1978}19791980//Put the data-main script in the files to load.1981cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];19821983return true;1984}1985});1986}19871988/**1989* The function that handles definitions of modules. Differs from1990* require() in that a string for the module should be the first argument,1991* and the function to execute after dependencies are loaded should1992* return a value to define the module corresponding to the first argument's1993* name.1994*/1995define = function (name, deps, callback) {1996var node, context;19971998//Allow for anonymous modules1999if (typeof name !== 'string') {2000//Adjust args appropriately2001callback = deps;2002deps = name;2003name = null;2004}20052006//This module may not have dependencies2007if (!isArray(deps)) {2008callback = deps;2009deps = null;2010}20112012//If no name, and callback is a function, then figure out if it a2013//CommonJS thing with dependencies.2014if (!deps && isFunction(callback)) {2015deps = [];2016//Remove comments from the callback string,2017//look for require calls, and pull them into the dependencies,2018//but only if there are function args.2019if (callback.length) {2020callback2021.toString()2022.replace(commentRegExp, '')2023.replace(cjsRequireRegExp, function (match, dep) {2024deps.push(dep);2025});20262027//May be a CommonJS thing even without require calls, but still2028//could use exports, and module. Avoid doing exports and module2029//work though if it just needs require.2030//REQUIRES the function to expect the CommonJS variables in the2031//order listed below.2032deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);2033}2034}20352036//If in IE 6-8 and hit an anonymous define() call, do the interactive2037//work.2038if (useInteractive) {2039node = currentlyAddingScript || getInteractiveScript();2040if (node) {2041if (!name) {2042name = node.getAttribute('data-requiremodule');2043}2044context = contexts[node.getAttribute('data-requirecontext')];2045}2046}20472048//Always save off evaluating the def call until the script onload handler.2049//This allows multiple modules to be in a file without prematurely2050//tracing dependencies, and allows for anonymous module support,2051//where the module name is not known until the script onload event2052//occurs. If no context, use the global queue, and get it processed2053//in the onscript load callback.2054(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);2055};20562057define.amd = {2058jQuery: true2059};206020612062/**2063* Executes the text. Normally just uses eval, but can be modified2064* to use a better, environment-specific call. Only used for transpiling2065* loader plugins, not for plain JS modules.2066* @param {String} text the text to execute/evaluate.2067*/2068req.exec = function (text) {2069/*jslint evil: true */2070return eval(text);2071};20722073//Set up with config info.2074req(cfg);2075}(this));207620772078