Source: widgets/replay/asset.js

define('application/widgets/replay/asset', [
    'application/widgets/asset',
    'application/utils',
    'antie/runtimecontext',
    'rofl/lib/date.format'
], function (
    Asset,
    AppUtils,
    RuntimeContext
) {
    'use strict';

    var application = RuntimeContext.getCurrentApplication(),
        layout = application.getLayout(),
        imageFormat = layout.imageFormat,
        landscapeFormat = imageFormat.landscape,
        portraitFormat = imageFormat.portrait;

    return Asset.extend({

        init: function init (data) {
            var type = data.type;

            init.base.call(this, data.item);

            this._type = type;
            this.addClass(type);
        },

        /**
         * Sets the data item.
         *
         * @param {Array} item - The item.
         */
        _setData: function (item) {
            var subtitle = AppUtils.getAssetDateSubtitle(
                    new Date(item.getStartTime() * 1000),
                    new Date(item.getEndTime() * 1000),
                    item.getDuration()
                ),
                background = item.getImageUrl(landscapeFormat.width + 'x' + landscapeFormat.height),
                logo = item.getChannelLogo(),
                startTime = item.getStartTime() / 1000,
                endTime = item.getEndTime() / 1000,
                now = new Date(application.getDate()) / 1000,
                isLive = false;

            if (this.hasClass('portrait')) {
                background = item.getImageUrl(portraitFormat.width + 'x' + portraitFormat.height);
            }

            if ((startTime <= now) && (now <= endTime)) {
                isLive = true;
            }

            this.setBackground(background);
            this.setLogo(logo);
            this.setLiveMark(isLive);
            this.setTitle(item.getTitle());
            this.setSubtitle(subtitle);
        }
    });
});