Permalink
Browse files

changes to facilitate loading via AMD loader

  • Loading branch information...
1 parent b7ea8b6 commit 74fd0629a9a576e99414c63353041f699d1646d2 @neonstalwart committed Apr 17, 2012
Showing with 41 additions and 34 deletions.
  1. +41 −34 CordovaLib/javascript/cordova.ios.js
@@ -21,44 +21,46 @@
under the License.
*/
-;(function() {
-
// file: lib/scripts/require.js
var require,
define;
(function () {
var modules = {};
- function build(module) {
- var factory = module.factory;
- module.exports = {};
- delete module.factory;
- factory(require, module.exports, module);
- return module.exports;
- }
-
- require = function (id) {
- if (!modules[id]) {
- throw "module " + id + " not found";
- }
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
- };
-
- define = function (id, factory) {
- if (modules[id]) {
- throw "module " + id + " already defined";
+ if (typeof require === "undefined") {
+ function build(module) {
+ var factory = module.factory;
+ module.exports = {};
+ delete module.factory;
+ factory(require, module.exports, module);
+ return module.exports;
}
- modules[id] = {
- id: id,
- factory: factory
+ require = function (id) {
+ if (!modules[id]) {
+ throw "module " + id + " not found";
+ }
+ return modules[id].factory ? build(modules[id]) : modules[id].exports;
};
- };
+ }
- define.remove = function (id) {
- delete modules[id];
- };
+ if (typeof define === "undefined") {
+ define = function (id, factory) {
+ if (modules[id]) {
+ throw "module " + id + " already defined";
+ }
+
+ modules[id] = {
+ id: id,
+ factory: factory
+ };
+ };
+
+ define.remove = function (id) {
+ delete modules[id];
+ };
+ }
})();
@@ -4406,10 +4408,9 @@ module.exports = _self;
});
-window.cordova = require('cordova');
-
// file: lib/scripts/bootstrap.js
-(function (context) {
+define("cordova/_bootstrap", function (require, exports, module) {
+//(function (context) {
var channel = require("cordova/channel"),
_self = {
boot: function () {
@@ -4473,8 +4474,14 @@ window.cordova = require('cordova');
if (window._nativeReady) {
channel.onNativeReady.fire();
}
+});
-}(window));
-
-
-})();
+if (define.amd) {
+ require(["cordova", "cordova/_bootstrap"], function (cordova) {
+ window.cordova = cordova;
+ });
+}
+else {
+ window.cordova = require("cordova");
+ require("cordova/bootstrap");
+}

0 comments on commit 74fd062

Please sign in to comment.