Source: widgets/detail/vod/header.js

define('application/widgets/detail/vod/header', [
    'rofl/widgets/container',
    'rofl/widgets/label',
    'rofl/widgets/image',
    'rofl/widgets/horizontallist',
    'rofl/widgets/verticallist',
    'rofl/lib/utils'
], function (
    Container,
    Label,
    Image,
    HorizontalList,
    VerticalList,
    Utils
) {
    'use strict';

    return Container.extend({

        /**
         * Initialises the widget.
         */
        init: function init () {
            init.base.call(this);

            this.addClass('vod-header');
            this._build();
        },

        /**
         * Builds the widget.
         *
         * @private
         */
        _build: function () {
            var title = this._title = new Label(''),
                subtitle = this._subtitle = new Label(''),
                list = this._list = new VerticalList(),
                buttonList = this._buttonList = new HorizontalList(),
                gradient = new Container(),
                image = this._image = new Image(null, '');

            title.addClass('title');
            subtitle.addClass('subtitle');
            buttonList.addClass('buttons');
            gradient.addClass('gradient');

            list.appendChildWidget(buttonList);

            this.appendChildWidget(image);
            this.appendChildWidget(gradient);
            this.appendChildWidget(title);
            this.appendChildWidget(subtitle);
            this.appendChildWidget(list);
        },

        /**
         * Returns back button element.
         *
         * @returns {*} - Back button.
         */
        getBackButton: function () {
          return this._backButton;
        },

        /**
         * Sets the data item.
         *
         * @param {Object} opts - The opts.
         */
        setDataItem: function setDataItem (opts) {
            var actions = opts.actions,
                item = opts.item,
                title = opts.title,
                image = opts.image,
                subtitle = opts.subtitle,
                buttonList = this._buttonList;

            setDataItem.base.call(this, item);

            buttonList.removeChildWidgets();
            this._title.setText(title);
            this._subtitle.setText(subtitle);
            this._image.setSrc(image);

            this._actions = actions;

            Utils.each(actions, function (action) {
                buttonList.appendChildWidget(action);
            });

            buttonList.setActiveChildIndex(0);
        },

        /**
         * Focuses the widget.
         *
         * @returns {boolean} - True if focus is set.
         */
        focus: function () {
            return this._buttonList.focus();
        },

        /**
         * Clears the widget.
         */
        clear: function () {
            this._image.setSrc('');
            this._title.setText('');
            this._subtitle.setText('');
            this._buttonList.removeChildWidgets();
        }
    });
});