new exports()
- Description:
Constructor.
- Source:
Constructor.
The class constructor.
The only param this method gets is a constructor with all the mandatory and optional component data. Component will receive the same descriptor as create method param.
This method will call the "create" method before registering the component into the reactive module. This way any component can add default selectors and events.
Name | Type | Description |
---|---|---|
descriptor |
descriptor | data to create the object. |
Class constructor.
Name | Type | Description |
---|---|---|
reactive |
CourseEditor | the course editor object |
Setup the core/tree keyboard navigation.
Name | Type | Description |
---|---|---|
mainElement |
Element | undefined | an alternative main element in case it is not from the parent component |
selectors |
Object | undefined | alternative selectors |
preventcache |
boolean | if the elements cache must be disabled. |
Constructor.
To make a list draggable, create a new instance of this object, passing the necessary config. For example: { // Selector for the list (or lists) to be reordered. list: 'ul.my-list',
// Selector, relative to the list selector, for the items that can be moved.
item: '> li',
// While the proxy is being dragged, this class is added to the item being moved.
// You can probably use "osep-itemmoving" here.
itemMovingClass: "osep-itemmoving",
// This is a callback which, when called with the DOM node for an item,
// returns the string that uniquely identifies each item.
// Therefore, the result of the drag action will be represented by the array
// obtained by calling this method on each item in the list in order.
idGetter: function(item) { return node.id; },
// Function that will be called when a re-order starts (optional, can be not set).
// Useful if you need to save information about the initial state.
// This function should have two parameters. The first will be a
// jQuery object for the list that was reordered, the second will
// be the jQuery object for the item moved - which will not yet have been moved.
// Note, it is quite possible for reorderStart to be called with no
// subsequent call to reorderDone.
reorderStart: function($list, $item) { ... }
// Function that will be called when a drag has finished, and the list
// has been reordered. This function should have three parameters. The first will be
// a jQuery object for the list that was reordered, the second will be the jQuery
// object for the item moved, and the third will be the new order, which is
// an array of ids obtained by calling idGetter on each item in the list in order.
// This callback will only be called in the new order is actually different from the old order.
reorderDone: function($list, $item, newOrder) { ... }
// Function that is always called when a re-order ends (optional, can be not set)
// whether the order has changed. Useful if you need to undo changes made
// in reorderStart, since reorderDone is only called if the new order is different
// from the original order.
reorderEnd: function($list, $item) { ... }
}
There is a subtlety, If you have items in your list that do not have a drag handle, they are considered to be placeholders in otherwise empty containers.
Name | Type | Description |
---|---|---|
config |
Object | As above. |