
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
		@style=$('<style>')

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

		@append @style

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

	###
	Change a list of properties in the current skin
	this function should be overrided in the widget main component
	###
	changeSkin: (skin)->
		# console.log("Widget Base changeSkin:", skin);
		@

	###
	Set current content
	###
	setContent  : (content=[])->
		@content  = content
		@clearContent()
		@addContent(item) for item in content
		@

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

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

	resize:  (w,h) ->

module.exports = Widget
