diff --git a/src/jquery.collision.js b/src/jquery.collision.js index 6cf304462..881af220d 100644 --- a/src/jquery.collision.js +++ b/src/jquery.collision.js @@ -6,7 +6,16 @@ * Licensed under the MIT licenses. */ -;(function($, window, document, undefined){ +;(function(root, factory) { + + if (typeof define === 'function' && define.amd) { + define('gridster-collision', ['jquery', 'gridster-coords'], factory); + } else { + root.GridsterCollision = factory(root.$ || root.jQuery, + root.GridsterCoords); + } + +}(this, function($, Coords) { var defaults = { colliders_context: document.body, @@ -227,5 +236,6 @@ return new Collision( this, collider, options ); }; + return Collision; -}(jQuery, window, document)); +})); diff --git a/src/jquery.coords.js b/src/jquery.coords.js index bf221804d..821b67c8b 100644 --- a/src/jquery.coords.js +++ b/src/jquery.coords.js @@ -6,7 +6,15 @@ * Licensed under the MIT licenses. */ -;(function($, window, document, undefined){ +;(function(root, factory) { + + if (typeof define === 'function' && define.amd) { + define('gridster-coords', ['jquery'], factory); + } else { + root.GridsterCoords = factory(root.$ || root.jQuery); + } + +}(this, function($) { /** * Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height) * to simulate DOM elements on the screen. @@ -112,4 +120,6 @@ return ins; }; -}(jQuery, window, document)); + return Coords; + +})); diff --git a/src/jquery.draggable.js b/src/jquery.draggable.js index a03d4eae5..030404c4c 100644 --- a/src/jquery.draggable.js +++ b/src/jquery.draggable.js @@ -6,7 +6,15 @@ * Licensed under the MIT licenses. */ -;(function($, window, document, undefined) { +;(function(root, factory) { + + if (typeof define === 'function' && define.amd) { + define('gridster-draggable', ['jquery'], factory); + } else { + root.GridsterDraggable = factory(root.$ || root.jQuery); + } + +}(this, function($) { var defaults = { items: 'li', @@ -402,5 +410,6 @@ return new Draggable(this, options); }; + return Draggable; -}(jQuery, window, document)); +})); diff --git a/src/jquery.gridster.extras.js b/src/jquery.gridster.extras.js index 6b3c347b2..e7ea59f8b 100644 --- a/src/jquery.gridster.extras.js +++ b/src/jquery.gridster.extras.js @@ -1,6 +1,14 @@ -;(function($, window, document, undefined) { +;(function(root, factory) { - var fn = $.Gridster; + if (typeof define === 'function' && define.amd) { + define(['jquery', 'gridster'], factory); + } else { + root.Gridster = factory(root.$ || root.jQuery, root.Gridster); + } + +}(this, function($, Gridster) { + + var fn = Gridster.prototype; fn.widgets_in_col = function(col) { if (!this.gridmap[col]) { @@ -162,4 +170,6 @@ return false; }; -}(jQuery, window, document)); + return Gridster; + +})); diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js index 61cf35120..c70f50d20 100755 --- a/src/jquery.gridster.js +++ b/src/jquery.gridster.js @@ -5,7 +5,17 @@ * Copyright (c) 2012 ducksboard * Licensed under the MIT licenses. */ -;(function($, window, document, undefined) { + +;(function(root, factory) { + + if (typeof define === 'function' && define.amd) { + define(['jquery', 'gridster-draggable', 'gridster-collision'], factory); + } else { + root.Gridster = factory(root.$ || root.jQuery, root.GridsterDraggable, + root.GridsterCollision); + } + + }(this, function($, Draggable, Collision) { var defaults = { namespace: '', @@ -3111,6 +3121,6 @@ }); }; - $.Gridster = fn; + return Gridster; -}(jQuery, window, document)); +}));