define('application/components/details/vod', [
'application/components/details/details',
'application/widgets/detail/tablist',
'application/widgets/detail/vod/header',
'rofl/widgets/verticallist',
'application/widgets/detail/tabs/info',
'rofl/lib/utils',
'antie/runtimecontext',
'application/widgets/detail/buttons/play',
'rofl/lib/l10n',
'rofl/widgets/container',
'rofl/widgets/label',
'rofl/lib/promise',
'rofl/analytics/web/google'
], function (
BaseDetail,
TabList,
Header,
VerticalList,
InfoTab,
Utils,
RuntimeContext,
PlayButton,
L10N,
Container,
Label,
Promise,
GoogleAnalytics
) {
'use strict';
var application = RuntimeContext.getCurrentApplication(),
layout = application.getLayout(),
layoutModifier = layout.modifier,
l10n = L10N.getInstance(),
GA = GoogleAnalytics.getInstance();
return BaseDetail.extend({
/**
* Initialises the component.
*/
init: function init () {
init.base.call(this, 'vod');
},
/**
* Sets the header data.
*
* @param {Object} data - Contains detail data.
* @private
*/
_setHeaderData: function (data) {
var item = data.contentDetail;
this._playbutton = new PlayButton();
if (!this._userCanWatch) {
this._playbutton.addClass('greyed-out-bigger-icon');
if (this._price) {
this._playbutton.setText(l10n.get('movies.buy_from', {price: this._price}));
} else {
this._playbutton.setText(l10n.get('movies.buy_no_price'));
}
this._playbutton.setIcon('icon-ticket');
} else {
this._playbutton.setIcon('icon-play-v2');
}
this._header.setDataItem({
title: item.getContentSubtype() === 'EPISODE' ? item.getSeriesTitle() : item.getTitle(),
subtitle: item.getYear() + ' | ' + item.getFormattedDuration(),
image: item.getImage('manual', {
width: 900 * layoutModifier,
height: 500 * layoutModifier
}),
actions: [
this._playbutton
]
});
},
/**
* Sets the tabs data.
*
* @param {Object} item - The item.
* @private
*/
_setTabsData: function (item) {
var tabList = this._tabList;
tabList.setDataItem([
{
widget: InfoTab,
data: {
description: item.getDescription(),
people: [
{
type: 'actors',
people: item.getActors()
},
{
type: 'directors',
people: item.getDirectors()
}
],
ratings: [
item.getAgeRating()
].concat(item.getVideoRatings()),
imdbRating: item.getImdbRating()
},
text: l10n.get('description')
}
]);
},
/**
* Sets the content's details.
*
* @param {Object} data - Contains detail data.
* @private
*/
_setDetailData: function (data) {
var contentDetail = data.contentDetail;
this._setTabsData(contentDetail);
this._header.focus();
if (!this._userCanWatch) {
this._purchaseMessage.addClass('visible');
this._backButton.focus();
this._playbutton.setDisabled(true);
} else {
this._purchaseMessage.removeClass('visible');
}
},
/**
* On Select event.
*
* @param {Event} e - The event data.
*/
_onSelect: function (e) {
var target = e.target,
id = target.id,
targetData = this.getDataItem();
if (id === 'up' || id === 'down') {
this._focusItem(id);
return;
}
target.focus();
switch (id) {
case 'playnow':
this._onPlay(targetData);
break;
case 'back-button':
this._onBack();
break;
default:
this._purchaseMessage.removeClass('visible');
}
},
/**
* Attempts to play the video.
*
* @param {Object} dataItem - The data item.
* @private
*/
_onPlay: function (dataItem) {
var data = dataItem || this._data[0];
if (data.canPlay()) {
application.route('vodplayer', {
data: data
});
}
GA.onEvent('player', 'started', {eventLabel: this._callingPage});
}
});
});