/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. 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   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache("vote_failed vote_now vote_first vote_error_retrieving vote_lower votes_lower voters voter".split(" "),["maxpolloptions"]);
(function(c){function r(h,m){const n=h.find(".js-change-vote"),d=h.find(".js-poll-option");h=h.find(".js-vote-now");n.toggleClass("h-hide-imp",m);h.toggleClass("h-hide-imp",!m);d.attr("disabled",!m)}c(function(){function h(d,g,a){d=c("<span />").addClass(g).text(vBulletin.phrase.get(d));m(d,a)}function m(d,g){g.html(d);g.fadeIn("slow");c("body").on("click.voterpopup",function(a){0==c(a.target).closest(".voter-icon").length&&(g.hide(),c("body").off("click.voterpopup"))})}function n(d,g){var a=d.parent(),
b=g.options,e;for(e in b){var f=c(".pollresults-option-"+b[e].polloptionid);f.find(".title").html(JShtmlEncode(b[e].title));f.find(".bar-container .bar").css("width",b[e].percentage+"%");f.find(".percentage").html(b[e].display_percentage+"%");f.find(".js-votes span").html(b[e].votes);var k=1==b[e].votes?"vote_lower":"votes_lower";f.find(".js-votes label").html(vBulletin.phrase.get(k))}c(".pollresults .pollvote-count span",a).html(g.poll_votes);k=1==g.poll_votes?"voter":"voters";c(".pollresults .pollvote-count label",
a).html(vBulletin.phrase.get(k));d.hide();c("div.pollresults",a).removeClass("h-hide-imp");r(d,!1)}vBulletin.conversation.bindEditFormEventHandlers("poll");(function(d){var g=function(a){a.find(".js-remove-button").prop("disabled",2>=a.find("li").length)};c(".b-poll-fieldset__poll-answers").each(function(){g(c(this))});d.offon("click",".js-poll__view-results",function(a){a.preventDefault();a=c(this).attr("data-nodeid");var b=c(this).closest("form");c.post(vBulletin.getAjaxBaseurl()+"/poll/get",{nodeid:a},
function(e){n(b,e)},"json")});d.offon("click",".js-poll__back-to-poll",function(a){a.preventDefault();a=c(this).closest(".js-poll__parent");a.find("div.pollresults").addClass("h-hide-imp");a.find("form.poll").show()});d.offon("click",".b-poll-fieldset__add-more",function(a){a=c(this);var b=a.prev(".b-poll-fieldset__poll-answers"),e=b.find("li").first().clone(!0),f=e.find(".b-form-input__input");f.val("").attr("name","polloptions[new][]");e.appendTo(b);f.trigger("focus");b.find("li").length==vBulletin.options.get("maxpolloptions")&&
a.addClass("h-hide");g(b);return!1});d.offon("click",".b-poll-fieldset__poll-answers .js-remove-button",function(){var a=c(this),b=a.closest(".b-poll-fieldset__poll-answers");a.closest("li").remove();b.next(".b-poll-fieldset__add-more").removeClass("h-hide");g(b);return!1});d.offon("click",".js-change-vote",a=>r(c(a.currentTarget).closest("form"),!0));d.offon("submit.formpoll","form.poll",function(a){a.preventDefault();let b=c(this);a=b.find('[name="polloptionid"]:checked').val();let e=[];b.find('[name="polloptionids[]"]:checked').each(function(){e.push(c(this).val())});
c.post(vBulletin.normalizeAjaxUrl(b.attr("action")),{polloptionid:a,"polloptionids[]":e},function(f){if(0==f)vBulletin.warning("vote_now","vote_failed");else{n(b,f);var k=b.parent();f.canchangevotes||c("div.pollresults",k).find(".js-poll__back-to-poll").remove()}},"json")});d.offon("click",".pollresults-data .voter-icon",a=>{a=c(a.currentTarget);var b=a.find(".voters");if(b.is(":visible"))return!1;c(".pollresults-data .voter-icon .voters").hide();var e=a.attr("data-node-id"),f=a.attr("data-polloption-id"),
k=a.closest("form");vBulletin.AJAX({call:"/poll/get-voters",data:{nodeid:e,polloptionid:f},success:l=>{var {options:{[f]:p}={}}=l;if(p)if(n(k,l),l=p.votersinfo,c.isEmptyObject(l))h("vote_first","note",b);else{p=[];for(let q of Object.values(l))p.push('<a href="{0}" data-vbnamecard="{1}">{2}</a>'.format(q.profileurl,q.userid,q.displayname_safe));m(p.join(", "),b)}else h("vote_error_retrieving","error",b)},api_error:l=>h(l[0],"error",b),error:()=>h("vote_error_retrieving","error",b)})});d.offon("click",
".pollresults-data .voter-icon .voters",a=>{a.stopPropagation();return!0})})(c(document))})})(jQuery);
