/*=======================================================================*\
|| ###################################################################### ||
|| # 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,[]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,[]);(function(A){var C=[".forum-channel-content-widget",".blog-channel-content-widget",".sg-channel-content-widget",".search-results-widget .topic-list-container"];if(!vBulletin.pageHasSelectors(C)){return false}var B={};vBulletin.conversation.editTopicTitle=function(G){var F=A(G.target),D=F.closest(".js-topic-item"),E=D.find(".js-topic-wrapper"),I=D.data("node-id"),H=D.data("can-edit-title");if(!H){return }if(B[I]){return }B[I]="edit";if(E.find(".js-loading-icon").length==0){A('<img class="loading-icon js-loading-icon" src="'+pageData.baseurl+'/images/misc/progress.gif" />').appendTo(E)}E.find(".js-loading-icon").show();vBulletin.AJAX({call:"/create-content/loadtitleedit",data:{nodeid:I,isAjaxTemplateRender:true},success:function(J){E.find(".js-topic-title").hide();E.find(".js-loading-icon").hide();E.find(".js-topic-title").after(J);var L=E.find(".js-topic-title-edit");L.data("original-title",L.val());var K=30;E.find(".js-prefix, .js-post-icon, .js-topic-prefix, .js-go-to-first-unread").each(function(){K+=A(this).outerWidth(true)});L.outerWidth(L.outerWidth()-K);E.find(".js-topic-title-edit-form").on("submit",vBulletin.conversation.saveTopicTitle);L.on("blur",vBulletin.conversation.saveTopicTitle);L.select().focus()}})};vBulletin.conversation.saveTopicTitle=function(G){G.preventDefault();var F=A(G.target).closest(".js-topic-wrapper"),D=F.find(".js-topic-title-edit-form"),I=D.find(".js-node-id").val(),H=D.find(".js-topic-title-edit").val();if(B[I]=="save"){return }B[I]="save";var J=F.find(".js-topic-title-edit"),E=J.data("original-title");if(E==H){F.find(".js-loading-icon").remove();F.find(".js-topic-title-edit-form").remove();F.find(".js-topic-title").show();B[I]=false}else{F.find(".js-loading-icon").appendTo(D).show();vBulletin.AJAX({call:"/create-content/savetitleedit",data:{nodeid:I,title:H},success:function(K){F.find(".js-loading-icon").remove();F.find(".js-topic-title-edit-form").remove();F.find(".js-topic-title").html(K.title).show();B[I]=false}})}};A(document).ready(function(){vBulletin.conversation=vBulletin.conversation||{};var G=A(".channel-content-widget .channel-conversation-list-wrapper");var J=A("#activity-stream-tab",G);if(J.length==0){J=A("#article-tab",G)}var O=A("#recommended-tab",G);var P=A("#subscribed-tab",G);var g=A("#topic-tab",G);var K=A("#media-tab",G);var Q=A(".conversation-list",J);var j=A(".conversation-list",O);var b=A(".conversation-list",P);var h=A(".conversation-list",g);var Y=A(".conversation-list",G);var M,i,V,c,D;var f,d,W,F;var N,a,X,Z;var e,H,S=true;var L=G.find(".widget-tabs-nav .ui-tabs-nav > li"),U=L.filter(".ui-tabs-selected"),T=U.index(),l,E=L.parent().data("allow-history")=="1",I=new vBulletin.history.instance(E);if(T==-1){T=0;U=L.first()}l=U.find("> a").attr("href");var R=function(m){var n=(G.offset().top+(G.outerHeight()-parseFloat(G.css("border-bottom-width")))-m.height());console.log(n);return n};var k=function(m){m=m||l;return L.filter('li:has(a[href*="'+m+'"])').first().index()};L.removeClass("ui-state-disabled");vBulletin.tabify.call(G,{tabHistory:I,getTabIndexByHash:k,allowHistory:E,tabParamAsQueryString:true,hash:G.find(".js-module-top-anchor").attr("id"),tabOptions:{selected:T,select:function(o,p){if(X){X.hideFilterOverlay()}if(V){V.hideFilterOverlay()}if(W){W.hideFilterOverlay()}var n=G.find(".widget-tabs-panel .ui-tabs-panel:visible");var m=n.find(".list-item-body-wrapper.edit-post .edit-conversation-container");if(m.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(m.closest(".list-item").offset().top,{duration:"slow"})}});return false}},show:function(o,q){if(q.tab.hash=="#activity-stream-tab"||q.tab.hash=="#article-tab"){if(V){V.toggleNewConversations(false)}if(!X){N=A(".conversation-toolbar-wrapper.scrolltofixed-floating",J);a=new vBulletin.scrollToFixed({element:N,limit:R(N)});H=new vBulletin.pagination({context:J,allowHistory:E,onPageChanged:function(r,s){X.updatePageNumber(r);if(!s){X.applyFilters(false,true,false,true)}}});X=new vBulletin.conversation.filter({context:J,autoCheck:A(".toolbar-filter-overlay input[type=radio][value=conversations_on]",J).is(":checked"),scrollToTop:G,pagination:H,allowHistory:E,onContentLoad:function(){a.updateLimit(R(N));vBulletin.truncatePostContent(Q);vBulletin.conversation.processPostContent(Q)}});if(l==q.tab.hash){vBulletin.truncatePostContent(Q);vBulletin.conversation.processPostContent(Q);X.lastFilters={filters:X.getSelectedFilters(A(".toolbar-filter-overlay",J))}}}else{X.setOption("context",J);H.setOption("context",J);if(typeof X.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",q.panel).length>0){delete X.lastFilters}}X.applyFilters(false,true)}else{if(q.tab.hash=="#subscribed-tab"){if(X){X.toggleNewConversations(false)}if(V){V.toggleNewConversations(false)}if(!W){f=A(".conversation-toolbar-wrapper.scrolltofixed-floating",P);d=new vBulletin.scrollToFixed({element:f,limit:R(f)});W=new vBulletin.conversation.filter({context:P,scrollToTop:G,allowHistory:E,onContentLoad:function(){d.updateLimit(R(f));vBulletin.truncatePostContent(b);vBulletin.conversation.processPostContent(b)}});if(l==q.tab.hash){vBulletin.truncatePostContent(b);vBulletin.conversation.processPostContent(b);W.lastFilters={filters:W.getSelectedFilters(A(".toolbar-filter-overlay",P))}}}else{W.setOption("context",P);if(typeof W.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",q.panel).length>0){delete W.lastFilters}}W.applyFilters(false)}else{if(q.tab.hash=="#topic-tab"){if(X){X.toggleNewConversations(false)}if(!V){M=A(".conversation-toolbar-wrapper.scrolltofixed-floating",g);i=new vBulletin.scrollToFixed({element:M,limit:R(M)});e=new vBulletin.pagination({context:g,allowHistory:E,onPageChanged:function(r,s){V.updatePageNumber(r);if(!s){V.applyFilters(false,true,false,true)}}});V=new vBulletin.conversation.filter({context:g,autoCheck:A(".toolbar-filter-overlay input[type=radio][value=conversations_on]",g).is(":checked"),scrollToTop:G,pagination:e,allowHistory:E,onContentLoad:function(){i.updateLimit(R(M));vBulletin.markreadcheck()}});if(l==q.tab.hash){V.lastFilters={filters:V.getSelectedFilters(A(".toolbar-filter-overlay",g))}}}else{V.setOption("context",g);e.setOption("context",g);if(typeof V.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",q.panel).length>0){delete V.lastFilters}}V.applyFilters(false,true)}else{if(q.tab.hash=="#media-tab"){if(X){X.toggleNewConversations(false)}if(V){V.toggleNewConversations(false)}if(!c){c=A(".conversation-toolbar-wrapper.scrolltofixed-floating",K);D=new vBulletin.scrollToFixed({element:c,limit:R(c)});var n=new vBulletin.history.instance(E);if(n.isEnabled()){var p=n.getState();if(!p||A.isEmptyObject(p.data)){var m={from:"filter",page:1,tab:q.tab.hash,filters:vBulletin.getSelectedFilters(A("form.toolbar-filter-overlay",q.panel))};n.setDefaultState(m,document.title,location.href)}n.setStateChange(function(u,v,s){var t=n.getState();if(t.data.from=="filter"){n.log(t.data,t.title,t.url);if(q.tab.hash!=t.data.tab){vBulletin.selectTabByIndex.call(A(q.tab).closest(".ui-tabs-nav"),q.index)}else{var r=A('.media-filter-overlay input[name="filter_time"][value="{0}"]'.format(t.data.filters.filter_time),q.panel).prop("checked",true);if(r.hasClass("js-default-checked")&&r.prop("defaultChecked")){A(".filtered-by .x",q.panel).trigger("click")}else{r.trigger("change",[true])}}}},"filter")}if(l==q.tab.hash){S=false}}else{S=true}if(S&&A("#profileMediaDetailContainer .album-detail",q.panel).length==0){if(!F){F=vBulletin.media.calculatePhotosPerPage(vBulletin.media.TARGET_PHOTOS_PERPAGE)}loadGalleryById({nodeid:-2,channelid:pageData.channelid,pageno:1,dateFilter:A(".filter-options input[name=filter_time]:checked",q.panel).val()||"time_lastweek",perpage:F},true,0,{complete:function(){A(".profile-toolbar .media-toolbar-filter",K).removeClass("h-hide");D.updateLimit(R(c))}})}}}}}}}});Y.off("click",".list-item-poll .view-more-ctrl").on("click",".view-more-ctrl",function(n){var m=A(this).closest("form.poll");var o=m.find("ul.poll");A(this).addClass("h-hide");o.css("max-height","none").find("li.h-hide").slideDown(100,function(){m.find(".action-buttons").removeClass("h-hide").next(".view-less-ctrl").removeClass("h-hide");vBulletin.animateScrollTop(m.offset().top,{duration:"fast"})});return false});Y.off("click",".list-item-poll .view-less-ctrl").on("click",".view-less-ctrl",function(n){var m=A(this).closest("form.poll");vBulletin.conversation.limitVisiblePollOptionsInAPost(m,3);m.find("ul.poll").css("max-height","").find("li.h-hide").slideUp(100);return false});Y.off("click",".js-post__history").on("click",".js-post__history",vBulletin.conversation.showPostHistory);Y.off("click",".js-post-control__ip-address").on("click",".js-post-control__ip-address",vBulletin.conversation.showIp);Y.off("click",".js-post-control__edit").on("click",".js-post-control__edit",function(m){vBulletin.conversation.editPost.apply(this,[m,X])});Y.off("click",".js-post-control__vote").on("click",".js-post-control__vote",function(m){if(A(m.target).closest(".bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(m.target,[m])}else{vBulletin.conversation.votePost.apply(this,[m])}return false});Y.off("click",".js-post-control__flag").on("click",".js-post-control__flag",vBulletin.conversation.flagPost);Y.off("click",".js-post-control__comment").on("click",".js-post-control__comment",vBulletin.conversation.toggleCommentBox);Y.off("click",".js-comment-entry__post").on("click",".js-comment-entry__post",function(m){vBulletin.conversation.postComment.apply(this,[m,function(){X.updatePageNumber(1).applyFilters(false,true)}])});vBulletin.conversation.bindEditFormEventHandlers("all");A(document).off("dblclick",".js-cell-topic").on("dblclick",".js-cell-topic",vBulletin.conversation.editTopicTitle)})})(jQuery);