Skip to content

Commit

Permalink
suuport for AMD and CommonJS
Browse files Browse the repository at this point in the history
  • Loading branch information
etaypere committed Jul 6, 2013
1 parent 980a7cc commit c70900f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions dist/witch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/* rivets adapter and config */
/* witch */
(function($, rivets, WatchJS) {
(function (factory) {
// CommonJS
if (typeof exports === 'object')
module.exports = factory(require('jquery'), require('rivets'), require('WatchJS'));

// AMD
else if (typeof define === 'function' && define.amd)
define(['jquery', 'rivets', 'WatchJS'], factory);

// Browser globals
else
window.witch = factory($ || jQuery, rivets, WatchJS);

})(function($, rivets, WatchJS) {
if (!$)
return console.error('Witch: where is jQuery?');
if (!rivets)
Expand Down Expand Up @@ -211,7 +224,7 @@
};


window.witch = {
var witch = {
Model: Model,
Collection: Collection,
Template: Template,
Expand Down Expand Up @@ -251,4 +264,6 @@
witch.init();
});

})($ || jQuery, rivets, WatchJS);
return witch;

});

0 comments on commit c70900f

Please sign in to comment.