/*
* Ignatius Steven
* Tue, 14 Jan 2014 - 5:18:02 PM
*
* Angular JS Multi Select
* Creates a dropdown-like button with checkboxes. Accepts an array of object & modifies it based on the checkboxes status.
*
* Usage:
*
*
*
*
* or
*
*
* (*** be careful with browser compatibility)
*
* Attributes:
*
* list-items (REQUIRED):
* $scope variable. Array of objects such as
* [
* { firstName: "John", lastName: "Robert" , ....., selected: false },
* { firstName: "Jane", lastName: "Angel" , ....., selected: true },
* { firstName: "Luke", lastName: "Skywalker" , ....., selected: true },
* { firstName: "John", lastName: "Wayne" , ....., selected: true }
* ]
* item-label (String) (REQUIRED)
* The object property that you want to display on the button & checkboxes. Separate multiple values by space.
* Example: item-label="firstName lastName"
* item-ticker (String) (REQUIRED):
* Column name with a boolean value that represent the state of a checkbox. For example, in the list-items sample above,
* the item-ticker is "selected". So if selected === true, checkbox will be ticked. If selected === false, checkbox will not be ticked.
* If not specified, the default will be "selected"
* orientation (String - "vertical" | "horizontal")
* Orientation of the list of checkboxes.
* If not specified, the default will be "vertical".
* max-labels (String)
* Maximum number of items that will be displayed in the dropdown button. If not specified, will display all selected items.
* Example: "2" -> Using the list-items above, then button will display the first two selected: "Jane Angel, Luke Skywalker, ..."
* max-height (String)
* Maximum height of the list of checkboxes in pixels. Will show scrollbar on overflow.
* Example: "100".
* is-disabled (String - "true" | "false")
* Disable or enable the checkboxes.
* If not specified, the default will be "false".
*
*/
angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$timeout', '$compile' , function ( $timeout, $compile ) {
return {
restrict:
'AE',
replace:
true,
scope:
{
listItems : '=',
itemLabel : '@',
itemTicker : '@',
orientation : '@',
maxLabels : '@',
maxHeight : '@',
isDisabled : '=',
},
template:
'' +
'' +
'