Commits

Matthew Schinckel committed e54323b

Use UMD definition.

  • Participants
  • Parent commits 5e6a952

Comments (0)

Files changed (2)

contrib/knockout.garmin.js

-define(['knockout', 'garmin'], function(ko, Garmin) {
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        // AMD. Register as an anonymous module.
+        define(['knockout', 'garmin'], function (ko, Garmin) {
+            // Also create a global in case some scripts
+            // that are loaded still are looking for
+            // a global even when an AMD loader is in use.
+            return (root.GarminViewModel = factory(ko, Garmin));
+        });
+    } else {
+        // Browser globals
+        root.Garmin = factory(root.ko, root.Garmin);
+    }
+}(this, function (ko, Garmin) {
+  
   var GarminViewModel = function GarminViewModel(options) {
     var plugin = new Garmin.Communicator(options);
     var devices = ko.observableArray([]);
   };
   
   return GarminViewModel;
-});
+}));
 // Look in {{{contrib/knockout.garmin.js}}} for an example/base ViewModel
 // for use in KnockoutJS.
 
-define(['jquery', 'underscore'], function($, _){
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        // AMD. Register as an anonymous module.
+        define(['jquery', 'underscore'], function ($, _) {
+            // Also create a global in case some scripts
+            // that are loaded still are looking for
+            // a global even when an AMD loader is in use.
+            return (root.Garmin = factory($, _));
+        });
+    } else {
+        // Browser globals
+        root.Garmin = factory(root.$, root._);
+    }
+}(this, function ($, _) {
 
   var Garmin = {};
   
   };
   
   return Garmin;
-});
+
+}));