define([
    'Global',
    'SubHeaderView',
    'MainView',
    'waitListFilterView',
    'AccordionView',
    'User',
    'Text!../data/waitListSections.json'
],
    function (Global, SubHeaderView, MainView, waitListFilterView,
              AccordionView, User, WaitListSectionsData) {
        'use strict';
        return Backbone.View.extend({
            initialize: function () {
            },

            render: function () {
				MainView
                    .instance()
                    .clearView();

                new SubHeaderView()
                    .render({
                        subtitle: 'Wait List',
                        information: User.attributes.facilityName
                    });

                new AccordionView({
                        sections: JSON.parse(WaitListSectionsData),
                        onExpand: this.onExpand,
                        onCollapse: this.onCollapse,
                        container: getSidebarContent(),
						attributes: {
							'data-corners': 'false'
						}
                    })
                    .render();

                waitListFilterView.render();
                Global.getUtilities().eventAggregator.trigger("default-view");
            },

            onExpand: function(e) {
                Global.getUtilities().eventAggregator.trigger("default-view");

                $('.accordion').data().expanded = $(e.currentTarget).attr('id');

                $('.selected-active')
                    .removeClass('selected-active')
                    .prop({'title': 'Tap to see details.'});
            },

            onCollapse: function(e) {
                var $which = $(e.currentTarget),
                    accordionData = $('.accordion').data();

                if ($which.attr('id') === accordionData.expanded) {
                    accordionData.expanded = "";
                    Global.getUtilities().eventAggregator.trigger("default-view");
                }
            }
        });
    }
);
