var CardController = Backbone.Model.extend({ options: {}, initialize: function(options) { var that = this; $.extend(true, that.options, options); }, initCard: function(card) { var that = this; that.initTabs(card); that.initUndergroundBlocks(); }, initTabs: function(card) { var tabBar = $('.tab-bar', card); var that = application.controller.card; $('.tab', tabBar).click(function() { var tab = $(this).attr('data'); that.showTab(tab, card); }); var maxTabHeight = 0; var tab; $('.tab', tabBar).each(function() { if ($(this).attr('data') !== undefined) { tab = $(this).attr('data'); var tabHeight = $('.abs-card-body-content-' + tab, card).height(); maxTabHeight = Math.max(maxTabHeight, tabHeight); } }); $('.abs-card-body-content-' + tab, card).parent().height(maxTabHeight); }, showTab: function(tab, card) { if (tab !== null && tab !== undefined) { $('.abs-card-body-content', card).hide(); $('.abs-card-body-content-' + tab, card).removeClass('hidden').show(); $('.tab-bar .tab', card).removeClass('active'); $('.tab-bar .tab[data="' + tab + '"]', card).addClass('active'); } }, setTab: function(tab, el) { var that = application.controller.card; var card = $(el).parents('.abs-card'); that.showTab(tab, card); }, initUndergroundBlocks: function(card) { var undergroundBlock = $('.underground.block', card); $('.ug', undergroundBlock).each(function() { $(this).tooltip({placement: 'top'}); if ($('span', this).width() >= $(this).width()) { $('span', this).remove(); } }); } });