(function() { Luca.containers.TabView = Luca.containers.CardView.extend({ events: { "click ul.nav-tabs li": "select" }, hooks: ["before:select", "after:select"], componentType: 'tab_view', className: 'luca-ui-tab-view tabbable', tab_position: 'top', tabVerticalOffset: '50px', initialize: function(options) { this.options = options != null ? options : {}; Luca.containers.CardView.prototype.initialize.apply(this, arguments); _.bindAll(this, "select", "highlightSelectedTab"); this.setupHooks(this.hooks); return this.bind("after:card:switch", this.highlightSelectedTab); }, activeTabSelector: function() { return this.tabSelectors().eq(this.activeCard); }, prepareLayout: function() { var _this = this; return this.card_containers = _(this.cards).map(function(card, index) { _this.$('.tab-content').append(Luca.templates["containers/basic"](card)); return $("#" + card.id); }); }, beforeLayout: function() { this.$el.addClass("tabs-" + this.tab_position); if (this.tab_position === "below") { this.$el.append(Luca.templates["containers/tab_view"](this)); this.$el.append(Luca.templates["containers/tab_selector_container"](this)); } else { this.$el.append(Luca.templates["containers/tab_selector_container"](this)); this.$el.append(Luca.templates["containers/tab_view"](this)); } return Luca.containers.CardView.prototype.beforeLayout.apply(this, arguments); }, beforeRender: function() { var _ref; if ((_ref = Luca.containers.CardView.prototype.beforeRender) != null) { _ref.apply(this, arguments); } this.activeTabSelector().addClass('active'); if (Luca.enableBootstrap && this.tab_position === "left" || this.tab_position === "right") { this.$el.addClass('grid-12'); this.tabContainerWrapper().addClass('grid-3'); this.tabContentWrapper().addClass('grid-9'); if (this.tabVerticalOffset) { return this.tabContainerWrapper().css('padding-top', this.tabVerticalOffset); } } }, highlightSelectedTab: function() { this.tabSelectors().removeClass('active'); return this.activeTabSelector().addClass('active'); }, select: function(e) { var me, my; me = my = $(e.currentTarget); this.trigger("before:select", this); this.activate(my.data('target')); return this.trigger("after:select", this); }, tabContentWrapper: function() { return $("#" + this.cid + "-tab-view-content"); }, tabContainerWrapper: function() { return $("#" + this.cid + "-tabs-selector"); }, tabContainer: function() { return $("ul#" + this.cid + "-tabs-nav"); }, tabSelectors: function() { return $('li.tab-selector', this.tabContainer()); } }); }).call(this);