define('application/widgets/player/buttons/seek', [
'application/widgets/pointerfocusablebutton',
'rofl/widgets/label'
], function (
Button,
Label
) {
'use strict';
var TYPES = {
REWIND: 'rewind',
FASTFORWARD: 'fastforward'
},
REWIND_CLASS = 'icon-rewind-v2',
FAST_FORWARD_CLASS = 'icon-forward-v2',
SeekButton;
SeekButton = Button.extend({
/**
* Initialises the button.
*
* @param {string} id - The id of the button.
* @param {string} type - The seek type.
*/
init: function init (id, type) {
init.base.call(this, id);
type = type || TYPES.REWIND;
this.addClass(['control', 'seek', type]);
this._build(type);
},
/**
* Builds the seek button.
*
* @param {string} type - The seek type.
* @private
*/
_build: function (type) {
var icon = new Label({ text: '', classNames: ['v-align-target', 'icon'] }),
helper = new Label({ text: '', classNames: ['v-align-helper'] }),
speedLabel = this._speedLabel = new Label({ classNames: ['speed', 'v-align-target'] });
this.appendChildWidget(helper);
if (type === TYPES.REWIND) {
icon.addClass(REWIND_CLASS);
// For rewind, first append the speed label and then the icon.
this.appendChildWidget(speedLabel);
this.appendChildWidget(icon);
} else if (type === TYPES.FASTFORWARD) {
icon.addClass(FAST_FORWARD_CLASS);
// For fast forward, first append the speed label and then the icon.
this.appendChildWidget(icon);
this.appendChildWidget(speedLabel);
}
},
/**
* Resets the seek button.
*/
reset: function () {
this.removeClass('activated');
this._speedLabel.setText('');
},
/**
* Sets the speed.
*
* @param {number} speed - Speed number.
*/
setSpeed: function (speed) {
speed = speed.toString().replace('-', '');
if (!this.hasClass('activated')) {
this.addClass('activated');
}
this._speedLabel.setText(speed + 'x');
}
});
SeekButton.TYPES = TYPES;
return SeekButton;
});