/**
 * Class for poll (frontend)
 *
 * @package Poll
 * @category Module
 * @author Mirek Bily
 * @copyright e-invent s.r.o.
 */
function PollFE() {

	/** @var {object} */
	var self = this;


	/**
	 * Handle ajax request after voting.
	 * Reloading poll snippet.
	 *
	 * @param {json} xmldata
	 * @return {void}
	 */
	self.reloadPollBox = function(xmldata){
		$('#snippet-pollBox').html('');
		$('#snippet-pollBox').html(xmldata);
	};


	/**
	 * Handle voting signal
	 * (ajax request)
	 *
	 * @param {int} pollId
	 * @param {int} answerId
	 * @return {void}
	 */
	self.voting = function(pollId, answerId) {
		system.ajaxRequest(
			[ 'modul', php.pollModuleId ],
			'actionVoting',
			[
				[ 'answerId', answerId ],
				[ 'pollId', pollId ],
				[ 'languageId', php.languageId]
			],
			{fce : self.reloadPollBox}
		);
	}

}


var pollFE = new PollFE();

