Skip to content

Commit

Permalink
feat: make gridster AMD compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
vieron committed Jun 25, 2014
1 parent 5c6d25c commit 589d7fd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/jquery.collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -227,5 +236,6 @@
return new Collision( this, collider, options );
};

return Collision;

}(jQuery, window, document));
}));
14 changes: 12 additions & 2 deletions src/jquery.coords.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -112,4 +120,6 @@
return ins;
};

}(jQuery, window, document));
return Coords;

}));
13 changes: 11 additions & 2 deletions src/jquery.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -402,5 +410,6 @@
return new Draggable(this, options);
};

return Draggable;

}(jQuery, window, document));
}));
16 changes: 13 additions & 3 deletions src/jquery.gridster.extras.js
Original file line number Diff line number Diff line change
@@ -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]) {
Expand Down Expand Up @@ -162,4 +170,6 @@
return false;
};

}(jQuery, window, document));
return Gridster;

}));
16 changes: 13 additions & 3 deletions src/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -3111,6 +3121,6 @@
});
};

$.Gridster = fn;
return Gridster;

}(jQuery, window, document));
}));

0 comments on commit 589d7fd

Please sign in to comment.