/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 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   # ||
|| ###################################################################### ||
\*========================================================================*/
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,["follow","following","following_pending","social_group_count_members_x","unsubscribe_overlay_error"]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,[]);(function(){vBulletin.subscribe={};var C=function(J){var M=$(J);if(M.hasClass("isSubscribed")||M.hasClass("is-pending")){return true}var O=parseInt(M.attr("data-node-id"),10),N={},K="";if(M.hasClass("is-topic")){K="/ajax/api/follow/add";N.follow_item=O;N.type="follow_contents";D(M,K,N)}else{var L={};L.channelid=O;L.recipient=parseInt(M.attr("data-owner-id"),10);if(M.hasClass("is-blog-channel")){L.requestType="member"}else{if(M.hasClass("is-sg-channel")){L.requestType="sg_subscriber"}else{L.requestType="subscriber"}}D(M,"/ajax/api/node/requestChannel",L)}};var H=function(J,K){J.children(".js-button__text-primary").text(vBulletin.phrase.get(K))};var F=function(L,M,K,J){H(L,M);L.addClass((K||"")+" b-button--special").removeClass((J||"")+" b-button--secondary")};var E=function(L,M,K,J){H(L,M);L.addClass((K||"")+" b-button--secondary").removeClass((J||"")+" b-button--special")};var D=function(K,J,L){vBulletin.AJAX({call:J,data:L,success:function(M){if(!isNaN(M)&&M>=1){if(M==1){F(K,"following","isSubscribed")}else{F(K,"following_pending","is-pending")}}else{vBulletin.error("follow","follow_error")}},title_phrase:"follow",error_phrase:"follow_error"})};function B(K,J){var L=$(".js-replace-member-count-"+K);if(L.length){L.each(function(){var P=$(this),O=P.data("replace-phrase-varname"),N=parseInt(P.data("member-count"),10),M=N+J;P.text(vBulletin.phrase.get(O,M));P.data("member-count",M)})}}var A=function(J){var L=$(J),M=parseInt(L.attr("data-node-id"),10),K=parseInt(L.attr("data-owner-id"),10);vBulletin.AJAX({call:"/ajax/api/node/requestChannel",data:({channelid:M,recipient:K,requestType:"sg_member"}),success:function(N){if(N===true){F(L,"joined","has-joined");B(M,1);if(L.hasClass("join-to-post-btn")||L.hasClass("js-refresh")){window.location.reload()}}else{if(!isNaN(N)){F(L,"following_pending","is-pending")}}},title_phrase:"join",error_phrase:"join_error"})};var I=function(J){var K=$(J),L=parseInt($(J).attr("data-node-id"),10);vBulletin.AJAX({call:"/ajax/api/blog/leaveChannel",data:{channelId:L},success:function(M){if(M===true){if(K.hasClass("js-button--follow")){H(K,"follow");K.addClass("b-button--special").removeClass("isSubscribed b-button--unfollow")}else{H(K,"join");K.removeClass("has-joined b-button--special leave-btn")}B(L,-1);if(!K.is(".js-no-refresh")){location.reload()}}else{vBulletin.error("leave","invalid_server_response_please_try_again")}},title_phrase:"leave",error_phrase:"invalid_server_response_please_try_again"})};var G=function(J){var K=$(J),L=$(J).attr("data-node-id");vBulletin.AJAX({call:"/ajax/api/follow/delete",data:{follow_item:L,type:"follow_contents"},success:function(M){if(M==1){E(K,"follow","","isSubscribed b-button--unfollow")}else{vBulletin.error("follow","unfollow_error")}},title_phrase:"follow",error_phrase:"unfollow_error"})};vBulletin.subscribe.updateSubscribeButton=function(K){if(typeof K!="undefined"){var J=$(".js-button--follow").filter(function(){return $(this).data("node-id")==pageData.nodeid&&pageData.nodeid!=pageData.channelid});switch(K){case 0:E(J,"follow","","isSubscribed b-button--unfollow");break;case 1:E(J,"following","isSubscribed");break;case 2:E(J,"following_pending","is-pending");break}}};$(".js-button--follow").on("click",function(J){if(!$(this).hasClass("isSubscribed")){C(this)}else{if($(this).hasClass("b-button--unfollow")){if($(this).hasClass("is-blog-channel")){I(this)}else{G(this)}}}});$(".js-button--follow").on("mouseover",function(J){var K=$(this);if(K.hasClass("isSubscribed")&&!K.hasClass("is-owner")){E(K,"following_remove","b-button--unfollow")}});$(".js-button--follow").on("mouseout",function(J){var K=$(this);if(K.hasClass("b-button--unfollow")){F(K,"following","","b-button--unfollow")}});$(".join-to-post-btn").on("click",function(J){if(!$(this).hasClass("has-joined")&&!$(this).hasClass("is-pending")){A(this)}});$(document).on("click",".join-btn",function(J){if(!$(this).hasClass("has-joined")&&!$(this).hasClass("is-pending")){A(this)}else{if($(this).hasClass("leave-btn")&&!$(this).hasClass("is-owner")){I(this)}}});$(document).on("mouseover",".join-btn",function(J){var K=$(this);if(K.hasClass("has-joined")&&!K.hasClass("is-owner")){E(K,"leave","leave-btn")}});$(document).on("mouseout",".join-btn",function(J){var K=$(this);if(K.hasClass("leave-btn")&&!K.hasClass("is-owner")){F(K,"joined","","leave-btn")}})})();