+
enable
+
+
+
()
+
+
+
+
+ Class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Returns:
@@ -1975,7 +2140,7 @@ into account the dimensions (
size_y
and
size_x
attrs.
-
src/jquery.gridster.js:1671
+
src/jquery.gridster.js:1730
@@ -2103,7 +2268,7 @@ each one.
-
src/jquery.gridster.js:1692
+
src/jquery.gridster.js:1751
@@ -2231,7 +2396,7 @@ each one.
-
src/jquery.gridster.js:1711
+
src/jquery.gridster.js:1770
@@ -2364,7 +2529,7 @@ each one.
-
src/jquery.gridster.js:1777
+
src/jquery.gridster.js:1836
@@ -2511,7 +2676,7 @@ iteration. The value of
this
inside the function is the jQuery wrap
-
src/jquery.gridster.js:1793
+
src/jquery.gridster.js:1852
@@ -2652,7 +2817,7 @@ iteration. The value of
this
inside the function is the jQuery wrap
-
src/jquery.gridster.js:1922
+
src/jquery.gridster.js:2027
@@ -2762,7 +2927,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1996
+
src/jquery.gridster.js:2101
@@ -2850,7 +3015,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1855
+
src/jquery.gridster.js:1941
@@ -2969,7 +3134,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1643
+
src/jquery.gridster.js:1702
@@ -3063,7 +3228,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1809
+
src/jquery.gridster.js:1868
@@ -3144,7 +3309,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1608
+
src/jquery.gridster.js:1667
@@ -3249,7 +3414,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1626
+
src/jquery.gridster.js:1685
@@ -3366,7 +3531,7 @@ detect row or column that we want to go.
-
src/jquery.gridster.js:1095
+
src/jquery.gridster.js:1148
@@ -3494,7 +3659,7 @@ theupper
rowsarray. Iteration starts from row specified in
src/jquery.gridster.js:1982
+ src/jquery.gridster.js:2087
@@ -3565,7 +3730,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:1173
+ src/jquery.gridster.js:1226
@@ -3636,7 +3801,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:931
+ src/jquery.gridster.js:975
@@ -3723,7 +3888,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:850
+ src/jquery.gridster.js:894
@@ -3848,7 +4013,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:869
+ src/jquery.gridster.js:913
@@ -3973,7 +4138,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:823
+ src/jquery.gridster.js:867
@@ -4092,7 +4257,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:837
+ src/jquery.gridster.js:881
@@ -4202,7 +4367,7 @@ theupperrowsarray. Iteration starts from row specified in
src/jquery.gridster.js:791
+ src/jquery.gridster.js:835
@@ -4330,7 +4495,7 @@ HTMLElements.
- src/jquery.gridster.js:808
+ src/jquery.gridster.js:852
@@ -4456,7 +4621,7 @@ and col given.
- src/jquery.gridster.js:889
+ src/jquery.gridster.js:933
@@ -4582,7 +4747,7 @@ else returns the jQuery HTMLElement
- src/jquery.gridster.js:914
+ src/jquery.gridster.js:958
@@ -4714,7 +4879,7 @@ params and if this is under the widget that is being dragged.
- src/jquery.gridster.js:745
+ src/jquery.gridster.js:789
@@ -4856,7 +5021,7 @@ each widget) in descending way.
- src/jquery.gridster.js:1357
+ src/jquery.gridster.js:1410
@@ -4975,7 +5140,7 @@ each widget) in descending way.
- src/jquery.gridster.js:1268
+ src/jquery.gridster.js:1321
@@ -5087,7 +5252,7 @@ if they can.
- src/jquery.gridster.js:1311
+ src/jquery.gridster.js:1364
@@ -5213,7 +5378,7 @@ if they can.
- src/jquery.gridster.js:173
+ src/jquery.gridster.js:159
@@ -5335,7 +5500,7 @@ if they can.
- src/jquery.gridster.js:444
+ src/jquery.gridster.js:452
@@ -5448,7 +5613,7 @@ if they can.
- src/jquery.gridster.js:521
+ src/jquery.gridster.js:545
@@ -5576,7 +5741,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:561
+ src/jquery.gridster.js:585
@@ -5700,7 +5865,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:395
+ src/jquery.gridster.js:400
@@ -5807,7 +5972,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:1206
+ src/jquery.gridster.js:1259
@@ -5911,7 +6076,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:1218
+ src/jquery.gridster.js:1271
@@ -6017,7 +6182,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:470
+ src/jquery.gridster.js:489
@@ -6124,7 +6289,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:1230
+ src/jquery.gridster.js:1283
@@ -6228,7 +6393,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:1248
+ src/jquery.gridster.js:1301
@@ -6322,7 +6487,7 @@ overlapped or stops being overlapped.
- src/jquery.gridster.js:1958
+ src/jquery.gridster.js:2063
@@ -6394,7 +6559,7 @@ the browser is resized.
- src/jquery.gridster.js:277
+ src/jquery.gridster.js:265
@@ -6476,7 +6641,7 @@ mapped array of positions.
- src/jquery.gridster.js:326
+ src/jquery.gridster.js:329
@@ -6581,7 +6746,7 @@ mapped array of positions.
- src/jquery.gridster.js:217
+ src/jquery.gridster.js:201
@@ -6685,7 +6850,7 @@ mapped array of positions.
- src/jquery.gridster.js:243
+ src/jquery.gridster.js:231
@@ -6783,7 +6948,7 @@ mapped array of positions.
- src/jquery.gridster.js:265
+ src/jquery.gridster.js:253
@@ -6871,7 +7036,7 @@ mapped array of positions.
- src/jquery.gridster.js:1520
+ src/jquery.gridster.js:1573
@@ -6980,7 +7145,7 @@ mapped array of positions.
- src/jquery.gridster.js:1841
+ src/jquery.gridster.js:1927
@@ -7067,7 +7232,7 @@ mapped array of positions.
- src/jquery.gridster.js:953
+ src/jquery.gridster.js:997
@@ -7194,7 +7359,7 @@ mapped array of positions.
- src/jquery.gridster.js:597
+ src/jquery.gridster.js:621
@@ -7315,7 +7480,7 @@ mapped array of positions.
- src/jquery.gridster.js:686
+ src/jquery.gridster.js:710
@@ -7420,7 +7585,7 @@ each widget) in ascending way.
- src/jquery.gridster.js:706
+ src/jquery.gridster.js:750
@@ -7476,6 +7641,111 @@ coords of each widget) in ascending way.
+
+
+
+
+
sort_by_row_asc
+
+
+
+
+
+
+
+ Array
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Sorts an Array of grid coords objects (representing the grid coords of
+each widget) placing first the empty cells upper left.
+
+
+
+
+
Parameters:
+
+
+
+
+
+ widgets
+ Array
+
+
+
+
+
+
Array of grid coords objects
+
+
+
+
+
+
+
+
+
+
+
+
Returns:
+
+
+
+
+ Array :
+
+ Returns the array sorted.
+
+
+
+
+
+
@@ -7525,7 +7795,7 @@ coords of each widget) in ascending way.
-
src/jquery.gridster.js:726
+
src/jquery.gridster.js:770
@@ -7636,7 +7906,7 @@ each widget) in descending way.
-
src/jquery.gridster.js:305
+
src/jquery.gridster.js:308
@@ -7759,7 +8029,7 @@ the grid coords object passed in the
grid_data
param.
-
src/jquery.gridster.js:1491
+
src/jquery.gridster.js:1544
@@ -7863,7 +8133,7 @@ the grid coords object passed in the
grid_data
param.
-
src/jquery.gridster.js:650
+
src/jquery.gridster.js:674
diff --git a/docs/data.json b/docs/data.json
index 45ae5c0f72..63b56646c8 100644
--- a/docs/data.json
+++ b/docs/data.json
@@ -19,6 +19,15 @@
"fors": {},
"namespaces": {}
},
+ "src/jquery.draggable.js": {
+ "name": "src/jquery.draggable.js",
+ "modules": {},
+ "classes": {
+ "Draggable": 1
+ },
+ "fors": {},
+ "namespaces": {}
+ },
"src/jquery.gridster.js": {
"name": "src/jquery.gridster.js",
"modules": {},
@@ -104,7 +113,7 @@
],
"file": "src/jquery.coords.js",
"line": 10,
- "description": "Coords description",
+ "description": "Coords",
"params": [
{
"name": "obj",
@@ -114,6 +123,19 @@
],
"is_constructor": 1
},
+ "Draggable": {
+ "name": "Draggable",
+ "shortname": "Draggable",
+ "classitems": [],
+ "plugins": [],
+ "extensions": [],
+ "plugin_for": [],
+ "extension_for": [],
+ "file": "src/jquery.draggable.js",
+ "line": 24,
+ "description": "Draggable",
+ "is_constructor": 1
+ },
"Gridster": {
"name": "Gridster",
"shortname": "Gridster",
@@ -123,7 +145,7 @@
"plugin_for": [],
"extension_for": [],
"file": "src/jquery.gridster.js",
- "line": 70,
+ "line": 33,
"uses": [
"Coords",
"Collision"
@@ -215,7 +237,31 @@
"classitems": [
{
"file": "src/jquery.gridster.js",
- "line": 140,
+ "line": 105,
+ "description": "Disable dragging.",
+ "itemtype": "method",
+ "name": "enable",
+ "return": {
+ "description": "Returns the instance of the Gridster Class.",
+ "type": "Class"
+ },
+ "class": "Gridster"
+ },
+ {
+ "file": "src/jquery.gridster.js",
+ "line": 117,
+ "description": "Enable dragging.",
+ "itemtype": "method",
+ "name": "enable",
+ "return": {
+ "description": "Returns the instance of the Gridster Class.",
+ "type": "Class"
+ },
+ "class": "Gridster"
+ },
+ {
+ "file": "src/jquery.gridster.js",
+ "line": 129,
"description": "Add a new widget to the grid.",
"itemtype": "method",
"name": "add_widget",
@@ -237,14 +283,14 @@
}
],
"return": {
- "description": "Returns the jQuery wrapped HTMLElement representing\n the widget that was just created.",
+ "description": "Returns the jQuery wrapped HTMLElement representing.\n the widget that was just created.",
"type": "HTMLElement"
},
"class": "Gridster"
},
{
"file": "src/jquery.gridster.js",
- "line": 173,
+ "line": 159,
"description": "Get the most left column below to add a new widget.",
"itemtype": "method",
"name": "next_position",
@@ -268,7 +314,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 217,
+ "line": 201,
"description": "Remove a widget from the grid.",
"itemtype": "method",
"name": "remove_widget",
@@ -287,7 +333,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 243,
+ "line": 231,
"description": "Returns a serialized array of the widgets in the grid.",
"itemtype": "method",
"name": "serialize",
@@ -307,7 +353,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 265,
+ "line": 253,
"description": "Returns a serialized array of the widgets that have changed their position.",
"itemtype": "method",
"name": "serialize_changed",
@@ -319,7 +365,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 277,
+ "line": 265,
"description": "Creates the grid coords object representing the widget a add it to the\nmapped array of positions.",
"itemtype": "method",
"name": "register_widget",
@@ -331,7 +377,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 305,
+ "line": 308,
"description": "Update in the mapped array of positions the value of cells represented by\nthe grid coords object passed in the `grid_data` param.",
"params": [
{
@@ -355,7 +401,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 326,
+ "line": 329,
"description": "Remove a widget from the mapped array of positions.",
"itemtype": "method",
"name": "remove_from_gridmap",
@@ -374,7 +420,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 339,
+ "line": 342,
"description": "Add a widget to the mapped array of positions.",
"itemtype": "method",
"name": "add_to_gridmap",
@@ -398,7 +444,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 361,
+ "line": 364,
"description": "Make widgets draggable. It Wraps the jQuery UI Draggable Plugin.",
"itemtype": "method",
"name": "draggable",
@@ -410,7 +456,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 395,
+ "line": 400,
"description": "This function is executed when the player begins to be dragged.",
"itemtype": "method",
"name": "on_start_drag",
@@ -430,7 +476,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 444,
+ "line": 452,
"description": "This function is executed when the player is being dragged.",
"itemtype": "method",
"name": "on_drag",
@@ -450,7 +496,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 470,
+ "line": 489,
"description": "This function is executed when the player stops being dragged.",
"itemtype": "method",
"name": "on_stop_drag",
@@ -470,7 +516,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 521,
+ "line": 545,
"description": "Executes the callbacks passed as arguments when a column begins to be\noverlapped or stops being overlapped.",
"params": [
{
@@ -494,7 +540,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 561,
+ "line": 585,
"description": "Executes the callbacks passed as arguments when a row starts to be\noverlapped or stops being overlapped.",
"params": [
{
@@ -518,7 +564,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 597,
+ "line": 621,
"description": "Sets the current position of the player",
"params": [
{
@@ -542,7 +588,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 650,
+ "line": 674,
"description": "See which of the widgets in the $widgets param collection can go to\na upper row and which not.",
"itemtype": "method",
"name": "widgets_contraints",
@@ -561,7 +607,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 686,
+ "line": 710,
"description": "Sorts an Array of grid coords objects (representing the grid coords of\neach widget) in ascending way.",
"itemtype": "method",
"name": "sort_by_row_asc",
@@ -580,7 +626,26 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 706,
+ "line": 730,
+ "description": "Sorts an Array of grid coords objects (representing the grid coords of\neach widget) placing first the empty cells upper left.",
+ "itemtype": "method",
+ "name": "sort_by_row_asc",
+ "params": [
+ {
+ "name": "widgets",
+ "description": "Array of grid coords objects",
+ "type": "Array"
+ }
+ ],
+ "return": {
+ "description": "Returns the array sorted.",
+ "type": "Array"
+ },
+ "class": "Gridster"
+ },
+ {
+ "file": "src/jquery.gridster.js",
+ "line": 750,
"description": "Sorts an Array of grid coords objects by column (representing the grid\ncoords of each widget) in ascending way.",
"itemtype": "method",
"name": "sort_by_row_asc",
@@ -599,7 +664,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 726,
+ "line": 770,
"description": "Sorts an Array of grid coords objects (representing the grid coords of\neach widget) in descending way.",
"itemtype": "method",
"name": "sort_by_row_desc",
@@ -618,7 +683,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 745,
+ "line": 789,
"description": "Sorts an Array of grid coords objects (representing the grid coords of\neach widget) in descending way.",
"itemtype": "method",
"name": "manage_movements",
@@ -647,7 +712,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 791,
+ "line": 835,
"description": "Determines if there is a widget in the row and col given. Or if the\nHTMLElement passed as first argument is the player.",
"itemtype": "method",
"name": "is_player",
@@ -672,7 +737,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 808,
+ "line": 852,
"description": "Determines if the widget that is being dragged is currently over the row\nand col given.",
"itemtype": "method",
"name": "is_player_in",
@@ -696,7 +761,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 823,
+ "line": 867,
"description": "Determines if the placeholder is currently over the row and col given.",
"itemtype": "method",
"name": "is_placeholder_in",
@@ -720,7 +785,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 837,
+ "line": 881,
"description": "Determines if the placeholder is currently over the column given.",
"itemtype": "method",
"name": "is_placeholder_in_col",
@@ -739,7 +804,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 850,
+ "line": 894,
"description": "Determines if the cell represented by col and row params is empty.",
"itemtype": "method",
"name": "is_empty",
@@ -763,7 +828,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 869,
+ "line": 913,
"description": "Determines if the cell represented by col and row params is occupied.",
"itemtype": "method",
"name": "is_occupied",
@@ -787,7 +852,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 889,
+ "line": 933,
"description": "Determines if there is a widget in the cell represented by col/row params.",
"itemtype": "method",
"name": "is_widget",
@@ -811,7 +876,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 914,
+ "line": 958,
"description": "Determines if there is a widget in the cell represented by col/row\nparams and if this is under the widget that is being dragged.",
"itemtype": "method",
"name": "is_widget_under_player",
@@ -835,7 +900,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 931,
+ "line": 975,
"description": "Get widgets overlapping with the player.",
"itemtype": "method",
"name": "get_widgets_under_player",
@@ -847,7 +912,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 953,
+ "line": 997,
"description": "Put placeholder at the row and column specified.",
"itemtype": "method",
"name": "set_placeholder",
@@ -871,7 +936,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 995,
+ "line": 1048,
"description": "Determines whether the player can move to a position above.",
"itemtype": "method",
"name": "can_go_player_up",
@@ -890,7 +955,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1044,
+ "line": 1097,
"description": "Determines whether a widget can move to a position above.",
"itemtype": "method",
"name": "can_go_widget_up",
@@ -909,7 +974,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1095,
+ "line": 1148,
"description": "Search a valid row for the widget represented by `widget_grid_data' in\nthe `upper_rows` array. Iteration starts from row specified in `min_row`.",
"itemtype": "method",
"name": "get_valid_rows",
@@ -938,7 +1003,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1173,
+ "line": 1226,
"description": "Get widgets overlapping with the player.",
"itemtype": "method",
"name": "get_widgets_overlapped",
@@ -950,7 +1015,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1206,
+ "line": 1259,
"description": "This callback is executed when the player begins to collide with a column.",
"itemtype": "method",
"name": "on_start_overlapping_column",
@@ -969,7 +1034,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1218,
+ "line": 1271,
"description": "A callback executed when the player begins to collide with a row.",
"itemtype": "method",
"name": "on_start_overlapping_row",
@@ -988,7 +1053,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1230,
+ "line": 1283,
"description": "A callback executed when the the player ends to collide with a column.",
"itemtype": "method",
"name": "on_stop_overlapping_column",
@@ -1007,7 +1072,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1248,
+ "line": 1301,
"description": "This callback is executed when the player ends to collide with a row.",
"itemtype": "method",
"name": "on_stop_overlapping_row",
@@ -1026,7 +1091,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1268,
+ "line": 1321,
"description": "Move a widget to a specific row. The cell or cells must be empty.\nIf the widget has widgets below, all of these widgets will be moved also\nif they can.",
"itemtype": "method",
"name": "move_widget_to",
@@ -1045,7 +1110,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1311,
+ "line": 1364,
"description": "Move up the specified widget and all below it.",
"itemtype": "method",
"name": "move_widget_up",
@@ -1070,7 +1135,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1357,
+ "line": 1410,
"description": "Move down the specified widget and all below it.",
"itemtype": "method",
"name": "move_widget_down",
@@ -1094,7 +1159,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1402,
+ "line": 1455,
"description": "Check if the widget can move to the specified row, else returns the\nupper row possible.",
"itemtype": "method",
"name": "can_go_up_to_row",
@@ -1123,7 +1188,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1491,
+ "line": 1544,
"description": "Get widgets below a widget.",
"itemtype": "method",
"name": "widgets_below",
@@ -1142,7 +1207,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1520,
+ "line": 1573,
"description": "Update the array of mapped positions with the new player position.",
"itemtype": "method",
"name": "set_cells_player_occupies",
@@ -1166,7 +1231,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1537,
+ "line": 1590,
"description": "Remove from the array of mapped positions the reference to the player.",
"itemtype": "method",
"name": "empty_cells_player_occupies",
@@ -1178,7 +1243,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1574,
+ "line": 1627,
"description": "Check if it's possible to move a widget to a specific col/row. It takes\ninto account the dimensions (`size_y` and `size_x` attrs. of the grid coords\n object) the widget occupies.",
"itemtype": "method",
"name": "can_move_to",
@@ -1207,7 +1272,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1608,
+ "line": 1667,
"description": "Given the leftmost column returns all columns that are overlapping with the player.",
"itemtype": "method",
"name": "get_targeted_columns",
@@ -1227,7 +1292,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1626,
+ "line": 1685,
"description": "Given the upper row returns all rows that are overlapping with the player.",
"itemtype": "method",
"name": "get_targeted_rows",
@@ -1247,7 +1312,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1643,
+ "line": 1702,
"description": "Get all columns and rows that a widget occupies.",
"itemtype": "method",
"name": "get_cells_occupied",
@@ -1266,7 +1331,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1671,
+ "line": 1730,
"description": "Iterate over the cells occupied by a widget executing a function for\neach one.",
"itemtype": "method",
"name": "for_each_cell_occupied",
@@ -1290,7 +1355,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1692,
+ "line": 1751,
"description": "Iterate over the columns occupied by a widget executing a function for\neach one.",
"itemtype": "method",
"name": "for_each_column_occupied",
@@ -1314,7 +1379,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1711,
+ "line": 1770,
"description": "Iterate over the rows occupied by a widget executing a function for\neach one.",
"itemtype": "method",
"name": "for_each_row_occupied",
@@ -1338,7 +1403,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1777,
+ "line": 1836,
"description": "Iterate over each widget above the column and row specified.",
"itemtype": "method",
"name": "for_each_widget_above",
@@ -1367,7 +1432,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1793,
+ "line": 1852,
"description": "Iterate over each widget below the column and row specified.",
"itemtype": "method",
"name": "for_each_widget_below",
@@ -1396,7 +1461,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1809,
+ "line": 1868,
"description": "Returns the highest occupied cell in the grid.",
"itemtype": "method",
"name": "get_highest_occupied_cell",
@@ -1408,7 +1473,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1841,
+ "line": 1927,
"description": "Set the current height of the parent grid.",
"itemtype": "method",
"name": "set_dom_grid_height",
@@ -1420,7 +1485,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1855,
+ "line": 1941,
"description": "It generates the neccessary styles to position the widgets.",
"itemtype": "method",
"name": "generate_stylesheet",
@@ -1444,7 +1509,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1899,
+ "line": 2004,
"description": "Injects the given CSS as string to the head of the document.",
"itemtype": "method",
"name": "add_style_tag",
@@ -1463,7 +1528,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1922,
+ "line": 2027,
"description": "Generates a faux grid to collide with it when a widget is dragged and\ndetect row or column that we want to go.",
"itemtype": "method",
"name": "generate_faux_grid",
@@ -1487,7 +1552,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1958,
+ "line": 2063,
"description": "Recalculates the offsets for the faux grid. You need to use it when\nthe browser is resized.",
"itemtype": "method",
"name": "recalculate_faux_grid",
@@ -1499,7 +1564,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1982,
+ "line": 2087,
"description": "Get all widgets in the DOM and register them.",
"itemtype": "method",
"name": "get_widgets_from_DOM",
@@ -1511,7 +1576,7 @@
},
{
"file": "src/jquery.gridster.js",
- "line": 1996,
+ "line": 2101,
"description": "Calculate columns and rows to be set based on the configuration\n parameters, grid dimensions, etc ...",
"itemtype": "method",
"name": "generate_grid_and_stylesheet",
diff --git a/docs/files/src_jquery.collision.js.html b/docs/files/src_jquery.collision.js.html
index 18bf3441af..0d078d2bd7 100644
--- a/docs/files/src_jquery.collision.js.html
+++ b/docs/files/src_jquery.collision.js.html
@@ -46,6 +46,8 @@
Coords
+
Draggable
+
Gridster
@@ -211,18 +213,18 @@
}
};
- fn.find_collisions = function(){
+ fn.find_collisions = function(player_data_coords){
var self = this;
var colliders_coords = [];
var colliders_data = [];
var $colliders = (this.colliders || this.$colliders);
var count = $colliders.length;
+ var player_coords = self.$element.coords().update(player_data_coords || false).get();
while(count--){
var $collider = self.$colliders ? $($colliders[count]) : $colliders[count];
- var player_coords = self.$element.coords().update().get();
var $collider_coords_ins = ($collider.isCoords) ?
- $collider.update() : $collider.coords();
+ $collider : $collider.coords();
var collider_coords = $collider_coords_ins.get();
var overlaps = self.overlaps(player_coords, collider_coords);
@@ -262,8 +264,8 @@
};
- fn.get_closest_colliders = function(){
- var colliders = this.find_collisions();
+ fn.get_closest_colliders = function(player_data_coords){
+ var colliders = this.find_collisions(player_data_coords);
var min_area = 100;
colliders.sort(function(a, b){
diff --git a/docs/files/src_jquery.coords.js.html b/docs/files/src_jquery.coords.js.html
index 0b0b63e7bc..ef5dd34b99 100644
--- a/docs/files/src_jquery.coords.js.html
+++ b/docs/files/src_jquery.coords.js.html
@@ -46,6 +46,8 @@
Coords
+
Draggable
+
Gridster
@@ -101,7 +103,7 @@
;(function($, window, document, undefined){
/**
- * Coords description
+ * Coords
*
* @class Coords
* @param {HTMLElement|Object} obj HTMLElement or a literal Object with the left, top, width and height properties.
@@ -127,12 +129,20 @@
this.original_coords = this.get();
};
- fn.set = function() {
+
+ fn.set = function(update, not_update_offsets) {
var el = this.el;
- if (el) {
- this.data = el.offset();
- this.data.width || (this.data.width = el.width());
- this.data.height || (this.data.height = el.height());
+
+ if (el && !update) {
+ this.data = {} || el.offset();
+ this.data.width = el.width();
+ this.data.height = el.height();
+ };
+
+ if (el && update && !not_update_offsets) {
+ var offset = el.offset();
+ this.data.top = offset.top;
+ this.data.left = offset.left;
}
var d = this.data;
@@ -150,19 +160,23 @@
return this;
};
+
fn.update = function(data){
if (!data && !this.el) {
return this;
}
if (data) {
- var new_data = $.extend(this.data, data);
+ var new_data = $.extend({}, this.data, data);
this.data = new_data;
+ return this.set(true, true);
}
- this.set();
+
+ this.set(true);
return this;
};
+
fn.get = function(){
return this.coords;
};
diff --git a/docs/files/src_jquery.draggable.js.html b/docs/files/src_jquery.draggable.js.html
new file mode 100644
index 0000000000..01b39af04c
--- /dev/null
+++ b/docs/files/src_jquery.draggable.js.html
@@ -0,0 +1,338 @@
+
+
+
+
+
src/jquery.draggable.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Show:
+
+
+ Inherited
+
+
+
+
+ Protected
+
+
+
+
+ Private
+
+
+
+ Deprecated
+
+
+
+
+
+
+
+
+
File: src/jquery.draggable.js
+
+
+
+/*
+ * jquery.draggable
+ * https://github.com/ducksboard/gridster.js
+ *
+ * Copyright (c) 2012 ducksboard
+ * Licensed under the MIT, GPL licenses.
+ */
+
+;(function($, window, document, undefined){
+
+ var defaults = {
+ items: '.gs_w',
+ distance: 1,
+ limit: true,
+ offset_left: 0,
+ drag: function(e){},
+ start : function(e, ui){},
+ stop : function(e){}
+ };
+
+ var $body = $(document.body);
+
+
+ /**
+ * Draggable
+ *
+ * @class Draggable
+ * @constructor
+ */
+ function Draggable(element, options) {
+ this.options = $.extend(defaults, options);
+ this.$container = $(element);
+ this.$dragitems = $(this.options.items, this.$container);
+ this.is_dragging = false;
+ this.player_min_left = 0 + this.options.offset_left;
+
+ this.init();
+ };
+
+ var fn = Draggable.prototype;
+
+ fn.init = function() {
+ this.$container.css('position', 'relative');
+ this.enable();
+ };
+
+ fn.get_actual_pos = function($el) {
+ var pos = $el.position();
+ return pos;
+ };
+
+
+ fn.get_mouse_pos = function(e) {
+ return {
+ left: e.clientX,
+ top: e.clientY
+ };
+ };
+
+
+ fn.drag_handler = function(e) {
+ var self = this;
+ var first = true;
+ this.$player = $(e.currentTarget);
+
+ this.el_init_pos = this.get_actual_pos(this.$player);
+ this.mouse_init_pos = this.get_mouse_pos(e);
+
+ $body.on('mousemove.draggable', function(mme){
+ var mouse_actual_pos = self.get_mouse_pos(mme);
+ var diff_x = Math.abs(mouse_actual_pos.left - self.mouse_init_pos.left);
+ var diff_y = Math.abs(mouse_actual_pos.top - self.mouse_init_pos.top);
+ if (!(diff_x > self.options.distance || diff_y > self.options.distance)) {
+ return false;
+ }
+
+ if (first) {
+ first = false;
+ self.on_dragstart.call(self, mme);
+ return false;
+ }
+
+ if (self.is_dragging == true) {
+ throttle(self.on_dragmove.call(self, mme), 130);
+ };
+
+ return false;
+
+ });
+
+ return false;
+ };
+
+
+ fn.on_dragstart = function(e) {
+ e.preventDefault();
+ this.drag_start = true;
+ this.is_dragging = true;
+ this.$container_offset = this.$container.offset();
+ if (this.options.helper === 'clone') {
+ this.$helper = this.$player.clone().appendTo(this.$container).addClass('helper');
+ this.helper = true;
+ }else{
+ this.helper = false;
+ }
+ this.el_init_offset = this.$player.offset();
+ this.player_width = this.$player.width();
+ this.player_max_left = this.$container.width() - this.player_width + this.options.offset_left;
+ if (this.options.start) {
+ this.options.start.call(this.$player, e, {
+ helper: this.helper ? this.$helper : this.$player
+ });
+ };
+ return false;
+ };
+
+
+ fn.get_offset = function(e) {
+ e.preventDefault();
+ var mouse_actual_pos = this.get_mouse_pos(e);
+ var diff_x = mouse_actual_pos.left - this.mouse_init_pos.left;
+ var diff_y = mouse_actual_pos.top - this.mouse_init_pos.top;
+
+ var left = this.el_init_offset.left + diff_x - this.$container_offset.left;
+ var top = this.el_init_offset.top + diff_y - this.$container_offset.top;
+
+ if (this.options.limit) {
+ if (left > this.player_max_left) {
+ left = this.player_max_left;
+ }else if(left < this.player_min_left) {
+ left = this.player_min_left;
+ }
+ };
+
+ return {
+ left: left,
+ top: top
+ }
+ };
+
+
+ fn.on_dragmove = function(e) {
+ var offset = this.get_offset(e);
+
+ (this.helper ? this.$helper : this.$player).css({
+ 'position': 'absolute',
+ 'left' : offset.left,
+ 'top' : offset.top
+ });
+
+ var ui = {
+ 'position': {
+ 'left': offset.left,
+ 'top': offset.top
+ }
+ };
+
+ if (this.options.drag) {
+ this.options.drag.call(this.$player, e, ui);
+ }
+ return false;
+ };
+
+
+ fn.on_dragstop = function(e) {
+ var offset = this.get_offset(e);
+
+ this.drag_start = false;
+
+ var ui = {
+ 'position': {
+ 'left': offset.left,
+ 'top': offset.top
+ }
+ }
+
+ if (this.options.stop) {
+ this.options.stop.call(this.$player, e, ui);
+ }
+
+ if (this.helper) {
+ this.$helper.remove();
+ }
+
+ return false;
+ };
+
+
+ fn.enable = function(){
+ this.$container.on('mousedown.draggable', this.options.items, $.proxy(this.drag_handler, this));
+ $body.on('mouseup.draggable', $.proxy(function(e) {
+ this.is_dragging = false;
+ $body.off('mousemove.draggable');
+ if (this.drag_start) {
+ this.on_dragstop(e);
+ }
+ }, this));
+ };
+
+
+ fn.disable = function(){
+ this.$container.off('mousedown.draggable');
+ $body.off('mouseup.draggable');
+ };
+
+
+ fn.destroy = function(){
+ this.disable();
+ $.removeData(this.$container, 'draggable');
+ };
+
+
+ //jQuery adapter
+ $.fn.draggable = function ( options ) {
+ return this.each(function () {
+ if (!$.data(this, 'draggable')) {
+ $.data(this, 'draggable', new Draggable( this, options ));
+ }
+ });
+ };
+
+
+}(jQuery, window, document));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/files/src_jquery.gridster.js.html b/docs/files/src_jquery.gridster.js.html
index 4b865c9dcd..4df4a9e481 100644
--- a/docs/files/src_jquery.gridster.js.html
+++ b/docs/files/src_jquery.gridster.js.html
@@ -46,6 +46,8 @@
Coords
+
Draggable
+
Gridster
@@ -109,6 +111,7 @@
min_cols: 1,
min_rows: 10,
autogenerate_stylesheet: true,
+ avoid_overlapped_widgets: true,
serialize_params: function($w, wgd) {
return {
col: wgd.col,
@@ -116,47 +119,9 @@
};
},
collision: {},
- draggable: {}
- };
-
-
- /* Debounce and throttle functions taken from underscore.js */
- var debounce = function(func, wait, immediate) {
- var timeout;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) func.apply(context, args);
- };
- if (immediate && !timeout) func.apply(context, args);
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- };
- };
-
-
- var throttle = function(func, wait) {
- var context, args, timeout, throttling, more, result;
- var whenDone = debounce(
- function(){ more = throttling = false; }, wait, true);
- return function() {
- context = this; args = arguments;
- var later = function() {
- timeout = null;
- if (more) func.apply(context, args);
- whenDone();
- };
- if (!timeout) timeout = setTimeout(later, wait);
- if (throttling) {
- more = true;
- } else {
- result = func.apply(context, args);
- }
- whenDone();
- throttling = true;
- return result;
- };
+ draggable: {
+ distance: 4
+ }
};
@@ -216,6 +181,8 @@
this.init();
}
+ Gridster.generated_stylesheets = [];
+
var fn = Gridster.prototype;
fn.init = function() {
@@ -230,6 +197,30 @@
};
+ /**
+ * Disable dragging.
+ *
+ * @method enable
+ * @return {Class} Returns the instance of the Gridster Class.
+ */
+ fn.disable = function(){
+ this.drag_api.disable();
+ return this;
+ }
+
+
+ /**
+ * Enable dragging.
+ *
+ * @method enable
+ * @return {Class} Returns the instance of the Gridster Class.
+ */
+ fn.enable = function(){
+ this.drag_api.enable();
+ return this;
+ }
+
+
/**
* Add a new widget to the grid.
*
@@ -237,7 +228,7 @@
* @param {String} html The string representing the HTML of the widget.
* @param {Number} size_x The nº of rows the widget occupies horizontally.
* @param {Number} size_y The nº of columns the widget occupies vertically.
- * @return {HTMLElement} Returns the jQuery wrapped HTMLElement representing
+ * @return {HTMLElement} Returns the jQuery wrapped HTMLElement representing.
* the widget that was just created.
*/
fn.add_widget = function(html, size_x, size_y) {
@@ -254,12 +245,9 @@
this.register_widget($w);
- this.$widgets.draggable('destroy');
- this.draggable();
-
this.set_dom_grid_height();
- $w.fadeIn();
+ return $w.fadeIn();
};
@@ -299,9 +287,7 @@
}
if (valid_pos.length) {
- var next_position = this.sort_by_row_desc(valid_pos);
- next_position = this.sort_by_col_asc(next_position)[0];
- return next_position;
+ return this.sort_by_row_and_col_asc(valid_pos)[0];
}
return false;
};
@@ -314,7 +300,7 @@
* @param {HTMLElement} el The jQuery wrapped HTMLElement you want to remove.
* @return {Class} Returns the instance of the Gridster Class.
*/
- fn.remove_widget = function(el) {
+ fn.remove_widget = function(el, callback) {
var $el = el instanceof jQuery ? el : $(el);
var wgd = $el.coords().grid;
@@ -329,6 +315,10 @@
$nexts.each($.proxy(function(i, widget){
this.move_widget_up( $(widget), wgd.size_y );
}, this));
+
+ if (callback) {
+ callback.apply(this, el);
+ };
}, this));
};
@@ -375,7 +365,8 @@
* @return {Array} Returns the instance of the Gridster class.
*/
fn.register_widget = function($el) {
- var widget_grid_data = {
+
+ var wgd = {
'col': parseInt($el.attr('data-col'), 10),
'row': parseInt($el.attr('data-row'), 10),
'size_x': parseInt($el.attr('data-sizex'), 10),
@@ -383,13 +374,27 @@
'el': $el
};
+ if (this.options.avoid_overlapped_widgets &&
+ !this.can_move_to(
+ { size_x: wgd.size_x, size_y: wgd.size_y }, wgd.col, wgd.row)
+ ) {
+ wgd = this.next_position(wgd.size_x, wgd.size_y);
+ wgd.el = $el;
+ $el.attr({
+ 'data-col': wgd.col,
+ 'data-row': wgd.row,
+ 'data-sizex': wgd.size_x,
+ 'data-sizey': wgd.size_y
+ });
+ };
+
// attach Coord object to player data-coord attribute
$el.data('coords', $el.coords());
// Extend Coord object with grid position info
- $el.data('coords').grid = widget_grid_data;
+ $el.data('coords').grid = wgd;
- this.add_to_gridmap(widget_grid_data, $el);
+ this.add_to_gridmap(wgd, $el);
this.widgets.push($el);
return this;
};
@@ -460,28 +465,30 @@
fn.draggable = function() {
var self = this;
var draggable_options = $.extend(true, {}, this.options.draggable, {
- // containment : this.$wrapper,
+ offset_left: this.options.widget_margins[0],
+ items: '.gs_w',
start: function(event, ui) {
+ self.$widgets.filter('.player-revert').removeClass('player-revert');
self.$player = $(this);
self.$helper = self.options.draggable.helper === 'clone' ?
$(ui.helper) : self.$player;
+ self.helper = !self.$helper.is(self.$player);
self.on_start_drag.call(self, event, ui);
self.$el.trigger('gridster:dragstart');
},
stop: function(event, ui) {
- self.on_stop_drag.call(self, ui);
+ self.on_stop_drag.call(self, event, ui);
self.$el.trigger('gridster:dragstop');
},
- drag: throttle(function(event, ui) {
+ drag: function(event, ui) {
self.on_drag.call(self, event, ui);
self.$el.trigger('gridster:drag');
- }, 100, true)
+ }
});
- this.$widgets.draggable(draggable_options);
-
- return this;
+ this.drag_api = this.$el.draggable(draggable_options).data('draggable');
+ return this;
};
@@ -494,8 +501,10 @@
* See http://jqueryui.com/demos/draggable/ for more info.
*/
fn.on_start_drag = function(event, ui) {
+
+ this.$helper.add(this.$player).add(this.$wrapper).addClass('dragging');
+
this.$player.addClass('player');
- this.$wrapper.addClass('dragging');
this.player_grid_data = this.$player.coords().grid;
this.placeholder_grid_data = $.extend({}, this.player_grid_data);
@@ -514,8 +523,9 @@
this.last_cols = [];
this.last_rows = [];
+
// see jquery.collision.js
- this.drag_api = this.$helper.collision(
+ this.collision_api = this.$helper.collision(
colliders, this.options.collision);
this.$preview_holder = $('<li />', {
@@ -543,7 +553,11 @@
* See http://jqueryui.com/demos/draggable/ for more info.
*/
fn.on_drag = function(event, ui) {
- this.colliders_data = this.drag_api.get_closest_colliders();
+ var abs_offset = {
+ left: ui.position.left + this.baseX,
+ top: ui.position.top + this.baseY
+ }
+ this.colliders_data = this.collision_api.get_closest_colliders(abs_offset);
this.on_overlapped_column_change(
this.on_start_overlapping_column,
@@ -555,6 +569,13 @@
this.on_stop_overlapping_row
);
+ if (this.helper && this.$player) {
+ this.$player.css({
+ 'left': ui.position.left,
+ 'top': ui.position.top
+ });
+ }
+
if (this.options.draggable.drag) {
this.options.draggable.drag.call(this, event, ui);
}
@@ -569,7 +590,11 @@
* See http://jqueryui.com/demos/draggable/ for more info.
*/
fn.on_stop_drag = function(event, ui) {
- this.colliders_data = this.drag_api.get_closest_colliders();
+ this.$helper.add(this.$player).add(this.$wrapper).removeClass('dragging');
+
+ ui.position.left = ui.position.left + this.baseX;
+ ui.position.top = ui.position.top + this.baseY;
+ this.colliders_data = this.collision_api.get_closest_colliders(ui.position);
this.on_overlapped_column_change(
this.on_start_overlapping_column,
@@ -581,13 +606,14 @@
this.on_stop_overlapping_row
);
- this.$player.add(this.$helper).attr({
+ this.$player
+ .addClass('player-revert').removeClass('player').attr({
'data-col': this.placeholder_grid_data.col,
'data-row': this.placeholder_grid_data.row
}).css({
'left': '',
'top': ''
- }).removeClass('player');
+ });
this.$changed = this.$changed.add(this.$player);
@@ -796,6 +822,26 @@
};
+ /**
+ * Sorts an Array of grid coords objects (representing the grid coords of
+ * each widget) placing first the empty cells upper left.
+ *
+ * @method sort_by_row_asc
+ * @param {Array} widgets Array of grid coords objects
+ * @return {Array} Returns the array sorted.
+ */
+ fn.sort_by_row_and_col_asc = function(widgets) {
+ widgets = widgets.sort(function(a, b){
+ if (a.row > b.row || a.row == b.row && a.col > b.col) {
+ return 1;
+ }
+ return -1;
+ });
+
+ return widgets;
+ };
+
+
/**
* Sorts an Array of grid coords objects by column (representing the grid
* coords of each widget) in ascending way.
@@ -1061,12 +1107,21 @@
size_y: phgd.size_y,
size_x: phgd.size_x
});
+
+ //Prevents widgets go out of the grid
+ var right_col = (col + phgd.size_x - 1);
+ if (right_col > this.cols) {
+ col = col - (right_col - col);
+ };
+
var moved_down = this.placeholder_grid_data.row < row;
var changed_column = this.placeholder_grid_data.col !== col;
this.placeholder_grid_data.col = col;
this.placeholder_grid_data.row = row;
+
+
this.cells_occupied_by_placeholder = this.get_cells_occupied(
this.placeholder_grid_data);
@@ -1687,6 +1742,12 @@
};
var result = true;
+ //Prevents widgets go out of the grid
+ var right_col = col + widget_grid_data.size_x - 1;
+ if (right_col > this.cols) {
+ return false;
+ };
+
this.for_each_cell_occupied(future_wd, function(tcol, trow){
var $tw = this.is_widget(tcol, trow);
if ($tw && (!widget_grid_data.el || $tw.is($w))) {
@@ -1931,6 +1992,33 @@
};
+
+ fn.get_widgets_from = function(col, row) {
+ var ga = this.gridmap;
+ var $widgets = $();
+
+ if (col) {
+ $widgets = $widgets.add(
+ this.$widgets.filter(function(){
+ var tcol = $(this).attr('data-col');
+ return (tcol == col || tcol > col);
+ })
+ );
+ };
+
+ if (row) {
+ $widgets = $widgets.add(
+ this.$widgets.filter(function(){
+ var trow = $(this).attr('data-row');
+ return (trow == row || trow > row);
+ })
+ );
+ };
+
+ return $widgets;
+ }
+
+
/**
* Set the current height of the parent grid.
*
@@ -1953,7 +2041,7 @@
* @param {Number} cols Number of rows.
* @return {Object} Returns the instance of the Gridster class.
*/
- fn.generate_stylesheet = function(rows, cols) {
+ fn.generate_stylesheet = function(opts) {
var styles = '';
var extra_cells = 10;
var max_size_y = 6;
@@ -1961,28 +2049,47 @@
var i;
var rules;
+ opts || (opts = {});
+ opts.cols || (opts.cols = this.cols);
+ opts.rows || (opts.rows = this.rows);
+ opts.namespace || (opts.namespace = '');
+ opts.widget_base_dimensions || (opts.widget_base_dimensions = this.options.widget_base_dimensions);
+ opts.widget_margins || (opts.widget_margins = this.options.widget_margins);
+
+ opts.min_widget_width = (opts.widget_margins[0] * 2) + opts.widget_base_dimensions[0];
+ opts.min_widget_height = (opts.widget_margins[1] * 2) + opts.widget_base_dimensions[1];
+
+ var serialized_opts = $.param(opts);
+ // don't duplicate stylesheets for the same configuration
+ if ($.inArray(serialized_opts, Gridster.generated_stylesheets) >= 0) {
+ return false;
+ };
+
+ Gridster.generated_stylesheets.push(serialized_opts);
+
/* generate CSS styles for cols */
- for (i = cols + extra_cells; i >= 0; i--) {
- styles += '[data-col="'+ (i + 1) +'"] { left: ' +
- (i * this.min_widget_width) +
+ for (i = opts.cols + extra_cells; i >= 0; i--) {
+ styles += opts.namespace + ' [data-col="'+ (i + 1) +'"] { left: ' +
+ ((i * opts.widget_base_dimensions[0]) + (i *opts.widget_margins[0] ) + ((i+1) * opts.widget_margins[0])) +
'px;} ';
}
/* generate CSS styles for rows */
- for (i = rows + extra_cells; i >= 0; i--) {
- styles += '[data-row="' + (i + 1) + '"] { top: ' +
- (i * this.min_widget_height) + 'px;} ';
+ for (i = opts.rows + extra_cells; i >= 0; i--) {
+ styles += opts.namespace + ' [data-row="' + (i + 1) + '"] { top: ' +
+ ((i * opts.widget_base_dimensions[1]) + (i * opts.widget_margins[1]) + ((i+1) * opts.widget_margins[1]) ) +
+ 'px;} ';
}
for (var y = 1; y < max_size_y; y++) {
- styles += '[data-sizey="' + (y) + '"] { height: ' +
- (y * this.options.widget_base_dimensions[1] + (y-1)*(this.options.widget_margins[1]*2)) + 'px;}';
+ styles += opts.namespace + ' [data-sizey="' + (y) + '"] { height: ' +
+ (y * opts.widget_base_dimensions[1] + (y-1)*(opts.widget_margins[1]*2)) + 'px;}';
}
for (var x = 1; x < max_size_x; x++) {
- styles += '[data-sizex="' + (x) + '"] { width: ' +
- (x * this.options.widget_base_dimensions[0] + (x-1)*(this.options.widget_margins[0]*2)) + 'px;}';
+ styles += opts.namespace + ' [data-sizex="' + (x) + '"] { width: ' +
+ (x * opts.widget_base_dimensions[0] + (x-1)*(opts.widget_margins[0]*2)) + 'px;}';
}
return this.add_style_tag(styles);
@@ -2113,24 +2220,19 @@
var min_cols = Math.max.apply(null, actual_cols);
var min_rows = Math.max.apply(null, actual_rows);
- cols = Math.max(min_cols, cols, this.options.min_cols);
- rows = Math.max(min_rows, rows, this.options.min_rows);
+ this.cols = Math.max(min_cols, cols, this.options.min_cols);
+ this.rows = Math.max(min_rows, rows, this.options.min_rows);
- //this.support_grid_width = cols * this.min_widget_width;
- // this.support_grid_width = this.wrapper_width;
-
- // this.support_grid_height = rows * this.min_widget_height;
this.baseX = ($(window).width() - aw) / 2;
this.baseY = this.$wrapper.offset().top;
- //this.baseX = 0;
if (this.options.autogenerate_stylesheet) {
- this.generate_stylesheet(rows, cols);
+ this.generate_stylesheet();
}
/* more faux rows that needed are created so that there are cells
* where drag beyond the limits */
- return this.generate_faux_grid(rows, cols);
+ return this.generate_faux_grid(this.rows, this.cols);
};
diff --git a/docs/index.html b/docs/index.html
index 3da554286f..b51bc488fc 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -46,6 +46,8 @@
Coords
+
Draggable
+
Gridster
diff --git a/grunt.js b/grunt.js
index f0b2f9d34f..aa31d6a54e 100644
--- a/grunt.js
+++ b/grunt.js
@@ -13,7 +13,7 @@ module.exports = function(grunt) {
},
concat: {
dist_js: {
- src: ['
', '', '', '.js>'],
+ src: ['', '', '', 'src/utils.js', '', '.js>'],
dest: 'dist/<%= pkg.name %>.js'
},
dist_css: {
diff --git a/index.html b/index.html
index 2486a21e55..296a890a0c 100755
--- a/index.html
+++ b/index.html
@@ -56,7 +56,7 @@
@@ -196,11 +201,20 @@
autogenerate_stylesheet: true
If true, all the CSS required to position all widgets in their respective columns and rows will be generated automatically and injected to the <head>
of the document. You can set this to false, and write your own CSS targeting rows and cols via data-attributes like so: [data-col="1"] { left: 10px; }
+
+
Avoid that widgets loaded from the DOM can be overlapped. It is helpful if the positions were bad stored in the database or if there was any conflict.
+
serialize_params: function($w, wgd) { return { col: wgd.col, row: wgd.row } }
Return the data you want for each widget in the serialize method. Two arguments are passed: `$w`: the jQuery wrapped HTMLElement, and `wgd`: the grid coords object (`col`, `row`, `size_x`, `size_y`).
-
draggable: {}
-
The configuration object of the jQuery UI Draggable Plugin. See http://jqueryui.com/demos/draggable/ for more information.
+
draggable.start: function(event, ui){}
+
Executes a function when dragging starts.
+
+
draggable.drag: function(event, ui){}
+
Executes a function when the mouse is moved during the dragging.
+
+
draggable.stop: function(event, ui){}
+
Executes a function when dragging stops.
collision.on_overlap_start: function(collider_data) { }
Executes a function first time a widget overlaps with a "faux" grid cell.
@@ -292,7 +306,7 @@
- Reminds that gridster.js depends on jQuery and jQuery UI draggable. Download the latest release at jQuery and jQuery UI .
+
Reminds that gridster.js depends on jQuery. Download the latest release at jQuery .
gridster.js
@@ -354,7 +368,6 @@
-
@@ -367,10 +380,7 @@
widget_margins: [10, 10],
widget_base_dimensions: [140, 140],
min_cols: 6,
- min_rows: 10,
- draggable: {
- helper: "clone"
- }
+ min_rows: 10
}).data('gridster');
});