Skip to content

Commit

Permalink
Merge branch 'MDL-51538-master' of git://github.com/damyon/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Oct 6, 2015
2 parents 8d49ad2 + a362086 commit 6b58b26
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 50 deletions.
3 changes: 3 additions & 0 deletions lib/requirejs/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Description of import into Moodle:
// Download from https://requirejs.org/docs/download.html
// Put the require.js and require.min.js and LICENSE file in this folder.
63 changes: 45 additions & 18 deletions lib/requirejs/require.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.15 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.1.20 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
Expand All @@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) {
var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.15',
version = '2.1.20',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
Expand All @@ -21,7 +21,6 @@ var requirejs, require, define;
ostring = op.toString,
hasOwn = op.hasOwnProperty,
ap = Array.prototype,
apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete
Expand Down Expand Up @@ -244,7 +243,7 @@ var requirejs, require, define;
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') {
if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
Expand Down Expand Up @@ -554,11 +553,13 @@ var requirejs, require, define;
function takeGlobalQueue() {
//Push all the globalDefQueue items into the context's defQueue
if (globalDefQueue.length) {
//Array splice in the values since the context code has a
//local var ref to defQueue, so cannot just reassign the one
//on context.
apsp.apply(defQueue,
[defQueue.length, 0].concat(globalDefQueue));
each(globalDefQueue, function(queueItem) {
var id = queueItem[0];
if (typeof id === 'string') {
context.defQueueMap[id] = true;
}
defQueue.push(queueItem);
});
globalDefQueue = [];
}
}
Expand Down Expand Up @@ -589,7 +590,7 @@ var requirejs, require, define;
id: mod.map.id,
uri: mod.map.url,
config: function () {
return getOwn(config.config, mod.map.id) || {};
return getOwn(config.config, mod.map.id) || {};
},
exports: mod.exports || (mod.exports = {})
});
Expand Down Expand Up @@ -845,7 +846,10 @@ var requirejs, require, define;
factory = this.factory;

if (!this.inited) {
this.fetch();
// Only fetch if not already in the defQueue.
if (!hasProp(context.defQueueMap, id)) {
this.fetch();
}
} else if (this.error) {
this.emit('error', this.error);
} else if (!this.defining) {
Expand Down Expand Up @@ -1117,12 +1121,22 @@ var requirejs, require, define;
this.depCount += 1;

on(depMap, 'defined', bind(this, function (depExports) {
if (this.undefed) {
return;
}
this.defineDep(i, depExports);
this.check();
}));

if (this.errback) {
on(depMap, 'error', bind(this, this.errback));
} else if (this.events.error) {
// No direct errback on this module, but something
// else is listening for errors, so be sure to
// propagate the error correctly.
on(depMap, 'error', bind(this, function(err) {
this.emit('error', err);
}));
}
}

Expand Down Expand Up @@ -1226,13 +1240,15 @@ var requirejs, require, define;
while (defQueue.length) {
args = defQueue.shift();
if (args[0] === null) {
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
args[args.length - 1]));
} else {
//args are id, deps, factory. Should be normalized by the
//define() function.
callGetModule(args);
}
}
context.defQueueMap = {};
}

context = {
Expand All @@ -1242,6 +1258,7 @@ var requirejs, require, define;
defined: defined,
urlFetched: urlFetched,
defQueue: defQueue,
defQueueMap: {},
Module: Module,
makeModuleMap: makeModuleMap,
nextTick: req.nextTick,
Expand Down Expand Up @@ -1313,7 +1330,7 @@ var requirejs, require, define;
each(cfg.packages, function (pkgObj) {
var location, name;

pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;

name = pkgObj.name;
location = pkgObj.location;
Expand All @@ -1340,7 +1357,7 @@ var requirejs, require, define;
//late to modify them, and ignore unnormalized ones
//since they are transient.
if (!mod.inited && !mod.map.unnormalized) {
mod.map = makeModuleMap(id);
mod.map = makeModuleMap(id, null, true);
}
});

Expand Down Expand Up @@ -1476,6 +1493,7 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id);

mod.undefed = true;
removeScript(id);

delete defined[id];
Expand All @@ -1486,10 +1504,11 @@ var requirejs, require, define;
//in array so that the splices do not
//mess up the iteration.
eachReverse(defQueue, function(args, i) {
if(args[0] === id) {
if (args[0] === id) {
defQueue.splice(i, 1);
}
});
delete context.defQueueMap[id];

if (mod) {
//Hold on to listeners in case the
Expand Down Expand Up @@ -1551,6 +1570,7 @@ var requirejs, require, define;

callGetModule(args);
}
context.defQueueMap = {};

//Do this after the cycle of callGetModule in case the result
//of those calls/init calls changes the registry.
Expand Down Expand Up @@ -1845,6 +1865,9 @@ var requirejs, require, define;
if (isBrowser) {
//In the browser so use a script tag
node = req.createNode(config, moduleName, url);
if (config.onNodeCreated) {
config.onNodeCreated(node, config, moduleName, url);
}

node.setAttribute('data-requirecontext', context.contextName);
node.setAttribute('data-requiremodule', moduleName);
Expand Down Expand Up @@ -1973,7 +1996,7 @@ var requirejs, require, define;
//like a module name.
mainScript = mainScript.replace(jsSuffixRegExp, '');

//If mainScript is still a path, fall back to dataMain
//If mainScript is still a path, fall back to dataMain
if (req.jsExtRegExp.test(mainScript)) {
mainScript = dataMain;
}
Expand Down Expand Up @@ -2052,14 +2075,18 @@ var requirejs, require, define;
//where the module name is not known until the script onload event
//occurs. If no context, use the global queue, and get it processed
//in the onscript load callback.
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
if (context) {
context.defQueue.push([name, deps, callback]);
context.defQueueMap[name] = true;
} else {
globalDefQueue.push([name, deps, callback]);
}
};

define.amd = {
jQuery: true
};


/**
* Executes the text. Normally just uses eval, but can be modified
* to use a better, environment-specific call. Only used for transpiling
Expand Down
Loading

0 comments on commit 6b58b26

Please sign in to comment.