vanilla.namespace('biknok.vente');

biknok.vente.deamon =
{
    init : function(properties)
    {
	this.properties = properties;
	this.view = $("#view-" + properties.viewId);
    },

    manageFavoris : function(articleId, action, success, error, complete)
    {
	$.ajax
	(
	    {
		type	    : "post", 
		url	    : this.properties.libraryURL + "biknok/plugin/vente/ajax_favoris.php",
		data	    : {action:action, id:articleId},

		success : function(json)
		{
		    var div = this.view.find("div.button");
		    if ( json.result.type == "success" )
		    {
			div.find("span").text(json.text);
		    }

		    success(json, div);
		}
		.bind(this),

		error : error,
		complete : complete
	    }
	);
    }
}

