console = window.require 'spine/utils/console'
Controller = window.require 'spine/controller'
Container  = window.require 'spine/controller/container'
###
Base class for all widgets
###
class Widget extends Controller
	className:'blogvio-widget'

	@include Container

	constructor : (opts,skin,content)->
		super
		@el.attr 'data-version', @VERSION if @VERSION
		console.group('WidgetController:constructor');
		@style=$('<style>')

		@setSkin(skin) if skin?
		@setContent(content) if content?

		@append @style
		console.groupEnd('WidgetController:constructor');

	###
	Set the current skin
	###
	setSkin  	: (skin)->
		console.group 'WidgetController:setSkin'
		console.debug skin
		@stopListening(@skin)
		@stopListening(skin)
		@skin = skin
		@listenTo(@skin, 'update', =>
			console.group 'WidgetController:changeSkin'
			@changeSkin arguments...
			console.groupEnd 'WidgetController:changeSkin'
		) if @skin.bind?
		@changeSkin(skin)
		console.groupEnd 'WidgetController:setSkin'
		@

	changeSkin: (skin)->

	###
	Set current content
	###
	setContent  : (content=[])->
		console.group 'WidgetController:setContent'
		console.table content
		@content  = content
		@clearContent()
		@addContent(item) for item in content
		console.groupEnd 'WidgetController:setContent'
		@

	###
	Add one content item
	###
	addContent   : (item)->
		@

	###
	Remove all content from the widget
	###
	clearContent: ->
		@

	resize:  (w,h) ->

module.exports = Widget
