new tableDrag(table, tableSettings)
Provides table and field manipulation.
Parameters:
Name | Type | Description |
---|---|---|
table |
HTMLElement | DOM object for the table to be made draggable. |
tableSettings |
object | Settings for the table added via drupal_add_dragtable(). |
- Source:
Members
$table :jQuery
Type:
- Source:
$table :jQuery
Type:
- Source:
(nullable) $toggleWeightButton :jQuery
Type:
- Source:
changed :bool
Whether anything in the entire table has changed.
Type:
- bool
- Source:
changed :bool
Whether anything in the entire table has changed.
Type:
- bool
- Source:
(nullable) dragObject :HTMLElement
Used to hold information about a current drag operation.
Type:
- HTMLElement
- Source:
(nullable) dragObject :HTMLElement
Used to hold information about a current drag operation.
Type:
- HTMLElement
- Source:
indentAmount :number
Type:
- number
- Source:
indentAmount :number
Type:
- number
- Source:
indentCount :number
Total width of indents, set in makeDraggable.
Type:
- number
- Source:
indentCount :number
Total width of indents, set in makeDraggable.
Type:
- number
- Source:
indentEnabled :bool
Check this table's settings for parent relationships.
For efficiency, large sections of code can be skipped if we don't need to track horizontal movement and indentations.
Type:
- bool
- Source:
indentEnabled :bool
Check this table's settings for parent relationships.
For efficiency, large sections of code can be skipped if we don't need to track horizontal movement and indentations.
Type:
- bool
- Source:
maxDepth :number
Maximum amount of allowed parenting.
Type:
- number
- Source:
maxDepth :number
Maximum amount of allowed parenting.
Type:
- number
- Source:
(nullable) oldRowElement :HTMLElement
Remember the previous element.
Type:
- HTMLElement
- Source:
(nullable) oldRowElement :HTMLElement
Remember the previous element.
Type:
- HTMLElement
- Source:
(nullable) oldY :number
Used to determine up or down direction from last mouse move.
Type:
- number
- Source:
(nullable) oldY :number
Used to determine up or down direction from last mouse move.
Type:
- number
- Source:
(nullable) rowObject :HTMLElement
Provides operations for row manipulation.
Type:
- HTMLElement
- Source:
(nullable) rowObject :HTMLElement
Provides operations for row manipulation.
Type:
- HTMLElement
- Source:
rtl :number
Direction of the table.
Type:
- number
- Source:
rtl :number
Direction of the table.
Type:
- number
- Source:
(nullable) scrollInterval :number
Type:
- number
- Source:
(nullable) scrollInterval :number
Type:
- number
- Source:
scrollSettings :object
Configure the scroll settings.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
amount |
number | |
interval |
number | |
trigger |
number |
- Source:
scrollSettings :object
Configure the scroll settings.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
amount |
number | |
interval |
number | |
trigger |
number |
- Source:
scrollY :number
Type:
- number
- Source:
scrollY :number
Type:
- number
- Source:
striping :bool
Type:
- bool
- Source:
striping :bool
Type:
- bool
- Source:
table :HTMLElement
Type:
- HTMLElement
- Source:
table :HTMLElement
Type:
- HTMLElement
- Source:
tableSettings :object
Type:
- object
- Source:
tableSettings :object
Type:
- object
- Source:
windowHeight :number
Type:
- number
- Source:
windowHeight :number
Type:
- number
- Source:
Methods
addColspanClass(columnIndex) → {function}
Mark cells that have colspan.
In order to adjust the colspan instead of hiding them altogether.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | The column index to add colspan class to. |
- Source:
Returns:
Function to add colspan class.
- Type
- function
addColspanClass(columnIndex) → {function}
Mark cells that have colspan.
In order to adjust the colspan instead of hiding them altogether.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | The column index to add colspan class to. |
- Source:
Returns:
Function to add colspan class.
- Type
- function
checkScroll(cursorY) → {number}
Check the suggested scroll of the table.
Parameters:
Name | Type | Description |
---|---|---|
cursorY |
number | The Y position of the cursor. |
- Source:
Returns:
The suggested scroll.
- Type
- number
checkScroll(cursorY) → {number}
Check the suggested scroll of the table.
Parameters:
Name | Type | Description |
---|---|---|
cursorY |
number | The Y position of the cursor. |
Returns:
The suggested scroll.
- Type
- number
copyDragClasses(sourceRow, targetRow, group)
Copy all tableDrag related classes from one row to another.
Copy all special tableDrag classes from one row's form elements to a different one, removing any special classes that the destination row may have had.
Parameters:
Name | Type | Description |
---|---|---|
sourceRow |
HTMLElement | The element for the source row. |
targetRow |
HTMLElement | The element for the target row. |
group |
string | The group selector. |
- Source:
copyDragClasses(sourceRow, targetRow, group)
Copy all tableDrag related classes from one row to another.
Copy all special tableDrag classes from one row's form elements to a different one, removing any special classes that the destination row may have had.
Parameters:
Name | Type | Description |
---|---|---|
sourceRow |
HTMLElement | The element for the source row. |
targetRow |
HTMLElement | The element for the target row. |
group |
string | The group selector. |
displayColumns(displayWeight)
Hide or display weight columns. Triggers an event on change.
Parameters:
Name | Type | Description |
---|---|---|
displayWeight |
bool | 'true' will show weight columns. |
- Source:
Fires:
displayColumns(displayWeight)
Hide or display weight columns. Triggers an event on change.
Parameters:
Name | Type | Description |
---|---|---|
displayWeight |
bool | 'true' will show weight columns. |
- Source:
Fires:
dragRow(event, self) → {bool|undefined}
Pointer movement handler, bound to document.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
self |
Drupal.tableDrag | The tableDrag instance. |
- Source:
Returns:
Undefined if no dragObject is defined, false otherwise.
- Type
- bool | undefined
dragRow(event, self) → {bool|undefined}
Pointer movement handler, bound to document.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
self |
Drupal.tableDrag | The tableDrag instance. |
- Source:
Returns:
Undefined if no dragObject is defined, false otherwise.
- Type
- bool | undefined
dragStart(event, self, item)
Pointer event initiator, creates drag object and information.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The event object that trigger the drag. |
self |
Drupal.tableDrag | The drag handle. |
item |
HTMLElement | The item that is being dragged. |
- Source:
dragStart(event, self, item)
Pointer event initiator, creates drag object and information.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The event object that trigger the drag. |
self |
Drupal.tableDrag | The drag handle. |
item |
HTMLElement | The item that is being dragged. |
- Source:
dropRow(event, self)
Pointerup behavior.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
self |
Drupal.tableDrag | The tableDrag instance. |
- Source:
dropRow(event, self)
Pointerup behavior.
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
self |
Drupal.tableDrag | The tableDrag instance. |
- Source:
findDropTargetRow(x, y) → {*}
Find the row the mouse is currently over.
This row is then taken and swapped with the one being dragged.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x coordinate of the mouse on the page (not the screen). |
y |
number | The y coordinate of the mouse on the page (not the screen). |
- Source:
Returns:
The drop target row, if found.
- Type
- *
findDropTargetRow(x, y) → {*}
Find the row the mouse is currently over.
This row is then taken and swapped with the one being dragged.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x coordinate of the mouse on the page (not the screen). |
y |
number | The y coordinate of the mouse on the page (not the screen). |
Returns:
The drop target row, if found.
- Type
- *
getPointerOffset(target, event) → {object}
Get the event offset from the target element.
Given a target element and a pointer event, get the event offset from that element. To do this we need the element's position and the target position.
Parameters:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The target HTML element. |
event |
jQuery.Event | The pointer event. |
- Source:
Returns:
An object with x
and y
keys indicating the position.
- Type
- object
getPointerOffset(target, event) → {object}
Get the event offset from the target element.
Given a target element and a pointer event, get the event offset from that element. To do this we need the element's position and the target position.
Parameters:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The target HTML element. |
event |
jQuery.Event | The pointer event. |
Returns:
An object with x
and y
keys indicating the position.
- Type
- object
hideColumns()
Hide the columns containing weight/parent form elements.
Undo showColumns().
- Source:
hideColumns()
Hide the columns containing weight/parent form elements.
Undo showColumns().
- Source:
initColumns()
Initialize columns containing form elements to be hidden by default.
Identify and mark each cell with a CSS class so we can easily toggle show/hide it. Finally, hide columns if user does not have a 'Drupal.tableDrag.showWeight' localStorage value.
- Source:
initColumns()
Initialize columns containing form elements to be hidden by default.
Identify and mark each cell with a CSS class so we can easily toggle show/hide it. Finally, hide columns if user does not have a 'Drupal.tableDrag.showWeight' localStorage value.
- Source:
makeDraggable(item)
Take an item and add event handlers to make it become draggable.
Parameters:
Name | Type | Description |
---|---|---|
item |
HTMLElement | The item to add event handlers to. |
- Source:
makeDraggable(item)
Take an item and add event handlers to make it become draggable.
Parameters:
Name | Type | Description |
---|---|---|
item |
HTMLElement | The item to add event handlers to. |
- Source:
onDrag() → {null}
Stub function. Allows a custom handler when a row begins dragging.
- Source:
Returns:
Returns null when the stub function is used.
- Type
- null
onDrag() → {null}
Stub function. Allows a custom handler when a row begins dragging.
Returns:
Returns null when the stub function is used.
- Type
- null
onDrop() → {null}
Stub function. Allows a custom handler when a row is dropped.
- Source:
Returns:
Returns null when the stub function is used.
- Type
- null
onDrop() → {null}
Stub function. Allows a custom handler when a row is dropped.
Returns:
Returns null when the stub function is used.
- Type
- null
pointerCoords(event) → {object}
Get the coordinates from the event (allowing for browser differences).
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
- Source:
Returns:
An object with x
and y
keys indicating the position.
- Type
- object
pointerCoords(event) → {object}
Get the coordinates from the event (allowing for browser differences).
Parameters:
Name | Type | Description |
---|---|---|
event |
jQuery.Event | The pointer event. |
- Source:
Returns:
An object with x
and y
keys indicating the position.
- Type
- object
restripeTable()
Command to restripe table properly.
- Source:
restripeTable()
Command to restripe table properly.
row(tableRow, method, indentEnabled, maxDepth, addClasses)
Constructor to make a new object to manipulate a table row.
Parameters:
Name | Type | Description |
---|---|---|
tableRow |
HTMLElement | The DOM element for the table row we will be manipulating. |
method |
string | The method in which this row is being moved. Either 'keyboard' or 'mouse'. |
indentEnabled |
bool | Whether the containing table uses indentations. Used for optimizations. |
maxDepth |
number | The maximum amount of indentations this row may contain. |
addClasses |
bool | Whether we want to add classes to this row to indicate child relationships. |
- Source:
row(tableRow, method, indentEnabled, maxDepth, addClasses)
Constructor to make a new object to manipulate a table row.
Parameters:
Name | Type | Description |
---|---|---|
tableRow |
HTMLElement | The DOM element for the table row we will be manipulating. |
method |
string | The method in which this row is being moved. Either 'keyboard' or 'mouse'. |
indentEnabled |
bool | Whether the containing table uses indentations. Used for optimizations. |
maxDepth |
number | The maximum amount of indentations this row may contain. |
addClasses |
bool | Whether we want to add classes to this row to indicate child relationships. |
rowSettings(group, row) → {object}
Find the target used within a particular row and group.
Parameters:
Name | Type | Description |
---|---|---|
group |
string | Group selector. |
row |
HTMLElement | The row HTML element. |
- Source:
Returns:
The table row settings.
- Type
- object
rowSettings(group, row) → {object}
Find the target used within a particular row and group.
Parameters:
Name | Type | Description |
---|---|---|
group |
string | Group selector. |
row |
HTMLElement | The row HTML element. |
- Source:
Returns:
The table row settings.
- Type
- object
setScroll(scrollAmount)
Set the scroll for the table.
Parameters:
Name | Type | Description |
---|---|---|
scrollAmount |
number | The amount of scroll to apply to the window. |
- Source:
setScroll(scrollAmount)
Set the scroll for the table.
Parameters:
Name | Type | Description |
---|---|---|
scrollAmount |
number | The amount of scroll to apply to the window. |
showColumns()
Show the columns containing weight/parent form elements.
Undo hideColumns().
- Source:
showColumns()
Show the columns containing weight/parent form elements.
Undo hideColumns().
- Source:
toggleColumns()
Toggle the weight column depending on 'showWeight' value.
Store only default override.
- Source:
toggleColumns()
Toggle the weight column depending on 'showWeight' value.
Store only default override.
- Source:
updateField(changedRow, group)
After the row is dropped, update a single table field.
Parameters:
Name | Type | Description |
---|---|---|
changedRow |
HTMLElement | DOM object for the row that was just dropped. |
group |
string | The settings group on which field updates will occur. |
- Source:
updateField(changedRow, group)
After the row is dropped, update a single table field.
Parameters:
Name | Type | Description |
---|---|---|
changedRow |
HTMLElement | DOM object for the row that was just dropped. |
group |
string | The settings group on which field updates will occur. |
updateFields(changedRow)
After the row is dropped, update the table fields.
Parameters:
Name | Type | Description |
---|---|---|
changedRow |
HTMLElement | DOM object for the row that was just dropped. |
- Source:
updateFields(changedRow)
After the row is dropped, update the table fields.
Parameters:
Name | Type | Description |
---|---|---|
changedRow |
HTMLElement | DOM object for the row that was just dropped. |