use proper AMD style
This commit is contained in:
parent
527fcff5f5
commit
8c06c538ee
3 changed files with 20 additions and 9 deletions
|
|
@ -43,7 +43,12 @@
|
|||
|
||||
(function() {
|
||||
|
||||
var _define = function(module, payload) {
|
||||
if (window.require) {
|
||||
require.packaged = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var _define = function(module, deps, payload) {
|
||||
if (typeof module !== 'string') {
|
||||
if (_define.original)
|
||||
_define.original.apply(window, arguments);
|
||||
|
|
@ -76,13 +81,12 @@ var _require = function(module, callback) {
|
|||
if (!dep && _require.original)
|
||||
return _require.original.apply(window, arguments);
|
||||
params.push(dep);
|
||||
};
|
||||
}
|
||||
if (callback) {
|
||||
callback.apply(null, params);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module === 'string') {
|
||||
else if (typeof module === 'string') {
|
||||
var payload = lookup(module);
|
||||
if (!payload && _require.original)
|
||||
return _require.original.apply(window, arguments);
|
||||
|
|
@ -92,8 +96,12 @@ var _require = function(module, callback) {
|
|||
}
|
||||
|
||||
return payload;
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_require.original)
|
||||
return _require.original.apply(window, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
if (window.require)
|
||||
_require.original = window.require;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
(function() {
|
||||
|
||||
var _define = function(module, payload) {
|
||||
var _define = function(module, deps, payload) {
|
||||
if (typeof module !== 'string') {
|
||||
if (_define.original)
|
||||
_define.original.apply(window, arguments);
|
||||
|
|
|
|||
|
|
@ -30,11 +30,14 @@ var require = function(id) {
|
|||
require.modules = {};
|
||||
require.tlns = {};
|
||||
|
||||
var define = function(id, factory) {
|
||||
if (!factory) {
|
||||
var define = function(id, deps, factory) {
|
||||
if (arguments.length == 2) {
|
||||
factory = deps;
|
||||
} else if (arguments.length == 1) {
|
||||
factory = id;
|
||||
id = require.id;
|
||||
}
|
||||
|
||||
if (id.indexOf("text!") === 0)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue