Commit Graph
83 Commits
Author SHA1 Message Date
Dustin Moore ea77853b07 Removed console.logs 2012-11-28 08:01:21 -08:00
Dustin Moore 6786984511 Good enough swap logic for now 2012-11-28 07:58:37 -08:00
Dustin Moore a3d2b09b8a Swap queue awesomeness 2012-11-27 14:55:15 -08:00
Dustin Moore 24cd3be70d Swap queue awesomeness 2012-11-27 14:10:11 -08:00
Dustin Moore 136923ec50 working on map grid functionality 2012-11-26 16:43:08 -08:00
Dustin Moore 98204f1c69 Added swaping queue, better handling of large to small swaps 2012-11-26 15:20:15 -08:00
Dustin Moore 773828731c More predictable default behavior 2012-11-20 12:02:29 -08:00
Dustin Moore 67465875aa Added property to prevent larger widget shifting 2012-11-20 10:16:19 -08:00
Dustin Moore 898b77d2d3 Added grid-swap behavior 2012-11-20 10:07:38 -08:00
vieron 55edd11ef8 gridster: new method remove_all_widgets
Remove multiple widgets without chaining callbacks was not possible so I've added a new argument to remove_widget method named `silent` which if it's value is true, widgets below the removed will not move up.

Also added the method remove_all_widgets.

Fixes #63
2012-10-20 01:37:41 +02:00
Philip Manavopoulos 552df22e1c Allow for an optional drag handle to be specified
When defining the gridster, you can now define a draggable.handle selector:

For example:

    $("#widgets").gridster({
        widget_margins: [10, 10],
        widget_base_dimensions: [565, 400],
		draggable: {
			stop: function(event, ui) {
				console.log('save new columns');
			},
			handle: '.title'
		}
    });

If handle is omitted (or left blank), it works as it did previously. If a value is specified, then dragging only starts if the element which was clicked matches the selector specified.

Added by @vieron:
Closes #29
2012-10-20 00:12:10 +02:00
vieron 68f1d6279c Avoid dynamic column generation.
Using add_faux_col each time a new widget is added to the grid caused the widget was always positioned in the first row on the right. Related to #60.
2012-10-15 15:47:31 +02:00
vieron 5411836c88 events/onselectstart: Don't prevent default behaviour on form fields
Fixes #56.
2012-10-07 21:36:58 +02:00
vieron 5a3c382c8b Immediate children selection for widgets. Fixes #52. 2012-10-07 21:12:38 +02:00
vieron cd5c936939 gridster extra methods
Some new methods we need at Ducksboard to implement TV mode.

Two new distributions of Gridster are generated with grunt:
    - jquery.gridster.with-extras.js
    - jquery.gridster.with-extras.min.js
2012-10-07 21:12:38 +02:00
vieron 7dbbc105c1 add_faux_cell: create parent array if doesn't exists 2012-10-07 21:12:38 +02:00
vieron 82b8778762 if not passed, use default namespace for generating stylessheets 2012-10-07 21:12:38 +02:00
vieron 7fc97d0f79 Allow to extend gridster out of the scope 2012-10-07 21:12:38 +02:00
vieron 0b1c9899d0 some code style corrections/improvements 2012-10-07 21:12:38 +02:00
vieron c4fee63b96 ability to specify a max row as limit in can_move_to method 2012-10-03 15:40:16 +02:00
vieron 3d5077dd7b add_faux_cols method 2012-10-03 15:33:46 +02:00
vieron c6bd80be8e Fixed disable method, it didn't work well for multiple instances.
Previously, disabling gridster caused all the instances of Gridster running on the pages was disabled. Because Draggable class uses event delegation from the body to manage drag events.
2012-10-03 13:48:55 +02:00
vieron 3bc9ea3527 Possibility to namespace first-time styles generated by gridster.
Useful if you have multiple grid instances in the same document.
2012-09-12 17:50:48 +02:00
vieron b71b8727df gridster: moving down widgets under placeholder. Related to #4.
This solves the overlapping-blocks seen in the screencast provided by @daniel-nelson. I've captured another one trying to reproduce the same movements with this commit applied: http://www.screenr.com/g7J8
2012-09-09 14:21:31 +02:00
vieron dc61567454 collision: ignore min_area in collision sorting
This doesn't work with grids with small values in widget_base_dimensions and widget_margins options.
2012-09-08 13:58:47 +02:00
vieron 9402f202b8 update coords for the new widget size.
Reported by @bmla in https://github.com/ducksboard/gridster.js/commit/dbf98cc9bdc#commitcomment-1735360
2012-08-20 21:06:21 +02:00
vieron dbf98cc9bd Resize widgets feature. Closes #15.
By popular demand, now gridster allows to change the size of widgets dynamically.

