/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2018 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,["contenttype_vbforum_socialgroup","error","invalid_page_specified","searchtype_social_groups"]);(function(A){var B=[".socialgroup-home-widget",".socialgroup-category-list-widget"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){vBulletin.conversation=vBulletin.conversation||{};var Z=A(".socialgroup-widget"),N=A(".activity-stream-widget"),E=A("#activity-stream-tab",N),J=A(".conversation-list",E),C=A(".groups-tab",Z),U,S,I,R,b,V={},L=N.find(".js-module-top-anchor").attr("id");if(Z.hasClass("socialgroup-home-widget")){function M(f){var g=(N.offset().top+(N.outerHeight()-parseFloat(N.css("border-bottom-width")))-f.height());return g}var F=N.find(".widget-tabs-nav .ui-tabs-nav > li"),P=F.filter(".ui-tabs-active"),O=P.index(),e,Y=false,K=F.parent().data("allow-history")=="1",D=new vBulletin.history.instance(K);if(O==-1){O=0;P=F.first()}e=P.find("> a").attr("href");var c=function(f){f=f||e;return F.filter('li:has(a[href*="'+f+'"])').first().index()};var T=function(m,j,l,k,o,f){var h=A(".conversation-toolbar-wrapper.scrolltofixed-floating",m),i=new vBulletin.scrollToFixed({element:h,limit:M(h)}),g=null,n;if(k){n=new vBulletin.pagination({context:m,allowHistory:l,onPageChanged:function(p,q){g.updatePageNumber(p);if(!q){g.applyFilters(false,true,false,true)}}})}g=new vBulletin.conversation.filter({context:m,autoCheck:o?A(".toolbar-filter-overlay input[type=radio][value=conversations_on]",m).is(":checked"):undefined,scrollToTop:j,pagination:n,allowHistory:l,onContentLoad:f});return{"$bar":h,"$floating":i,pagination:n,filter:g}};var Q=function(f){vBulletin.truncatePostContent(f);vBulletin.conversation.processPostContent(f)};var a=function(i,h,f){var g=h.filter;if(h.pagination){h.pagination.setOption("context",i)}g.setOption("context",i);if(typeof g.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",f).length>0){delete g.lastFilters}};var d=function(l,i,k,j,n,g,h,o){var m=T(l,i,k,j,n,function(){m.$floating.updateLimit(M(m.$bar));if(h){Q(h)}if(o){o()}});var f=m.filter;if(g){if(h){Q(h)}f.lastFilters={filters:f.getSelectedFilters(A(".toolbar-filter-overlay",l))}}return m};var X=function(i,g,k){var h=g.id,j=(e==k);if(typeof V[h]=="undefined"){V[h]=A(".conversation-toolbar-wrapper",g).data("allow-history")=="1"}if(k=="#activity-stream-tab"){if(!S){U=d(E,N,V[h],false,true,j,J,null);S=U.filter;if(j){A(this).data("noPushState",true)}}else{a(E,U,g)}S.applyFilters(false,true)}else{if(k=="#groups-tab"){if(S){S.toggleNewConversations(false)}if(!b){b=vBulletin.history.instance(V[h]);if(j){H(true)}W()}var f=A(".conversation-empty",g);if(f.length>0){if(j&&!I){I=true;return false}f.addClass("h-hide");G({},!A(this).data("noPushState"))}}}};F.removeClass("ui-state-disabled");vBulletin.tabify.call(N,{tabHistory:D,getTabIndexByHash:c,allowHistory:K,tabParamAsQueryString:true,hash:L,tabOptions:{active:O,beforeActivate:function(h,i){if(S){S.hideFilterOverlay()}var g=N.find(".widget-tabs-panel .ui-tabs-panel:visible");var f=g.find(".list-item-body-wrapper.edit-post .edit-conversation-container");if(f.length>0){openAlertDialog({title:vBulletin.phrase.get("edit_conversation"),message:vBulletin.phrase.get("you_have_a_pending_edit_unsaved"),iconType:"warning",onAfterClose:function(){vBulletin.animateScrollTop(f.closest(".list-item").offset().top,{duration:"slow"})}});return false}},create:function(f,g){X(g.tab,g.panel,g.panel.selector)},activate:function(f,g){X(g.newTab,g.newPanel,g.newPanel.selector)}}});N.off("click",".list-item-poll .view-more-ctrl").on("click",".list-item-poll .view-more-ctrl",function(g){var f=A(this).closest("form.poll");var h=f.find("ul.poll");A(this).addClass("h-hide");h.css("max-height","none").find("li.h-hide").slideDown(100,function(){f.find(".js-button-group").removeClass("h-hide").next(".view-less-ctrl").removeClass("h-hide");vBulletin.animateScrollTop(f.offset().top,{duration:"fast"})});return false});N.off("click",".list-item-poll .view-less-ctrl").on("click",".list-item-poll .view-less-ctrl",function(g){var f=A(this).closest("form.poll");vBulletin.conversation.limitVisiblePollOptionsInAPost(f,3);f.find("ul.poll").css("max-height","").find("li.h-hide").slideUp(100);return false});N.off("click",".js-post-control__ip-address").on("click",".js-post-control__ip-address",vBulletin.conversation.showIp);N.off("click",".js-post-control__edit").on("click",".js-post-control__edit",function(f){vBulletin.conversation.editPost.apply(this,[f,S])});N.off("click",".js-post-control__vote").on("click",".js-post-control__vote",function(f){if(A(f.target).closest(".js-bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(f.target,[f])}else{vBulletin.conversation.votePost.apply(this,[f])}return false});N.off("click",".js-post-control__flag").on("click",".js-post-control__flag",vBulletin.conversation.flagPost);N.off("click",".js-post-control__comment").on("click",".js-post-control__comment",vBulletin.conversation.toggleCommentBox);N.off("click",".js-comment-entry__post").on("click",".js-comment-entry__post",function(f){vBulletin.conversation.postComment.apply(this,[f,function(){S.updatePageNumber(1).applyFilters(false,true)}])});vBulletin.conversation.bindEditFormEventHandlers("all")}function H(i){if(b.isEnabled()){var j=b.getState();if(!j||A.isEmptyObject(j.data)){var g={from:"filter_groups",page:Number(A(".pagenav-form .defaultpage",C).val())||1,filters:{filter_groups:A(".js-button-filter.js-checked",C).data("filter-value")}};i?(g.tab="#groups-tab"):null;var f=vBulletin.parseQueryString(location.search),h;if(i&&typeof f.tab=="undefined"&&e&&e!="#groups-tab"){f.tab="groups-tab";h=location.pathname+"?"+A.param(f)}else{h=location.href}b.setDefaultState(g,document.title,h)}}}function W(){if(b.isEnabled()){b.setStateChange(function(j,m,l){var f=b.getState();if(f.data.from=="filter_groups"||m=="pagination"){b.log(f.data,f.title,f.url);var k=Z.hasClass("ui-tabs")&&Z,h=k&&k.tabs("option","selected"),n=k&&k.find(".ui-tabs-nav > li").eq(h).find("a").attr("href");if(n!==false&&n!=f.data.tab){var i=k.find(".ui-tabs-nav > li").filter('li:has(a[href*="{0}"])'.format(f.data.tab)).index();vBulletin.selectTabByIndex.call(k,i)}else{var g={page:f.data.page,my:m=="pagination"&&l?(l.filter_groups||"show_all"):f.data.filters.filter_groups};G(g,false)}}},"filter")}}A(document).off("click",".add-sg").on("click",".add-sg",function(f){vBulletin.AJAX({call:"/ajax/api/content_channel/canAddChannel",data:{nodeid:pageData.channelid},success:function(g){if(g.can===true){location.href=pageData.baseurl+"/sgadmin/create/settings"}else{if(g.exceeded>0){vBulletin.warning("social_groups","you_can_only_create_x_groups_delete")}}},title_phrase:"social_groups"})});V["groups-tab"]=V["groups-tab"]||A(".conversation-toolbar-wrapper",C).data("allow-history")=="1";C.off("click",".js-button-filter").on("click",".js-button-filter",function(f){var g={my:A(this).data("filter-value"),page:1};G(g,true)});R=new vBulletin.pagination({context:C,allowHistory:V["groups-tab"],onPageChanged:function(j,i,g,h){if(!i){var f=typeof h!="undefined"?vBulletin.parseQueryString(f):null,k={my:f&&typeof f.filter_groups=="undefined"?"show_all":A(".js-button-filter.js-checked",C).data("filter-value"),page:j};G(k,i)}}});if(!Z.hasClass("ui-tabs")){b=vBulletin.history.instance(V["groups-tab"]);H(false);W()}function G(m,i){var j=A(".conversation-list",C),l=A(".sg-groups-list",j),g=A(".sg-groups-pagination",l);m.sgparent=m.sgparent||A(".js-category",g).val();m.page=m.page||A(".js-pagenum",g).val();m.perpage=m.perpage||A(".js-perpage",g).val();m.my=m.my||C.find(".js-button-filters .js-button-filter.js-checked").data("filter-value");m.routeInfo=m.routeInfo||l.find(".sg-groups-list-container").data("route");A(".js-button-filters .js-button-filter",C).removeClass("js-checked").filter('[data-filter-value="{0}"]'.format(m.my)).addClass("js-checked");m.isAjaxTemplateRenderWithData=true;vBulletin.AJAX({call:"/ajax/render/socialgroup_nodes",data:m,success:function(p){j.replaceWith(p.template);var t=A(".conversation-toolbar-wrapper .pagenav-controls .pagenav-form",C),r=A(".arrow",t).removeClass("h-disabled"),n=C.find(".sg-groups-list .sg-groups-pagination"),q=n.find(".js-prevpage").val(),s=n.find(".js-nextpage").val();A(".js-pagenum",t).val(n.find(".js-pagenum").val());A(".pagetotal",t).text(n.find(".js-totalpages").val());var o=function(w,v){var u=r.filter(w).toggleClass("h-disabled",!v);if(v){u.attr("href",v)}else{u.removeAttr("href")}};o("[rel=prev]",q);o("[rel=next]",s)},title_phrase:"contenttype_vbforum_socialgroup",error_phrase:"unable_to_contact_server_please_try_again",});if(i){var h=location.pathname;if(e&&e!="#groups-tab"){h+="?tab=groups-tab"}h=vBulletin.makePaginatedUrl(h,m.page);h=vBulletin.makeFilterUrl(h,"filter_groups",m.my,C);if(b&&b.isEnabled()){var k=b.getState(),f={from:"filter_groups",page:m.page,tab:C.hasClass("ui-tabs-panel")?"#"+C.attr("id"):undefined,filters:{filter_groups:m.my}};b.pushState(f,document.title,h)}else{if(V["groups-tab"]){h=vBulletin.makeFilterUrl(h,"filter_groups",filterValue,C,L);location.href=h;return false}}}}})})(jQuery);