define('application/widgets/recordings/filters', [
'rofl/widgets/horizontallist',
'application/widgets/filters/button',
'rofl/lib/l10n',
'rofl/lib/utils'
], function (
HorizontalList,
FilterButton,
L10N,
Utils
) {
'use strict';
var l10n = L10N.getInstance(),
filters = [
{
id: 'current-recordings',
text: l10n.get('recordings.filters.current'),
isDropDown: false
},
{
id: 'planned-recordings',
text: l10n.get('recordings.filters.planned'),
isDropDown: false
}
];
return HorizontalList.extend({
/**
* Initialises the widget.
*/
init: function init () {
init.base.call(this);
this.addClass('filters');
this._build();
},
/**
* Builds the widget.
*
* @private
*/
_build: function () {
Utils.each(filters, function (filter) {
this.appendChildWidget(new FilterButton(filter));
}, this);
},
/**
* Sets the selected filter.
*
* @param {Object} filter - The filter.
*/
setSelectedItem: function (filter) {
if (this._selected) {
this._selected.removeClass('selected');
}
filter.addClass('selected');
this._selected = filter;
}
});
});