define('application/widgets/channellist/progress', [
'rofl/widgets/container'
], function (
Container
) {
'use strict';
var ProgressBar;
ProgressBar = Container.extend({
/**
* Initialises the widget.
*/
init: function init () {
init.base.call(this, 'progressbar');
this._build();
},
/**
* Builds the widget.
*
* @private
*/
_build: function () {
var progressbar = this._progressbar = this._buildProgressBar();
this.appendChildWidget(progressbar);
},
/**
* Builds the progressBar.
*
* @returns {Object} - The progressBar.
* @private
*/
_buildProgressBar: function () {
var bar = new Container(),
progress = this._progress = new Container();
bar.addClass('progressbar');
progress.addClass('progress');
bar.appendChildWidget(progress);
return bar;
},
/**
* Sets the progress percentage.
*
* @param {number} percentage - The percentage.
*/
setProgress: function (percentage) {
// Never go beyond the full length of the bar.
if (percentage > 100) {
percentage = 100;
}
this._progress.setStyleTo('width', percentage + '%');
},
/**
* Sets the progress state to live if true.
*
* @param {boolean} isLive - True if the progress widget reports live progress.
*/
setIsLive: function (isLive) {
if (isLive) {
this.addClass('live');
} else {
this.removeClass('live');
}
}
});
return ProgressBar;
});