/*=======================================================================*\
|| ###################################################################### ||
|| # 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   # ||
|| ###################################################################### ||
\*========================================================================*/
(function(B){window.vBulletin=window.vBulletin||{};B(document).off("click",".deletedItems-remove").on("click",".deletedItems-remove",function(){$button=B(this);var C,D=false;if($button.parents("#pmFloatingBarContent").hasClass("deletedItems-paginator")){C=getSelectedMessages()}else{C=[$button.parents(".list-item").data("nodeId")]}if(C.length>0){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/node/deleteNodes",data:{nodeids:C,hard:1},success:function(E){location.reload()}})}});B(".deletedItems-restore").off("click").on("click",function(E){$button=B(this);var C,D=false;if($button.parents("#pmFloatingBarContent").hasClass("deletedItems-paginator")){C=getSelectedMessages()}else{C=[$button.parents(".list-item").data("nodeId")]}if(C.length>0){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/node/undeleteNodes",data:{nodeids:C},success:function(F){location.reload()}})}});B(document).off("click","#privatemessagePaging .deletedItemsPrev").on("click","#privatemessagePaging .deletedItemsPrev",function(D){D.preventDefault();var C=B(this).closest("#privatemessagePaging").find(':input[type=hidden][name="prev-page"]').val();A(B(this),C)});B(document).off("click","#privatemessagePaging .deletedItemsNext").on("click","#privatemessagePaging .deletedItemsNext",function(D){D.preventDefault();var C=B(this).closest("#privatemessagePaging").find(':input[type=hidden][name="next-page"]').val();A(B(this),C)});B(document).off("keypress","#privatemessagePaging .deletedItemsPageTo").on("keypress","#privatemessagePaging .deletedItemsPageTo",function(D){if(D.keyCode==13){D.preventDefault();var E=B(this);var C=parseInt(E.val(),10);if(isNaN(C)){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_page_number"),iconType:"error"});return false}A(E,C)}});B("#deletedItemsFilters").trigger("reset").find(".filter-options input").off("click").on("click",function(C){deletedItemsFilter.apply(this)});function A(C,F,K){if(!C){C=B("#private-message-toolbar .deletedItems-paginator .deletedItemsPageTo");if(C.length==0){return false}}if(!K){K=0}var H=C.closest(".deletedItems-paginator");var J=B("#privateMessageContainer .main-pane .pending-posts-container");var E=H.find("#maxPageNum").filter(":input[type=hidden]").val();var G=parseInt(H.find(":input[type=hidden][name=pagenum]").val(),10);var I=parseInt(H.find(":input[type=hidden][name=per-page]").val(),10);var L=H.find("input[name=routeInfoJson]").val();F=parseInt(F,10);if(isNaN(F)||isNaN(E)||isNaN(G)){return false}if((F<1)||(F>E)){if(!C.is(".h-disabled")){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_page_number"),iconType:"error"})}return false}else{if((F==G)&&!K){return false}}var D={setCurrentPage:F,setPerPage:I,getPagingInfo:K,options:{},routeInfoJson:L};B("#deletedItemsFilters input:checked").each(function(){D.options[this.name]=this.value});if(D.options.time){D.options.time={from:D.options.time}}B.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/privatemessage_deleteditems_main",type:"POST",data:D,dataType:"json",success:function(O){J.html(O);if(B(".deletedItems-list").length>0){}var N=0;var M=0;if(F<E){if(F>1){M=F+1;N=F-1}else{M=F+1}}else{N=F-1}H.find(":input[type=hidden][name=pagenum]").val(F);H.find(":input[type=hidden][name=next-page]").val(M);H.find(":input[type=hidden][name=prev-page]").val(N);if(M){H.find(".deletedItemsNext").removeClass("h-disabled")}else{H.find(".deletedItemsNext").addClass("h-disabled")}if(N){H.find(".deletedItemsPrev").removeClass("h-disabled")}else{H.find(".deletedItemsPrev").addClass("h-disabled")}H.find(".deletedItemsPageTo").val(F);if(K){var P=B("#privateMessageContainer .main-pane .pending-posts-container .pending-posts-pageinfo");H.find("#maxPageNum").filter(":input[type=hidden]").val(parseInt(P.find(".totalpages").val(),10));H.find(".deletedItemsPageCount").text(parseInt(P.find(".totalpages").val(),10));B(".folder-list .folder-item.pending-posts .count",$pmWidget).text(parseInt(P.find(".totalcount").val(),10))}},error:function(){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}deletedItemsFilter=function(D){$paginateButton=B("#private-message-toolbar .deletedItems-paginator .deletedItemsPageTo");if($paginateButton.length){A($paginateButton,1,true);return }var C={};B(this).closest(".filter-options-list").find("input:checked").each(function(){C[this.name]=B(this).val()});if(C.time){C.time={from:C.time}}B(this).attr("checked","checked");C.page=1;C.perpage=pmPerPage;var E={options:C};B.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/privatemessage_deleteditems_main",type:"POST",dataType:"json",data:E,success:function(F){B("#privateMessageContainer .pending-posts-container").html(F);pmPageNum=1}})}})(jQuery);