OTRS API Reference JavaScript

Namespace: Core.UI.DnD

Core.UI. DnD

Drag and Drop.
Author:
  • OTRS AG
Source:

Methods

(static) Sortable($Elements, Options)

This function initializes the sortable nature on the specified Elements. Child elements with the class "CanDrag" can then be sorted with Drag and Drop.
Parameters:
Name Type Description
$Elements jQueryObject The elements which should be made sortable.
Options Object Hash which contains the config options.
Properties
Name Type Attributes Description
Handle String <optional>
To restrict the dragging start to a sub-element (e.g. a h2).
Containment String <optional>
Constrains dragging to within the bounds of the specified element. Can be a DOM element, 'parent', 'document', 'window', or a jQuery selector.
Axis String <optional>
If defined, the items can be dragged only horizontally or vertically. Possible values:'x', 'y'.
Items String <optional>
To restrict the draggable child elements with a selector.
Placeholder String <optional>
Class to give to the placeholder div which indicates the drop area.
Tolerance String <optional>
This is the way the reordering behaves during drag. Possible values: 'intersect', 'pointer'. In some setups, 'pointer' is more natural. intersect: draggable overlaps the droppable at least 50% (this is the default value). pointer: mouse pointer overlaps the droppable.
Opacity Number <optional>
Defines the opacity of the helper while sorting. From 0.01 to 1.
Opacity Number <optional>
Only start visible dragging after a certain minimum pixel distance.
Source:
Example
Core.UI.DnD.Sortable(
        $(".SidebarColumn"),
            {
                Handle: '.Header h2',
                Containment: '.SidebarColumn',
                Axis: 'y',
                Items: '.CanDrag',
                Placeholder: 'DropPlaceholder',
                Tolerance: 'pointer',
                Distance: 15,
                Opacity: 0.9
            }
        );