define('application/formatters/recordings', [
'antie/iterator',
'application/utils',
'antie/runtimecontext',
'rofl/lib/l10n',
'rofl/lib/utils',
'application/models/production/series',
'application/formatters/epgasset'
], function (
Iterator,
AppUtils,
RuntimeContext,
L10N,
Utils,
Series,
EpgFormatter
) {
'use strict';
var l10n = L10N.getInstance(),
layout = RuntimeContext.getCurrentApplication().getLayout().asset.epg;
return EpgFormatter.extend({
/**
* Formats the widget.
*
* @param {Object|Iterator} item - The item.
* @returns {Object} - The formatted widget.
*/
format: function format (item) {
var formatParams;
if (item instanceof Iterator) {
item = item.next();
}
if (item instanceof Series) {
if (item.getItemCount() === 1) {
item = item.getItems()[0];
}
}
formatParams = {
subTitle: this._getSubtitle(item),
width: layout.width,
height: layout.height,
isRecording: true,
item: item,
imageDimension: {
width: layout.image.width,
height: layout.image.height
}
};
return format.base.call(this, item, formatParams);
},
/**
* Returns the asset subtitle.
*
* @param {Object} item - The item.
* @returns {string} - The subtitle.
* @private
*/
_getSubtitle: function (item) {
var start,
end;
if (item instanceof Series) {
return l10n.get('asset.episodes', {episodes: item.getItemCount()});
}
start = new Date(item.getStartTime() * 1000);
end = new Date(item.getEndTime() * 1000);
return l10n.get('asset.epgDurationText', {
date: AppUtils.getDate(start, end),
duration: AppUtils.getHourMinutesText(item.getDuration())
});
}
});
});