Source: formatters/vodasset.js

  1. define('application/formatters/vodasset', [
  2. 'rofl/lib/l10n',
  3. 'antie/formatter',
  4. 'antie/iterator',
  5. 'antie/runtimecontext',
  6. 'application/widgets/asset/asset',
  7. 'application/utils'
  8. ], function (
  9. L10N,
  10. Formatter,
  11. Iterator,
  12. RuntimeContext,
  13. Asset,
  14. AppUtils
  15. ) {
  16. 'use strict';
  17. var layout = RuntimeContext.getCurrentApplication().getLayout().movie,
  18. l10n = L10N.getInstance();
  19. return Formatter.extend({
  20. /**
  21. * Formats the widget.
  22. *
  23. * @param {Object|Iterator} item - The item.
  24. * @param {Object} params - Contains format params passed by child class.
  25. * @returns {Object} - The formatted widget.
  26. */
  27. format: function (item, params) {
  28. var formatParams = params || {},
  29. button,
  30. isSeries = item.isBundles(),
  31. isVodEpisode = item.isVodEpisode(),
  32. start = new Date(item.getStartTime() * 1000),
  33. end = new Date(item.getEndTime() * 1000),
  34. assetWidth = Math.round(formatParams.width || layout.width),
  35. assetHeight = Math.round(formatParams.height || layout.height),
  36. imageDimensions = {
  37. width: Math.round(assetWidth),
  38. height: Math.round(assetHeight)
  39. },
  40. gradient = formatParams.gradient,
  41. background = item.getImage('manual', imageDimensions),
  42. lockedBackground = background.replace('?blurred=true', '?blurred=true'),
  43. subTitleClassnames = isVodEpisode ? [] : ['year'],
  44. subTitle,
  45. subTitle2;
  46. subTitle = l10n.get('asset.vodDurationText', {
  47. year: item.getYear(),
  48. duration: AppUtils.getHourMinutesText(item.getDuration())
  49. });
  50. if (isSeries) {
  51. subTitle = item.getYear();
  52. }
  53. button = new Asset({
  54. title: item.getTitle(),
  55. subTitle: subTitle,
  56. subTitle2: subTitle2,
  57. lockedTitle: l10n.get('settings.parental.title'),
  58. startTime: start,
  59. endTime: end,
  60. background: background,
  61. lockedBackground: lockedBackground,
  62. gradient: gradient,
  63. classNames: {
  64. widget: 'vod',
  65. title: ['title'],
  66. subTitle: subTitleClassnames,
  67. subTitle2: ['duration']
  68. },
  69. item: item
  70. });
  71. button.addClass('vod');
  72. return button;
  73. }
  74. });
  75. });