/*=======================================================================*\
|| ###################################################################### ||
|| # 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,["add_folder","are_you_sure_move_to_trash","are_you_sure_permanently_delete_messages","delete_folder","edit_folder","error","error_deleting_folder","error_editing_folder","error_x","folder_name","follow_request_denied","invalid_node_id","messages_updated_desc","need_folder_name","no_moderate_permissions","no_publish_permissions","page_does_not_exist","pending_posts","delete_pending_posts","please_enter_a_valid_page_number","please_select_messages","pm_ajax_error_desc","selected_folder_and_contents_will_be_deleted","sent_follow_request","private_messages","mark_message_status_text_for_move","mark_messages_status_text_for_move","mark_message_status_text_for_delete","mark_messages_status_text_for_delete","mark_message_status_text_for_read","mark_messages_status_text_for_read","mark_message_status_text_for_unread","mark_messages_status_text_for_unread","mark_message_status_text_generic","mark_messages_status_text_generic","mark_report_status_text_for_delete","mark_reports_status_text_for_delete","mark_report_status_text_for_open","mark_reports_status_text_for_open","mark_report_status_text_for_closed","mark_reports_status_text_for_closed","mark_report_status_text_generic","mark_reports_status_text_generic","messages_header","following","following_pending","follow","members_in_this_message","all_changes_made_will_be_lost_would_you_like_to_continue","cancel","need_privatemessage_text","invalid_pm_recipients"]);var $pmWidget;(function(G){window.vBulletin=window.vBulletin||{};window.vBulletin.privateMessage=window.vBulletin.privateMessage||{};var E=vBulletin.history.instance(true),C=getNotificationsFilterParams(),B={};if(Object.keys(C).length>0){B.notificationFilterParams=C}E.setDefaultState(B,document.title,window.location.href);E.setStateChange(function(K){var I=E.getState();if(I.data.hasOwnProperty("notificationFilterParams")){var J=I.data.notificationFilterParams;H(J);A(J.page,true)}},"privatemessage");window.vBulletin.privateMessage.pmFilterHistory=E;vBulletin.privateMessage.updatePaginationLinks=function(R,Z,L){var I=R.find(".js-pagenav");if(I.length>0){var M=I.find(".js-pagenav-button:not(.js-pagenav-button--template)"),W=I.find(".js-pagenav-next-button"),V=I.find(".js-pagenav-prev-button"),P=I.find(".js-pagenav-button--template"),O=/\/(\d+)\/?$/,a=0,T="",K="",X="",J={},Y=Z-2,S=Z+2,Q=G("#maxPageNum").val();if(P.attr("href")==""&&I.data("baseurl")!=""){P.attr("href",I.data("baseurl"))}X=P.attr("href");J=D(Z,X);P.attr("href",J.newHrefBase);K=J.queryString;if(Y<1){Y=1}S=Y+4;if(S>Q){S=Q}M.not(".js-pagenav-next-button, .js-pagenav-prev-button").remove();for(var U=Y;U<=S;U++){T=P.attr("href").replace(O,"/"+U)+K;var N=P.clone().removeClass("js-pagenav-button--template h-hide-imp").attr("data-page",U).text(U).attr("href",T);if(U==Z){N.removeClass("b-button--secondary").addClass("b-button--primary")}N.insertBefore(W);G(document.createTextNode("\n")).insertBefore(W)}a=parseInt(Z,10)-1;a=a>1?a:1;V.data("page",a);T=P.attr("href").replace(O,"/"+a)+K;V.attr("href",T);a=parseInt(Z,10)+1;a=a<=Q?a:Q;W.data("page",a);T=P.attr("href").replace(O,"/"+a)+K;W.attr("href",T);V.add(W).removeClass("h-hide h-hide-imp");if(Z==1){V.addClass("h-hide-imp")}if(Z==Q){W.addClass("h-hide-imp")}if(typeof (L)!="undefined"){var b=(L>1);I.closest(".pagenav-container").toggleClass("h-hide",!b);I.closest(".js-pagenav-wrapper").toggleClass("h-hide",!b)}}};function H(I){G.each(["readFilter","sortDir","typename"],function(J,L){var K="filter_"+L;if(I.hasOwnProperty(K)){I[L]=I[K];delete I[K]}});if(!I.hasOwnProperty("readFilter")){I.readFilter="unread_only"}if(!I.hasOwnProperty("sortDir")){I.sortDir="DESC"}if(!I.hasOwnProperty("typename")){I.typename=""}G("#notificationFilters").find("input:radio").each(function(J,L){var M=G(this),K=M.attr("name");if(I.hasOwnProperty(K)&&I[K]==M.val()){M.attr("checked","checked")}})}function F(I){G(this).closest(".filter-options").find(":input[type=radio]").removeAttr("checked");G(this).attr("checked","checked");A(1)}function A(I,K){I=I||1;K=K||false;var J=getNotificationsFilterParams();J.page=I;vBulletin.AJAX({call:"/ajax/render/privatemessage_notificationcontent",data:{params:J,isAjaxTemplateRenderWithData:true,},success:function(L){G("#notificationContent").html(L.template);pmPageNum=I;G("#notificationPageto").val(pmPageNum);G("#iconNotificationNext").toggleClass("h-disabled",(I>=pmPages));G("#iconNotificationPrevious").toggleClass("h-disabled",(I<=1));if(E.isEnabled()&&!K){var O=D(pmPageNum),N={notificationFilterParams:J,};E.pushState(N,document.title,O.url)}var M={folderid:folderid,page:pmPageNum,perpage:pmPerPage,about:"",filterParams:J};vBulletin.privateMessage.updatePaginationLinks(G("#notificationContent").parent(),G("#notificationPageto").val());vBulletin.AJAX({call:"/ajax/api/content_privatemessage/getFolderMsgCount",data:M,success:function(P){if(P&&P.pages>0){if(E.isEnabled()&&!K&&pmPageNum!=P.pagenum){var R=D(P.pagenum),Q={notificationFilterParams:J,};E.setDefaultState(Q,document.title,R.url)}pmPageNum=P.pagenum;pmPages=P.pages;pmNotificationCount=P.count;G("#notificationPageCount").html(pmPages);G("#maxPageNum").val(pmPages);G("#iconNotificationNext").toggleClass("h-disabled",!(pmPages>1));G("#privatemessagePaging").toggleClass("h-hide",(pmPages<=1));G("#notificationPageto").val(pmPageNum);G("#iconNotificationPrevious").toggleClass("h-disabled",(pmPageNum<=1));G("#iconNotificationNext").toggleClass("h-disabled",(pmPageNum>=pmPages));vBulletin.privateMessage.updatePaginationLinks(G("#notificationContent").parent(),pmPageNum,pmPages)}}})}})}vBulletin.privateMessage.getPageFiltersForUrl=function(I){return I};function D(I,N){var R={},P="",L=/\/(\d+)\/?$/,M={};if(typeof N=="undefined"){N=window.location.href}P=N;M=vBulletin.parseUrl(N);if(M.search.length>1){var O=M.search.substr(1).split("&");for(var J=0;J<O.length;J++){var Q=O[J].split("=");if(Q.length>1){R[Q[0]]=Q[1]}}P=window.location.protocol+"//"+M.hostname;if(M.port.length>0){P+=":"+M.port+M.pathname}else{P+=M.pathname}}P=P.replace(L,"/"+I);if(G("#notificationFilters").length){var K=getNotificationsFilterParams();G.each(["readFilter","sortDir","typename"],function(S,T){if(K.hasOwnProperty(T)){R["filter_"+T]=K[T]}})}R=vBulletin.privateMessage.getPageFiltersForUrl(R);queryString="?"+G.param(R);return{newHrefBase:P,queryString:queryString,hash:M.hash,url:P+queryString+M.hash,}}vBulletin.privateMessage.getPrivateMessageUrl=D;G(document).ready(function(){$pmWidget=G(".private-message-widget");var L=G(".js-pm-content-entry-container"),Q=G(".js-editor",L);G(document).off("focus",".js-editor.js-focus-on-page-load").on("focus",".ckeditor-bare-box.ckeditor-load-on-focus",function(){vBulletin.ckeditor.initEditor(G(this).attr("id"),{error:function(X){G("#"+X).prop("disabled",false).removeClass("ckeditor-load-on-focus").closest(".js-pm-content-entry-container").addClass("no-ckeditor")}})});if(Q.length>0&&(L.hasClass("msg-type-new")||L.hasClass("msg-type-forward"))){vBulletin.ckeditor.initEditor(Q.attr("id"),{success:function(X){var Y=Q.prev(".js-editor-parsed-text");if(Y.length>0){this.setData(Y.html())}setTimeout(function(){G(".autocompleteHelper",L)[0].focus()},200)},error:function(X){G("#"+X).prop("disabled",false).removeClass("ckeditor-load-on-focus").closest(".js-pm-content-entry-container").addClass("no-ckeditor")}})}G(".folder-list.custom-folder-list form",$pmWidget).trigger("reset");$pmWidget.off("click",".folder-item.custom-folder .edit-icon-wrapper").on("click",".folder-item.custom-folder .edit-icon-wrapper",function(Z){Z.stopPropagation();var X=G(this).closest(".custom-folder").addClass("edit-folder-mode");var Y=X.find(".edit-folder-box").select().focus();Y.val(vBulletin.htmlEntities_decode(Y.val()));Y.data({origFolderName:Y.val(),updateFlag:true});U(true);return false});var R;$pmWidget.off("keydown blur",".folder-item.custom-folder .edit-folder-box").on("keydown",".folder-item.custom-folder .edit-folder-box",function(Z){var Y=G(this),X=false;switch(Z.which){case 27:Y.data("updateFlag",false);Y.closest(".custom-folder").removeClass("edit-folder-mode");U(false);Y.val(Y.data("origFolderName"));X=true;break;case 13:Y.data("updateFlag",true);Y.trigger("blur",[true]);X=true;break;default:}return !X}).on("blur",".folder-item.custom-folder .edit-folder-box",function(a,X){var Y=G(this);var Z=function(){if(!Y.data("updateFlag")){return false}Y.data("updateFlag",false);if(!isFolderNameValid(Y,"edit_folder")){Y.data("updateFlag",true);return false}U(false);var c=Y.closest(".custom-folder"),d=Y.val().trim(),b=Y.data("origFolderName");if(d!=b){vBulletin.AJAX({call:"/ajax/api/content_privatemessage/updateFolderTitle",data:{folderName:d,folderid:Y.data("nodeId")},success:function(e){c.find(".label").text(d);S(c.detach(),$pmWidget);P(folderid,d)},title_phrase:"edit_folder",error_phrase:"error_editing_folder",complete:function(){c.removeClass("edit-folder-mode")},after_error:function(){Y.val(b)}})}else{c.removeClass("edit-folder-mode")}};if(!X){R=setTimeout(Z,200)}else{Z()}});$pmWidget.off("click",".folder-item.custom-folder .delete-icon").on("click",".folder-item.custom-folder .delete-icon",function(Z,X){clearTimeout(R);Z.stopPropagation();var a=G(this),Y=a.prev(".edit-folder-box");if(!X){openConfirmDialog({title:vBulletin.phrase.get("delete_folder"),message:vBulletin.phrase.get("selected_folder_and_contents_will_be_deleted"),iconType:"warning",onClickYes:function(){a.trigger("click",[true])},onClickNo:function(){Y.select().focus()}});return false}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/deleteFolder",data:{folderid:Y.attr("data-node-id")},success:function(b){U(false);var d=a.closest(".custom-folder"),c=d.find("a").hasClass("selected");d.remove();if(c){location.href=G(".nav-pane .folder-list .folder-item.messages a",$pmWidget).attr("href")}},title_phrase:"delete_folder",error_phrase:"error_deleting_folder",})});$pmWidget.off("click",".folder-list .folder-item > a[href]").on("click",".folder-list .folder-item > a[href]",function(Z){var X=G(".folder-list .custom-folder.edit-folder-mode",$pmWidget);if(X.length>0){X.trigger("blur",[true]);return false}var a=G(this),Y=a.parent();if(Y.hasClass("edit-folder-mode")||(!Y.hasClass("special-folder")&&a.hasClass("selected"))){return false}if(!Y.hasClass("add-folder")){G(".folder-list .folder-item > a.selected",$pmWidget).removeClass("selected");a.addClass("selected")}return true});$pmWidget.off("click",".folder-list .folder-item.add-folder > a[href]").on("click",".folder-list .folder-item.add-folder > a[href]",function(X){createNewFolder.apply(this,[X,function(Z,c){var b=G(".folder-item.custom-folder.template",$pmWidget).clone(true).removeClass("h-hide template"),a=b.find("a"),Y=b.find(".label").text(c);a.attr("href",a.attr("href").replace(/\/list\/0\//i,"/list/"+Z+"/"));b.find(".edit-folder-box").attr("data-node-id",Z).val(c);S(b,$pmWidget);P(Z,c)},function(){G(this).removeClass("selected")}]);return false});function S(c,Z){var a=false,b=c.find(".edit-folder-box").val().toLowerCase(),Y=G(".folder-list.custom-folder-list"),X;Y.find(".folder-item",Z).each(function(){X=G(this);if(b<X.find(".label").text().toLowerCase()){X.before(c);a=true;return false}});if(!a){Y.append(c)}}function P(a,b){var Z=false,Y=G("folder_"+a),X;b=vBulletin.htmlEntities(b);if(Y.length){Y.find("span").html(b);Y.parent().detach()}else{Y=G('<li class="pmMoveToFolder" id="folder_'+a+'"><span>'+b+"</span></li>")}b=b.toLowerCase();G("#pmMoveToFolder li.pmMoveToFolder").each(function(c){X=G(this);if(c>0&&b<X.html().trim().toLowerCase()){X.before(Y);Z=true;return false}});if(!Z&&X){X.after(Y)}}function U(Z){var Y,X;if(Z){Y="data-href";X="href"}else{Y="href";X="data-href"}G(".folder-list .folder-item a",$pmWidget).each(function(){var a=G(this);var b={};b[Y]=a.attr(X);a.attr(b).removeAttr(X)})}function J(X){return T(X.postId,X.postContentTypeId,X.currentPosition,X.maxPosition,X.userId,X.postType)}function T(X,Y,b,c,Z,d){var a={nodeid:X,contenttypeid:Y,currentPosition:b,maxPosition:c,};G.each(a,function(f,e){a[f]=parseInt(e,10)});Z=parseInt(Z,10);if(G.map(a,isNaN).some(Boolean)||isNaN(Z)){return false}a.postType=d;a.isAjaxTemplateRenderWithData=true;vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_overlay",type:"POST",data:a,success:function(e){G(".pending-post-overlay").html(e.template).dialog({title:vBulletin.phrase.get("pending_posts"),modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:700,dialogClass:"dialog-container pending-post-overlay-container dialog-box",}).dialog("open");var h=G(".pending-post-overlay-container"),g=h.find(".ui-dialog-titlebar");g.find(".nav-buttons").remove();var f=h.find(".pending-post-overlay .nav-buttons").detach();g.append(f);G(".pending-post-overlay .list-item").data("user-id",Z).data("post-type",d).prepend(G(".pending-posts-container .list-container .list-item[data-node-id={0}] .list-item-header".format(a.nodeid)).clone());vBulletin.ckeditor.initEditor("ckeditor-bare",{success:function(j,i){if(!i){i=vBulletin.ckeditor.getEditor(j)}i.setData(G(".pending-post-overlay .list-item .ckeditor-bare-box").html())}})},error_phrase:"unable_to_contact_server_please_try_again"})}function N(c,a){var g=parseInt(c.data("nodeId"),10),Y=parseInt(c.data("userId"),10),X=c.data("postType");a=parseInt(a,10);if(isNaN(g)||isNaN(a)){return false}var b=-1,Z=0;G(".conversation-list .list-item",$pmWidget).filter(function(h){Z++;if(G(this).attr("data-node-id")==g){b=h;return true}});if(b==-1){return false}b=b+a;var d=G(".conversation-list .list-item",$pmWidget).filter(function(h){if(b==h){return true}});if(d.length>0){var e=parseInt(d.attr("data-node-id"),10),f=parseInt(d.attr("data-node-contenttype-id"));Y=d.data("userId");X=d.data("postType");b++;return{postId:e,postContentTypeId:f,currentPosition:b,maxPosition:Z,userId:Y,postType:X}}else{return false}}function M(X,b,g){if(!X){X=G("#private-message-toolbar .pending-posts-paginator .pendingpostsPageTo");if(X.length==0){return false}}if(!g){g=0}var d=X.closest(".pending-posts-paginator"),f=d.find("#maxPageNum").filter("input[type=hidden]"),Z=d.find("input[name=pagenum]"),a=f.val(),c=parseInt(Z.val(),10),e=parseInt(d.find("input[name=per-page]").val(),10),h=d.find("input[name=routeInfoJson]").val();b=parseInt(b,10);if(isNaN(b)||isNaN(a)||isNaN(c)){return false}if((b<1)||(b>a)){vBulletin.error("error","please_enter_a_valid_page_number");return false}if((b==c)&&!g){return false}var Y={setCurrentPage:b,setPerPage:e,getPagingInfo:g,options:{},routeInfoJson:h,isAjaxTemplateRenderWithData:true,};G("#pendingFilters input:checked").each(function(){Y.options[this.name]=this.value});vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_main",data:Y,success:function(l){G("#privateMessageContainer .main-pane .pending-posts-container").html(l.template);var k=b-1,j=0;if(b<a){j=b+1}Z.val(b);d.find("input[name=next-page]").val(j);d.find("input[name=prev-page]").val(k);d.find(".pendingpostsNext").toggleClass("h-disabled",!j);d.find(".pendingpostsPrev").toggleClass("h-disabled",!k);d.find(".pendingpostsPageTo").val(b);if(g){var m=G("#privateMessageContainer .main-pane .pending-posts-container .pending-posts-pageinfo"),i=parseInt(m.find(".totalpages").val(),10);f.val(i);d.find("div.pendingpostsPageCount").text(i);G(".folder-list .folder-item.pending-posts .count",$pmWidget).text(i)}},error_phrase:"unable_to_contact_server_please_try_again"})}G("#pmBtnMarkRead").off("click").on("click",function(){markMessages(G(this).text(),"setRead","read",1,false)});G("#pmBtnMarkUnRead").off("click").on("click",function(){markMessages(G(this).text(),"setRead","read",0,false)});G("#pmBtnDelete").off("click").on("click",function(Z){var X=(typeof (messageDetailPage)!="undefined"&&messageDetailPage),Y=getSelectedMessages(),a=G(this).text();if(Y.length>0){openConfirmDialog({title:vBulletin.phrase.get("messages_header"),message:vBulletin.phrase.get("are_you_sure_move_to_trash"),iconType:"warning",onClickYes:function(){markMessages(a,"toTrashcan",false,false,X,Y)}})}});G(".pmBtnDeletePermanently").off("click").on("click",function(Y){var X=getSelectedMessages(),Z=G(this).text();if(X.length>0){openConfirmDialog({title:vBulletin.phrase.get("messages_header"),message:vBulletin.phrase.get("are_you_sure_permanently_delete_messages"),iconType:"warning",onClickYes:function(){markMessages(Z,"deleteMessages",false,false,false,X)}})}});G(".pmBtnUndelete").off("click").on("click",function(X){markMessages(G(this).text(),"undeleteMessage",false,false,false)});G("#reportBtnMarkOpen").off("click").on("click",function(X){markReports(G(this).text(),"openClose","op","open")});G("#reportBtnMarkClosed").off("click").on("click",function(X){markReports(G(this).text(),"openClose","op","closed")});G("#reportBtnDelete").off("click").on("click",function(X){markReports(G(this).text(),"bulkdelete",false,false)});$pmWidget.off("click",".split-button .move-button-set button").on("click",".split-button .move-button-set button",startMove);G("#pmBtnForward").off("click").on("click",startForward);G("#pmInfoClose").off("click").on("click",function(X){G("#pmInfoDialog").dialog("close")});G("#privatemessagePageto, #sentItemsPageTo").bind("keydown blur",gotoPage);G(".btnPmCancel").off("click").on("click",function(){openConfirmDialog({title:vBulletin.phrase.get("cancel"),message:vBulletin.phrase.get("all_changes_made_will_be_lost_would_you_like_to_continue"),iconType:"warning",onClickYes:function(){history.back()}})});G(".pmRequestAccept").off("click").on("click",acceptRequest);G(".pmRequestDeny").off("click").on("click",denyRequest);G("#pmBtnReply").off("click").on("click",function(){var Z=G(".js-pm-content-entry-container .js-editor"),Y=Z.attr("id"),X=vBulletin.ckeditor.editorExists(Y)?vBulletin.ckeditor.getEditor(Y):null;G("body,html").animate({scrollTop:G(".js-pm-content-entry-container").offset().top},"slow",function(){(X||Z[0]||G()).focus()})});G("#pmFloatingBarContent .toolbar-filter").off("click").bind("click",function(Y){var X=G(this),Z=G(".filter-wrapper",X).toggleClass("selected");G(".arrow .vb-icon",X).toggleClass("vb-icon-triangle-down-wide vb-icon-triangle-up-wide");X.closest(".toolbar-wrapper").find(".toolbar-filter-overlay").slideToggle("slow",function(){var a="pm_filter",c=this;if(G(c).is(":visible")){G("body").off("click."+a).bind("click."+a,function(d){if(G(d.target).closest(".toolbar-filter-overlay").length==0&&G(d.target).closest(".toolbar-filter").length==0){G("body").off("click."+a);X.triggerHandler("click")}});var b={};if(!vBulletin.isScrolledIntoView(c,b)){G("html,body").animate({scrollTop:"+="+Math.abs(b.bottom)},"fast")}}else{G("body").off("click."+a)}})});G(".list-controls .select-all").off("click").on("click",function(X){G(".privateMessageActionCheck").prop("checked",true)});G(".list-controls .select-none").off("click").on("click",function(X){G(".privateMessageActionCheck").prop("checked",false)});if(typeof messageDetailPage!="undefined"&&messageDetailPage){G("#pmBtnBackToMessage").off("click").on("click",function(Y){if(pmParentFolderId){location.href="{0}/privatemessage/list/{1}/1".format(pageData.baseurl,pmParentFolderId)}else{var X=G(".nav-pane .folder-list .folder-item.special-folder.messages a").attr("href");location.href=X}})}function I(X){A(X)}G("#notificationFilters").trigger("reset").find(".filter-options input").off("click").on("click",F);G("#pmBtnNotificationDismissAll").off("click").on("click",dismissNotifications);G("#pmBtnNotificationDismissPage").off("click").on("click",dismissNotifications);G("#iconNotificationNext").off("click").on("click",function(X){X.preventDefault();pmPageNum=parseInt(pmPageNum);if(pmPageNum<pmPages){I(pmPageNum+1)}});G("#iconNotificationPrevious").off("click").on("click",function(X){X.preventDefault();pmPageNum=parseInt(pmPageNum);if(pmPageNum>1){I(pmPageNum-1)}});G("#notificationContent").on("click",".js-notification-dismiss",dismissSingleNotification);G("#notificationContent").on("click",".js-notification-others-dialog",toggleOthersDialog);if(G("#notificationContent").length==0){G("ul.pm-notification-list").on("click",".js-notification-dismiss",dismissSingleNotification);G("ul.pm-notification-list").on("click",".js-notification-others-dialog",toggleOthersDialog)}G("#notificationPageto").bind("keydown blur",function(Y){var Z=G(this);if(Y.type=="blur"||(Y.type=="keydown"&&Y.keyCode==13)){var X=Number(Z.val());if(!isNaN(X)&&X!=pmPageNum&&X>0&&X<=pmPages){I(X)}else{Z.val(pmPageNum)}return false}return true});searchAuthorAutocomplete=new vBulletin_Autocomplete(G(".privatemessage_author"),{apiClass:"user"});G("#pmSearch").submit(function(){var Z=G(this),Y=Z.find("[name=searchJSON]"),a=Z.find("[name=q]"),X={};X.keywords=a.val();X.type="vBForum_PrivateMessage";X.ignore_protected=0;Y.val(JSON.stringify(X));return(a.val().length>3)});var K=false;G(document).off("click",".view-post").on("click",".view-post",function(){var Z=G(this),e=G(this).closest(".list-item"),Y=parseInt(e.data("nodeId"),10),d=parseInt(e.data("nodeContenttypeId"),10),a=parseInt(e.data("userId"),10),c=e.data("postType"),b=G("ul.conversation-list li.list-item",$pmWidget).index(e)+1,X=e.closest("ul.conversation-list").find("li.list-item").length;K=false;T(Y,d,b,X,a,c)});function V(Y){var X;if(G(".pending-post-overlay:visible").length){X=N(Y,1);if(!X){X=N(Y,-1)}}if(X){J(X)}else{G(".pending-post-close").trigger("click")}}function W(X){G(X).each(function(){G(".pending-posts-container .list-container .list-item[data-node-id={0}]".format(this)).remove()})}G(document).off("click",".pending-post-approve").on("click",".pending-post-approve",function(){var Z=[],e,d=G(this),b=d.closest(".pending-post-overlay").find("li.list-item");if(b.length==0){b=d.closest("li.list-item")}if(b.length!=0){Z.push(parseInt(b.data("nodeId"),10));e=b.data("postType")}else{if(d.closest("#pmFloatingBarContent").length){G(".pending-posts-container .list-item .privateMessageActionCheck:checked").each(function(){b=G(this).closest("li.list-item");Z.push(parseInt(b.data("nodeId"),10))});if(Z.length==0){return false}e="selected_posts"}else{return false}}var c={nodeid:Z,approved:1,data:{}},a=G(".title-field",b),Y=G(".text-field",b),X=G(".notes-field",b);if(a.length){c.data["title"]=a.val()}if(Y.length){c.data["rawtext"]=Y.val()}if(X.length){c.data["reason"]=X.val()}vBulletin.AJAX({call:"/ajax/api/node/setApprovedPost",data:c,error_phrase:"unable_to_contact_server_please_try_again",success:function(f){K=true;V(b);W(f)}})});G(document).off("click",".pending-post-delete").on("click",".pending-post-delete",function(){var Y=[],c,a=[],b=G(this);var Z=b.closest(".pending-post-overlay").find("li.list-item");if(Z.length==0){Z=b.closest("li.list-item")}if(Z.length!=0){Y.push(parseInt(Z.data("nodeId"),10));c=Z.data("postType");a.push(parseInt(Z.data("userId"),10))}else{if(b.closest("#pmFloatingBarContent").length){G(".pending-posts-container .list-item .privateMessageActionCheck:checked").each(function(){Z=G(this).closest("li.list-item");Y.push(parseInt(Z.data("nodeId"),10));a.push(parseInt(Z.data("userId"),10))});if(Y.length==0||a.lenght==0){return false}c="selected_posts"}else{return false}}var X=vBulletin.phrase.get("delete_x",vBulletin.phrase.get("posttype_"+c));vBulletin.inlinemod.delete_dialog(Y,function(d){K=true;V(Z);W(d)})});function O(Z){var X=G(this).closest(".pending-post-overlay-container").find(".pending-post-overlay li.list-item"),Y=N(X,Z);if($elementInfo!==false){G("pending-post-overlay").dialog("close");J(Y)}}G(document).off("click",".pending-post-next").on("click",".pending-post-next",function(){O(1)});G(document).off("click",".pending-post-previous").on("click",".pending-post-previous",function(){O(-1)});G(document).off("click",".pending-post-close").on("click",".pending-post-close",function(){G(".pending-post-overlay").dialog("close");if(K){M(false,1,true)}});G(document).off("click",".pending-posts-paginator .pendingpostsPrev").on("click",".pending-posts-paginator .pendingpostsPrev",function(Y){Y.preventDefault();var X=G(this).closest(".pending-posts-paginator").find(':input[type=hidden][name="prev-page"]').val();M(G(this),X)});G(document).off("click",".pending-posts-paginator .pendingpostsNext").on("click",".pending-posts-paginator .pendingpostsNext",function(Y){Y.preventDefault();var X=G(this).closest(".pending-posts-paginator").find(':input[type=hidden][name="next-page"]').val();M(G(this),X)});G(document).off("keypress",".pending-posts-paginator .pendingpostsPageTo").on("keypress",".pending-posts-paginator .pendingpostsPageTo",function(Y){if(Y.keyCode==13){Y.preventDefault();var Z=G(this),X=parseInt(Z.val(),10);if(isNaN(X)){vBulletin.error("error","please_enter_a_valid_page_number");return false}M(Z,X)}});$pmWidget.filter(".private-message-toolbar").off("click",".message-filters .filter-options :input[type=radio]").on("click",".message-filters .filter-options :input[type=radio]",function(Y){var X=G(this).closest("form.toolbar-filter-overlay");X.attr("action",(X.attr("action")+"?sortDir="+G(this).val()));X.submit()});G("#pendingFilters").trigger("reset").find(".filter-options input").off("click").on("click",pendingFilter);vBulletin.truncatePostContent(G(".pm-message-list"));vBulletin.privateMessage.jsReady=true;G(document).trigger("vb-privatemessage-js-ready")})})(jQuery);isFolderNameValid=function(D,B,E){var C,G=$.trim(D.val()).toLowerCase();if(G==""){C="error_enter_folder"}else{if(G.length>50){C="error_foldername_maxlength"}else{$(".folder-list.custom-folder-list .folder-item .edit-folder-box",$pmWidget).each(function(){if(D.hasClass("edit-folder-box")&&D.get(0)==this){return true}if(G==this.value.toLowerCase()){C="error_folder_exists";return false}})}}if(E===true){var A=D.closest("#prompt-dialog"),F=A.find("div.error-msg-box");if(C){if(F.length==0){F=$("<div></div>").addClass("error-msg-box error");$(".dialog-content",A).before(F)}F.text(vBulletin.phrase.get(C)).removeClass("h-hide")}else{if(F.length!=0){F.addClass("h-hide").text("")}}}else{if(C){vBulletin.warning(B,C,function(){D.focus()})}}return !C};getSelectedMessages=function(B){var A=[];if(!B&&$("#privateMessageNodeid").val()){A.push($("#privateMessageNodeid").val())}else{A=$(".privateMessageActionCheck:checked").map(function(){return this.value}).get()}if(A.length==0){vBulletin.warning("error","please_select_messages")}return A};markMessages=function(G,A,F,E,B,C){if(!C){C=getSelectedMessages()}if(C.length>0){var D={nodeid:C.join(",")};if(F){D[F]=E}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/"+A,data:D,success:function(I){var J="mark_message"+((C.length>1)?"s":"")+"_status_text_",H={methodName:"for_move",toTrashcan:"for_delete",setRead:"for_"+(E?"read":"unread"),deleteMessages:"for_delete_permanently",};if(H[A]){J+=H[A]}else{J+="generic"}openAlertDialog({title:G,message:vBulletin.phrase.get(J),onAfterClose:function(){if(B){if(pmParentFolderId){location.replace("{0}/privatemessage/list/{1}/1".format(pageData.baseurl,pmParentFolderId))}else{var K=$(".nav-pane .folder-list .folder-item.special-folder.messages a").attr("href");location.replace(K)}}else{location.reload(true)}}})}})}return false};markReports=function(E,A,D,C){var F=getSelectedMessages();if(F.length>0){var B={nodeids:F.join(",")};if(D){B[D]=C}vBulletin.AJAX({call:"/ajax/api/content_report/"+A,data:B,success:function(){var H="mark_report"+((F.length>1)?"s":"")+"_status_text_",G={bulkdelete:"for_delete",openClose:"for_"+C,};if(G[A]){H+=G[A]}else{H+="generic"}openAlertDialog({title:E,message:vBulletin.phrase.get(H),onAfterClose:function(){if(A=="bulkdelete"){location.replace(pageData.baseurl+"/privatemessage/report/1")}else{location.reload(true)}}})},error_phrase:"pm_ajax_error_desc"})}return false};gotoPage=function(D){var E=$(this);if(D.type=="blur"||(D.type=="keydown"&&D.keyCode==13)){var B=Number(E.val()),A=$("#maxPageNum").val();if(!isNaN(B)&&B!=pmPageNum&&B>0&&B<=A){var C="";if(typeof folderid!="undefined"){C="/"+routeAction+"/"+folderid+"/"}else{switch(routeAction){case"report":C="/"+routeAction+"/";break;default:break}}if(C!=""){newpage=window.location.href.replace(C+pmPageNum,C+B);window.location=newpage}else{return true}}else{E.val(pmPageNum)}return false}return true};startMove=function(B){var A=this;if(typeof (messageDetailPage)!="undefined"&&messageDetailPage){goBack=true}else{goBack=false}$(".pmMoveToFolder").off("click").on("click",function(C){var E=parseInt(this.id.substr(7),10);if(E){var D=$(A).text();if(!D){D=$(A).closest(".move-button-set").find(".button-text").text()}markMessages(D,"moveMessage","newFolderid",E,goBack)}});$("#pmOpenNewFolderName").off("click").on("click",function(D){var C=getSelectedMessages();if(C.length>0){createNewFolder.apply(this,[D,function(G,F){var E=$(this).closest(".split-button").find(".button-text").text();markMessages(E,"moveMessage","newFolderid",G,goBack)}])}return false})};createNewFolder=function(D,C,B){var A=this;$promtDlg=openPromptDialog({title:vBulletin.phrase.get("add_folder"),message:vBulletin.phrase.get("folder_name"),buttonLabel:{okLabel:vBulletin.phrase.get("ok"),cancelLabel:vBulletin.phrase.get("cancel")},validation:{custom:function(E){return isFolderNameValid(E,"add_folder",true)},override:true},onClickOK:function(G){var F=$promtDlg.find(".error-msg-box");function E(){if(F.length==0){F=$("<div></div>").addClass("error-msg-box error");$(".dialog-content",$promtDlg).before(F)}F.text(vBulletin.phrase.get("pm_ajax_error_desc"))}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/createMessageFolder",data:{folderName:G},success:function(H){$promtDlg.dialog("close");if(F.length!=0){F.addClass("h-hide").text("")}if(typeof C=="function"){C.apply(A,[H,G])}},api_error:E,error:E,emptyResponse:E})},onAfterClose:function(){var E=$promtDlg.find(".error-msg-box");if(E.length!=0){E.text("").addClass("h-hide")}if(typeof B=="function"){B.apply(A)}}});return false};startForward=function(C){if($(".privateMessageDetail .js-post").length==1){var B=getSelectedMessages();window.location=pageData.baseurl+"/privatemessage/forward/"+B[0]}else{var A=function(D){$("#pmMoveBlock").toggleClass("h-hide",D);$("#pmBtnReply, #pmBtnDelete").toggleClass("h-hide-imp",D);$("#btnMove").closest(".split-button").toggleClass("h-hide-imp",D);$("#pmForwardPrompt, .pmViewCb").toggleClass("h-hide",!D);$("#pmBtnCancel").toggleClass("h-hide-imp",!D)};A(true);$("#pmBtnCancel").off("click").on("click",function(D){A(false);$("#pmBtnForward").off("click").bind("click",startForward);$(".conversation-content.private-message-detail").removeClass("show-subcontrols")});$(".conversation-content.private-message-detail").addClass("show-subcontrols");$("#pmBtnForward").off("click").bind("click",function(E){var D=getSelectedMessages(true);if(D.length>0){window.location=pageData.baseurl+"/privatemessage/forward/"+D.join(",")}})}};acceptRequest=function(B){var A=parseInt(B.target.id.substr(16));vBulletin.AJAX({call:"/ajax/api/content_privatemessage/acceptRequest",data:{nodeid:A},success:function(C){openAlertDialog({title:vBulletin.phrase.get("private_messages"),message:C,});$("#msgSummary_"+A).remove()}})};denyRequest=function(B){var A=parseInt(B.target.id.substr(14));vBulletin.AJAX({call:"/ajax/api/content_privatemessage/denyRequest",data:{nodeid:A},success:function(C){if(C.result){vBulletin.alert("private_messages",C.result,"")}$("#msgSummary_"+A).remove()}})};notificationFadeOut=function(A){A.animate({opacity:"0.0"},{duration:500,complete:function(){A.empty();A.animate({height:0,width:0,"padding-top":0,"padding-right":0,"padding-bottom":0,"padding-left":0,},{duration:100,complete:function(){A.remove()}})}})};notificationFadeIn=function(A,B,C){if(!A){return }$container=$(".js-notification-container");$temp=$(A).hide();$container.append($temp);$temp.fadeIn()};function getNotificationsFilterParams(){var A={},B=$("#notificationFilters");if(!B.length){return{}}B.find("input[type=hidden], input[type=radio]:checked").each(function(C){if(this.value!=""){A[this.name]=this.value}});if(typeof (pmPageNum)!="undefined"){A.page=parseInt(pmPageNum)}if(typeof (pmPerPage)!="undefined"){A.perpage=parseInt(pmPerPage)}return A}decrementNotificationCount=function(){var C=$(".inbox .count"),E=$(".notifications .count"),A=C.text(),B=E.text();A=A-1;if(A<=0){C.hide()}B=B-1;if(B<=0){E.hide()}C.text(A);E.text(B);var D=$(".js-header-count-contains-notifications");D.each(function(F,G){var H=$(G).text();H--;if(H<=0){$(G).addClass("h-hide-imp")}$(G).text(H)})};toggleOthersDialog=function(A){var B=$(A.currentTarget).closest("li.message-item");$othersBox=B.find(".js-others-wrapper");if($othersBox){var C=$othersBox.data("titlephrase")||"members_in_this_message";$(this).qtip({content:{title:{text:vBulletin.phrase.get(C),button:true,},text:$othersBox.html(),},position:{my:"top center",at:"bottom center",viewport:$(window)},show:{event:"click",solo:true},events:{visible:function(E,D){$(".pmBtnFollowRequest").off("click").on("click",sendFollowRequest)},},hide:{event:"unfocus",fixed:true},style:{classes:"ui-tooltip-shadow ui-tooltip-light ui-tooltip-notification-others"}});$(this).qtip("api").show()}};dismissSingleNotification=function(B){var D=$(B.currentTarget).closest("li.message-item"),A=D.data("notificationid");if(A==null){return }var E={};$(".pm-notification-list").find("li.message-item.notification-unread").each(function(F){var G=$(this).data("notificationid");if(G!=null){E[G]=G}});var C={readIds:A,idsOnPage:E,filterParams:getNotificationsFilterParams()};if(C.filterParams.readFilter!="unread_only"){C.skipFetch=true}D.find(".js-waiting-for-ajax-response").removeClass("h-hide");vBulletin.AJAX({call:"/ajax/api/notification/dismissNotification",data:C,success:function(H){var M=H.insertNotification||"",L=H.lastsenttime||-1,G=C.filterParams.sortDir;D.removeClass("notification-unread js-notification-dismiss-touch");D.find("button.js-notification-dismiss").remove();decrementNotificationCount();if(C.filterParams.readFilter=="unread_only"){notificationFadeOut(D);notificationFadeIn(M,L,G);if(typeof pmNotificationCount!=="undefined"){pmNotificationCount--;if(pmNotificationCount>=0){var I=$("#notificationPageto");if(C.filterParams.page>1){var F=(C.filterParams.page-1)*C.filterParams.perpage+1;if(pmNotificationCount<F){var J=C.filterParams.page-1;I.val(J);I.trigger("blur")}}if(pmPages>1){var K=(pmPages-1)*C.filterParams.perpage+1;if(pmNotificationCount<K){pmPages--;$("#notificationPageCount").text(pmPages);$("#maxPageNum").val(pmPages);vBulletin.privateMessage.updatePaginationLinks($("#notificationContent").parent(),I.val(),pmPages)}}}}}},complete:function(){D.find(".js-waiting-for-ajax-response").addClass("h-hide")},error_phrase:"error_dismissing_notification",})};dismissNotifications=function(C){if(C.currentTarget.id=="pmBtnNotificationDismissAll"){var A=parseInt($("div.folder-item.special-folder.notifications .count").text());if(isNaN(A)||A<=0){vBulletin.warning("dismiss_notification_all","nothing_to_dismiss");return }openConfirmDialog({title:vBulletin.phrase.get("dismiss_notification_all"),message:vBulletin.phrase.get("confirm_about_to_dismiss_x_notifications",A),iconType:"warning",onClickYes:function(E){vBulletin.AJAX({call:"/ajax/api/notification/dismissAllNotifications",data:{},success:function(){location.reload()},error_phrase:"error_dismissing_notification",})}})}else{if(C.currentTarget.id=="pmBtnNotificationDismissPage"){var D={};$(".pm-notification-list").find(".js-notification-dismiss").each(function(E){var F=$(this).data("notificationid");if(F!=null){D[F]=F}});if($.isEmptyObject(D)){vBulletin.warning("dismiss_notification_page","nothing_to_dismiss");return }var B={readIds:D,idsOnPage:D,filterParams:getNotificationsFilterParams(),skipFetch:true,};vBulletin.AJAX({call:"/ajax/api/notification/dismissNotification",data:B,success:function(){$(".pm-notification-list").find(".js-notification-dismiss").each(function(E){$(this).removeClass("notification-unread")});location.reload()},error_phrase:"error_dismissing_notification",})}}};sendFollowRequest=function(C){var B=$(this),A=Number(B.data("userid"));if(!isNaN(A)){vBulletin.AJAX({call:"/ajax/api/follow/add",data:{follow_item:A},success:function(E){var D;if(E=="1"){B.removeClass("b-button--secondary").addClass("isSubscribed");D="following"}else{if(E=="2"){B.addClass("subscribe_pending");D="following_pending"}}if(D){B.prop("disabled",true).find(".js-button__text-primary").html(vBulletin.phrase.get(D))}},error_phrase:"pm_ajax_error_desc",})}};var currentFilter="";pendingFilter=function(A){$(this).closest(".filter-options").find(":input[type=radio]").removeAttr("checked");$(this).attr("checked","checked");var B={options:{}};$("#pendingFilters input:checked").each(function(){B.options[this.name]=this.value});B.isAjaxTemplateRenderWithData=true;vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_main",data:B,success:function(C){$("#privateMessageContainer .pending-posts-container").html(C.template);pmPageNum=1;$("#pendingpostsPageTo").val(pmPageNum);$(".privatemessagePaging .pendingpostsPrev").addClass("h-disabled");data={folderid:folderid,page:1,perpage:pmPerPage};if(currentFilter!=""){data.about=currentFilter}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/getFolderMsgCount",data:data,success:function(E){pmPageNum=E.pagenum;pmPages=E.pages;pmNotificationCount=E.count;var D=E.pages;if(D>0){$("#pendingpostsPageCount").html(D);$(".privatemessagePaging .pendingpostsNext").toggleClass("h-disabled",!(D>1))}$("#privatemessagePaging").toggleClass("h-hide",!(D>0))},emptyResponse:function(){$("#privatemessagePaging").addClass("h-hide")}})}})};