Gridster Class
Constructor
Gridster
-
el
-
[options]
-
[options.autogenerate_stylesheet] 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"]
-
[options.resize.axes] Axes in which widgets can be resized. Possible values: ['x', 'y', 'both']
-
[options.resize.max_size] Limit widget dimensions when resizing. Array values should be integers: `[max_cols_occupied, max_rows_occupied]
-
[options.resize.min_size] Limit widget dimensions when resizing. Array values should be integers: `[min_cols_occupied, min_rows_occupied]
Parameters:
-
el
HTMLElementThe HTMLelement that contains all the widgets.
-
[options]
Object optionalAn Object with all options you want to overwrite:
-
[widget_selector]
HTMLElement | String optionalDefine who will be the draggable widgets. Can be a CSS Selector String or a collection of HTMLElements
-
[widget_margins]
Array optionalMargin between widgets. The first index for the horizontal margin (left, right) and the second for the vertical margin (top, bottom).
-
[widget_base_dimensions]
Array optionalBase widget dimensions in pixels. The first index for the width and the second for the height.
-
[extra_cols]
Number optionalAdd more columns in addition to those that have been calculated.
-
[extra_rows]
Number optionalAdd more rows in addition to those that have been calculated.
-
[min_cols]
Number optionalThe minimum required columns.
-
[max_cols]
Number optionalThe maximum columns possible (set to null for no maximum).
-
[min_rows]
Number optionalThe minimum required rows.
-
[avoid_overlapped_widgets]
Boolean optionalAvoid 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.
-
[auto_init]
Boolean optionalAutomatically call gridster init method or not when the plugin is instantiated.
-
[serialize_params]
Function optionalReturn the data you want for each widget in the serialization. Two arguments are passed:
$w
: the jQuery wrapped HTMLElement, andwgd
: the grid coords object (col
,row
,size_x
,size_y
). -
[shift_larger_widgets_down]
Boolean optionalDetermines if how widgets get pushes out of the way of the player. If set to false smaller widgets will not move larger widgets out of their way . Defaults to true.
-
[shift_widgets_up]
Boolean optionalDetermines if the player will automatically condense the grid and not allow a widget to have space above it. Defaults to true.
-
[show_element]
Function optionalMakes the given element visible. Two arguments are passed:
$el
: the jQuery wrapped HTMLElement, andcallback
: a function that is executed after the element is made visible. The callback parameter is optional. -
[hide_element]
Function optionalHides the given element. Two arguments are passed:
$el
: the jQuery wrapped HTMLElement, andcallback
: a function that is executed after the element is hidden. The callback parameter is optional. -
[collision]
Object optionalAn Object with all options for Collision class you want to overwrite. See Collision docs for more info.
-
[wait_for_mouseup]
Boolean optionalDefault is false. If true then it will not move colliding widgets during drag, but only on mouseup.
-
-
[draggable]
Object optionalAn Object with all options for Draggable class you want to overwrite. See Draggable docs for more info.
-
[ignore_dragging]
Object | Function optionalNote that if you use a Function, and resize is enabled, you should ignore the resize handlers manually (options.resize.handle_class).
-
-
[resize]
Object optionalAn Object with resize config options.
-
[enabled]
Boolean optionalSet to true to enable resizing. -
[handle_append_to]
String optionalSet a valid CSS selector to append resize handles to. -
[handle_class]
String optionalCSS class name used by resize handles. -
[start]
Function optionalFunction executed when resizing starts. -
[resize]
Function optionalFunction executed during the resizing. -
[stop]
Function optionalFunction executed when resizing stops.
-
-
-
[options.autogenerate_stylesheet] 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"]
Boolean{ left: 10px; }`
-
[options.resize.axes] Axes in which widgets can be resized. Possible values: ['x', 'y', 'both']
Array.
-
[options.resize.max_size] Limit widget dimensions when resizing. Array values should be integers: `[max_cols_occupied, max_rows_occupied]
Array`
-
[options.resize.min_size] Limit widget dimensions when resizing. Array values should be integers: `[min_cols_occupied, min_rows_occupied]
Array`
Item Index
Methods
- add_faux_cell
- add_faux_cols
- add_faux_rows
- add_resize_handle representing the widget.
- add_style_tag
- add_to_gridmap
- add_widget
- can_go_player_up
- can_go_up_to_row
- can_go_widget_up
- can_move_to
- center_widgets
- collapse_widget
- destroy
- disable
- disable
- dom_to_coords
- draggable
- empty_cells
- empty_cells_player_occupies
- enable
- enable
- expand_widget
- fit_to_content
- for_each_cell_occupied widget.
- for_each_column_occupied
- for_each_row_occupied
- for_each_widget_above
- for_each_widget_below
- generate_faux_grid
- generate_grid_and_stylesheet
- generate_stylesheet
- get_cells_occupied
- get_highest_occupied_cell
- get_targeted_columns
- get_targeted_rows
- get_valid_rows
- get_widgets_from_DOM
- get_widgets_overlapped
- get_widgets_under_player
- is_empty
- is_occupied
- is_placeholder_in
- is_placeholder_in_col
- is_player
- is_player_in
- is_static
- is_widget
- is_widget_under_player
- manage_movements
- move_widget
- move_widget_down
- move_widget_to
- move_widget_up
- mutate_widget_in_gridmap
- next_position
- on_drag
- on_overlapped_column_change
- on_overlapped_row_change
- on_resize
- on_start_drag
- on_start_overlapping_column
- on_start_overlapping_row
- on_start_resize
- on_stop_drag
- on_stop_overlapping_column
- on_stop_overlapping_row
- on_stop_resize
- recalculate_faux_grid
- register_widget
- remove_all_widgets
- remove_empty_cells
- remove_from_gridmap
- remove_style_tag
- remove_widget
- resizable
- resize_widget
- resize_widget_dimensions
- serialize
- serialize_changed
- set_cells_player_occupies
- set_dom_grid_height
- set_dom_grid_width
- set_placeholder
- set_player
- set_widget_max_size
- set_widget_min_size
- setup_resize
- sort_by_col_asc
- sort_by_row_and_col_asc
- sort_by_row_asc
- sort_by_row_desc
- update_widget_dimensions
- update_widget_position
- update_widgets_dimensions
- widgets_below
- widgets_contraints
Methods
add_faux_cell
-
row
-
col
Add cell to the faux grid.
Parameters:
-
row
NumberThe row for the new faux cell.
-
col
NumberThe col for the new faux cell.
Returns:
Returns the instance of the Gridster class.
add_faux_cols
-
cols
Add cols to the faux grid.
Parameters:
-
cols
NumberThe number of cols you want to add to the faux grid.
Returns:
Returns the instance of the Gridster class.
add_faux_rows
-
rows
Add rows to the faux grid.
Parameters:
-
rows
NumberThe number of rows you want to add to the faux grid.
Returns:
Returns the instance of the Gridster class.
add_resize_handle
representing the widget.
-
$w
Append the resize handle into a widget.
Parameters:
-
$w
Object
Returns:
Returns instance of gridster Class.
add_style_tag
-
css
Injects the given CSS as string to the head of the document.
Parameters:
-
css
StringThe styles to apply.
Returns:
Returns the instance of the Gridster class.
add_to_gridmap
-
grid_data
-
[value]
Add a widget to the mapped array of positions.
Parameters:
-
grid_data
ObjectThe grid coords object representing the cells to update in the mapped array.
-
[value]
HTMLElement | Boolean optionalThe value to set in the specified position .
Returns:
Returns the instance of the Gridster Class.
add_widget
-
html
-
[size_x]
-
[size_y]
-
[col]
-
[row]
-
[max_size]
-
[min_size]
-
[callback]
Add a new widget to the grid.
Parameters:
-
html
String | HTMLElementThe string representing the HTML of the widget or the HTMLElement.
-
[size_x]
Number optionalThe nº of rows the widget occupies horizontally.
-
[size_y]
Number optionalThe nº of columns the widget occupies vertically.
-
[col]
Number optionalThe column the widget should start in.
-
[row]
Number optionalThe row the widget should start in.
-
[max_size]
Array optionalmax_size Maximun size (in units) for width and height.
-
[min_size]
Array optionalmin_size Minimum size (in units) for width and height.
-
[callback]
Function optionalFunction executed after the widget is shown.
Returns:
Returns the jQuery wrapped HTMLElement representing. the widget that was just created.
can_go_player_up
-
widget_grid_data
Determines whether the player can move to a position above.
Parameters:
-
widget_grid_data
ObjectThe actual grid coords object of the player.
Returns:
If the player can be moved to an upper row returns the row number, else returns false.
can_go_up_to_row
-
widget_grid_data
-
col
-
row
Check if the widget can move to the specified row, else returns the upper row possible.
Parameters:
-
widget_grid_data
NumberThe current grid coords object of the widget.
-
col
NumberThe target column.
-
row
NumberThe target row.
Returns:
Returns the row number if the widget can move to the target position, else returns false.
can_go_widget_up
-
widget_grid_data
Determines whether a widget can move to a position above.
Parameters:
-
widget_grid_data
ObjectThe actual grid coords object of the widget we want to check.
Returns:
If the widget can be moved to an upper row returns the row number, else returns false.
can_move_to
-
widget_grid_data
-
col
-
row
Check if it's possible to move a widget to a specific col/row. It takes
into account the dimensions (size_y
and size_x
attrs. of the grid
coords object) the widget occupies.
Parameters:
-
widget_grid_data
ObjectThe grid coords object that represents the widget.
-
col
ObjectThe col to check.
-
row
ObjectThe row to check.
Returns:
Returns true if all cells are empty, else return false.
center_widgets
()
Centers widgets in grid
collapse_widget
-
$widget
-
[callback]
Collapse the widget to it's pre-expanded size
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement representing the widget.
-
[callback]
Function optionalFunction executed when the widget is collapsed.
Returns:
Returns $widget.
destroy
-
remove
Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
Parameters:
-
remove
BooleanIf true, remove gridster from DOM.
Returns:
Returns the instance of the Gridster class.
disable
()
Gridster
Disables dragging.
Returns:
Returns the instance of the Gridster Class.
disable
()
Gridster
Disables drag-and-drop widget resizing.
Returns:
Returns instance of gridster Class.
dom_to_coords
-
$widget
Convert widgets from DOM elements to "widget grid data" Objects.
Parameters:
-
$widget
HTMLElementThe widget to be converted.
draggable
()
Gridster
Make widgets draggable.
Returns:
Returns the instance of the Gridster Class.
empty_cells
-
col
-
row
-
size_x
-
size_y
-
[$exclude]
Move down widgets in cells represented by the arguments col, row, size_x, size_y
Parameters:
-
col
NumberThe column where the group of cells begin.
-
row
NumberThe row where the group of cells begin.
-
size_x
NumberThe number of columns that the group of cells occupy.
-
size_y
NumberThe number of rows that the group of cells occupy.
-
[$exclude]
HTMLElement optionalExclude widgets from being moved.
Returns:
Returns the instance of the Gridster Class.
empty_cells_player_occupies
()
Gridster
Remove from the array of mapped positions the reference to the player.
Returns:
Returns the instance of the Gridster Class.
enable
()
Gridster
Enables drag-and-drop widget resizing.
Returns:
Returns instance of gridster Class.
expand_widget
-
$widget
-
size_x
-
size_y
-
col
-
[callback]
Expand the widget. Width is set to the current grid width.
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement representing the widget.
-
size_x
NumberThe number of cols that will occupy the widget.
-
size_y
NumberThe number of rows that will occupy the widget.
-
col
NumberThe column to resize the widget from.
-
[callback]
Function optionalFunction executed when the widget is expanded.
Returns:
Returns $widget.
fit_to_content
-
$widget
-
max_cols
-
max_rows
-
[callback]
Fit the size of a widget to its content (best guess)
Parameters:
-
$widget
HTMLElement$widget The jQuery wrapped HTMLElement
-
max_cols
Numbermax number of columns a widget can take up
-
max_rows
Numbermax number of rows a widget can take up
-
[callback]
Function optionalFunction executed when the widget is fit to content.
Returns:
Returns $widget.
for_each_cell_occupied
widget.
-
grid_data
-
callback
Iterate over the cells occupied by a widget executing a function for each one.
Parameters:
-
grid_data
Object -
callback
FunctionThe function to execute on each column iteration. Column and row are passed as arguments.
Returns:
Returns the instance of the Gridster Class.
for_each_column_occupied
-
el_grid_data
-
callback
Iterate over the columns occupied by a widget executing a function for each one.
Parameters:
-
el_grid_data
ObjectThe grid coords object that represents the widget.
-
callback
FunctionThe function to execute on each column iteration. The column number is passed as first argument.
Returns:
Returns the instance of the Gridster Class.
for_each_row_occupied
-
el_grid_data
-
callback
Iterate over the rows occupied by a widget executing a function for each one.
Parameters:
-
el_grid_data
ObjectThe grid coords object that represents the widget.
-
callback
FunctionThe function to execute on each column iteration. The row number is passed as first argument.
Returns:
Returns the instance of the Gridster Class.
for_each_widget_above
-
col
-
row
-
callback
Iterate over each widget above the column and row specified.
Parameters:
-
col
NumberThe column to start iterating.
-
row
NumberThe row to start iterating.
-
callback
FunctionThe function to execute on each widget iteration. The value of
this
inside the function is the jQuery wrapped HTMLElement.
Returns:
Returns the instance of the Gridster Class.
for_each_widget_below
-
col
-
row
-
callback
Iterate over each widget below the column and row specified.
Parameters:
-
col
NumberThe column to start iterating.
-
row
NumberThe row to start iterating.
-
callback
FunctionThe function to execute on each widget iteration. The value of
this
inside the function is the jQuery wrapped HTMLElement.
Returns:
Returns the instance of the Gridster Class.
generate_faux_grid
-
rows
-
cols
Generates a faux grid to collide with it when a widget is dragged and detect row or column that we want to go.
Parameters:
-
rows
NumberNumber of columns.
-
cols
NumberNumber of rows.
Returns:
Returns the instance of the Gridster class.
generate_grid_and_stylesheet
()
Object
Calculate columns and rows to be set based on the configuration parameters, grid dimensions, etc ...
Returns:
Returns the instance of the Gridster class.
generate_stylesheet
-
[opts]
It generates the necessary styles to position the widgets.
Parameters:
-
[opts]
Object optional- set of gridster config options to generate stylessheets based on
Returns:
Returns the instance of the Gridster class.
get_cells_occupied
-
el_grid_data
Get all columns and rows that a widget occupies.
Parameters:
-
el_grid_data
ObjectThe grid coords object of the widget.
Returns:
Returns an object like { cols: [], rows: []}
.
get_highest_occupied_cell
()
Object
Returns the highest occupied cell in the grid.
Returns:
Returns an object with col
and row
numbers.
get_targeted_columns
-
[from_col]
Given the leftmost column returns all columns that are overlapping with the player.
Parameters:
-
[from_col]
Number optionalThe leftmost column.
Returns:
Returns an array with column numbers.
get_targeted_rows
-
[from_row]
Given the upper row returns all rows that are overlapping with the player.
Parameters:
-
[from_row]
Number optionalThe upper row.
Returns:
Returns an array with row numbers.
get_valid_rows
-
widget_grid_data
-
upper_rows
-
min_row
Search a valid row for the widget represented by widget_grid_data' in
the
upper_rowsarray. Iteration starts from row specified in
min_row`.
Parameters:
-
widget_grid_data
ObjectThe actual grid coords object of the player.
-
upper_rows
ArrayAn array with columns as index and arrays of valid rows as values.
-
min_row
NumberThe upper row from which the iteration will start.
Returns:
Returns the upper row valid from the upper_rows
for the widget in question.
get_widgets_from_DOM
()
Object
Get all widgets in the DOM and register them.
Returns:
Returns the instance of the Gridster class.
get_widgets_overlapped
()
JQuery
Get widgets overlapping with the player.
Returns:
Returns a jQuery collection of HTMLElements.
get_widgets_under_player
()
HTMLElement
Get widgets overlapping with the player or with the object passed representing the grid cells.
Returns:
Returns a jQuery collection of HTMLElements
is_empty
-
col
-
row
Determines if the cell represented by col and row params is empty.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true or false.
is_occupied
-
col
-
row
Determines if the cell represented by col and row params is occupied.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true or false.
is_placeholder_in
-
col
-
row
Determines if the placeholder is currently over the row and col given.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true or false.
is_placeholder_in_col
-
col
Determines if the placeholder is currently over the column given.
Parameters:
-
col
NumberThe column to check.
Returns:
Returns true or false.
is_player
-
col_or_el
-
[row]
Determines if there is a widget in the row and col given. Or if the HTMLElement passed as first argument is the player.
Parameters:
-
col_or_el
Number | HTMLElementA jQuery wrapped collection of HTMLElements.
-
[row]
Number optionalThe column to which we want to move the widgets.
Returns:
Returns true or false.
is_player_in
-
col
-
row
Determines if the widget that is being dragged is currently over the row and col given.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true or false.
is_static
-
col
-
row
Determines if widget is supposed to be static. WARNING: as of 0.6.6 this feature is buggy when used with resizable widgets, as resizing widgets above and below a static widgit can cause it to move. This feature is considered experimental at this time
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true if widget exists and has static class, else returns false
is_widget
-
col
-
row
Determines if there is a widget in the cell represented by col/row params.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns false if there is no widget, else returns the jQuery HTMLElement
is_widget_under_player
-
col
-
row
Determines if there is a widget in the cell represented by col/row params and if this is under the widget that is being dragged.
Parameters:
-
col
NumberThe column to check.
-
row
NumberThe row to check.
Returns:
Returns true or false.
manage_movements
-
$widgets
-
to_col
-
to_row
Sorts an Array of grid coords objects (representing the grid coords of each widget) in descending way.
Depreciated.
Parameters:
-
$widgets
JQueryA jQuery collection of HTMLElements representing the widgets you want to move.
-
to_col
NumberThe column to which we want to move the widgets.
-
to_row
NumberThe row to which we want to move the widgets.
Returns:
Returns the instance of the Gridster Class.
move_widget
-
$widget
-
new_col
-
new_row
-
callback
Move a widget to a specific row and column. If the widget has widgets below, all of these widgets will be moved also
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement of the widget is going to be moved.
-
new_col
Numberthe column number to be set in widget
-
new_row
Numberthe row number to be set in widget
-
callback
Functionis called when whole process is done.
Returns:
Returns the instance of the Gridster Class.
move_widget_down
-
$widget
-
y_units
Move down the specified widget and all below it.
Parameters:
-
$widget
JQueryThe jQuery object representing the widget you want to move.
-
y_units
NumberThe number of cells that the widget has to move.
Returns:
Returns the instance of the Gridster Class.
move_widget_to
-
$widget
-
row
Move a widget to a specific row. The cell or cells must be empty. If the widget has widgets below, all of these widgets will be moved also if they can.
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement of the widget is going to be moved.
-
row
Object- row to move the widget to
Returns:
Returns the instance of the Gridster Class.
move_widget_up
-
$widget
-
[y_units]
Move up the specified widget and all below it.
Parameters:
-
$widget
HTMLElementThe widget you want to move.
-
[y_units]
Number optionalThe number of cells that the widget has to move.
Returns:
Returns if the widget moved
mutate_widget_in_gridmap
-
$widget
-
wgd
-
new_wgd
Mutate widget dimensions and position in the grid map.
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement representing the widget to mutate.
-
wgd
ObjectCurrent widget grid data (col, row, size_x, size_y).
-
new_wgd
ObjectNew widget grid data.
Returns:
Returns instance of gridster Class.
next_position
-
size_x
-
size_y
Get the most left column below to add a new widget.
Parameters:
-
size_x
NumberThe nº of rows the widget occupies horizontally.
-
size_y
NumberThe nº of columns the widget occupies vertically.
Returns:
Returns a grid coords object representing the future widget coords.
on_drag
-
event
-
ui
This function is executed when the player is being dragged.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
on_overlapped_column_change
-
start_callback
-
stop_callback
Executes the callbacks passed as arguments when a column begins to be overlapped or stops being overlapped.
Parameters:
-
start_callback
FunctionFunction executed when a new column begins to be overlapped. The column is passed as first argument.
-
stop_callback
FunctionFunction executed when a column stops being overlapped. The column is passed as first argument.
Returns:
Returns the instance of the Gridster Class.
on_overlapped_row_change
-
start_callback
-
end_callback
Executes the callbacks passed as arguments when a row starts to be overlapped or stops being overlapped.
Parameters:
-
start_callback
FunctionFunction executed when a new row begins to be overlapped. The row is passed as first argument.
-
end_callback
FunctionFunction executed when a row stops being overlapped. The row is passed as first argument.
Returns:
Returns the instance of the Gridster Class.
on_resize
-
event
-
ui
This function is executed when a widget is being resized.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
on_start_drag
-
event
-
ui
This function is executed when the player begins to be dragged.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
on_start_overlapping_column
-
col
This callback is executed when the player begins to collide with a column.
Parameters:
-
col
NumberThe collided column.
Returns:
Returns a jQuery collection of HTMLElements.
on_start_overlapping_row
-
row
A callback executed when the player begins to collide with a row.
Parameters:
-
row
NumberThe collided row.
Returns:
Returns a jQuery collection of HTMLElements.
on_start_resize
-
event
-
ui
This function is executed every time a widget starts to be resized.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
on_stop_drag
-
event
-
ui
This function is executed when the player stops being dragged.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
on_stop_overlapping_column
-
col
A callback executed when the the player ends to collide with a column.
Parameters:
-
col
NumberThe collided row.
Returns:
Returns a jQuery collection of HTMLElements.
on_stop_overlapping_row
-
row
This callback is executed when the player ends to collide with a row.
Parameters:
-
row
NumberThe collided row.
Returns:
Returns a jQuery collection of HTMLElements.
on_stop_resize
-
event
-
ui
This function is executed every time a widget stops being resized.
Parameters:
-
event
EventThe original browser event
-
ui
ObjectA prepared ui object with useful drag-related data
recalculate_faux_grid
()
Object
Recalculates the offsets for the faux grid. You need to use it when the browser is resized.
Returns:
Returns the instance of the Gridster class.
register_widget
-
$el
Creates the grid coords object representing the widget an add it to the mapped array of positions.
Parameters:
-
$el
HTMLElement | ObjectjQuery wrapped HTMLElement representing the widget, or an "widget grid data" Object with (col, row, el ...).
Returns:
Returns true if the widget final position is different than the original.
remove_all_widgets
-
callback
Remove all widgets from the grid.
Parameters:
-
callback
FunctionFunction executed for each widget removed.
Returns:
Returns the instance of the Gridster Class.
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.
Parameters:
-
col
NumberThe column where the group of cells begin.
-
row
NumberThe row where the group of cells begin.
-
size_x
NumberThe number of columns that the group of cells occupy.
-
size_y
NumberThe number of rows that the group of cells occupy.
-
exclude
HTMLElementExclude widgets from being moved.
Returns:
Returns the instance of the Gridster Class.
remove_from_gridmap
-
grid_data
Remove a widget from the mapped array of positions.
Parameters:
-
grid_data
ObjectThe grid coords object representing the cells to update in the mapped array.
Returns:
Returns the instance of the Gridster Class.
remove_style_tag
()
Object
Remove the style tag with the associated id from the head of the document
Returns:
Returns the instance of the Gridster class.
remove_widget
-
el
-
[silent]
-
[callback]
Remove a widget from the grid.
Parameters:
-
el
HTMLElementThe jQuery wrapped HTMLElement you want to remove.
-
[silent]
Boolean | Function optionalIf true, widgets below the removed one will not move up. If a Function is passed it will be used as callback.
-
[callback]
Function optionalFunction executed after the widget is removed.
Returns:
Returns the instance of the Gridster Class.
resizable
()
Gridster
Bind resize events to get resize working.
Returns:
Returns instance of gridster Class.
resize_widget
-
$widget
-
[size_x]
-
[size_y]
-
[callback]
Change the size of a widget. Width is limited to the current grid width.
Parameters:
-
$widget
HTMLElementThe jQuery wrapped HTMLElement representing the widget.
-
[size_x]
Number optionalThe number of columns that will occupy the widget. By default
size_x
is limited to the space available from the column where the widget begins, until the last column to the right. -
[size_y]
Number optionalThe number of rows that will occupy the widget.
-
[callback]
Function optionalFunction executed when the widget is removed.
Returns:
Returns $widget.
resize_widget_dimensions
-
options
Resize dimensions of widgets in grid based on given options
Parameters:
-
options
Object
Returns:
serialize
-
[$widgets]
Returns a serialized array of the widgets in the grid.
Parameters:
-
[$widgets]
HTMLElement optionalThe collection of jQuery wrapped HTMLElements you want to serialize. If no argument is passed all widgets will be serialized.
Returns:
Returns an Array of Objects with the data specified in the serialize_params option.
serialize_changed
()
Array
Returns a serialized array of the widgets that have changed their position.
Returns:
Returns an Array of Objects with the data specified in the serialize_params option.
set_cells_player_occupies
-
col
-
col
-
row
Update the array of mapped positions with the new player position.
Parameters:
-
col
NumberThe new player col.
-
col
NumberThe new player row.
-
row
Object
Returns:
Returns the instance of the Gridster Class.
set_dom_grid_height
()
Object
Set the current height of the parent grid.
Returns:
Returns the instance of the Gridster class.
set_dom_grid_width
()
Object
Set the current width of the parent grid.
Returns:
Returns the instance of the Gridster class.
set_placeholder
-
col
-
row
Put placeholder at the row and column specified.
Parameters:
-
col
NumberThe column to which we want to move the placeholder.
-
row
NumberThe row to which we want to move the placeholder.
Returns:
Returns the instance of the Gridster Class.
set_player
-
col
-
row
-
no_player
Sets the current position of the player
Parameters:
-
col
Number -
row
Number -
no_player
Boolean
Returns:
set_widget_max_size
-
$widget
-
max_size
Change widget size limits.
Parameters:
-
$widget
HTMLElement | NumberThe jQuery wrapped HTMLElement representing the widget or an index representing the desired widget.
-
max_size
ArrayMaximun size (in units) for width and height.
Returns:
Returns instance of gridster Class.
set_widget_min_size
-
$widget
-
min_size
Change widget size limits.
Parameters:
-
$widget
HTMLElement | NumberThe jQuery wrapped HTMLElement representing the widget or an index representing the desired widget.
-
min_size
ArrayMinimum size (in grid units) for width and height.
Returns:
Returns instance of gridster Class.
setup_resize
()
Gridster
Setup things required for resizing. Like build templates for drag handles.
Returns:
Returns instance of gridster Class.
sort_by_col_asc
-
widgets
Sorts an Array of grid coords objects by column (representing the grid coords of each widget) in ascending way.
Parameters:
-
widgets
ArrayArray of grid coords objects
Returns:
Returns the array sorted.
sort_by_row_and_col_asc
-
widgets
Sorts an Array of grid coords objects (representing the grid coords of each widget) placing first the empty cells upper left.
Parameters:
-
widgets
ArrayArray of grid coords objects
Returns:
Returns the array sorted.
sort_by_row_asc
-
widgets
Sorts an Array of grid coords objects (representing the grid coords of each widget) in ascending way.
Parameters:
-
widgets
ArrayArray of grid coords objects
Returns:
Returns the array sorted.
sort_by_row_desc
-
widgets
Sorts an Array of grid coords objects (representing the grid coords of each widget) in descending way.
Parameters:
-
widgets
ArrayArray of grid coords objects
Returns:
Returns the array sorted.
update_widget_dimensions
-
$widget
-
wgd
Update the width and height for a widgets coordinate data.
Parameters:
-
$widget
HTMLElementThe widget to update.
-
wgd
Objectwgd Current widget grid data (col, row, size_x, size_y).
Returns:
Returns the instance of the Gridster Class.
update_widget_position
-
grid_data
-
value
Update in the mapped array of positions the value of cells represented by
the grid coords object passed in the grid_data
param.
Parameters:
-
grid_data
ObjectThe grid coords object representing the cells to update in the mapped array.
-
value
HTMLElement | BooleanPass
false
or the jQuery wrapped HTMLElement, depends if you want to delete an existing position or add a new one.
Returns:
Returns the instance of the Gridster Class.
update_widgets_dimensions
()
Gridster
Update dimensions for all widgets in the grid.
Returns:
Returns the instance of the Gridster Class.
widgets_below
-
$el
Get widgets below a widget.
Parameters:
-
$el
ObjectThe jQuery wrapped HTMLElement.
Returns:
A jQuery collection of HTMLElements.
widgets_contraints
-
$widgets
See which of the widgets in the $widgets param collection can go to a upper row and which not.
Parameters:
-
$widgets
JQueryA jQuery wrapped collection of HTMLElements.
Returns:
Returns a literal Object with two keys: can_go_up
&
can_not_go_up
. Each contains a set of HTMLElements.