Skip to content

Commit 589d7fd

Browse files
committedJun 25, 2014
feat: make gridster AMD compatible
1 parent 5c6d25c commit 589d7fd

5 files changed

+61
-12
lines changed
 

‎src/jquery.collision.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
* Licensed under the MIT licenses.
77
*/
88

9-
;(function($, window, document, undefined){
9+
;(function(root, factory) {
10+
11+
if (typeof define === 'function' && define.amd) {
12+
define('gridster-collision', ['jquery', 'gridster-coords'], factory);
13+
} else {
14+
root.GridsterCollision = factory(root.$ || root.jQuery,
15+
root.GridsterCoords);
16+
}
17+
18+
}(this, function($, Coords) {
1019

1120
var defaults = {
1221
colliders_context: document.body,
@@ -227,5 +236,6 @@
227236
return new Collision( this, collider, options );
228237
};
229238

239+
return Collision;
230240

231-
}(jQuery, window, document));
241+
}));

‎src/jquery.coords.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
* Licensed under the MIT licenses.
77
*/
88

9-
;(function($, window, document, undefined){
9+
;(function(root, factory) {
10+
11+
if (typeof define === 'function' && define.amd) {
12+
define('gridster-coords', ['jquery'], factory);
13+
} else {
14+
root.GridsterCoords = factory(root.$ || root.jQuery);
15+
}
16+
17+
}(this, function($) {
1018
/**
1119
* Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height)
1220
* to simulate DOM elements on the screen.
@@ -112,4 +120,6 @@
112120
return ins;
113121
};
114122

115-
}(jQuery, window, document));
123+
return Coords;
124+
125+
}));

‎src/jquery.draggable.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
* Licensed under the MIT licenses.
77
*/
88

9-
;(function($, window, document, undefined) {
9+
;(function(root, factory) {
10+
11+
if (typeof define === 'function' && define.amd) {
12+
define('gridster-draggable', ['jquery'], factory);
13+
} else {
14+
root.GridsterDraggable = factory(root.$ || root.jQuery);
15+
}
16+
17+
}(this, function($) {
1018

1119
var defaults = {
1220
items: 'li',
@@ -402,5 +410,6 @@
402410
return new Draggable(this, options);
403411
};
404412

413+
return Draggable;
405414

406-
}(jQuery, window, document));
415+
}));

‎src/jquery.gridster.extras.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
;(function($, window, document, undefined) {
1+
;(function(root, factory) {
22

3-
var fn = $.Gridster;
3+
if (typeof define === 'function' && define.amd) {
4+
define(['jquery', 'gridster'], factory);
5+
} else {
6+
root.Gridster = factory(root.$ || root.jQuery, root.Gridster);
7+
}
8+
9+
}(this, function($, Gridster) {
10+
11+
var fn = Gridster.prototype;
412

513
fn.widgets_in_col = function(col) {
614
if (!this.gridmap[col]) {
@@ -162,4 +170,6 @@
162170
return false;
163171
};
164172

165-
}(jQuery, window, document));
173+
return Gridster;
174+
175+
}));

‎src/jquery.gridster.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
* Copyright (c) 2012 ducksboard
66
* Licensed under the MIT licenses.
77
*/
8-
;(function($, window, document, undefined) {
8+
9+
;(function(root, factory) {
10+
11+
if (typeof define === 'function' && define.amd) {
12+
define(['jquery', 'gridster-draggable', 'gridster-collision'], factory);
13+
} else {
14+
root.Gridster = factory(root.$ || root.jQuery, root.GridsterDraggable,
15+
root.GridsterCollision);
16+
}
17+
18+
}(this, function($, Draggable, Collision) {
919

1020
var defaults = {
1121
namespace: '',
@@ -3111,6 +3121,6 @@
31113121
});
31123122
};
31133123

3114-
$.Gridster = fn;
3124+
return Gridster;
31153125

3116-
}(jQuery, window, document));
3126+
}));

0 commit comments

Comments
 (0)
Please sign in to comment.