Activateable = window.require 'spine/controller/activateable'
Controller   = window.require 'spine/controller/index'

###
The tab class used to render a service tab.
###
class ServiceTab extends Controller
	className : 'browser-tab'
	events    : 'click':'active'
	@include Activateable

	constructor: ->
		super
		panelTitle = if @panel.serviceTitle? then @panel.serviceTitle else @panel.title
		panelTitle = panelTitle[0].toUpperCase() + panelTitle.slice 1

		@el.append(@len = $ '<div data-count="0"></div>')
			.addClass( @panel.title )
			# Show the service's capitalized title in a tooltip
			.attr 'data-tooltip-text': panelTitle, 'data-tooltip-position':'right center'

		if panelIcon  = @panel.options.icon
			@el.append "<div class=\"browser-tab--icon\" style=\"background-image: url('#{panelIcon}')\"></div>"

	count: (i) -> @len.attr 'data-count', i

module.exports = ServiceTab
