Initializer
$(".selector").iconList(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | A map of option-value pairs to set on the widget. |
- Since:
- 5.0
Examples
Create a simple iconList for selecting multiple items.
HTML:
<h3 id="iconsLabel">My Icons</h3>
<ul id="icons1" aria-labelledby="iconsLabel">
<li data-value="b"><span class="fa fa-bus"></span><span class="label">Bus</span></li>
<li class="is-selected" data-value="c"><span class="fa fa-car"></span><span class="label">Car</span></li>
<li data-value="t"><span class="fa fa-taxi"></span><span class="label">Taxi</span></li>
...
</ul>
JavaScript:
$("#icons1").iconList({
multiple: true
});
This example creates an iconList for navigation. In this example #navList is the element that becomes the iconList widget.
HTML:
<h2 id="mainNav">Main Site Navigation</h2>
<div role="navigation">
<div id="navList" aria-labelledby="mainNav">
<a href=...>...</a>
...
</div>
</div>
JavaScript:
$("#navList").iconList({
navigation: true
});
Options
addItemSelector :boolean
If itemSelector option is true and the initial iconList markup does not include the markup needed to show the selector then this option should be set to true so that the markup is automatically added.
This is ignored if itemSelector is false.
The markup to show the checkbox selector is:
<span class="u-selector"></span>
The markup to show the radio button selector (used when multiple is false) is:
<span class="u-selector u-selector--single"></span>
Type:
- boolean
- Default Value:
- true
allowCopy :boolean
If true the selection can be copied to the clipboard using the browsers copy event.
Type:
- boolean
- Default Value:
- true
contextMenu :Object
A menu widget options object use to create the context menu.
Only specify one of contextMenu or contextMenuId and contextMenuAction. If none of contextMenu, contextMenuId or contextMenuAction are specified there is no context menu.
Type:
- Object
- Default Value:
- null
contextMenuAction :function
A callback function that is called when it is time to display a context menu. function( event ) The function is responsible for showing the context menu. It is given the event that caused this callback to be called.
In most cases it is simpler and more consistent to use the contextMenu option. Only specify one of contextMenu or contextMenuId and contextMenuAction. If none of contextMenu, contextMenuId or contextMenuAction are specified there is no context menu.
Type:
- function
- Default Value:
- null
contextMenuId :string
If option contextMenu is given then this is the element id to give the context menu created. This allows other code to interact with the created context menu widget.
If option contextMenu is not given then this is the element id of an existing menu widget.
Type:
- string
- Default Value:
- null
itemSelector :boolean
If true a selector control is added before the item icon and label. The selector is a checkbox if multiple is true and a radio button if multiple is false. The iconList markup must include the necessary markup for the checkbox selector if iconList#addItemSelector is false. See iconList#addItemSelector for the needed markup.
Type:
- boolean
- Default Value:
- false
label :boolean|string
This option only applies to the type to select feature. It is a jQuery selector for finding the label text of an item or true to use the text of the item or false to disable type to search.
Type:
- boolean | string
- Default Value:
- true
multiple :boolean
If true multiple items can be selected. If false at most one item can be selected.
Must be false when navigation option is true.
Type:
- boolean
- Default Value:
- false
navigation :boolean
When true changes the mode of widget to navigation otherwise the mode is selection. This option can't be changed after create.
Type:
- boolean
- Default Value:
- false
Events
activate
Properties:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
event |
Event | jQuery event object. |
||||||
data |
object | Additional data for the event.
Properties
|
Examples
Initialize the iconList with the activate
callback specified:
$( ".selector" ).iconList({
activate: function( event, data ) {}
});
Bind an event listener to the iconlistactivate
event:
$( ".selector" ).on( "iconlistactivate", function( event, data ) {} );
selectionchange
Properties:
Name | Type | Description |
---|---|---|
event |
Event | jQuery event object. |
Examples
Initialize the iconList with the selectionChange
callback specified:
$( ".selector" ).iconList({
selectionChange: function( event ) {}
});
Bind an event listener to the iconlistselectionchange
event:
$( ".selector" ).on( "iconlistselectionchange", function( event ) {} );
Methods
focus()
Set focus to the iconList. The item that last had focus is focused or if no item had focus the first item is focused.
getColumns() → {number}
Returns the number of columns in the iconList.
Returns:
- Type
- number
getRows() → {number}
Returns the number of rows in the iconList.
Returns:
- Type
- number
getSelection() → {jQuery}
Returns the set of selected items. If there is no selection the empty set is returned.
Returns:
- Type
- jQuery
getSelectionValues() → {Array.<string>}
Returns the values, from the data-value attributes, of all the selected items. If there is no selection an empty array is returned.
Returns:
- Type
- Array.<string>
refresh()
Call refresh if the contents of the list changes or if the size of the container changes.
resize()
This method must be called if the size of the container changes so that the rows and columns can be recalculated.
setSelection(items$, focusopt, pNoNotifyopt)
Sets the iconList selection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
items$ |
jQuery | A jQuery object with the items to select. An empty jQuery set will clear the selection. | |
focus |
boolean |
<optional> |
If true the first item in items$ will be focused. |
pNoNotify |
boolean |
<optional> |
If true the selection change event will be suppressed. |