tableDrag

Drupal. tableDrag

new tableDrag(table, tableSettings)

Source:
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().

Members

$table :jQuery

Source:
Type:

changed :bool

Source:
Whether anything in the entire table has changed.
Type:
  • bool

(nullable) dragObject :HTMLElement

Source:
Used to hold information about a current drag operation.
Type:
  • HTMLElement

indentAmount :number

Source:
Type:
  • number

indentCount :number

Source:
Total width of indents, set in makeDraggable.
Type:
  • number

indentEnabled :bool

Source:
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

maxDepth :number

Source:
Maximum amount of allowed parenting.
Type:
  • number

(nullable) oldRowElement :HTMLElement

Source:
Remember the previous element.
Type:
  • HTMLElement

(nullable) oldY :number

Source:
Used to determine up or down direction from last mouse move.
Type:
  • number

(nullable) rowObject :HTMLElement

Source:
Provides operations for row manipulation.
Type:
  • HTMLElement

rtl :number

Source:
Direction of the table.
Type:
  • number

(nullable) scrollInterval :number

Source:
Type:
  • number

scrollSettings :object

Source:
Properties:
Name Type Description
amount number
interval number
trigger number
Configure the scroll settings.
Type:
  • object

scrollY :number

Source:
Type:
  • number

striping :bool

Source:
Type:
  • bool

table :HTMLElement

Source:
Type:
  • HTMLElement

tableSettings :object

Source:
Type:
  • object

windowHeight :number

Source:
Type:
  • number

Methods

addColspanClass(columnIndex) → {function}

Source:
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.
Returns:
Function to add colspan class.
Type
function

checkScroll(cursorY) → {number}

Source:
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)

Source:
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)

Source:
Hide or display weight columns. Triggers an event on change.
Parameters:
Name Type Description
displayWeight bool 'true' will show weight columns.
Fires:

dragRow(event, self) → {bool|undefined}

Source:
Pointer movement handler, bound to document.
Parameters:
Name Type Description
event jQuery.Event The pointer event.
self Drupal.tableDrag The tableDrag instance.
Returns:
Undefined if no dragObject is defined, false otherwise.
Type
bool | undefined

dragStart(event, self, item)

Source:
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.

dropRow(event, self)

Source:
Pointerup behavior.
Parameters:
Name Type Description
event jQuery.Event The pointer event.
self Drupal.tableDrag The tableDrag instance.

findDropTargetRow(x, y) → {*}

Source:
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}

Source:
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()

Source:
Hide the columns containing weight/parent form elements. Undo showColumns().

initColumns()

Source:
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.

makeDraggable(item)

Source:
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.

onDrag() → {null}

Source:
Stub function. Allows a custom handler when a row begins dragging.
Returns:
Returns null when the stub function is used.
Type
null

onDrop() → {null}

Source:
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}

Source:
Get the coordinates from the event (allowing for browser differences).
Parameters:
Name Type Description
event jQuery.Event The pointer event.
Returns:
An object with `x` and `y` keys indicating the position.
Type
object

restripeTable()

Source:
Command to restripe table properly.

row(tableRow, method, indentEnabled, maxDepth, addClasses)

Source:
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}

Source:
Find the target used within a particular row and group.
Parameters:
Name Type Description
group string Group selector.
row HTMLElement The row HTML element.
Returns:
The table row settings.
Type
object

setScroll(scrollAmount)

Source:
Set the scroll for the table.
Parameters:
Name Type Description
scrollAmount number The amount of scroll to apply to the window.

showColumns()

Source:
Show the columns containing weight/parent form elements. Undo hideColumns().

toggleColumns()

Source:
Toggle the weight column depending on 'showWeight' value. Store only default override.

updateField(changedRow, group)

Source:
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)

Source:
After the row is dropped, update the table fields.
Parameters:
Name Type Description
changedRow HTMLElement DOM object for the row that was just dropped.