Reorderer API - v0.3
Advanced use of the Reorderer
For cases where need more control over the configuration of your Reorderer instance, there is a constructor function that allows you to specify the Layout Handler - v0.3 used by the Reorderer, and offers a means to specify your items using functions instead of jQuery selectors. To use this advanced constructor, you need to:
Pass the container of the orderable elements itself to the Reorderer upon instantiation.
Specify a Javascript function that returns a list of all the orderable elements within the container. This function is passed to the Reorderer upon instantiation.
Specify a Layout Handler - v0.3 to deal with the spatial arrangement of orderable elements. The Reorderer includes several layout handlers to choose from out of the box, which will work with most types of markup supported by the Reorderer. The layout handler is passed to the Reorderer upon instantiation.
Optional:
Provide the Layout Handler - v0.3 with a callback to communicate ordering changes to the server.
Specify elements within the container which can be selected, i.e. which should be focused by the arrow keys, but which may or may not be movable.
Specify valid drop targets within the container.
Specify an element within the given
movablethat is to be used as a 'handle' for the mouse-based drag and drop of the movable.Configure the keystrokes to be used.
Customize the avatar used with mouse-based drag and drop.
Create CSS styles for desired appearance of orderable elements when selected and dragging.
Constructors
Reorderer(containerEl, findMovables, layoutHandler[, options]);
Reorderer(containerEl, findItems, layoutHandler[, options]);
Parameters
containerEl
The containerEl parameter is the root node of the Reorderer.
findMovables
The findMovables parameter is a function that returns all of the movable elements in the container.
findItems
The findItems parameter is an object containing a number of functions:
findItems {
movables: function(), // required
selectables: function(), // optional
dropTargets: function(), // optional
grabHandle: function(movable) // optional
};
movables: A function that returns all of the movable elements in the container. This is the only required item, but if it is the only function used, it can be passed directly to the constructor, as in the first form of the constructor above.
selectables: A function that returns all of the selectable elements in the container. This can be used if the container included elements that the user wishes to be included in the keyboard tab order, but which are not to be movable. All movable elements must also be selectable, so the element list returned by the selectables function must include all of the elements returned by the movables function. If selectables is not provided, the movables function will be used.
dropTargets: A function that returns all of the elements that can be used as drop targets for the mouse-based drag and drop functionality. If dropTargets is not provided, the movables function will be used.
grabhandle: A function that returns the element within the given movable that is to be used as a 'handle' for the mouse-based drag and drop of the movable. This can be used if the implementer wishes to restrict the user to click only on a portion of the movable item. If grabHandle is not provided, the entire movable element will be used.
layoutHandler
The layoutHandler parameter is an instance of a Layout Handler - v0.3.
options
The options parameter is an optional collection of name-value pairs that configure the Reorderer:
Name | Description | Values | Default |
|---|---|---|---|
| indicates the role, or general use, for this instance of the Reorderer | | |
| an object containing sets of keycodes to use for directional navigation, and for the modifier key used for moving a movable item. | The object must be a list of objects containing the following keys: |
fluid.defaultKeysets = [{
modifier : function (evt) {
return evt.ctrlKey;
},
up : fluid.keys.UP,
down : fluid.keys.DOWN,
right : fluid.keys.RIGHT,
left : fluid.keys.LEFT
},
{
modifier : function (evt) {
return evt.ctrlKey;
},
up : fluid.keys.i,
down : fluid.keys.m,
right : fluid.keys.k,
left : fluid.keys.j
}];
|
| an object containing class names for styling the Reorderer. See fluid:below for a discussion of CSS styling of the Reorderer | The object may contain any of the keys defined in the |
var defaultCssClassNames = {
defaultStyle: "orderable-default",
selected: "orderable-selected",
dragging: "orderable-dragging",
mouseDrag: "orderable-dragging",
hover: "orderable-hover",
dropMarker: "orderable-drop-marker",
avatar: "orderable-avatar"
};
|
| a function that returns a valid DOM node to be used as the dragging avatar |
| The item being dragged will be cloned |
| the ID of an element that should be displayed if users attempt to move an item to a location where movement is not permitted |
| (none) |
| the ID of the element containing any instructional messages |
| "message-bundle:" |
CSS Classes
The Reorderer applies CSS classes to orderable items, and updates them as they are moved. These classes can be used to apply visual cues to the various states of the orderable items. The class names are configurable. The default class names are:
orderable-default - This class is applied to elements in their default state.
orderable-selected - This class is applied to the element that has been selected. The selected item can then be moved using keystrokes.
orderable-hover - This class is applied to orderable elements when the mouse hovers over them.
orderable-dragging - This class is applied to the orderable element that is currently being moved using the keyboard.
orderable-mouseDrag - This class is applied to the orderable element that is currently being moved using the mouse.
orderable-avatar - This class is applied to the avatar, which defaults to the image of the orderable element as it is being dragged about by the mouse.
orderable-drop-marker - This class is applied to the drop target indicator when the mouse is used to drag an item.