/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.1
|| # ------------------------------------------------------------------ # ||
|| # 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,["cancel_new_with_quote","create_new_conversation_with_quote","error_fetching_comments","error_fetching_quotes","error_x","existing_message_will_be_deleted","invalid_server_response_please_try_again","new_with_quote","please_click_on_the_quote_icon_of_the_post_you_want_to_quote","post_reply","share_post_link_help","visitor_message","x_comment","x_comments_lower","your_post_is_now_being_reviewed_and_waiting_for_moderators_approval"]);(function(B){var C=[".forum-conversation-content-widget",".group-conversation-content-widget",".blog-conversation-content-widget",".profile-widget","#privateMessageContainer .infractions"];if(!vBulletin.pageHasSelectors(C)){return false}vBulletin.conversation=vBulletin.conversation||{};vBulletin.conversation.contentEntryBox=vBulletin.conversation.contentEntryBox||{};var A=function(D){if(D.nodeIds.length>0){B("body").css("cursor","wait");vBulletin.AJAX({call:"/createcontent/fetch-quotes",data:({nodeid:D.nodeIds}),complete:function(F,E){B("body").css("cursor","auto")},success:function(E,G,H){var F="";B.each(E,function(J,I){F+=JShtmlEncode(I)+"<br/><br/>"});if(typeof D.onSuccess=="function"){D.onSuccess(B.trim(F),G,H)}},title_phrase:"conversation",error_phrase:"error_fetching_quotes",})}};vBulletin.conversation.replyWithQuotes={clickQuoteIcon:function(G){this.setPostReplyButtonStyle(G);if(G==1){B(".post-reply-btn:visible").click()}if(G==0){var E=B(".js-content-entry").last(),H=B(".js-editor",E),F=H.attr("id"),D=vBulletin.ckeditor.editorExists(F);if(D){vBulletin.ckeditor.getEditor(F).setData("")}}},clickCancelButton:function(){B(".b-post-control__quote--selected").removeClass("b-post-control__quote--selected");this.setPostReplyButtonStyle(0);return true},setPostReplyButtonStyle:function(F){var D=B(".post-reply-btn"),E=D.find(".js-button__text-secondary");if(F>0){D.addClass("b-button--special");E.text("("+F+")")}else{D.removeClass("b-button--special");E.text("")}}};vBulletin.conversation.showPostLink=function(E){var D=B(this);if(this.tagName.toLowerCase()=="span"){D=D.parent()}D.qtip({content:{title:{text:vBulletin.phrase.get("share_post_link_help"),button:true},text:'<input type="text" class="textbox stretch" value="'+D.attr("href")+'" />'},position:{my:"right top",at:"left top",viewport:B(window)},show:{event:"click",solo:true},events:{show:function(G,F){},visible:function(G,F){F.elements.content.find("input.textbox").focus().select()},hide:function(G,F){}},hide:{event:"unfocus",fixed:true},style:{classes:"ui-tooltip-shadow ui-tooltip-light ui-tooltip-sharepostlink"}});D.qtip("api").show()};vBulletin.conversation.initialCommentCountToDisplay=1;vBulletin.conversation.init=function(){var H=B(".conversation-content-widget"),K=B(".conversation-toolbar-wrapper",H).data("allow-history")=="1";var J=H.filter(".widget-tabs").tabs({active:(B(".conversation-stream-view",H).length==1?1:0)});J.find(".widget-header .widget-tabs-nav li.ui-state-default:not(.ui-tabs-active) a").off("click").on("click",function(){location.href=B(this).attr("data-href");return false});var M=new vBulletin.pagination({context:H,allowHistory:K,onPageChanged:function(Q,S,P){N.updatePageNumber(Q);if(!S){var R=N.getOption("customFilter");if(R){R.pagenum=Q;delete N.lastFilters;if(P){delete R[B(".toolbar-search-form .js-filter-search",H).attr("name")]}}N.applyFilters(false,false,false,true)}vBulletin.Responsive.ConversationContent.checkForSignature()}});var E=B(".conversation-toolbar-wrapper.scrolltofixed-floating",H);var L=function(){if(H.length>0){var P=(H.offset().top+(H.outerHeight()-parseFloat(H.css("border-bottom-width")))-E.height());return P}return 0};try{var O=new vBulletin.scrollToFixed({element:E,limit:L()})}catch(D){}var N=new vBulletin.conversation.filter({context:H,scrollToTop:H,pagination:M,allowHistory:K,hash:H.find(".js-module-top-anchor").attr("id"),onContentLoad:function(){O.updateLimit(L())}});var F=function(){var R=B(".b-post-control__quote--selected",H);if(R.length>0){var Q=[];R.each(function(U){Q.push(B(this).parent().attr("data-node-id"))});var P=function(W,U){var V;console.log("setQuotes: start");if(vBulletin.ckeditor.editorExists(W)){V=vBulletin.ckeditor.getEditor(W);if(V){console.log("setQuotes: remove data");V.setData("",function(){console.log("setQuotes: insert quotes data");V.insertHtml(U.replace(/(\n)/gi,"<br />"));V.focus()})}}else{W.val(U.replace(/\<br(\s*\/|)\>/gi,"\n")).focus()}};var S={nodeIds:Q,onSuccess:function(U){var V=B(".js-content-entry .js-editor",H).last();P(V,U)}};A(S)}else{var T=B(".js-content-entry .js-editor",H).last();if(vBulletin.ckeditor.editorExists(T)){vBulletin.ckeditor.getEditor(T).focus()}else{T.focus()}}};B(document).off("click",".b-post__count").on("click",".b-post__count",function(P){P.preventDefault();vBulletin.conversation.showPostLink.apply(P.target,[P])});B(".conversation-toolbar .post-reply-btn").click(function(U,W){var V=B(".js-content-entry").last(),Y=this;if(V.length==1){var T=B(".js-editor",V),Q=V.offset().top,S=B(".conversation-toolbar-wrapper"),X=S.hasClass("scrolltofixed"),P=S.outerHeight(true),R=vBulletin.ckeditor.editorExists(T);if(!X){Q+=P}if(R){F.apply(Y)}else{vBulletin.ckeditor.initEditor(T,{complete:function(){F.apply(Y)}})}vBulletin.animateScrollTop(Q,{duration:500,complete:function(){if(R){vBulletin.ckeditor.focusEditor(T)}}})}});B(document).off("mouseover",".js-userinfo__signature").on("mouseover",".js-userinfo__signature",function(){if(B(this).data("qtip-initialized")=="1"){return }B(this).data("qtip-initialized","1");var P=B(this).find(".user-signature");if(B.trim(P.html()).length==0){P=B(this).closest(".list-item").find(".post-signature")}B(this).qtip({content:P,position:{my:"top left",at:"bottom center"},style:{classes:"ui-tooltip-shadow ui-tooltip-light ui-tooltip-rounded ui-tooltip-signature"},hide:{event:"unfocus"},show:{solo:true}});B(this).trigger("mouseover")});var I=B(".conversation-list",H);B(".js-post-controls",I).disableSelection();I.off("click",".js-post-control__quote").on("click",".js-post-control__quote",function(){B(this).toggleClass("b-post-control__quote--selected");var P=B(".post-reply-btn .js-button__text-secondary");var Q=P.text().match(/[0-9]+/);Q=Q?Number(Q[0]):0;if(B(this).hasClass("b-post-control__quote--selected")){Q++}else{Q--}vBulletin.conversation.replyWithQuotes.clickQuoteIcon(Q)});I.off("click",".js-post__history").on("click",".js-post__history",vBulletin.conversation.showPostHistory);I.off("click",".js-post-control__ip-address").on("click",".js-post-control__ip-address",vBulletin.conversation.showIp);I.off("click",".js-post-control__vote").on("click",".js-post-control__vote",function(P){if(B(P.target).closest(".bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(P.target,[P])}else{vBulletin.conversation.votePost.apply(this,[P])}return false});I.off("click",".js-post-control__edit").on("click",".js-post-control__edit",vBulletin.conversation.editPost);I.off("click",".js-post-control__flag").on("click",".js-post-control__flag",vBulletin.conversation.flagPost);I.off("click",".js-post-control__comment").on("click",".js-post-control__comment",function(P){vBulletin.conversation.toggleCommentBox.apply(this,[P])});if((typeof (vBulletin.inlinemod)!="undefined")&&(typeof (vBulletin.inlinemod.init)=="function")){vBulletin.inlinemod.init(H)}I.off("click",".js-comment-entry__post").on("click",".js-comment-entry__post",function(P){vBulletin.conversation.postComment.apply(this,[P,function(Z){if(Z){if(Z.redirecturl){location.replace(Z.redirecturl);return }if(Z.needmod){B(this).closest(".js-comment-entry").find(".js-comment-entry__textbox").val("").trigger("update.elastic");showStatusMessage(vBulletin.phrase.get("your_post_is_now_being_reviewed_and_waiting_for_moderators_approval"),"moderate");return }var W=B(this).closest(".js-post"),Q=Z.totalcomments,V=Math.ceil(Q/vBulletin.conversation.COMMENTS_PER_PAGE),X=W.find(".js-comments").removeClass("h-hide"),R=W.find(".js-comments__comments");B(this).closest(".js-comment-entry").addClass("b-comment-entry--has-comments").find(".js-comment-entry__textbox").val("").trigger("update.elastic");var U=B(Z.template),S=U.find(".js-comment");U.appendTo(R);X.find(".js-comments__footer").addClass("h-hide");X.find(".js-comments__page--prev").show().data("page-num",1).prev("label").hide();X.find(".js-comments__header").removeClass("h-hide").find(".js-comments__pagination").removeClass(function(){return(Q>1)?"h-hide":""}).end().find(".js-comments__total-text").text(function(){var a=Q>1?"x_comments_lower":"x_comment";return vBulletin.phrase.get(a,Q)});var T=W.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");if(T.hasClass("scrolltofixed-floating")){var Y=T.data("object-instance");if(Y){Y.addLimit(S.outerHeight(true))}}vBulletin.scrollToAnchor("#post"+Z.nodeId)}}])});I.off("click",".js-comments__page--prev, .js-comments__page--next").on("click",".js-comments__page--prev, .js-comments__page--next",function(){B("body").css("cursor","wait");var T=B(this),P=T.closest(".js-post"),U=P.find(".js-comments"),Q=U.find(".js-comments__comments"),S=Number(T.data("page-num"))||0,R=T.closest(".canvas-widget").attr("data-widget-instance-id");vBulletin.AJAX({call:"/ajax/fetch-comments",data:({page:S,parentid:P.attr("data-node-id"),postindex:P.find(".js-post__content .b-post__count").text().replace("#",""),widgetInstanceId:R,isblogcomment:T.closest(".blog-list").length==1?1:0,isarticlecomment:T.closest(".article-list").length==1?1:0}),complete:function(W,V){B("body").css("cursor","auto")},success:function(g,X,f){if(g.templates){var Y=B("<ul />").attr("class",Q.attr("class")),W=g.totalcomments;B.each(g.templates,function(h,i){Y.append(i)});Q.replaceWith(Y);var d=Number(Y.find(".js-comment:first-child .b-post__count span").text().replace(/\D/g,"")),e=Number(Y.find(".js-comment:last-child .b-post__count span").text().replace(/\D/g,"")),Z=Math.ceil(W/vBulletin.conversation.COMMENTS_PER_PAGE),V,c;if(T.hasClass("js-comments__page--prev")){V=T;c=U.find(".js-comments__page--next")}else{V=U.find(".js-comments__page--prev");c=T}var a=function(h,j,i){h.find(".js-comments__pagination > label").show().text(((j==i)?j:"{0} - {1}".format(j,i)))};S=g.page;a(U.find(".js-comments__header"),d,e);if(S==1){U.find(".js-comments__footer").addClass("h-hide")}else{d=e+1;e=d+vBulletin.conversation.COMMENTS_PER_PAGE-1;e=(e>W)?W:e;var b=U.find(".js-comments__footer");b.removeClass("h-hide");a(b,d,e)}V.data("page-num",S+1);c.data("page-num",((S-1)||1));V.removeClass("h-hide-imp")[Z>S?"show":"hide"]().prev("label").show();c[S>1?"show":"hide"]()}},title_phrase:"conversation",error_phrase:"error_fetching_comments",})});vBulletin.conversation.bindEditFormEventHandlers("text");vBulletin.conversation.bindEditFormEventHandlers("event");vBulletin.conversation.bindEditFormEventHandlers("comment");var G=parseInt(pageData.nodeid);if(G){if(pageData.threadmarking=="0"||pageData.userid=="0"){vBulletin.cookie.setBbarrayCookie("discussion_view",G,Math.round(new Date().getTime()/1000))}else{vBulletin.markRead(G)}vBulletin.AJAX({call:"/ajax/api/node/incrementNodeview",data:{nodeid:G},error:vBulletin.ajaxtools.logAjaxError,api_error:vBulletin.ajaxtools.logApiError})}if((location.href.indexOf("edit=1")!=-1)&&pageData.nodeid&&pageData.nodeid>0){B("#edit-"+pageData.nodeid).trigger("click")}B(document).off("change",".js-article-content-pagenav").on("change",".js-article-content-pagenav",function(){window.location.href=B(this).val()})};B(document).ready(function(){vBulletin.conversation.init()})})(jQuery);