/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 MH Sub I, LLC dba vBulletin. 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_moderator_gforumdisplay","blog_title_exists","blogs","confirm_delete_blog_channel","delete_a_blog_channel","delete_blog","error_adding_moderator","error_deleting_blog","kilobytes","loading_ellipsis","manage_subscribers","transfer_blog_ownership","unexpected_error"]);var blogIconEditDlg=false;(function(A){var B=[".blogadmin-widget",".summary-widget"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){var F=function(M){var K=A(M.target).closest(".manage_moderators_row"),J=A(M.target).attr("data-userid"),I=A(M.target).attr("data-groupid"),L=A(M.target).attr("data-nodeid");if(J&&(J>0)&&I&&(I>0)&&L&&(L>0)){vBulletin.AJAX({call:"/ajax/api/blog/removeChannelMember",data:{userId:J,channelId:L},success:function(){K.remove()},title_phrase:"manage_subscribers"})}};var H=1;var G=function(O){var L=parseInt(A(O.target).closest(".blogAdminSubscriberPaging").attr("data-pagecount")),J=A(O.target),K=J.add(J.parent()),N=J.closest(".blogAdminEditPage"),M;var I=function(Q,P){Q.find(".right-arrow").toggleClass("h-disabled",P>=L);Q.find(".left-arrow").toggleClass("h-disabled",P<=1);Q.find(".pagenav .textbox").val(P)};if(K.hasClass("left-arrow")){M=H-1}else{if(K.hasClass("right-arrow")){M=H+1}else{if(J.hasClass("textbox")){M=parseInt(A(O.target).val())}}}if(isNaN(M)||(M>L)||(M<1)){I(N,H);return }vBulletin.AJAX({call:"/ajax/render/blogadmin_subscriberlist",data:{pageno:M,nodeid:N.attr("data-nodeid")},success:function(P){var Q=N.find(".subscriberList");Q.html(P);A(".blogRemoveSubscriber",Q).off("click").on("click",F);H=M;I(N,M)}})};A(".blogadmin-widget select").selectBox();A(".btnBlogReset").off("click").on("click",function(K){if(A(".blogIcon .blogIconUrl").val()){A(".blogIcon .blogIconImg").attr("src",A(".blogIcon .blogIconUrl").val());A(".blogIcon .blogFileDataId").val(A(".blogIcon .initFiledataid").val())}else{A(".blogIcon .blogIconImg").addClass("h-hide");A(".blogIcon .blogFileDataId").val("")}var I=A(this).closest("form"),J=A('input[name="sidebarInfo"]',I).val().split(",");A.each(J,function(L,O){var P=O.split(":");var N=A('.sidebar-modules-container .widget[data-widget-instance-id="'+P[0]+'"]'),M=(P[1]=="hide");N.toggleClass("hidden-widget",M);A(".module-controls .hide-control",N).attr("checked",M);N.appendTo(".sidebar-modules-container")});return true});A(".blog-icon-controls .edit-blog-icon").off("click").on("click",function(I){I.preventDefault();A(".js-blog-admin__upload-icon").trigger("click")});A(".blog-icon-controls .remove-blog-icon").off("click").on("click",function(I){I.preventDefault();A(".blogIcon .blogIconImg").attr("src","").addClass("h-hide");A(".blogIcon .blogFileDataId").val("");A(".blogIcon .blog-icon-controls").addClass("h-hide");A(".js-blog-admin__upload-icon").closest(".b-button--upload").removeClass("h-hide-imp")});moderatorsAutocomplete=new vBulletin_Autocomplete(A(".moderator_input"),{apiClass:"user",maxItems:1,containerClass:"blog-moderator-autocomplete"});A(document).off("click",".add_moderator").on("click",".add_moderator",function(I){I.stopPropagation();$moderatorForm=A(this).closest("form");$channelid=$moderatorForm.find(':input[name="nodeid"]').val();$recipient=moderatorsAutocomplete.getElements();$recipient=$recipient[0]["value"];vBulletin.AJAX({call:"/ajax/api/node/requestChannel",data:{channelid:$channelid,recipientname:$recipient,requestType:"moderator_to"},success:function(){location.reload()},title_phrase:"add_moderator_gforumdisplay",error_phrase:"error_adding_moderator"})});A(document).off("click",".btnRemoveContributor").on("click",".btnRemoveContributor",function(I){I.stopPropagation();$moderatorForm=A(this).closest("form");$channelid=$moderatorForm.find(':input[name="nodeid"]').val();$userid=A(this).attr("userid");$usergroupid=A(this).attr("usergroupid");vBulletin.AJAX({call:"/ajax/api/blog/removeChannelModerator",data:{userId:$userid,channelId:$channelid},success:function(){location.reload()},title_phrase:"add_moderator_gforumdisplay",})});A(document).off("click",".btnCancelTransfer").on("click",".btnCancelTransfer",function(M){M.stopPropagation();var L=A(this),J=L.closest("form"),K=J.find(':input[name="nodeid"]').val(),I=L.attr("userid");vBulletin.AJAX({call:"/ajax/api/blog/cancelChannelTransfer",error_phrase:"error_transfer_ownership",data:{userId:I,channelId:K},success:function(){location.reload()}})});A(document).off("click",".btnTransferOwnership").on("click",".btnTransferOwnership",function(L){var J=A(this).closest("form"),I=J.find(':input[name="nodeid"]').val();var K=openConfirmDialog({title:vBulletin.phrase.get("transfer_blog_ownership"),message:vBulletin.phrase.get("loading_ellipsis"),width:500,dialogClass:"transfer-ownership-dialog loading",buttonLabel:{yesLabel:vBulletin.phrase.get("send_request"),noLabel:vBulletin.phrase.get("cancel")},onClickYes:function(){if(A(".transfer-ownership-dialog .transfer_owner_select:visible").length>0){$user="";$userid=A(".transfer-ownership-dialog .transfer_owner_select").val()}else{$user=A('.transfer-ownership-dialog :input[name="transfer_owner_autocomplete"]').val();$userid=0}if($user.length==0&&($userid.length==0||$userid==0)){return false}vBulletin.AJAX({call:"/ajax/api/node/requestChannel",data:{channelid:I,recipient:$userid,recipientname:$user,requestType:"owner_to"},success:function(){location.reload()},title_phrase:"transfer_blog_ownership",error_phrase:"error_transfer_ownership"})}});vBulletin.AJAX({call:"/ajax/render/blogadmin_transferownership",data:({nodeid:I}),success:function(M){K.removeClass("loading");A(".dialog-content .message",K).html(M).find("[placeholder]").placeholder();K.dialog("option","position",{of:window});transferOwnerAutocomplete=new vBulletin_Autocomplete(A(".transfer_owner_autocomplete"),{apiClass:"user",maxItems:1});A(".transfer_ownership_tabs").tabs()},after_error:function(){K.dialog("close")}})});var E=new vBulletin_Autocomplete(A(".moderator_members_input"),{apiClass:"user",containerClass:"blog-moderator-autocomplete"});A(document).off("click",".blogRemoveSubscriber").on("click",".blogRemoveSubscriber",F);A(document).off("click",".blogAdminSubscriberPaging .right-arrow, .blogAdminSubscriberPaging .left-arrow").on("click",".blogAdminSubscriberPaging .right-arrow, .blogAdminSubscriberPaging .left-arrow",G);A(".blogAdminSubscriberPaging .right-arrow ").removeClass("h-disabled");A(".blogAdminSubscriberPaging .pagenav .textbox").change(G);A(document).off("click",".editBlogIcon").on("click",".editBlogIcon",function(I){A(".editBlogIconDlg").dialog()});A(document).off("click",".btnBlogIconClose").on("click",".editBlogIconDlg",function(I){A(".editBlogIconDlg").dialog("close")});A(document).off("click","#btnBlogDelete").on("click","#btnBlogDelete",function(L){var I=A(this).closest("form"),J=I.find(':input[name="nodeid"]').val();var K=openConfirmDialog({title:vBulletin.phrase.get("delete_a_blog_channel"),message:vBulletin.phrase.get("confirm_delete_blog_channel"),iconType:"warning",onClickYes:function(){vBulletin.AJAX({call:"/ajax/api/content_channel/delete",data:{nodeid:J},success:function(){window.location.href=pageData.baseurl+"/blogs";return false},after_error:function(){K.dialog("close")},title_phrase:"delete_blog",error_phrase:"error_deleting_blog"});return false}});return false});A(".js-blog-admin__upload-icon").fileupload({dropZone:null,dataType:"json",formData:function(I){return[{name:"nodeid",value:I.data("nodeid")},{name:"uploadFrom",value:"blogicon"}]},add:function(K,J){var I=/(gif|jpg|jpeg|jpe|png)$/i;if(I.test(J.files[0].type)){A(".blogIcon .js-upload-progress").removeClass("h-hide");J.form.attr("action",A(this).data("url"));J.submit()}else{vBulletin.error("upload","invalid_image_allowed_filetypes_are")}},done:function(J,I){if(I.result&&I.result.thumbUrl){A(".blogIcon .blogIconImg").attr("src",I.result.thumbUrl).removeClass("h-hide");A(".blogIcon .blogFileDataId").val(I.result.filedataid);A(".blogIcon .blog-icon-controls").removeClass("h-hide");A(".js-blog-admin__upload-icon").closest(".b-button--upload").addClass("h-hide-imp")}if(I.result&&I.result.errors){vBulletin.error("upload",I.result.errors[0])}},fail:function(L,K){var J="error_uploading_image",I="error";if(K&&K.files.length>0){switch(K.files[0].error){case"acceptFileTypes":J="invalid_image_allowed_filetypes_are";I="warning";break}}vBulletin.alert("upload",J,I)},always:function(){A(".blogIcon .js-upload-progress").addClass("h-hide")}});A(".blogAdminForm button[type=submit]").off("click").on("click",function(){this.form.action=pageData.baseurl+"/create-content/blog"});A(document).off("click",".editBlogIcon").on("click",".editBlogIcon",function(I){if(!blogIconEditDlg){blogIconEditDlg=A(I.target).closest(".blogSummaryContainer").find(".sgIconUploader").dialog({width:600,autoOpen:false,modal:true,title:vBulletin.phrase.get("edit_blog_icon"),dialogClass:"dialog-container"})}A(blogIconEditDlg).dialog("open");vBulletin.Responsive.Modal.init();return false});A(document).off("click",".btnSGIconCancel").on("click",".btnSGIconCancel",function(I){A(I.target).closest(".sgIconUploader").dialog("close")});A(document).off("click",".btnSGIconUrlSubmit").on("click",".btnSGIconUrlSubmit",uploadIconFromUrl);A(document).off("click",".sgRadioIconFile").on("click",".sgRadioIconFile",function(I){A(I.target).closest(".sgIconUploader ").find(".js-file-chooser").removeClass("h-hide");A(I.target).closest(".sgIconUploader ").find(".sgIconUrlInput ").addClass("h-hide")});A(document).off("click",".sgRadioIconUrl").on("click",".sgRadioIconUrl",function(I){A(I.target).closest(".sgIconUploader ").find(".js-file-chooser").addClass("h-hide");A(I.target).closest(".sgIconUploader ").find(".sgIconUrlInput ").removeClass("h-hide")});var D=A(".blogIconImg");var C=vBulletin.getAjaxBaseurl()+"/uploader/"+(D.length>0?"uploadSGIcon":"upload-file");A(".js-sg-admin__upload-icon").fileupload({formData:function(I){return[{name:"nodeid",value:I.data("nodeid")},{name:"uploadFrom",value:"blogicon"}]},url:C,add:function(K,J){var I=/(gif|jpg|jpeg|jpe|png)$/i;if(I.test(J.files[0].type)){A(".sgIconUploader .js-upload-progress").removeClass("h-hide");J.submit()}else{vBulletin.error("upload","invalid_image_allowed_filetypes_are")}},done:function(J,I){if(I){if(I.result.errors){if(typeof (I.result.errors[0])=="undefined"){vBulletin.error("blog_icon",I.result.errors)}else{vBulletin.error("blog_icon",I.result.errors[0])}}else{if(I.result.imageUrl){if(D.length>0){A(".blogIconImg").attr("src",I.result.imageUrl);A(blogIconEditDlg).dialog("close")}else{A(".sgIconPreview").html('<img src="'+I.result.imageUrl+'" alt="">');A(".sGIconfiledataid").val(I.result.filedataid);A(sgIconUploadDlg).dialog("close")}}else{vBulletin.error("blog_icon","unable_to_upload_file")}}}else{vBulletin.error("blog_icon","invalid_server_response_please_try_again")}},fail:function(K,I){var J="error_uploading_image";iconType="error";if(I&&I.files.length>0){switch(I.files[0].error){case"acceptFileTypes":J="invalid_image_allowed_filetypes_are";iconType="warning";break}}vBulletin.alert("upload",J,iconType,function(){$editProfilePhotoDlg.find(".fileText").val("");$editProfilePhotoDlg.find(".browse-option").focus()})},always:function(){A(".sgIconUploader .js-upload-progress").addClass("h-hide")}});A(".sidebar-modules-container").trigger("reset").sortable({revert:true,tolerance:"pointer",placeholder:"widget module-drag-highlight",handle:false,items:".widget",cursor:"move",axis:"y"}).disableSelection();A(".sidebar-modules-container .module-controls .hide-control").off("click").on("click",function(){A(this).closest(".widget")[this.checked?"addClass":"removeClass"]("hidden-widget")});A("form.sidebarForm").off("submit.sidebar").on("submit.sidebar",function(){var I=[];A(".sidebar-modules-container .widget").each(function(){I.push(A(this).attr("data-widget-instance-id")+":"+(A(".module-controls .hide-control",A(this)).prop("checked")?"hide":"show"))});A('input[name="sidebarInfo"]',(this)).val(I.join())})})})(jQuery);uploadIconFromUrl=function(B){var A=$(".blogIconImg");$(".sgIconUploader .js-upload-progress").removeClass("h-hide");vBulletin.AJAX({call:"/uploader/"+(A.length>0?"uploadSGIcon":"url"),error_phrase:"upload_errors",data:{nodeid:$(B.target).closest(".sgicon-upload-form").data("nodeid"),url:$(B.target).parent(".sgIconUrlInput").find("#imgUrl").val()},success:function(C){if(A.length>0){$(".blogIconImg").attr("src",C.imageUrl);$(blogIconEditDlg).dialog("close")}else{$(".sgIconPreview").html('<img src="'+C.imageUrl+'" alt="">');$(".sGIconfiledataid").val(C.filedataid);$(blogIconEditDlg).dialog("close")}},complete:function(){$(".sgIconUploader .js-upload-progress").addClass("h-hide")}})};