Skip to content

Commit

Permalink
updated to latest requirejs
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed Jul 24, 2012
1 parent d377ff0 commit 7a0b9e4
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions assets/js/libs/require.js
@@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.0.4+ 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
*/
Expand All @@ -10,9 +10,9 @@ var requirejs, require, define;
(function (global) {
'use strict';

var version = '2.0.2',
var version = '2.0.4+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
currDirRegExp = /^\.\//,
ostring = Object.prototype.toString,
Expand Down Expand Up @@ -288,6 +288,7 @@ var requirejs, require, define;
*/
function normalize(name, baseName, applyMap) {
var baseParts = baseName && baseName.split('/'),
normalizedBaseParts = baseParts,
map = config.map,
starMap = map && map['*'],
pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
Expand All @@ -302,17 +303,17 @@ var requirejs, require, define;
if (config.pkgs[baseName]) {
//If the baseName is a package name, then just treat it as one
//name to concat the name with.
baseParts = [baseName];
normalizedBaseParts = baseParts = [baseName];
} else {
//Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
baseParts = baseParts.slice(0, baseParts.length - 1);
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
}

name = baseParts.concat(name.split('/'));
name = normalizedBaseParts.concat(name.split('/'));
trimDots(name);

//Some use of packages may use a . path to reference the
Expand Down Expand Up @@ -450,17 +451,7 @@ var requirejs, require, define;
} else {
//A regular module.
normalizedName = normalize(name, parentName, applyMap);

//Calculate url for the module, if it has a name.
//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);
url = context.nameToUrl(normalizedName);
}
}

Expand Down Expand Up @@ -1371,7 +1362,11 @@ var requirejs, require, define;
//update the maps for them, since their info, like URLs to load,
//may have changed.
eachProp(registry, function (mod, id) {
mod.map = makeModuleMap(id);
//If module already has init called, since it is too
//late to modify them.
if (!mod.inited) {
mod.map = makeModuleMap(id);
}
});

//If a deps array or a config callback is specified, then call
Expand Down Expand Up @@ -1583,20 +1578,21 @@ var requirejs, require, define;
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
}

return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
return context.nameToUrl(normalize(moduleNamePlusExt, relModuleMap && relModuleMap.id, true),
ext);
},

/**
* Converts a module name to a file path. Supports cases where
* moduleName may actually be just an URL.
* Note that it **does not** call normalize on the moduleName,
* it is assumed to have already been normalized. This is an
* internal API, not a public one. Use toUrl for the public API.
*/
nameToUrl: function (moduleName, ext, relModuleMap) {
nameToUrl: function (moduleName, ext) {
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
parentPath;

//Normalize module name if have a base relative module name to work from.
moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true);

//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, contains a query arg (i.e. ?)
//or ends with .js, then assume the user meant to use an url and not a module id.
Expand Down Expand Up @@ -1822,6 +1818,7 @@ var requirejs, require, define;
document.createElement('script');
node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8';
node.async = true;

node.setAttribute('data-requirecontext', context.contextName);
node.setAttribute('data-requiremodule', moduleName);
Expand Down Expand Up @@ -1924,21 +1921,21 @@ var requirejs, require, define;
//baseUrl, if it is not already set.
dataMain = script.getAttribute('data-main');
if (dataMain) {

//Pull off the directory of data-main for use as the
//baseUrl.
src = dataMain.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';

//Set final baseUrl if there is not already an explicit one.
if (!cfg.baseUrl) {
//Pull off the directory of data-main for use as the
//baseUrl.
src = dataMain.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';

cfg.baseUrl = subPath;
dataMain = mainScript;
}

//Strip off any trailing .js since dataMain is now
//like a module name.
dataMain = mainScript.replace(jsSuffixRegExp, '');
dataMain = dataMain.replace(jsSuffixRegExp, '');

//Put the data-main script in the files to load.
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
Expand Down

0 comments on commit 7a0b9e4

Please sign in to comment.