Alloy UI

aui-rating  1.0.1

 
Filters

Class Rating - extends Component

Known Subclasses:
ThumbRating

A base class for Rating, providing:
  • A non-obstrusive star rating control
  • Could be based on a set of radio input boxes
Quick Example:
var instance = new A.Rating({
boundingBox: '#rating',
defaultSelected: 3,
disabled: false,
label: 'Label'
}).render();
Check the list of Configuration Attributes available for Rating.

Constructor

Rating ( config )
Parameters:
config <Object> Object literal specifying widget configuration properties.

Properties

Rating.ATTRS - static Object

Static property used to define the default attribute configuration for the Rating.

Rating.NAME - static String

Static property provides a string to identify the class.

StarRating.HTML_PARSER - static Object

Object hash, defining how attribute values are to be parsed from markup contained in the widget's content box.

Properties inherited from Attribute:

Properties inherited from Base:

Properties inherited from Component:

Configuration Attributes

canReset - boolean

If true could be reseted (i.e., have no values selected).
Default Value: true

defaultSelected - writeonce Number

The number of selected starts when the Rating render.
Default Value: 0

disabled - boolean

Whether the Rating is disabled or not. Disabled Ratings don't allow hover or click, just display selected stars.
Default Value: false

elements - writeonce NodeList

NodeList of elements used on the Rating. Each element is one Star.

hiddenInput - Node

Hidden input to handle the selected value. This hidden input replace the radio elements and keep the same name.

inputName - String

Name of the hiddenInput element. If not specified will use the name of the replaced radio.
Default Value: ''

label - String

Label to be displayed with the Rating elements.
Default Value: ''

labelNode - String

DOM Node to display the text of the StarRating. If not specified try to query using HTML_PARSER an element inside boundingBox which matches aui-rating-label-element.
Default Value: Generated div element.

selectedIndex - Number

Stores the index of the selected element.
Default Value: -1

showTitle - boolean

If true will extract the value of the title attribute on the radio, and use it on the generated Rating elements.
Default Value: true

size - Number

Number of Rating elements to be displayed.
Default Value: 5

title - String

If set, will be used when there is no DOM title on the radio elements.
Default Value: null

value - String

Stores the value of the current selected Rating element.
Default Value: null

Configuration attributes inherited from Widget:

Configuration attributes inherited from Base:

Configuration attributes inherited from Component:

Methods

_afterSetLabel

protected void _afterSetLabel ( event )
Fires after the value of the label attribute change.
Parameters:
event <EventFacade>

_canFireCustomEvent

protected Boolean _canFireCustomEvent ( event )
Check if the Rating element can fire the custom events. Disabled elements won't fire nothing.
Parameters:
event <EventFacade>

_createElements

protected NodeList _createElements ( )
Create rating elements based on the size attribute. It's only invoked when the HTML_PARSER does not find nothing.

_createEvents

protected void _createEvents ( )
Create the custom events.

_defRatingItemClickFn

protected void _defRatingItemClickFn ( event )
Fires the itemClick event.
Parameters:
event <EventFacade> itemClick event facade

_defRatingItemOutFn

protected void _defRatingItemOutFn ( event )
Fires the itemOut event.
Parameters:
event <EventFacade> itemOut event facade

_defRatingItemOverFn

protected void _defRatingItemOverFn ( event )
Fires the itemOver event.
Parameters:
event <EventFacade> itemOver event facade

_defRatingItemSelectFn

protected void _defRatingItemSelectFn ( event )
Fires the itemSelect event.
Parameters:
event <EventFacade> itemSelect event facade

_getInputData

protected void _getInputData ( )
Get the index element input data stored on inputElementsData.

_handleClickEvent

protected void _handleClickEvent ( event )
Fires the click event.
Parameters:
event <EventFacade> click event facade

_handleMouseOutEvent

protected void _handleMouseOutEvent ( event )
Fires the mouseOut event.
Parameters:
event <EventFacade> mouseOut event facade

_handleMouseOverEvent

protected void _handleMouseOverEvent ( event )
Fires the mouseOver event.
Parameters:
event <EventFacade> mouseOver event facade

_parseInputElements

protected void _parseInputElements ( )
Parse the HTML radio elements from the markup to be Rating elements.

_renderElements

protected void _renderElements ( )
Render the Rating elements.

_renderLabel

protected void _renderLabel ( )
Render the Rating label.

_syncElements

protected void _syncElements ( )
Sync the Rating elements.

_syncLabelUI

protected void _syncLabelUI ( )
Sync the Rating label UI.

bindUI

protected void bindUI ( )
Bind the events on the Rating UI. Lifecycle.

clearSelection

void clearSelection ( )
Clear all selected starts to the default state.

fillTo

void fillTo ( index , className )
Add the className on the the index element and all the previous Rating elements.
Parameters:
index <Number> Index to be selected
className <String> Class name to be applied when fill the Rating elements

indexOf

Number indexOf ( elem )
Finds the index of the elem.
Parameters:
elem <Node> Rating element

initializer

protected void initializer ( )
Construction logic executed during Rating instantiation. Lifecycle.

renderUI

protected void renderUI ( )
Create the DOM structure for the Rating. Lifecycle.

select

void select ( index )
Selects the index Rating element.
Parameters:
index <Number> Index to be selected

syncUI

protected void syncUI ( )
Sync the Rating UI. Lifecycle.

Methods inherited from Plugin.Host:

Events

canResetChange

canResetChange ( event )
Fires when the value for the configuration attribute 'canReset' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

defaultSelectedChange

defaultSelectedChange ( event )
Fires when the value for the configuration attribute 'defaultSelected' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

disabledChange

disabledChange ( event )
Fires when the value for the configuration attribute 'disabled' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

elementsChange

elementsChange ( event )
Fires when the value for the configuration attribute 'elements' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

hiddenInputChange

hiddenInputChange ( event )
Fires when the value for the configuration attribute 'hiddenInput' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

inputNameChange

inputNameChange ( event )
Fires when the value for the configuration attribute 'inputName' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

itemClick

itemClick ( event )
Handles the itemClick event.
Parameters:
event<Event.Facade> The itemClick event.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defRatingItemClickFn.

itemOut

itemOut ( event )
Handles the itemOut event.
Parameters:
event<Event.Facade> The itemOut event.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defRatingItemOutFn.

itemSelect

itemSelect ( event )
Handles the itemSelect event.
Parameters:
event<Event.Facade> The itemSelect event.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defRatingItemSelectFn.

labelChange

labelChange ( event )
Fires when the value for the configuration attribute 'label' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

labelNodeChange

labelNodeChange ( event )
Fires when the value for the configuration attribute 'labelNode' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

selectedIndexChange

selectedIndexChange ( event )
Fires when the value for the configuration attribute 'selectedIndex' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

showTitleChange

showTitleChange ( event )
Fires when the value for the configuration attribute 'showTitle' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

sizeChange

sizeChange ( event )
Fires when the value for the configuration attribute 'size' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

titleChange

titleChange ( event )
Fires when the value for the configuration attribute 'title' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

valueChange

valueChange ( event )
Fires when the value for the configuration attribute 'value' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event<Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set