/*=======================================================================*\
|| ###################################################################### ||
|| # 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,["following","following_pending","following_remove","showing_x_subscribers","showing_x_subscriptions","unable_to_contact_server_please_try_again"]);(function(A){var B=[".subscriptions-widget"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){var N=A(".subscriptions-widget .subscribeTabs"),D=A(".subscriptions-tab",N),Q=A(".subscribers-tab",N),O=A(".subscription-list",D),G,I,R={},J,P,F,L,K,U;A(".ui-tabs-nav > li",N).removeClass("ui-state-disabled");F=N.find(".ui-tabs-nav > li");L=F.filter(".ui-tabs-selected");K=L.index();$defaultTabAnchor=L.find("> a");U=$defaultTabAnchor.data("url-path");allowTabHistory=F.parent().data("allow-history")=="1";tabHistory=new vBulletin.history.instance(allowTabHistory);vBulletin.tabify.call(N,{tabHistory:tabHistory,getTabIndexByHash:function(V){V=V||U;return F.filter('li:has(a[href*="#'+V+'"])').first().index()},allowHistory:allowTabHistory,tabParamAsQueryString:false,hash:N.find(".js-module-top-anchor").attr("id"),tabOptions:{select:function(V,W){if(J){J.hideFilterOverlay()}},show:function(X,Y){var W=Y.panel.id,V=A(this);if(typeof R[W]=="undefined"){R[W]=A(".conversation-toolbar-wrapper",Y.panel).data("allow-history")=="1"}if(Y.tab.hash=="#subscriptionsTab"){if(!J){G=new vBulletin.pagination({context:D,allowHistory:R[W],tabParamAsQueryString:false,onPageChanged:function(Z,a){J.updatePageNumber(Z);if(!a){J.applyFilters(false,false,false,true)}}});J=new vBulletin.conversation.filter({context:D,allowHistory:R[W],pagination:G,tabParamAsQueryString:false,onContentLoad:function(Z){if(J.isFilterSelected("mostactive")){A(".subscription-list-header .last-activity .arrow .vb-icon",D).addClass("vb-icon-triangle-down-wide").removeClass("vb-icon-triangle-up-wide")}else{A(".subscription-list-header .last-activity .arrow .vb-icon",D).addClass("vb-icon-triangle-up-wide").removeClass("vb-icon-triangle-down-wide")}A(".subscriptions-totalcount",D).html(vBulletin.phrase.get("showing_x_subscriptions",Z.total))}});if(U==A(Y.tab).data("url-path")){J.lastFilters={filters:J.getSelectedFilters(A(".toolbar-filter-overlay",D))}}}J.applyFilters(false,false,false,true)}else{if(Y.tab.hash=="#subscribersTab"){if(!P){I=new vBulletin.pagination({context:Q,allowHistory:R[W],tabParamAsQueryString:false,onPageChanged:function(Z,a){P.updatePageNumber(Z);if(!a){P.applyFilters(false,false,false,true)}}});P=new vBulletin.conversation.filter({context:Q,allowHistory:R[W],pagination:I,tabParamAsQueryString:false,onContentLoad:function(Z){if(P.isFilterSelected("mostactive")){A(".subscription-list-header .last-activity .arrow .vb-icon",Q).addClass("vb-icon-triangle-down-wide").removeClass("vb-icon-triangle-up-wide")}else{A(".subscription-list-header .last-activity .arrow .vb-icon",Q).addClass("vb-icon-triangle-up-wide").removeClass("vb-icon-triangle-down-wide")}A(".subscribers-totalcount",Q).html(vBulletin.phrase.get("showing_x_subscribers",Z.total))}});if(U==A(Y.tab).data("url-path")){P.lastFilters={filters:P.getSelectedFilters(A(".toolbar-filter-overlay",Q))}}}P.applyFilters(false,false,false,true)}}}}});if(tabHistory.isEnabled()){var H=tabHistory.getState(),C=vBulletin.parseQueryString(location.search,["_"]),T=Object.keys(C).length;if(T==0&&(!H||A.isEmptyObject(H.data))){var E=location.pathname.match(/\/(subscriptions|subscribers)\/?$/),S=(E&&E[1])||$defaultTabAnchor.data("url-path"),M={from:"tabs",tab:S};tabHistory.setDefaultState(M,document.title,location.href)}}N.off("click",".js-subscription__follow").on("click",".js-subscription__follow",actionSubscribeButton);A(".subscriptionsContainer").off("mouseenter mouseleave",".js-subscription__follow").on("mouseenter",".js-subscription__follow",function(){var V=A(this);if(!V.hasClass("subcribe_pending")&&V.hasClass("subscribed_button")){V.data("hover-timer",setTimeout(function(){V.toggleClass("subscribed_button unsubscribe_button").toggleClass("special secondary").find(".button-text-primary").text(vBulletin.phrase.get("following_remove"))},100))}}).on("mouseleave",".js-subscription__follow",function(){var V=A(this);clearTimeout(V.data("hoverTimer"));if(!V.hasClass("subcribe_pending")&&V.hasClass("unsubscribe_button")){V.toggleClass("subscribed_button unsubscribe_button").toggleClass("special secondary").find(".button-text-primary").text(vBulletin.phrase.get("following"))}});A(document).off("click",".subscription-list-header .last-activity .arrow").on("click",".subscription-list-header .last-activity .arrow",function(){var W=A(".vb-icon",this).hasClass("vb-icon-triangle-down-wide")?"leastactive":"mostactive",V=A(this).closest(".tab");if(V.attr("id")=="subscriptionsTab"){J.updatePageNumber(1);delete J.lastFilters}else{P.updatePageNumber(1);delete P.lastFilters}V.find(".conversation-toolbar-wrapper .toolbar-filter-overlay .filter-options input[name=filter_sort][value="+W+"]").prop("checked",false).click()});A(document).off("click",".subscription-list-header .subscription-name .arrow").on("click",".subscription-list-header .subscription-name .arrow",function(){var W=A(".vb-icon",this),X=W.hasClass("vb-icon-triangle-up-wide")?true:false,V=A(this).closest(".subscription-list-container").find(".subscription-list");$listitems=V.hasClass("js-subscribers-list")?V.find(".subscription-item .subscription-name .author"):V.find(".subscription-item .subscription-name a");$listitems.sort(function(Z,Y){if(X){return A(Y).text().toUpperCase().localeCompare(A(Z).text().toUpperCase())}else{return A(Z).text().toUpperCase().localeCompare(A(Y).text().toUpperCase())}});A.each($listitems,function(Y,Z){V.append(A(Z).closest(".subscription-item"))});if(X){W.removeClass("vb-icon-triangle-up-wide").addClass("vb-icon-triangle-down-wide")}else{W.removeClass("vb-icon-triangle-down-wide").addClass("vb-icon-triangle-up-wide")}})})})(jQuery);actionSubscribeButton=function(){var A=$(this);var E=parseInt(A.attr("data-follow-id"));var D=A.attr("data-type");if((D=="follow_members"||D=="follow_contents")&&E){var C="";if(A.hasClass("add")){C="add"}else{if(A.hasClass("delete")){C="delete"}}var B=vBulletin.getAjaxBaseurl()+"/profile/follow_button?do="+C+"&follower="+E+"&type="+D;$.ajax({url:B,type:"POST",dataType:"json",success:function(F){if(F==true||F=="1"){if(C=="delete"){if(A.attr("data-canusefriends")){A.addClass("add subscribe_button secondary").removeClass("delete subscribed_button unsubscribe_button special").find(".button-text-primary").text(vBulletin.phrase.get("follow"))}else{A.remove()}}else{A.addClass("delete subscribed_button special").removeClass("add subscribe_button secondary").find(".button-text-primary").text(vBulletin.phrase.get("following"))}}else{if(F.errors){console.log(F.errors);openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}else{if(F==2){A.addClass("subscribe_pending secondary").removeClass("special").prop("disabled",true).find(".button-text-primary").text(vBulletin.phrase.get("following_pending"))}}}},error:function(){openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}};