autocomplete-list.js revision 109f2c001bf1d522fbb70a1332c1568553706344
/**
* AutoComplete dropdown list widget.
*
* @module autocomplete-list
* @class AutoCompleteList
* @extends Widget
* @uses AutoCompleteBase
* @uses WidgetPosition
* @uses WidgetPositionAlign
* @uses WidgetStack
* @constructor
* @param {Object} config Configuration object.
* @since 3.3.0
*/
YArray = Y.Array,
INPUT_NODE = 'inputNode',
VISIBLE = 'visible',
WIDTH = 'width',
], {
// -- Prototype Properties -------------------------------------------------
CONTENT_TEMPLATE: '<ul/>',
ITEM_TEMPLATE: '<li role="option"/>',
// -- Lifecycle Prototype Methods ------------------------------------------
initializer: function () {
this._events = [];
if (!this._inputNode) {
Y.error('No inputNode specified.');
}
if (!this.get('align.node')) {
}
}
},
destructor: function () {
this._unbindInput();
}
},
bindUI: function () {
this._bindInput();
this._bindList();
},
renderUI: function () {
// See http://www.w3.org/WAI/PF/aria/roles#combobox for ARIA details.
'aria-autocomplete': 'list',
role: 'combobox'
});
},
syncUI: function () {
this._syncResults();
this._syncVisibility();
},
// -- Public Prototype Methods ---------------------------------------------
/**
* Hides the list.
*
* @method hide
* @see show
*/
hide: function () {
},
/**
* Shows the list.
*
* @method show
* @see hide
*/
show: function () {
},
// -- Protected Prototype Methods ------------------------------------------
/**
* Appends the specified result <i>items</i> to the list inside a new item
* node.
*
* @method _add
* @param {Array|Node|HTMLElement|String} items Result item or array of
* result items.
* @protected
*/
var itemNodes = [];
}, this);
},
/**
* Binds list events.
*
* @method _bindList
* @protected
*/
_bindList: function () {
]);
},
/**
* Clears the contents of the tray.
*
* @method _clear
* @protected
*/
_clear: function () {
},
/**
* Creates an item node with the specified <i>content</i>.
*
* @method _createItemNode
* @param {Node|HTMLElement|String} content
* @protected
* @returns {Node} Item node.
*/
_createItemNode: function (content) {
},
/**
* Synchronizes the results displayed in the tray with those in the
* <i>results</i> argument.
*
* @method _syncResults
* @param {Array} results Results.
* @protected
*/
_syncResults: function (results) {
if (!results) {
}
this._clear();
}
},
/**
* Synchronizes the visibility of the tray with the <i>visible</i> argument,
* or with the <code>visible</code> attribute if an argument is not
* provided.
*
* @method _syncVisibility
* @param {Boolean} visible (optional) Visibility.
* @protected
*/
_syncVisibility: function (visible) {
}
},
// -- Protected Event Handlers ---------------------------------------------
/**
* Handles <code>inputNode</code> blur events.
*
* @method _afterInputBlur
* @param {EventTarget} e
* @protected
*/
_afterInputBlur: function () {
// Hide the list when neither the input node nor the list has focus.
Y.later(20, this, function () {
if (!this.get('focused')) {
this.hide();
}
});
},
/**
* Handles <code>resultsChange</code> events.
*
* @method _afterResultsChange
* @param {EventFacade} e
* @protected
*/
_afterResultsChange: function (e) {
this._syncResults(e.newVal);
},
/**
* Handles <code>visibleChange</code> events.
*
* @method _afterVisibleChange
* @param {EventFacade} e
* @protected
*/
_afterVisibleChange: function (e) {
this._syncVisibility(!!e.newVal);
}
}, {
ATTRS: {
align: {
value: {
}
},
visible: {
value: false
}
},
});
Y.AutoCompleteList = List;
}, '@VERSION@' ,{skinnable:true, requires:['autocomplete-base', 'widget', 'widget-position', 'widget-position-align', 'widget-stack']});