define([
  'client/controllers/module',
  'common/modules/tab',
  'client/views/visualisations/tab',
  'extensions/collections/collection'
],
function (ModuleController, TabController, TabView, Collection) {

  var parent = ModuleController.extend(TabController);

  var TabModule = parent.extend({

    visualisationClass: TabView,
    collectionClass: Collection,

    initialize: function () {
      var controllerMap = TabModule.map;

      this.tabs = _.map(this.model.get('tabs'), function (tab) {
        tab.controller = controllerMap[tab['module-type']];
        return tab;
      }, this);

      if (!this.model.has('activeIndex')) {
        this.model.set('activeIndex', 0);
      }

      parent.prototype.initialize.apply(this, arguments);
    },

    ready: function () {
      this.listenTo(this.model, 'change:activeIndex', this.renderTabs, this);
      this.renderTabs();
    },

    renderTabs: function () {
      var tab = this.tabs[this.model.get('activeIndex')];
      if (tab.rendered) {
        return;
      }
      this.renderModules(
        [tab],
        this.model.get('parent'),
        {},
        {},
        _.bind(function () {
          var height = this.view.$('section').eq(this.model.get('activeIndex')).height();
          this.view.$('section').css('min-height', height);
          ModuleController.prototype.ready.call(this);
          tab.rendered = true;
        }, this)
      );
    }

  });

  return TabModule;

});

@@ -96,47 +96,8 @@
 tab'
-,%0A  'extensions/collections/collection'
 %0A%5D,%0A
@@ -150,20 +150,8 @@
 View
-, Collection
 ) %7B%0A
@@ -278,41 +278,8 @@
 iew,
-%0A    collectionClass: Collection,
 %0A%0A  

Revert tabs