define('application/formatters/vodasset', [
'rofl/lib/l10n',
'antie/formatter',
'antie/iterator',
'antie/runtimecontext',
'application/widgets/asset/asset',
'application/utils'
], function (
L10N,
Formatter,
Iterator,
RuntimeContext,
Asset,
AppUtils
) {
'use strict';
var layout = RuntimeContext.getCurrentApplication().getLayout().movie,
l10n = L10N.getInstance();
return Formatter.extend({
/**
* Formats the widget.
*
* @param {Object|Iterator} item - The item.
* @param {Object} params - Contains format params passed by child class.
* @returns {Object} - The formatted widget.
*/
format: function (item, params) {
var formatParams = params || {},
button,
isSeries = item.isBundles(),
isVodEpisode = item.isVodEpisode(),
start = new Date(item.getStartTime() * 1000),
end = new Date(item.getEndTime() * 1000),
assetWidth = Math.round(formatParams.width || layout.width),
assetHeight = Math.round(formatParams.height || layout.height),
imageDimensions = {
width: Math.round(assetWidth),
height: Math.round(assetHeight)
},
gradient = formatParams.gradient,
background = item.getImage('manual', imageDimensions),
lockedBackground = background.replace('?blurred=true', '?blurred=true'),
subTitleClassnames = isVodEpisode ? [] : ['year'],
subTitle,
subTitle2;
subTitle = l10n.get('asset.vodDurationText', {
year: item.getYear(),
duration: AppUtils.getHourMinutesText(item.getDuration())
});
if (isSeries) {
subTitle = item.getYear();
}
button = new Asset({
title: item.getTitle(),
subTitle: subTitle,
subTitle2: subTitle2,
lockedTitle: l10n.get('settings.parental.title'),
startTime: start,
endTime: end,
background: background,
lockedBackground: lockedBackground,
gradient: gradient,
classNames: {
widget: 'vod',
title: ['title'],
subTitle: subTitleClassnames,
subTitle2: ['duration']
},
item: item
});
button.addClass('vod');
return button;
}
});
});