Posted by Prana
2015-11-18

Hi,
How would you cut off voting so when people come to the page it just shows the results?
Posted by Tom
2015-11-18

Hi, You can force the script to show the result page by adding the following line at the end of the run function in web/js/ajax_poll.js.
		//-- add the following lines at the end of "run" function
this.b_front = false;

var form = this.form;
form.find( '.ajax-poll-item-desc-box' ).hide();

form.find( '.ajax-poll-item-bar' ).css( 'width', 0 );
form.find( '.ajax-poll-item-count' ).html( '' );
form.find( '.ajax-poll-item-perc' ).html( '' );
form.find( '.ajax-poll-item-stats-box' ).show();

form.find( '.ajax-poll-vote-box' ).hide();
form.find( '.ajax-poll-back-box' ).show();

form.find( '.ajax-poll-item-radio' ).hide();

this.send("");
After adding the lines, the run function will look like
	//-----------------------------------------------
// run
//-----------------------------------------------
run : function()
{
var _this = this;

//-- [BEGIN] Row mouse over
this.form.find( '.ajax-poll-item' ).mouseover( function() {
$( this ).addClass( "ajax-poll-item-mover" );
}).mouseout( function() {
$( this ).removeClass( "ajax-poll-item-mover" );
});
//-- [END] Row mouse over

//-- [BEGIN] Setup radio buttons
this.form.find( '.ajax-poll-item' ).each( function(){
var form_tid = _this.tid;
var item_tid = $(this).attr( 'tid' );
var radio = $(this).find( '.ajax-poll-item-radio' ).eq(0);
radio.attr( 'name', form_tid );
radio.attr( 'value', item_tid );
});
//-- [END] Setup radio buttons

//-- [BEGIN] Select an item
this.form.find( '.ajax-poll-item' ).click( function(e){
//e.preventDefault();
if ( !_this.b_front ) return;

var tid = $(this).attr( 'tid' );
var radio = $(this).find( 'input[value="' + tid + '"]' );
radio.attr( 'checked', 'checked' );

_this.form.find( '.ajax-poll-item' )
.removeClass( "ajax-poll-item-sel" );
$(this).addClass( "ajax-poll-item-sel" );
});
//-- [END] Select an item

//-- [BEGIN] Vote
this.form.find( '.ajax-poll-btn-vote' ).click( function(e){
e.preventDefault();

var form = $(this).parents( '.ajax-poll-form' ).eq(0);

var item_tid = form.find( 'input[name="' + _this.tid + '"]:checked').val();
if ( typeof(item_tid) == 'undefined' ) item_tid = '';

if ( item_tid == '' )
{
showTip( form.find( '.ajax-poll-vote-box' ),
MSG_SELECT_ONE, "#ff0000" );
return
}
else
{
if ( _this.checkCookie() )
{
showTip( form.find( '.ajax-poll-vote-box' ),
MSG_THANK_YOU );
}
else
{
showTip( form.find( '.ajax-poll-vote-box' ),
MSG_CANT_VOTE, "#ff0000" );
return;
}
}

_this.b_front = false;

form.find( '.ajax-poll-item-desc-box' ).hide();

form.find( '.ajax-poll-item-bar' ).css( 'width', 0 );
form.find( '.ajax-poll-item-count' ).html( '' );
form.find( '.ajax-poll-item-perc' ).html( '' );
form.find( '.ajax-poll-item-stats-box' ).show();

form.find( '.ajax-poll-vote-box' ).hide();
form.find( '.ajax-poll-back-box' ).show();

form.find( '.ajax-poll-item-radio' ).hide();

_this.vote( e, item_tid );
});
//-- [END] Vote

//-- [BEGIN] View result
this.form.find( '.ajax-poll-btn-view' ).click( function(e){
e.preventDefault();
_this.b_front = false;

var form = _this.form;
form.find( '.ajax-poll-item-desc-box' ).hide();

form.find( '.ajax-poll-item-bar' ).css( 'width', 0 );
form.find( '.ajax-poll-item-count' ).html( '' );
form.find( '.ajax-poll-item-perc' ).html( '' );
form.find( '.ajax-poll-item-stats-box' ).show();

form.find( '.ajax-poll-vote-box' ).hide();
form.find( '.ajax-poll-back-box' ).show();

form.find( '.ajax-poll-item-radio' ).hide();

_this.vote( e, '' );
});
//-- [END] View result

//-- [BEGIN] Go Back
this.form.find( '.ajax-poll-btn-back' ).click( function(e){
e.preventDefault();
_this.b_front = true;

var form = _this.form;
form.find( '.ajax-poll-item-desc-box' ).show();
form.find( '.ajax-poll-item-stats-box' ).hide();

form.find( '.ajax-poll-vote-box' ).show();
form.find( '.ajax-poll-back-box' ).hide();

form.find( '.ajax-poll-item-radio' ).show();
});
//-- [END] Go Back

//-- [BEGIN] Reset cookie
this.form.next( '.ajax-poll-btn-reset' ).click( function(e){
e.preventDefault();
Cookie.del( _this.getCookieName() );
alert( "Cookie has been reset!" );
});
//-- [END] Reset cookie

//-- add the following lines at the end of "run" function
this.b_front = false;

var form = this.form;
form.find( '.ajax-poll-item-desc-box' ).hide();

form.find( '.ajax-poll-item-bar' ).css( 'width', 0 );
form.find( '.ajax-poll-item-count' ).html( '' );
form.find( '.ajax-poll-item-perc' ).html( '' );
form.find( '.ajax-poll-item-stats-box' ).show();

form.find( '.ajax-poll-vote-box' ).hide();
form.find( '.ajax-poll-back-box' ).show();

form.find( '.ajax-poll-item-radio' ).hide();

this.send("");
},