Usage.
- gridster_api.resize_wiget($widget, [size_x], [size_y]);

E.g. (try in gridster.net):
    - gridster.resize_widget($('.gs_w:eq(3)'), 6);
    - gridster.resize_widget($('.gs_w:eq(3)'), 1, 4);

To do this, two new methods were added to gridster:

    - empty_cells(col, row, size_x, size_y, $exclude)
      Move down widgets in cells represented by the arguments col, row, size_x,
      size_y.

    - remove_empty_cells(col, row, size_x, size_y, $exclude)
      Move up widgets below cells represented by the arguments col, row, size_x,
      size_y.

Also, add_widget method supports specifying a row and column. This was easy
through empty_cells method. Related to #24. Thanks to @parkerd for the help!

The code should be improved and make it more reusable when the feature of
"move widgets dynamically" is added (related to #20).
2012-08-20 01:31:34 +02:00
vieron 010444f57c Allow widgets to start in a specific col+row on the grid 2012-08-18 22:10:12 +02:00
vieron 32ea0da04b wip: resize widget feature 2012-08-18 22:10:12 +02:00
vieron 1d65da9260 Improving the way that rows are calculated. Related to #30.
Until now, the number of rows for the faux grid (this.cols) was calculated taking the highest
value among min_rows option, the highest widget, and the number of rows
that fits on the wrapper height (based on widget_base_dimensions, widget_margins
and extra_rows options).

In addition to this, styles for data-row attributes ara generated based on
this.cols (above) plus a constant value of 10. This was done to reduce
the number of cells by which iterate when dragging, but it's not very logical...

So, now the number of rows is calculated by adding the height of all widgets.
In this way we ensure that there is always available cells in the grid.
Also the same number of rows are generated for both the faux grid and
the DOM grid (css styles).
2012-08-18 19:34:47 +02:00
vieron 573ed66922 fixes in drag/stop callbacks. Related to #23.
- break ondrag callback execution if stop event already was fired.
- unset this.$player after the execution of draggable.stop callback.
2012-08-14 00:06:03 +02:00
vieron 81c96b92d5 fixed: drag api access from gridster and draggable.disable method.
Fixes #25. I broke this in the issue #17 and commit 8e7a5c.
2012-08-13 22:32:35 +02:00
vieron 8e7a5cec53 prevent selection when dragging 2012-08-13 00:35:28 +02:00
vieron 6c9eaf067d Fixes related to overlapping problems. Solve part of #4.
Some fixes are about errors (seen in the link provided by @floflow in #16)
produced by drag large blocks.
2012-08-12 18:47:02 +02:00
vieron d78bd254bd renamed jQuery adapter for Draggable class to $.fn.drag. Fixes #17.
Prevents name collisions with jQuery UI draggable module.
2012-08-08 23:33:31 +02:00
vieron 5f4e6ded39 fixed index error in for loop. Fixes #16. 2012-08-08 20:37:02 +02:00
vieron 148963d12f added max_size_x and max_size_y as configurable options. Fixes #16.
The maximum number of columns/rows that a widget can span
was hardcoded to 6. Maybe it makes sense for dashboards but
not for other uses of gridster.
2012-08-08 01:21:30 +02:00
vieron dc0a548bd4 stupid typos 2012-08-07 00:59:58 +02:00
vieron ca7577950e don't start drag if <button> is clicked 2012-08-07 00:59:00 +02:00
vieron f359a7eb76 fixed typo in docs 2012-08-06 23:55:30 +02:00
vieron 1316a37e60 added touch support. Closes #12, closes #9 2012-08-05 12:39:51 +02:00
vieron 0e942677ec increased scroll area size and scroll speed 2012-08-05 11:00:08 +02:00
vieron 39a473cedf Doing form elements inside widgets clickable. Fixes #7. 2012-08-03 23:49:46 +02:00
vieron 9987989c8c Caching $(document.body) once document is ready. Fixes #10. 2012-08-03 16:45:49 +02:00
vieron 4048784eaf Forcing conversion to arrays before calling Math.max 2012-07-30 21:17:03 +02:00
vieron 6972f9fb33 recalculate grid height when a widget is removed 2012-07-27 17:55:04 +02:00
Jan Urbański f4e425ced2 switch to using the MIT license exclusively 2012-07-27 13:29:07 +02:00
vieron 341e1bbd4c prevent cols/rows from being empty arrays (needed to pass phantom tests) 2012-07-26 09:58:39 +02:00
vieron e4e06f4cde gridster: passing Math (not null) as first argument in Math.max.apply() 2012-07-25 17:58:18 +02:00
vieron f12cebb33e increased the mouse area that triggers scroll 2012-07-24 17:05:07 +02:00