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:
-
elHTMLElementThe 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:
-
rowNumberThe row for the new faux cell.
-
colNumberThe 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:
-
colsNumberThe 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:
-
rowsNumberThe 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:
-
$wObject
Returns:
Returns instance of gridster Class.
add_style_tag
-
css
Injects the given CSS as string to the head of the document.
Parameters:
-
cssStringThe 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_dataObjectThe 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:
-
htmlString | 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_dataObjectThe 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_dataNumberThe current grid coords object of the widget.
-
colNumberThe target column.
-
rowNumberThe 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_dataObjectThe 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_dataObjectThe grid coords object that represents the widget.
-
colObjectThe col to check.
-
rowObjectThe 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:
-
$widgetHTMLElementThe 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:
-
removeBooleanIf 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:
-
$widgetHTMLElementThe 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:
-
colNumberThe column where the group of cells begin.
-
rowNumberThe row where the group of cells begin.
-
size_xNumberThe number of columns that the group of cells occupy.
-
size_yNumberThe 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:
-
$widgetHTMLElementThe jQuery wrapped HTMLElement representing the widget.
-
size_xNumberThe number of cols that will occupy the widget.
-
size_yNumberThe number of rows that will occupy the widget.
-
colNumberThe 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:
-
$widgetHTMLElement$widget The jQuery wrapped HTMLElement
-
max_colsNumbermax number of columns a widget can take up
-
max_rowsNumbermax 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_dataObject -
callbackFunctionThe 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_dataObjectThe grid coords object that represents the widget.
-
callbackFunctionThe 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_dataObjectThe grid coords object that represents the widget.
-
callbackFunctionThe 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:
-
colNumberThe column to start iterating.
-
rowNumberThe row to start iterating.
-
callbackFunctionThe function to execute on each widget iteration. The value of
thisinside 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:
-
colNumberThe column to start iterating.
-
rowNumberThe row to start iterating.
-
callbackFunctionThe function to execute on each widget iteration. The value of
thisinside 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:
-
rowsNumberNumber of columns.
-
colsNumberNumber 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_dataObjectThe 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
theupper_rowsarray. Iteration starts from row specified inmin_row`.
Parameters:
-
widget_grid_dataObjectThe actual grid coords object of the player.
-
upper_rowsArrayAn array with columns as index and arrays of valid rows as values.
-
min_rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe row to check.
Returns:
Returns true or false.
is_placeholder_in_col
-
col
Determines if the placeholder is currently over the column given.
Parameters:
-
colNumberThe 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_elNumber | 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
colNumberThe column to check.
-
rowNumberThe 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:
-
$widgetsJQueryA jQuery collection of HTMLElements representing the widgets you want to move.
-
to_colNumberThe column to which we want to move the widgets.
-
to_rowNumberThe 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:
-
$widgetHTMLElementThe jQuery wrapped HTMLElement of the widget is going to be moved.
-
new_colNumberthe column number to be set in widget
-
new_rowNumberthe row number to be set in widget
-
callbackFunctionis 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:
-
$widgetJQueryThe jQuery object representing the widget you want to move.
-
y_unitsNumberThe 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:
-
$widgetHTMLElementThe jQuery wrapped HTMLElement of the widget is going to be moved.
-
rowObject- 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:
-
$widgetHTMLElementThe 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:
-
$widgetHTMLElementThe jQuery wrapped HTMLElement representing the widget to mutate.
-
wgdObjectCurrent widget grid data (col, row, size_x, size_y).
-
new_wgdObjectNew 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_xNumberThe nº of rows the widget occupies horizontally.
-
size_yNumberThe 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:
-
eventEventThe original browser event
-
uiObjectA 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_callbackFunctionFunction executed when a new column begins to be overlapped. The column is passed as first argument.
-
stop_callbackFunctionFunction 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_callbackFunctionFunction executed when a new row begins to be overlapped. The row is passed as first argument.
-
end_callbackFunctionFunction 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:
-
eventEventThe original browser event
-
uiObjectA 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:
-
eventEventThe original browser event
-
uiObjectA 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:
-
colNumberThe 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:
-
rowNumberThe 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:
-
eventEventThe original browser event
-
uiObjectA prepared ui object with useful drag-related data
on_stop_drag
-
event -
ui
This function is executed when the player stops being dragged.
Parameters:
-
eventEventThe original browser event
-
uiObjectA 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:
-
colNumberThe 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:
-
rowNumberThe 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:
-
eventEventThe original browser event
-
uiObjectA 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:
-
$elHTMLElement | 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:
-
callbackFunctionFunction 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:
-
colNumberThe column where the group of cells begin.
-
rowNumberThe row where the group of cells begin.
-
size_xNumberThe number of columns that the group of cells occupy.
-
size_yNumberThe number of rows that the group of cells occupy.
-
excludeHTMLElementExclude 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_dataObjectThe 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:
-
elHTMLElementThe 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:
-
$widgetHTMLElementThe jQuery wrapped HTMLElement representing the widget.
-
[size_x]Number optionalThe number of columns that will occupy the widget. By default
size_xis 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:
-
optionsObject
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:
-
colNumberThe new player col.
-
colNumberThe new player row.
-
rowObject
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:
-
colNumberThe column to which we want to move the placeholder.
-
rowNumberThe 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:
-
colNumber -
rowNumber -
no_playerBoolean
Returns:
set_widget_max_size
-
$widget -
max_size
Change widget size limits.
Parameters:
-
$widgetHTMLElement | NumberThe jQuery wrapped HTMLElement representing the widget or an index representing the desired widget.
-
max_sizeArrayMaximun 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:
-
$widgetHTMLElement | NumberThe jQuery wrapped HTMLElement representing the widget or an index representing the desired widget.
-
min_sizeArrayMinimum 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:
-
widgetsArrayArray 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:
-
widgetsArrayArray 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:
-
widgetsArrayArray 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:
-
widgetsArrayArray 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:
-
$widgetHTMLElementThe widget to update.
-
wgdObjectwgd 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_dataObjectThe grid coords object representing the cells to update in the mapped array.
-
valueHTMLElement | BooleanPass
falseor 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:
-
$elObjectThe 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:
-
$widgetsJQueryA 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.