define([
    'Global',
    'Text!../html/templates/sub-header.html'
],
    function (Global, subHeader) {
        'use strict';
        return Backbone.View.extend({
            tagName: 'div',
            initialize: function () {
                this.template = _.template(subHeader);
            },
            render: function (details) {
                // sets a default pane
                details.pane = details.pane || "left";

                var $subHeader;

                if (details.pane === "left") {
                    $subHeader = getSubHeaderLeft();
                } else {
                    $subHeader = getSubHeaderRight();
                }

                $subHeader
                    .empty()
                    .append(this.$el.append(this.template(details)))
                    .trigger('create');

                return this;
            },
            events: {
                'tap .ui-btn-right': 'tapButton'
            },
            tapButton: function (e) {
                if (this.options.buttonAction !== undefined) {
                    e.preventDefault();
                    this.options.buttonAction();
                }
            }
        });
    }
);
