Alloy UI

aui-char-counter  1.0.1

 
Filters

Class CharCounter - extends Base - uses AUI~input~handle

A base class for CharCounter, providing:
  • Limit the number of characters allowed in an input box
  • Display the number of characters left
Quick Example:
var instance = new A.CharCounter({
input: '#elementId',
counter: '#counterDisplayId',
maxLength: 10
});
Check the list of Configuration Attributes available for CharCounter.

Constructor

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

Properties

CharCounter.ATTRS - static Object

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

CharCounter.NAME - static String

Static property provides a string to identify the class.

handler - protected EventHandle

Event handler for the input aui-event event.

Properties inherited from Attribute:

Properties inherited from Base:

Configuration Attributes

counter - {Node | String}

Node or Selector to display the information of the counter.
Default Value: null

input - {Node | String}

Node or Selector for the input field. Required.
Default Value: null

maxLength - Number

Max number of characters the input can have.
Default Value: Infinity

Configuration attributes inherited from Base:

Methods

_onInputChange

protected void _onInputChange ( event )
Fired on input value change.
Parameters:
event <EventFacade>

_setMaxLength

protected Number _setMaxLength ( v )
Setter for maxLength.
Parameters:
v <Number> Value of the new maxLenght.

bindUI

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

checkLength

void checkLength ( )
Check the current value of the input, truncate the data if needed, and re-sync the UI. Fired from _onInputChange.

destroy

protected void destroy ( )
Descructor lifecycle implementation for the CharCounter class. Purges events attached to the node (and all child nodes).

initializer

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

syncUI

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

Events

counterChange

counterChange ( event )
Fires when the value for the configuration attribute 'counter' 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

inputChange

inputChange ( event )
Fires when the value for the configuration attribute 'input' 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

maxLengthChange

maxLengthChange ( event )
Fires when the value for the configuration attribute 'maxLength' 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

Events inherited from Base: