define('application/widgets/search/contentList', [
'rofl/widgets/label',
'rofl/widgets/verticallist',
'rofl/lib/utils',
'application/widgets/carousel/carousel'
], function (
Label,
VerticalList,
Utils,
Carousel
) {
'use strict';
return VerticalList.extend({
init: function init () {
init.base.call(this);
this.addClass('content-list');
},
/**
* Creates the content for this list.
*
* @param {Object} contentData - Object that contais the info to build the carousels.
**/
setContent: function (contentData) {
Utils.each(contentData, Utils.bind(this._buildCarousel, this));
},
/**
* Builds the carousel.
*
* @param {Object} carouselData - Contains carousel data and configuration.
* @private
*/
_buildCarousel: function (carouselData) {
var horizontalCarousel = new Carousel(carouselData.carouselConfig);
horizontalCarousel.setDataItem(carouselData.data);
this.appendChildWidget(horizontalCarousel);
},
/**
* Aligns the carousels to force them to render items.
*/
alignCarousels: function () {
Utils.each(this.getChildWidgets(), function (widget) {
if (widget && widget instanceof Carousel) {
widget.alignToIndex(0);
}
});
},
/**
* Gets all the carousels in the the content list.
*
* @returns {Array} Array of carousels appended to this content list.
*/
getCarousels: function () {
var content = [];
Utils.each(this.getChildWidgets(), function (widget) {
if (widget && widget instanceof Carousel) {
content.push(widget.getMask().getWidgetStrip());
}
});
return content;
},
/**
* Shows widget.
*
* @param {Object} opts - Show parameter options.
*/
show: function show (opts) {
this.setFocusable(true);
if (!this.isVisible()) {
show.base.call(this, opts);
}
},
/**
* Hides widget.
*
* @param {Object} opts - Hide parameter options.
*/
hide: function hide (opts) {
this.setFocusable(false);
if (this.isVisible()) {
hide.base.call(this, opts);
}
},
/**
* Sets the focusable state for this widget.
*
* @param {boolean} focusable - True if the widget can be focused.
*/
setFocusable: function (focusable) {
this._isFocusable = focusable;
},
/**
* Determines if the widget is focusable.
*
* @returns {boolean} - True if the widget is focusable.
*/
isFocusable: function isFocusable () {
return this._isFocusable;
}
});
});