Control.Selection
Programmable object selection API for Prototype.
Selection tutorial is coming soon.
DOM Modifications
Control.Selection.load() will insert div#control_selection as a child of document.body. Control.Selection.DragProxy.load() will be called if the drag_proxy option in Control.Selection.load() is set to true, and will insert div#control_selection_drag_proxy as a child of document.body.
Class
| Return | Name | Description |
| null | load([Hash options]) | |
| null | addSelectable(Element selectable [,object related [, mixed activation_targets [,function activation_target_callback]]]) | See Control.Selection.addSelectable(). |
| null | deselect() | |
| null | disable() | |
| null | enable() | Must be explicitly called. |
| null | recalculateLayout() | Call when the page layout changes. Calculates dimensions and position of all selectable elements. |
| null | removeSelectable(Element selectable) | |
| null | select(mixed selection) | A single Element, or an array of Elements. Will destroy the existing selection. |
| bool | active | |
| array | elements | Returns an array of all selectable elements that are currently selected. |
| array | objects | See Accessing a Selectable's Related Object |
Control.Selection.addSelectable()
related is an object that will become available in the Control.Selection.objects array. activation_targets is an Element, or an array of Elements, all of which interact with the DragProxy. The simplest explanation is in the Windows Explorer/Finder column views. Each file/folder row is selectable, but you must click directly on the file or folder icon & label (activation_targets) to drag the items.
Class Options
Class options are set once during load(), or can be set via Control.Selection.options.option_name = value;
| Type | Name | Default | Description |
| bool | drag_proxy | false | |
| Hash | drag_proxy_options | {} | |
| string | selection_id | 'control_selection' | id of the selection div. |
| Hash | selection_style | {zIndex: 999, cursor: 'default', border: '1px dotted #000'} | Hash of styles to apply to the selection div. |
Events
| Name | Description |
| change(array selectable_elements, array related_objects) | Contains all currently selected elements/objects, does not contain the delta. |
| deselected(Element selectable, mixed related) | |
| selected(Element selectable, mixed related) |
Control.Selection.DragProxy Class
| Return | Name | Description |
| bool | active |
Control.Selection.DragProxy Events
| Name | Description |
| start(Element dragproxy_container,array selectable_elements) | |
| stop() |