/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.1.9 Patch Level 4
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2016 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["vote_failed","vote_now","vote_first","vote_error_retrieving","votes","vote"]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,["maxpolloptions"]);(function(A){A(document).ready(function(){function E(I){var H=window.vBulletin.options.get("maxpolloptions"),G=(H>3)?3:H;I.off("click",".js-poll__view-results").on("click",".js-poll__view-results",function(L){L.preventDefault();var K=A(this).attr("data-nodeid"),J=A(this).closest("form");A.post(vBulletin.getAjaxBaseurl()+"/poll/get",{nodeid:K},function(M){B(J,M)},"json")});I.off("click",".js-poll__back-to-poll").on("click",".js-poll__back-to-poll",function(K){K.preventDefault();var J=A(this).closest(".js-poll__parent");J.find("div.pollresults").addClass("h-hide");J.find("form.poll").show()});I.off("click",".b-poll-fieldset__add-more").on("click",".b-poll-fieldset__add-more",function(L){var M=A(this),K=M.prev(".b-poll-fieldset__poll-answers"),J=K.find("li").first().clone(true);J.find(".b-form-input__input").val("").attr("name","polloptions[new][]");J.find(".js-remove-button").prop("disabled",false);J.appendTo(K).find(".b-form-input__input").focus();if(K.find("li").length==H){M.addClass("h-hide")}K.find(".js-remove-button").prop("disabled",false);return false});I.off("click",".b-poll-fieldset__poll-answers .js-remove-button").on("click",".b-poll-fieldset__poll-answers .js-remove-button",function(){var K=A(this),J=K.closest(".b-poll-fieldset__poll-answers");K.closest("li").remove();J.next(".b-poll-fieldset__add-more").removeClass("h-hide");if(J.find("li").length==1){J.find(".js-remove-button").prop("disabled",true)}return false});I.off("click",".js-poll-timeout").on("click",".js-poll-timeout",function(K){var J=A(this).closest(".b-poll-fieldset__poll-options").next(".b-poll-fieldset__datepicker-container");if(this.checked){J.removeClass("h-hide")}else{J.addClass("h-hide").find(".b-datepicker__input").val("")}});I.off("submit.formpoll","form.poll").on("submit.formpoll","form.poll",function(M){M.preventDefault();var J=A(this);var L=J.find('[name="polloptionid"]:checked').val();var K=[];J.find('[name="polloptionids[]"]:checked').each(function(){K.push(A(this).val())});A.post(vBulletin.normalizeAjaxUrl(J.attr("action")),{polloptionid:L,"polloptionids[]":K},function(O){if(O==false){openAlertDialog({title:vBulletin.phrase.get("vote_now"),message:vBulletin.phrase.get("vote_failed"),iconType:"warning"})}else{B(J,O);var N=J.parent();A("div.pollresults",N).find(".js-poll__back-to-poll").remove()}},"json")});A(document).off("click",".pollresults-data .voter-icon").on("click",".pollresults-data .voter-icon",function(){var J=A(this);if(J.find(".voters").is(":visible")){return false}A(".pollresults-data tr td.pollvoter-cell .voter-icon .voters").hide();var M=J.attr("data-node-id");var L=J.attr("data-polloption-id");var K=J.closest("form");A.post(vBulletin.getAjaxBaseurl()+"/poll/get-voters",{nodeid:M,polloptionid:L},function(N){if(N){if(!N.error){C(K,N,L,J)}else{D({message:N.error,type:"error"},J)}}else{D({message:vBulletin.phrase.get("vote_error_retrieving"),type:"error"},J)}},"json")});A(document).off("click",".pollresults-data .voter-icon .voters").on("click",".pollresults-data .voter-icon .voters",function(){e.stopPropagation();return true});if(A(".polloptioncontainer.new",I).length>0){for(var F=0;F<G-1;F++){A("a#addanswer",I).click()}if(G==H){A("a#addanswer",I).hide()}}}vBulletin.conversation.bindEditFormEventHandlers("poll");function D(H,G){var I=G.find(".voters");if(H.message){var F=A("<span />").addClass(H.type).text(H.message);I.html(F)}else{I.html(H.voters)}I.fadeIn("slow");A("body").on("click.voterpopup",function(J){if(A(J.target).closest(".voter-icon").length==0){I.hide();A("body").off("click.voterpopup")}})}function C(F,H,K,I){var M=false;if(H.options){B(F,H);var J=H.options[K];if(J){M=true;if(!A.isEmptyObject(J.votersinfo)){var L=[];for(var G in J.votersinfo){L.push('<a href="{0}">{1}</a>'.format(pageData.baseurl+J.votersinfo[G].profileUrl,J.votersinfo[G].username))}D({voters:L.join(", ")},I)}else{D({message:vBulletin.phrase.get("vote_first"),type:"note"},I)}}}if(!M){D({message:vBulletin.phrase.get("vote_error_retrieving"),type:"error"},I)}}function B(G,L){var F=G.parent(),H=L.options,K="";for(var I in H){var J=A(".pollresults-option-"+H[I].polloptionid);J.find(".title").html(JShtmlEncode(H[I].title));J.find(".bar-container .bar").css("width",H[I].percentage+"%");J.find(".percentage").html(H[I].percentage+"%");J.find(".votes span").html(H[I].votes);if(H[I].votes==1){K="vote"}else{K="votes"}J.find(".votes label").html(vBulletin.phrase.get(K))}A(".pollresults .pollvote-count span",F).html(L.poll_votes);if(L.poll_votes==1){K="vote"}else{K="votes"}A(".pollresults .pollvote-count label",F).html(vBulletin.phrase.get(K));G.hide();A("div.pollresults",F).removeClass("h-hide")}E(A(document))})})(jQuery);