update require.js in demo
This commit is contained in:
parent
cf23198610
commit
adbed85f97
2 changed files with 161 additions and 48 deletions
|
|
@ -677,13 +677,6 @@ require("ace/multi_select").MultiSelect(env.editor);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/* var Editor = require("ace/editor").Editor;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
var MultiSelect = require("ace/multi_select").MultiSelect; */
|
||||
|
||||
function singleLineEditor(el) {
|
||||
var renderer = new Renderer(el);
|
||||
renderer.scrollBar.element.style.display = "none";
|
||||
|
|
@ -734,7 +727,7 @@ function singleLineEditor(el) {
|
|||
editor.setHighlightActiveLine(false);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.renderer.setShowGutter(false);
|
||||
editor.renderer.setHighlightGutterLine(false);
|
||||
// editor.renderer.setHighlightGutterLine(false);
|
||||
return editor;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
/** vim: et:ts=4:sw=4:sts=4
|
||||
* @license RequireJS 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
||||
* @license RequireJS 1.0.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/jrburke/requirejs for details
|
||||
*/
|
||||
/*jslint strict: false, plusplus: false, sub: true */
|
||||
/*global window: false, navigator: false, document: false, importScripts: false,
|
||||
jQuery: false, clearInterval: false, setInterval: false, self: false,
|
||||
setTimeout: false, opera: false */
|
||||
/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
|
||||
|
||||
var requirejs, require, define;
|
||||
(function () {
|
||||
(function (undefined) {
|
||||
//Change this version number for each release.
|
||||
var version = "1.0.3",
|
||||
var version = "1.0.8",
|
||||
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
||||
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
|
||||
currDirRegExp = /^\.\//,
|
||||
|
|
@ -37,8 +35,13 @@ var requirejs, require, define;
|
|||
interactiveScript = null,
|
||||
checkLoadedDepth = 0,
|
||||
useInteractive = false,
|
||||
reservedDependencies = {
|
||||
require: true,
|
||||
module: true,
|
||||
exports: true
|
||||
},
|
||||
req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script,
|
||||
src, subPath, mainScript, dataMain, i, ctx, jQueryCheck, checkLoadedTimeoutId;
|
||||
src, subPath, mainScript, dataMain, globalI, ctx, jQueryCheck, checkLoadedTimeoutId;
|
||||
|
||||
function isFunction(it) {
|
||||
return ostring.call(it) === "[object Function]";
|
||||
|
|
@ -323,7 +326,15 @@ var requirejs, require, define;
|
|||
url = urlMap[normalizedName];
|
||||
if (!url) {
|
||||
//Calculate url for the module, if it has a name.
|
||||
url = context.nameToUrl(normalizedName, null, parentModuleMap);
|
||||
//Use name here since nameToUrl also calls normalize,
|
||||
//and for relative names that are outside the baseUrl
|
||||
//this causes havoc. Was thinking of just removing
|
||||
//parentModuleMap to avoid extra normalization, but
|
||||
//normalize() still does a dot removal because of
|
||||
//issue #142, so just pass in name here and redo
|
||||
//the normalization. Paths outside baseUrl are just
|
||||
//messy to support.
|
||||
url = context.nameToUrl(name, null, parentModuleMap);
|
||||
|
||||
//Store the URL mapping for later.
|
||||
urlMap[normalizedName] = url;
|
||||
|
|
@ -383,8 +394,8 @@ var requirejs, require, define;
|
|||
* per module because of the implication of path mappings that may
|
||||
* need to be relative to the module name.
|
||||
*/
|
||||
function makeRequire(relModuleMap, enableBuildCallback) {
|
||||
var modRequire = makeContextModuleFunc(context.require, relModuleMap, enableBuildCallback);
|
||||
function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
|
||||
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
|
||||
|
||||
mixin(modRequire, {
|
||||
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
|
||||
|
|
@ -412,18 +423,19 @@ var requirejs, require, define;
|
|||
fullName = map.fullName,
|
||||
args = manager.deps,
|
||||
listeners = manager.listeners,
|
||||
execCb = config.requireExecCb || req.execCb,
|
||||
cjsModule;
|
||||
|
||||
//Call the callback to define the module, if necessary.
|
||||
if (cb && isFunction(cb)) {
|
||||
if (config.catchError.define) {
|
||||
try {
|
||||
ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
|
||||
ret = execCb(fullName, manager.callback, args, defined[fullName]);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
} else {
|
||||
ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
|
||||
ret = execCb(fullName, manager.callback, args, defined[fullName]);
|
||||
}
|
||||
|
||||
if (fullName) {
|
||||
|
|
@ -599,7 +611,22 @@ var requirejs, require, define;
|
|||
//Use parentName here since the plugin's name is not reliable,
|
||||
//could be some weird string with no path that actually wants to
|
||||
//reference the parentName's path.
|
||||
plugin.load(name, makeRequire(map.parentMap, true), load, config);
|
||||
plugin.load(name, makeRequire(map.parentMap, true, function (deps, cb) {
|
||||
var moduleDeps = [],
|
||||
i, dep, depMap;
|
||||
//Convert deps to full names and hold on to them
|
||||
//for reference later, when figuring out if they
|
||||
//are blocked by a circular dependency.
|
||||
for (i = 0; (dep = deps[i]); i++) {
|
||||
depMap = makeModuleMap(dep, map.parentMap);
|
||||
deps[i] = depMap.fullName;
|
||||
if (!depMap.prefix) {
|
||||
moduleDeps.push(deps[i]);
|
||||
}
|
||||
}
|
||||
depManager.moduleDeps = (depManager.moduleDeps || []).concat(moduleDeps);
|
||||
return context.require(deps, cb);
|
||||
}), load, config);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -628,7 +655,7 @@ var requirejs, require, define;
|
|||
prefix = map.prefix,
|
||||
plugin = prefix ? plugins[prefix] ||
|
||||
(plugins[prefix] = defined[prefix]) : null,
|
||||
manager, created, pluginManager;
|
||||
manager, created, pluginManager, prefixMap;
|
||||
|
||||
if (fullName) {
|
||||
manager = managerCallbacks[fullName];
|
||||
|
|
@ -666,7 +693,18 @@ var requirejs, require, define;
|
|||
//If there is a plugin needed, but it is not loaded,
|
||||
//first load the plugin, then continue on.
|
||||
if (prefix && !plugin) {
|
||||
pluginManager = getManager(makeModuleMap(prefix), true);
|
||||
prefixMap = makeModuleMap(prefix);
|
||||
|
||||
//Clear out defined and urlFetched if the plugin was previously
|
||||
//loaded/defined, but not as full module (as in a build
|
||||
//situation). However, only do this work if the plugin is in
|
||||
//defined but does not have a module export value.
|
||||
if (prefix in defined && !defined[prefix]) {
|
||||
delete defined[prefix];
|
||||
delete urlFetched[prefixMap.url];
|
||||
}
|
||||
|
||||
pluginManager = getManager(prefixMap, true);
|
||||
pluginManager.add(function (plugin) {
|
||||
//Create a new manager for the normalized
|
||||
//resource ID and have it call this manager when
|
||||
|
|
@ -855,15 +893,62 @@ var requirejs, require, define;
|
|||
}
|
||||
};
|
||||
|
||||
function forceExec(manager, traced) {
|
||||
if (manager.isDone) {
|
||||
return undefined;
|
||||
function findCycle(manager, traced) {
|
||||
var fullName = manager.map.fullName,
|
||||
depArray = manager.depArray,
|
||||
fullyLoaded = true,
|
||||
i, depName, depManager, result;
|
||||
|
||||
if (manager.isDone || !fullName || !loaded[fullName]) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//Found the cycle.
|
||||
if (traced[fullName]) {
|
||||
return manager;
|
||||
}
|
||||
|
||||
traced[fullName] = true;
|
||||
|
||||
//Trace through the dependencies.
|
||||
if (depArray) {
|
||||
for (i = 0; i < depArray.length; i++) {
|
||||
//Some array members may be null, like if a trailing comma
|
||||
//IE, so do the explicit [i] access and check if it has a value.
|
||||
depName = depArray[i];
|
||||
if (!loaded[depName] && !reservedDependencies[depName]) {
|
||||
fullyLoaded = false;
|
||||
break;
|
||||
}
|
||||
depManager = waiting[depName];
|
||||
if (depManager && !depManager.isDone && loaded[depName]) {
|
||||
result = findCycle(depManager, traced);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fullyLoaded) {
|
||||
//Discard the cycle that was found, since it cannot
|
||||
//be forced yet. Also clear this module from traced.
|
||||
result = undefined;
|
||||
delete traced[fullName];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function forceExec(manager, traced) {
|
||||
var fullName = manager.map.fullName,
|
||||
depArray = manager.depArray,
|
||||
i, depName, depManager, prefix, prefixManager, value;
|
||||
|
||||
|
||||
if (manager.isDone || !fullName || !loaded[fullName]) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (fullName) {
|
||||
if (traced[fullName]) {
|
||||
return defined[fullName];
|
||||
|
|
@ -894,7 +979,7 @@ var requirejs, require, define;
|
|||
}
|
||||
}
|
||||
|
||||
return fullName ? defined[fullName] : undefined;
|
||||
return defined[fullName];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -907,8 +992,9 @@ var requirejs, require, define;
|
|||
var waitInterval = config.waitSeconds * 1000,
|
||||
//It is possible to disable the wait interval by using waitSeconds of 0.
|
||||
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
|
||||
noLoads = "", hasLoadedProp = false, stillLoading = false, prop,
|
||||
err, manager;
|
||||
noLoads = "", hasLoadedProp = false, stillLoading = false,
|
||||
cycleDeps = [],
|
||||
i, prop, err, manager, cycleManager, moduleDeps;
|
||||
|
||||
//If there are items still in the paused queue processing wait.
|
||||
//This is particularly important in the sync case where each paused
|
||||
|
|
@ -938,7 +1024,20 @@ var requirejs, require, define;
|
|||
noLoads += prop + " ";
|
||||
} else {
|
||||
stillLoading = true;
|
||||
break;
|
||||
if (prop.indexOf('!') === -1) {
|
||||
//No reason to keep looking for unfinished
|
||||
//loading. If the only stillLoading is a
|
||||
//plugin resource though, keep going,
|
||||
//because it may be that a plugin resource
|
||||
//is waiting on a non-plugin cycle.
|
||||
cycleDeps = [];
|
||||
break;
|
||||
} else {
|
||||
moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps;
|
||||
if (moduleDeps) {
|
||||
cycleDeps.push.apply(cycleDeps, moduleDeps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -955,9 +1054,26 @@ var requirejs, require, define;
|
|||
err = makeError("timeout", "Load timeout for modules: " + noLoads);
|
||||
err.requireType = "timeout";
|
||||
err.requireModules = noLoads;
|
||||
err.contextName = context.contextName;
|
||||
return req.onError(err);
|
||||
}
|
||||
if (stillLoading || context.scriptCount) {
|
||||
|
||||
//If still loading but a plugin is waiting on a regular module cycle
|
||||
//break the cycle.
|
||||
if (stillLoading && cycleDeps.length) {
|
||||
for (i = 0; (manager = waiting[cycleDeps[i]]); i++) {
|
||||
if ((cycleManager = findCycle(manager, {}))) {
|
||||
forceExec(cycleManager, {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If still waiting on loads, and the waiting load is something
|
||||
//other than a plugin resource, or there are still outstanding
|
||||
//scripts, then just try back later.
|
||||
if (!expired && (stillLoading || context.scriptCount)) {
|
||||
//Something is still waiting to load. Wait for it, but only
|
||||
//if a timeout is not already in effect.
|
||||
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
|
||||
|
|
@ -1015,6 +1131,9 @@ var requirejs, require, define;
|
|||
resume = function () {
|
||||
var manager, map, url, i, p, args, fullName;
|
||||
|
||||
//Any defined modules in the global queue, intake them now.
|
||||
context.takeGlobalQueue();
|
||||
|
||||
resumeDepth += 1;
|
||||
|
||||
if (context.scriptCount <= 0) {
|
||||
|
|
@ -1056,7 +1175,7 @@ var requirejs, require, define;
|
|||
} else {
|
||||
//Regular dependency.
|
||||
if (!urlFetched[url] && !loaded[fullName]) {
|
||||
req.load(context, fullName, url);
|
||||
(config.requireLoad || req.load)(context, fullName, url);
|
||||
|
||||
//Mark the URL as fetched, but only if it is
|
||||
//not an empty: URL, used by the optimizer.
|
||||
|
|
@ -1178,8 +1297,7 @@ var requirejs, require, define;
|
|||
context.requireWait = false;
|
||||
//But first, call resume to register any defined modules that may
|
||||
//be in a data-main built file before the priority config
|
||||
//call. Also grab any waiting define calls for this context.
|
||||
context.takeGlobalQueue();
|
||||
//call.
|
||||
resume();
|
||||
|
||||
context.require(cfg.priority);
|
||||
|
|
@ -1256,10 +1374,6 @@ var requirejs, require, define;
|
|||
//then resume the dependency processing.
|
||||
if (!context.requireWait) {
|
||||
while (!context.scriptCount && context.paused.length) {
|
||||
//For built layers, there can be some defined
|
||||
//modules waiting for intake into the context,
|
||||
//in particular module plugins. Take them.
|
||||
context.takeGlobalQueue();
|
||||
resume();
|
||||
}
|
||||
}
|
||||
|
|
@ -1365,7 +1479,8 @@ var requirejs, require, define;
|
|||
moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName);
|
||||
|
||||
//If a colon is in the URL, it indicates a protocol is used and it is just
|
||||
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
||||
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
|
||||
//or ends with .js, then assume the user meant to use an url and not a module id.
|
||||
//The slash is important for protocol-less URLs as well as full paths.
|
||||
if (req.jsExtRegExp.test(moduleName)) {
|
||||
//Just a plain path, not module name lookup, so just return it.
|
||||
|
|
@ -1401,7 +1516,7 @@ var requirejs, require, define;
|
|||
|
||||
//Join the path parts together, then figure out if baseUrl is needed.
|
||||
url = syms.join("/") + (ext || ".js");
|
||||
url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url;
|
||||
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? "" : config.baseUrl) + url;
|
||||
}
|
||||
|
||||
return config.urlArgs ? url +
|
||||
|
|
@ -1737,7 +1852,8 @@ var requirejs, require, define;
|
|||
node = context && context.config && context.config.xhtml ?
|
||||
document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") :
|
||||
document.createElement("script");
|
||||
node.type = type || "text/javascript";
|
||||
node.type = type || (context && context.config.scriptType) ||
|
||||
"text/javascript";
|
||||
node.charset = "utf-8";
|
||||
//Use async so Gecko does not block on executing the script if something
|
||||
//like a long-polling comet tag is being run first. Gecko likes
|
||||
|
|
@ -1764,7 +1880,15 @@ var requirejs, require, define;
|
|||
//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
|
||||
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
||||
//script execution mode.
|
||||
if (node.attachEvent && !isOpera) {
|
||||
if (node.attachEvent &&
|
||||
// check if node.attachEvent is artificially added by custom script or
|
||||
// natively supported by browser
|
||||
// read https://github.com/jrburke/requirejs/issues/187
|
||||
// if we can NOT find [native code] then it must NOT natively supported.
|
||||
// in IE8, node.attachEvent does not have toString()
|
||||
// TODO: a better way to check interactive mode
|
||||
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code]') < 0) &&
|
||||
!isOpera) {
|
||||
//Probably IE. IE (at least 6-8) do not fire
|
||||
//script onload right after executing the script, so
|
||||
//we cannot tie the anonymous define call to a name.
|
||||
|
|
@ -1822,7 +1946,7 @@ var requirejs, require, define;
|
|||
//Figure out baseUrl. Get it from the script tag with require.js in it.
|
||||
scripts = document.getElementsByTagName("script");
|
||||
|
||||
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
||||
for (globalI = scripts.length - 1; globalI > -1 && (script = scripts[globalI]); globalI--) {
|
||||
//Set the "head" where we can append children by
|
||||
//using the script's parent.
|
||||
if (!head) {
|
||||
|
|
@ -1930,14 +2054,10 @@ var requirejs, require, define;
|
|||
setTimeout(function () {
|
||||
ctx.requireWait = false;
|
||||
|
||||
//Any modules included with the require.js file will be in the
|
||||
//global queue, assign them to this context.
|
||||
ctx.takeGlobalQueue();
|
||||
|
||||
if (!ctx.scriptCount) {
|
||||
ctx.resume();
|
||||
}
|
||||
req.checkReadyState();
|
||||
}, 0);
|
||||
}
|
||||
}());
|
||||
}());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue