/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.0 Release Candidate 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_moderator_gforumdisplay","confirm_delete_blog_channel","delete_a_blog_channel","delete_blog","error_adding_moderator","error_deleting_blog","manage_subscribers","transfer_blog_ownership","unexpected_error","blogs","blog_title_exists","kilobytes"]);var blogIconEditDlg=false;(function(A){var B=[".blogadmin-widget",".summary-widget"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){var F=function(P){var N=A(P.target).closest(".manage_moderators_row"),M=A(P.target).attr("data-userid"),L=A(P.target).attr("data-groupid"),O=A(P.target).attr("data-nodeid");if(M&&(M>0)&&L&&(L>0)&&O&&(O>0)){vBulletin.AJAX({call:"/ajax/api/blog/removeChannelMember",data:{userId:M,channelId:O},success:function(){N.remove()},title_phrase:"manage_subscribers"})}};var J=1;var K=function(R){var O=parseInt(A(R.target).closest(".blogAdminSubscriberPaging").attr("data-pagecount")),M=A(R.target),N=M.add(M.parent()),Q=M.closest(".blogAdminEditPage"),P;var L=function(T,S){T.find(".right-arrow").toggleClass("h-disabled",S>=O);T.find(".left-arrow").toggleClass("h-disabled",S<=1);T.find(".pagenav .textbox").val(S)};if(N.hasClass("left-arrow")){P=J-1}else{if(N.hasClass("right-arrow")){P=J+1}else{if(M.hasClass("textbox")){P=parseInt(A(R.target).val())}}}if(isNaN(P)||(P>O)||(P<1)){L(Q,J);return }vBulletin.AJAX({call:"/ajax/render/blogadmin_subscriberlist",data:{pageno:P,nodeid:Q.attr("data-nodeid")},success:function(S){var T=Q.find(".subscriberList");T.html(S);A(".blogRemoveSubscriber",T).off("click").on("click",F);J=P;L(Q,P)}})};A(".blogadmin-widget select").selectBox();A(".btnBlogReset").off("click").on("click",function(N){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 L=A(this).closest("form"),M=A('input[name="sidebarInfo"]',L).val().split(",");A.each(M,function(O,R){var S=R.split(":");var Q=A('.sidebar-modules-container .widget[data-widget-instance-id="'+S[0]+'"]'),P=(S[1]=="hide");Q.toggleClass("hidden-widget",P);A(".module-controls .hide-control",Q).attr("checked",P);Q.appendTo(".sidebar-modules-container")});return true});A(".blog-icon-controls .edit-blog-icon").off("click").on("click",function(L){L.preventDefault();A(".js-blog-admin__upload-icon").trigger("click")});A(".blog-icon-controls .remove-blog-icon").off("click").on("click",function(L){L.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(L){L.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(L){L.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(P){P.stopPropagation();var O=A(this),M=O.closest("form"),N=M.find(':input[name="nodeid"]').val(),L=O.attr("userid");vBulletin.AJAX({call:"/ajax/api/blog/cancelChannelTransfer",error_phrase:"error_transfer_ownership",data:{userId:L,channelId:N},success:function(){location.reload()}})});A(document).off("click",".btnTransferOwnership").on("click",".btnTransferOwnership",function(O){var M=A(this).closest("form"),L=M.find(':input[name="nodeid"]').val();var N=openConfirmDialog({title:vBulletin.phrase.get("transfer_blog_ownership"),message:"Loading...",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:L,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:L}),success:function(P){N.removeClass("loading");A(".dialog-content .message",N).html(P).find("[placeholder]").placeholder();N.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(){N.dialog("close")}})});var H=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",K);A(".blogAdminSubscriberPaging .right-arrow ").removeClass("h-disabled");A(".blogAdminSubscriberPaging .pagenav .textbox").change(K);A(document).off("click",".editBlogIcon").on("click",".editBlogIcon",function(L){A(".editBlogIconDlg").dialog()});A(document).off("click",".btnBlogIconClose").on("click",".editBlogIconDlg",function(L){A(".editBlogIconDlg").dialog("close")});A(document).off("click","#btnBlogDelete").on("click","#btnBlogDelete",function(O){var L=A(this).closest("form"),M=L.find(':input[name="nodeid"]').val();var N=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:M},success:function(){window.location.href=pageData.baseurl+"/blogs";return false},after_error:function(){N.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",add:function(N,M){var L=/(gif|jpg|jpeg|jpe|png)$/i;if(L.test(M.files[0].type)){A(".blogIcon .js-upload-progress").removeClass("h-hide");M.form.attr("action",A(this).data("url"));M.submit()}else{vBulletin.error("upload","invalid_image_allowed_filetypes_are")}},done:function(M,L){if(L.result&&L.result.thumbUrl){A(".blogIcon .blogIconImg").attr("src",L.result.thumbUrl).removeClass("h-hide");A(".blogIcon .blogFileDataId").val(L.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(L.result&&L.result.errors){vBulletin.error("upload",L.result.errors[0])}},fail:function(O,N){var M="error_uploading_image",L="error";if(N&&N.files.length>0){switch(N.files[0].error){case"acceptFileTypes":M="invalid_image_allowed_filetypes_are";L="warning";break}}vBulletin.alert("upload",M,L)},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"});var G=A.cookie(pageData.cookie_prefix+"blog_title");if(G!=null){A('.blogAdminForm :input[name="title"]').val(G.replace(/\+/g," "));A.cookie(pageData.cookie_prefix+"blog_title",null,{path:pageData.cookie_path,domain:pageData.cookie_domain})}var I=A.cookie(pageData.cookie_prefix+"blog_description");if(I!=null){A('.blogAdminForm :input[name="description"]').val(I.replace(/\+/g," "));A.cookie(pageData.cookie_prefix+"blog_description",null,{path:pageData.cookie_path,domain:pageData.cookie_domain})}var D=A.cookie(pageData.cookie_prefix+"blogadmin_error");if(D!=null){vBulletin.error("blogs",D);A.cookie(pageData.cookie_prefix+"blogadmin_error",null,{path:pageData.cookie_path,domain:pageData.cookie_domain})}A(document).off("click",".editBlogIcon").on("click",".editBlogIcon",function(L){if(!blogIconEditDlg){blogIconEditDlg=A(L.target).closest(".blogSummaryContainer").find(".sgIconUploader").dialog({width:600,autoOpen:false})}A(blogIconEditDlg).dialog("open");return false});A(document).off("click",".btnSGIconCancel").on("click",".btnSGIconCancel",function(L){A(L.target).closest(".sgIconUploader").dialog("close")});A(document).off("click",".btnSGIconUrlSubmit").on("click",".btnSGIconUrlSubmit",uploadIconFromUrl);A(document).off("click",".sgRadioIconFile").on("click",".sgRadioIconFile",function(L){A(L.target).closest(".sgIconUploader ").find(".js-file-chooser").removeClass("h-hide");A(L.target).closest(".sgIconUploader ").find(".sgIconUrlInput ").addClass("h-hide")});A(document).off("click",".sgRadioIconUrl").on("click",".sgRadioIconUrl",function(L){A(L.target).closest(".sgIconUploader ").find(".js-file-chooser").addClass("h-hide");A(L.target).closest(".sgIconUploader ").find(".sgIconUrlInput ").removeClass("h-hide")});var E=A(".blogIconImg");var C=vBulletin.getAjaxBaseurl()+"/uploader/"+(E.length>0?"uploadSGIcon":"upload-file");A(".js-sg-admin__upload-icon").fileupload({formData:function(L){return[{name:"nodeid",value:L.data("nodeid")}]},url:C,add:function(N,M){var L=/(gif|jpg|jpeg|jpe|png)$/i;if(L.test(M.files[0].type)){A(".sgIconUploader .js-upload-progress").removeClass("h-hide");M.submit()}else{vBulletin.error("upload","invalid_image_allowed_filetypes_are")}},done:function(M,L){if(L){if(L.result.errors){if(typeof (L.result.errors[0])=="undefined"){vBulletin.error("blog_icon",L.result.errors)}else{vBulletin.error("blog_icon",L.result.errors[0])}}else{if(L.result.imageUrl){if(E.length>0){A(".blogIconImg").attr("src",L.result.imageUrl);A(blogIconEditDlg).dialog("close")}else{A(".sgIconPreview").html('<img src="'+L.result.imageUrl+'" alt="">');A(".sGIconfiledataid").val(L.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(N,L){var M="error_uploading_image";iconType="error";if(L&&L.files.length>0){switch(L.files[0].error){case"acceptFileTypes":M="invalid_image_allowed_filetypes_are";iconType="warning";break}}vBulletin.alert("upload",M,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 L=[];A(".sidebar-modules-container .widget").each(function(){L.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(L.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")}})};