EntryController = require './index'
Activateable 	= window.require 'spine/controller/activateable'
class FileController extends EntryController 
	className: 'browser-entry'

	@include Activateable
	
	events:
		'click .browser-entry-prew':'toggle'

	constructor: ->
		super
		@update({@selected})
		@activate() if @selected
		@listenTo @item, 'refresh', @refresh
		@refresh()

	update:(opts={})->
		@el.toggleClass('active',opts.selected)

	toggle: ->
		return if !@isActive() and @item.onActivate? and !@item.onActivate?()
		if @isActive() then @deactivate() else @active()

	getPreviewURL: => @getPreview @item if @item

	refresh: =>
		if @item.isPrivate
			@el.addClass 'private-entry'
			@el.attr 'data-tooltip-text', 'To use this item, make it public.'
		else
			@el.removeClass 'private-entry',
			@el.removeAttr 'data-tooltip-text'

module.exports = FileController