/*=======================================================================*\
|| ###################################################################### ||
|| # 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   # ||
|| ###################################################################### ||
\*========================================================================*/
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,["action","active","ad_list_description","add_modules","add_subforum","adding_multiple_modules_not_allowed","all","applying_new_template","are_you_sure_want_to_delete_ad_x","cancel","cannot_add_system_module","cannot_convert_channel","cannot_remove_system_module","channels","check_to_hide_module","choose_base_module","choose_options_site_logo","click_text_edit_title","confirm_deletion_gcpglobal","confirm_deletion_x","confirm_remove_page_desc","content_types","create_ad","create_new_custom_module","delete","display_order","do_you_want_to_cancel_editing_search_module","do_you_want_to_exit_without_saving_page","do_you_want_to_remove_channel","do_you_want_to_remove_forum","do_you_want_to_remove_module","do_you_want_to_remove_tab","drag_and_drop_module_here","drop_page_here","dropping_container_module_into_container_module_not_allowed","edit","edit_ad_x","edit_blog_categories","edit_custom_html_module","edit_navigation_item","edit_search_module","edit_site_logo","error_adding_widgets","error_cloning_widget","error_deleting_page","error_fetching_channels","error_loading_search_config_script","error_processing_site_logo","error_renaming_module_title","error_retrieving_cloned_widget_template","error_retrieving_configuration","error_retrieving_list_user_groups","error_retrieving_modules","error_retrieving_navigation_bar_configuration","error_retrieving_page_map","error_retrieving_templates","error_saving_configuration_module","error_saving_forums","error_saving_forums_code","error_saving_navigation_bar_configuration","error_saving_page","error_saving_search_config","error_saving_site_logo","error_uploading_logo","exit_without_saving_page","expand","forum_changes_will_be_lost","input_navigation_item_name","input_target_url","invalid_image_url","main_navigation_bar","make_category","make_forum","manage_ads","module_configuration","module_icon","move_not_allowed","moving_main_nav_to_own_sub_nav_error","moving_main_nav_with_sub_nav_error","new_navigation_item","new_subnavigation_item","next","no","no_ad_added","no_configurations_found","no_modules","no_permission","none","overwrite_template_continue","page_template_title_cannot_be_empty","page_title_cannot_be_empty","please_choose_overwrite_template_options","please_enter_channel_title","please_enter_new_module_title","please_enter_new_template_name","please_enter_page_name","previous","remove_channel","remove_channel_q","remove_forum","remove_forum_q","remove_module_q","rename","rename_custom_module","reset","save","save_new_page","save_page","search_results","select_edit_link_header","special_options","sub_navigation_bar","subchannels_will_be_deleted","switch_template","template_changes_will_be_lost","this_url_is_already_used","title","unable_to_delete_widget_instances","uncheck_to_unhide_module","url_too_long","user_group_settings","warning","warning_gcpuser","yes","you_are_here","you_can_also_drag_and_drop_modules_here","you_cannot_revert_this_layout_confirm","you_must_specify_a_screen_layout"]);(function(AT){var e,AS,m,Ab,AD,a,z=[],AB,AH,r=false,u=false,n={},x=false,AE=false,k=false,t=false,AY=false,S=false,s=false,g={},v={},AM={},H={},b,AL,p,AZ={saveNewWidgetInstance:false},A=AT("<div>"),P;function Ai(){window.setTimeout(function(){if(vBulletin.vBScroller&&vBulletin.vBScroller.initializeScroller){AT(".js-vbscroller-wrapper:visible").each(function(){vBulletin.vBScroller.initializeScroller(AT(this))})}},0)}function Ah(){var Ak=AT("#edit-page-dropdown .panel .panel-main-content:visible");if(Ak.length>0){var Aj=parseFloat(Ak.css("margin-left"))+parseFloat(Ak.css("margin-right"))+parseFloat(Ak.css("border-left-width"))+parseFloat(Ak.css("border-right-width"))+parseFloat(Ak.css("padding-left"))+parseFloat(Ak.css("padding-right"));AT("#edit-page-dropdown .panel .panel-main-content").width(AT("#edit-page-dropdown .panel:visible").width()-AT("#edit-page-dropdown .panel .panel-header-text:visible").outerWidth(true)-Aj-1);AT("#edit-page-dropdown form .form-gutter-right").width(Math.ceil((AT("#edit-page-dropdown form:visible").width()-AT("#edit-page-dropdown .panel:visible").outerWidth(true))/2));Ai()}}function AU(Ak,Am){if(AT.isEmptyObject(Am)){return }var Al=Ak.find(".js-admin-widget-list"),Aj=false;AT.each(Am,function(){Al.append(this.rendered_template);Aj=true});if(Aj){Al.closest(".js-widget-content").removeClass("h-hide")}Al.closest(".js-widget-content").css({minHeight:"35px"});Al.css({minHeight:"0",height:"auto",paddingBottom:"10px"})}function AK(Am,Aj,Ao){var Ak=Am.attr("data-widget-id"),An=Am.attr("data-widget-instance-id")||"",Al={widgetinstanceid:An,widgetid:Ak,guid:"",userid:0,channelId:0,withTemplate:false,};if(typeof Ao=="undefined"){Ao=false}else{Ao=Boolean(Ao)}vBulletin.AJAX({call:"/ajax/api/widget/fetchConfigAndIsUserEditable",data:Al,success:function(Ap){console.log("fetchConfig in getModuleConfig() successful! result:"+JSON.stringify(Ap));var Aq=Ap;if(!Ao){Aq=Ap.config}if(typeof Aj=="function"){Aj(Aq)}}})}function AA(Ak){if(!Ak.tab_data){Ak.tab_data=[]}if(!Ak.default_tab){Ak.default_tab=0}if(!Ak.submodules_key){console.log({msg:"Missing submodules key!",config:Ak,});Ak.submodules_key="tabbedContainerSubModules__temp"}if(!Ak.display_tabs){Ak.display_tabs=""}if(Ak.display_tabs==""){var Aj={};AT.each(Ak.tab_data,function(Am,Al){Aj[Am]="1"});Ak.display_tabs=Aj}return Ak}function W(){if(typeof p=="undefined"){p=AT("#config_pagetemplateid").val()||AT("#select-template input[type=radio]:checked").val()||""}return p}function c(Aj){Aj=parseInt(Aj,10);p=Aj;AT("#config_pagetemplateid, #save-page-form #pagetemplateid-yes, #save-page-form #pagetemplateid-new").val(p)}function Z(Ak,Aj){console.log({msg:"saveModuleConfig()",$module:Ak,config:Aj,});vBulletin.AJAX({call:"/ajax/api/widget/saveAdminConfig",data:{widgetid:Ak.attr("data-widget-id"),widgetinstanceid:Ak.attr("data-widget-instance-id")||"",pagetemplateid:W(),data:Aj},complete:function(){AT("body").css("cursor","auto")},success:function(Al){console.log("saveAdminConfig in saveModuleConfig() successful! result:"+JSON.stringify(Al))}})}function q(Ak){var Aj=Ak.parents(".canvas-widget");if(Aj.length){$parentModule=AT(Aj[0]);return parseInt($parentModule.data("widget-instance-id"),10)}return 0}function R(Ak){var Aj=Ak.parents(".canvas-widget[data-is-tabbed-container='true']");if(Ak.data("is-tabbed-container")){console.log("---updating self tabbed container config");V(Ak)}if(Aj.length==0){console.log("---no parent tabbed container to update");return }console.log("---updating parent tabbed container config");V(AT(Aj[0]))}function f(Ak){var Aj={};Ak.find("> .js-admin-widget-content > .js-admin-widget-tab").each(function(){var Ao=AT(this),An=[],Al=Ao&&Ao.data("tab-number")||0,Am=Ao&&Ao.data("tab-title")||"";Aj[Al]={title:Am};Ao.find("> .widget-content > .canvas-layout-row > .canvas-widget-list > .canvas-widget:not(.dummy-widget)").each(function(){var As=AT(this),Ap=As.data("widget-id"),Aq=As.data("widget-instance-id")||As.attr("data-widget-instance-id"),Ar={};if(Aq){Ar.widgetinstanceid=Aq}if(Ap){Ar.widgetid=Ap}if(!AT.isEmptyObject(Ar)){An.push(Ar)}});Aj[Al]["widgets"]=An});return Aj}function V(Ak){var Aj=function(Al){var Al=AA(Al);Al.tab_data=f(Ak);if(!AT.isEmptyObject(Al)){Z(Ak,Al)}};AK(Ak,Aj)}function AO(Aj){vBulletin.AJAX({call:"/ajax/api/widget/deleteWidgetInstances",data:{widgetInstanceIds:Aj},success:function(Ak){console.log("saveAdminConfig in saveModuleConfig() successful! removeInstances: "+JSON.stringify(Aj)+" result:"+JSON.stringify(Ak))},emptyResponse:function(Ak){console.log("Empty response from deleteWidgetInstances after parent tab delete.")},api_error:vBulletin.ajaxtools.logApiError,})}function i(An,Am,Ak,Ao){var Ap=W(),Al=(Ap==""||Ap==0),Aj="save-new-widgetinstance-pagetemplateid-ready";if(Al){if(!AZ.saveNewWidgetInstance){AZ.saveNewWidgetInstance=true}else{A.one(Aj,function(Aq){i(An,Am,Ak,Ao)});return }}vBulletin.AJAX({call:"/ajax/api/widget/saveNewWidgetInstance",data:{containerinstanceid:An,widgetid:Am,pagetemplateid:Ap,subWidgetConfig:Ak,},success:function(Aq){console.log({msg:"/ajax/api/widget/saveNewWidgetInstance success!",result:Aq,});if(Al&&Aq.pagetemplateid){c(Aq.pagetemplateid);A.trigger(Aj)}if(Aq.widgetinstanceid){if(typeof Ao=="function"){Ao(Aq.widgetinstanceid)}}}})}function h(Ar){if(!Ar.data("is-tabbed-container")){return }var Ap=Ar.attr("data-widget-instance-id");if(!Ap){var Al=q(Ar),Ak=function(Ax){console.log({msg:"added missing tabbed container widgetinstance",widgetinstanceid:Ax,parentContainerinstanceid:Al,});Ar.attr("data-widget-instance-id",Ax);return h(Ar)};return i(Al,Ar.attr("data-widget-id"),{},Ak)}if(AT.isEmptyObject(AM)){return l(h,[Ar])}if(Ar.data("tabbed-container-initialized")){return }var Av=Ar.find(".js-admin-widget-tab-panel-template"),Au=Av.find(".js-admin-widget-list"),Ao=Ar.find(".js-admin-widget-tab-header-template"),As=Ar.find(".js-admin-widget-content"),Am=As.find(".js-tab-headers"),Aw=Am.find(".js-tab-add"),Aq,Aj;Av.detach().removeClass("js-admin-widget-tab-panel-template");Ao.detach().removeClass("js-admin-widget-tab-header-template");As.tabs({beforeActivate:function(Ax,Ay){if(AT(Ay.newTab).hasClass("js-tab-add")){return false}},});Aq=As.tabs("widget");Au.css({minHeight:"60px",height:"auto",paddingBottom:"10px"});Am.find(".js-tab-add").on("click",function(){var Ax=function(Az){var A1=AA(Az.config),A2=A1.tab_data,A3=A2.length||0,A0=A3,Ay=Az.isusereditable.tab_data||false;openPromptDialog({title:vBulletin.phrase.get("enter_tab_title"),message:"",buttonLabel:{okLabel:vBulletin.phrase.get("ok"),cancelLabel:vBulletin.phrase.get("cancel")},onClickOK:function(A4){if(!A4){return false}An(A4,[],A0,A0,Ay);A1.display_tabs[A0]="1";A1.tab_data=f(Ar);if(!AT.isEmptyObject(A1)){Z(Ar,A1)}}})};AK(Ar,Ax,true)});Ao.find(".js-edit-tab-button").on("click",function(){var A1=AT(this),Ax=A1.closest("li[aria-controls]"),Ay=Ax.attr("aria-controls"),A0=Aq.find(".js-admin-widget-tab[id='"+Ay+"']"),Az=A0&&A0.data("tab-title")||"";var A2=function(A3){var A4=AA(A3),A5=A4.tab_data;openPromptDialog({title:vBulletin.phrase.get("enter_tab_title"),message:"",initialValue:Az,buttonLabel:{okLabel:vBulletin.phrase.get("ok"),cancelLabel:vBulletin.phrase.get("cancel")},onClickOK:function(A6){Ax.find("span.js-tab-title").text(A6);A0.data("tab-title",A6);A4.tab_data=f(Ar);if(!AT.isEmptyObject(A4)){Z(Ar,A4)}}})};AK(Ar,A2);return false});Ao.find(".js-remove-tab-button").on("click",function(){var A1=AT(this),Ay=A1.closest("li[aria-controls]"),Az=Ay.attr("aria-controls"),A0=Aq.find(".js-admin-widget-tab[id='"+Az+"']");var Ax=function(A2){var A4=AA(A2.config),A5=A4.tab_data,A6=A5.length||0,A3=A0.data("tab-number");openConfirmDialog({title:vBulletin.phrase.get("remove_tab_q"),message:vBulletin.phrase.get("do_you_want_to_remove_tab",A0.data("tab-title")),iconType:"warning",onClickYes:function(){if(A4.default_tab==A3){A4.default_tab=0}if(!Array.isArray(A4.display_tabs)){A4.display_tabs=AT.map(A4.display_tabs,function(A8){return A8})}A4.display_tabs.splice(A3,1);var A7=[];A0.find(".canvas-widget").each(function(A8,BA){var A9=AT(this).data("widget-instance-id");if(A9){A7.push(A9)}});if(A7.length){AO(A7)}Ay.remove();A0.remove();Am.find("li:not('.js-tab-add')").each(function(A8,BC){var A9=AT(this),BB=A9.attr("aria-controls"),BA=Aq.find(".js-admin-widget-tab[id='"+BB+"']");if(BA.length){BA.data("tab-number",A8)}});Aq.tabs("refresh");A4.tab_data=f(Ar);if(!AT.isEmptyObject(A4)){Z(Ar,A4)}y();M();r=true}})};AK(Ar,Ax,true);return false});var An=function(A9,BA,Ax,A8,Az){if(typeof A9=="undefined"){A9="Untitled Tab"}if(typeof BA=="undefined"){BA=[]}if(typeof Ax=="undefined"){var BD=Ar.find(".js-admin-widget-tab");Ax=BD.length}var A0=BA.length,A4=Av.clone().uniqueId().removeClass("h-hide").data("tab-number",Ax).data("tab-title",A9),A7=A4.find(".js-admin-widget-list"),Ay=A4.attr("id"),A2=Ao.clone(true).removeClass("h-hide");A2.children("a.js-tab-header-link").attr("href","#"+Ay);A2.find("span.js-tab-title").text(A9);for(var A3=0;A3<A0;A3++){var BB=BA[A3],A1=BB.widgetid||AM[BB.guid],BC=BB.widgetinstanceid||"",A5=AT('<div data-widget-id="'+A1+'" />');A5.attr("data-tab-number",Ax);A5.attr("data-widget-order",A3);A5.attr("data-widget-instance-id",BC);A5.append(AT('<img src="images/loader-box-blue.gif" /> '));A7.append(A5);if(A1){var A6=(function(BH,BF,BG,BE){return function(BN){if(!BG){var BI=BH.adminconfig||{},BL=function(BQ){BN.attr("data-widget-instance-id",BQ);V(Ar)};i(Ap,BF,BI,BL)}else{BN.attr("data-widget-instance-id",BG)}if(!Az){var BO=BN.find(".js-move-button"),BJ=BN.find(".js-edit-button"),BP=BN.find(".js-remove-button"),BK=BN.find(".js-edit-tab-button"),BM=BN.find(".js-remove-tab-button");BO.hide();BJ.hide();BP.hide();BK.hide();BM.hide();BN.addClass("js-widget-non-sortable")}BE.replaceWith(BN);BN.filter(":not(.container-widget)").find(".toggle-button").trigger("click",[true]);h(BN)}})(BB,A1,BC,A5);Ag(A5,A6)}}Aw.before(A2);Aq.append(A4);Aq.tabs("refresh");Aq.tabs("option","active",A8);A7.prepend('<div class="canvas-widget dummy-widget dummy-widget--no-fixed-height"><span>{0}</span></div>'.format(vBulletin.phrase.get("drag_and_drop_modules_below")))};var At=function(A3){var Az=AA(A3.config),A7=Az.tab_data,A5=A7.length,A6=Az.default_tab,A0=A3.isusereditable.tab_data||false;for(var A2=0;A2<A5;A2++){An(A7[A2].title,A7[A2].widgets,A2,A6,A0)}if(A0){var Ay,A1,Ax,A4;Am.sortable({helper:"clone",opacity:1,axis:"x",items:"li:not('.js-tab-add')",cancel:".js-edit-tab-button, .js-remove-tab-button",start:function(){old_numidx_to_controls={};new_controls_to_numidx={};Aq.find(".js-admin-widget-tab").each(function(A8,A9){old_numidx_to_controls[A8]=AT(this).attr("id")})},stop:function(){Am.find("li:not('.js-tab-add')").each(function(A9,BD){var BA=AT(this),BC=BA.attr("aria-controls"),BB=Aq.find(".js-admin-widget-tab[id='"+BC+"']");if(BB.length){BB.data("tab-number",A9);Aq.append(BB)}new_controls_to_numidx[BC]=A9});Aq.tabs("refresh");var A8=function(A9){A6=new_controls_to_numidx[old_numidx_to_controls[A6]];A9.default_tab=A6;var BC={};for(var BD in A9.display_tabs){var BA=new_controls_to_numidx[old_numidx_to_controls[BD]],BB=A9.display_tabs[BD];BC[BA]=BB}A9.display_tabs=BC;A9.tab_data=f(Ar);if(!AT.isEmptyObject(A9)){Z(Ar,A9)}};AK(Ar,A8)},})}else{Aw.hide()}};AK(Ar,At,true);Ar.data("tabbed-container-initialized",true)}function I(Ak,Al){var Aj=AT(".js-canvas-layout-container > .canvas-layout").attr("id");if(!vBulletin.sitebuilder.tempModuleHTMLCache){vBulletin.sitebuilder.tempModuleHTMLCache={};AT(".js-canvas-layout-container .canvas-widget").each(function(){var Am=AT(this).data("widget-instance-id");vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+Am]=this.outerHTML})}AT(".js-canvas-layout-container").text("");vBulletin.AJAX({call:"/ajax/get-layouts-for-sitebuilder",data:{pagetemplateid:pageData.pagetemplateid,channelid:pageData.channelid},success:function(Am){console.log("ajax/get-layouts-for-sitebuilder result:");console.dir(Am);var An=AT(".js-canvas-layout-container");An.html(Am.screenlayoutlist);if(Am.widgets&&Am.widgets.length>0){var Ao=AT("#"+Aj);AT.each(Am.widgets,function(Ap,Aq){var Ar=Ao.find(".canvas-widget-list.section-"+Ap);AT.each(Aq,function(As,Au){Ar.append(Au.rendered_template);var At=Ar.find(".canvas-widget").filter(function(){return AT(this).data("widget-instance-id")==Au.widgetinstanceid});if(typeof Au.subModules!="undefined"){AU(At,Au.subModules)}h(At)})})}if(vBulletin.inlinemod&&vBulletin.inlinemod.initModMenuHover){vBulletin.inlinemod.initModMenuHover()}if(typeof Al=="function"){Al()}},title_phrase:"sitebuilder",error_phrase:"unable_to_load_layouts"})}function L(Al,An){var Aj=An.enableButtons,Am=AT(".js-top-menu-sitebuilder--list .js-top-menu-link");if(Aj){AT(".js-top-menu-user").removeClass("h-hide");Am.removeClass("b-top-menu__item-link--selected b-top-menu__item-link--disabled")}else{var Ak=AT(An.currentButton);Am.removeClass("b-top-menu__item-link--selected").addClass("b-top-menu__item-link--disabled");Ak.addClass("b-top-menu__item-link--selected");AT(".js-top-menu-user").addClass("h-hide")}}AT(document).on("vb-toggle-sitebuilder-menu",L);function Ae(Am){var Al=AT(Am.target),Aj=Al.data("panel-name");if(Al.is(".b-top-menu__item-link--disabled")){this.blur();Am.stopPropagation();return false}if(Al.is(".js-top-menu-tab--admincp")){return true}var Ak="vb-sitebuilder-panel--"+Aj;AT(document).trigger(Ak);return false}AT(document).on("click",".js-top-menu-sitebuilder--list .js-top-menu-link",Ae);function AV(Al,Ak){var Aj=AT(".js-top-menu-sitebuilder .js-top-menu-link");L(null,{enableButtons:!Ak,currentButton:Al});AT(document.body).toggleClass("edit-mode "+Al.id,Ak).toggleClass("view-mode",!Ak);AT(".js-top-menu-user").toggleClass("h-hide",Ak)}function d(){if(!AT(this).hasClass("selected")&&!AT(document.body).hasClass("edit-mode")){AV(this,true)}return false}vBulletin.sitebuilder.activateSB=d;function D(){AV(this,false);return false}function Y(Al,Ak){var Aj=AT("<div />").append(Al.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,'<span class="axd-placeholder">{0}'.format(vBulletin.phrase.get("x_will_show_up_here_when_saved",Ak))).replace(/<vb\:/g,"&lt;vb:").replace(/<\/vb\:/g,"&lt;/vb:"));Aj.find("span.axd-placeholder").not(":first").remove();Aj.find("iframe").remove();return Aj.html()}function AR(){var Am=null,Ak=null,Az=null,A0="",Aw="",Au="",Ap="";var Ay=function(A1){if(!A1){A1=""}if(A1.match(/^https?:\/\//i)){return A1}if(A1.substr(0,1)=="/"){return pageData.baseurl+A1}return pageData.baseurl+"/"+A1};var Al=function(A7,A3,A4,A6,A1,A2){A1=A1||[];console.log("createNavbarItem... Name: "+A3+" Url: "+A4+" NewWindow: "+A6+" UserGroups: "+A1+" itemAttr: "+A2);A3=JShtmlEncode(A3);var A5=AT("<li />").append("<label>{0}</label>".format(A3)).append(AT("<div />").addClass("nav-item-controls h-right").append('<i>|</i><span class="navbar-item-delete b-icon b-icon__trash b-icon--active" title="{0}"></span>'.format(vBulletin.phrase.get("delete"))).append('<i>|</i><span class="navbar-item-edit b-icon b-icon__pencil b-icon--active" title="{0}"></span>'.format(vBulletin.phrase.get("edit"))).append('<i>|</i><span class="navbar-item-opensubnav b-icon b-icon__arrow-right-m" title="{0}"></span>'.format(vBulletin.phrase.get("expand")))).data({"item-phrase":A7,"item-name":A3,"item-url":A4,"item-newwindow":A6,"item-usergroups":A1,"item-attr":A2});return A5};var Ao=function(A1){return A1.prevAll("li").size()};var Av=function(){var A2=(Ap=="navbar"),A1=A2?AT("#channel-tabbar ul"):AT("#footer-tabbar ul.nav-list"),A3=A2?AT("#channel-subtabbar ul"):AT();A1.html("");A3.html("");var A4=function(BA,A8,A5){var A7=A8.data("item-newwindow")?' target="_blank"':"",A9=A8.hasClass("selected")&&A5?' class="current"':"",A6=AT("<li{0}><a {1}>{2}</a></li>".format(A9,A7,A8.data("item-name")));A6.find("a").prop("href",Ay(A8.data("item-url")));BA.append(A6)};AT("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var A5=AT(this);A4(A1,A5,A2);if(A5.hasClass("selected")){AT(A5.data("subnav-element")).find("li").each(function(){A4(A3,AT(this),true)})}})};var An=function(A7,A9,A2,A3,A5,A8,A4){var A1=Al(A7,A9,A2,A3,A5,A4);console.log("insertNavbarItem... Name: "+A1.data("item-name")+" Url: "+A1.data("item-url")+" NewWindow: "+A1.data("item-newwindow")+" UserGroups: "+A1.data("item-usergroups")+" itemAttr: "+A1.data("item-attr"));A1.appendTo(Ak);var A6=AT("<ul />").addClass("sub-navbar-list navbar-list sortable");AT(A8).each(function(){var BG=this.phrase?this.phrase:"",BB=this.title?this.title:"",BE=this.url?this.url:"",BF=this.newWindow?this.newWindow:false,BA=this.usergroups?this.usergroups:[],BD=this.attr?this.attr:"";var BC=Al(BG,BB,BE,BF,BA,BD);BC.appendTo(A6)});(function(){var BA=null;A6.sortable({start:function(BB,BC){BC.placeholder.html(vBulletin.phrase.get("drop_page_here")).height(BC.item.height()-2)},stop:function(BB,BC){Av()},receive:function(BB,BC){var BD=BC.item.data("subnav-element")||AT();if(BD.is(":visible")){BC.sender.sortable("cancel");vBulletin.warning("move_not_allowed","moving_main_nav_to_own_sub_nav_error")}else{if(BD.find("li").length>0){BC.sender.sortable("cancel");vBulletin.warning("move_not_allowed","moving_main_nav_with_sub_nav_error")}}},connectWith:".sortable",placeholder:"sortable-highlight",forcePlaceholderSize:true}).disableSelection()})();A6.hide();A6.appendTo("#navbar-ui-container .subnavbar-list-container");A1.data("subnav-element",A6);Av()};var Ar=function(A2,A4,A5,A6,A1,A3){$newItem=Al(A2.data("item-phrase"),A4,A5,A6,A1,A3);console.log("updateNavbarItem... Name: "+$newItem.data("item-name")+" Url: "+$newItem.data("item-url")+" NewWindow: "+$newItem.data("item-newwindow")+" itemAttr: "+$newItem.data("item-attr"));if(A2.data("subnav-element")){$newItem.data("subnav-element",A2.data("subnav-element"))}if(A2.hasClass("selected")){$newItem.addClass("selected")}A2.replaceWith($newItem);Av()};var Ax=function(A2){Ap=A2;if(Ap=="navbar"){A0=AT("#channel-tabbar ul").html();Aw=AT("#channel-subtabbar ul").html();Au=AT("#channel-tabbar ul li.current a").attr("href");AT("#channel-subtabbar.h-hide").toggleClass("h-hide default-hide")}else{A0=AT("#footer-tabbar ul.nav-list").html();Au=AT("#footer-tabbar ul.nav-list li.current a").attr("href")}AT("#admin-navbar-strip-gutter").removeClass().addClass("navbar-"+Ap);AT("#header").add("#header-axd").hide();AT("#navbar-ui-container").find(".navbar-ui-wrapper, .subnavbar-ui-wrapper").remove();var A1=AT("#edit-navbar");A1.find(".panel-header-text").hide();AT("#edit-navbar #panel-header-"+Ap).show();A1.slideDown("slow",function(){vBulletin.AJAX({call:"/ajax/api/site/"+(Ap=="navbar"?"loadHeaderNavbar":"loadFooterNavbar"),data:({siteId:1,edit:1}),success:function(A3){var A6=AT("<ul />").addClass("main-navbar-list navbar-list sortable "+Ap),A5=AT("<div />").addClass("new-nav-item main-nav").html(vBulletin.phrase.get("new_navigation_item")),A4=AT("<h4 />").text(vBulletin.phrase.get("main_navigation_bar"));AT("<div />").addClass("navbar-ui-wrapper").append(A4).append(A6).append(A5).appendTo("#navbar-ui-container");var A9=null;A6.sortable({start:function(BB,BC){BC.placeholder.html(vBulletin.phrase.get("drop_page_here")).height(BC.item.height()-2)},stop:function(BB,BC){Av()},connectWith:".sortable",placeholder:"sortable-highlight",forcePlaceholderSize:true}).disableSelection();Ak=A6;var BA=AT("<div />").addClass("subnavbar-list-container"),A8=AT("<div />").addClass("new-nav-item sub-nav").html(vBulletin.phrase.get("new_subnavigation_item")),A7=AT("<h4 />").text(vBulletin.phrase.get("sub_navigation_bar"));AT("<div />").addClass("subnavbar-ui-wrapper").append(A7).append(BA).append(A8).appendTo("#navbar-ui-container").hide();if(A3){console.log("result:",A3);AT(A3).each(function(){var BH=this.phrase?this.phrase:"",BC=this.title?this.title:"",BF=this.url?this.url:"",BG=this.newWindow?true:false,BB=this.usergroups?this.usergroups:[],BE=this.subnav?this.subnav:[],BD=this.attr?this.attr:"";An(BH,BC,BF,BG,BB,BE,BD)})}AT("#edit-navbar .navbar-ui-wrapper ul li").first().find(".navbar-item-opensubnav").filter(":visible").click()},error_phrase:"error_retrieving_navigation_bar_configuration"})})};AT(document).on("vb-sitebuilder-panel--navbar",function(){var A1=AT(".js-top-menu-tab--navbar").get(0);if(AT("#edit-navbar").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",A1,function(){d.apply(A1);Ax("navbar")})}return false});AT(document).on("vb-sitebuilder-panel--footer",function(){var A1=AT(".js-top-menu-tab--footer").get(0);if(AT("#edit-navbar").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",A1,function(){d.apply(A1);Ax("footer")})}return false});var Aj=function(A1){AT("#navbar-edit-item").dialog({autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:400,dialogClass:"dialog-container navbar-item-dialog-container",open:function(){AT("#navbar-edit-name").focus()}}).dialog("option","title",A1||vBulletin.phrase.get("edit_navigation_item")).dialog("open")};AT("#edit-navbar").on("click",".new-nav-item",function(){Am=null;if(AT(this).closest(".navbar-ui-wrapper").size()>0){Ak=AT(this).closest(".navbar-ui-wrapper").find("ul")}else{Ak=AT(this).closest(".subnavbar-ui-wrapper").find("ul").filter(":visible")}AT("#navbar-edit-name").val("");AT("#navbar-edit-url").val("");AT("#navbar-edit-attr").val("");AT("#navbar-edit-newwindow").prop("checked",false);Aj(AT(this).html());return false});AT(document).on("click","#navbar-edit-save",function(){if(AT("#navbar-edit-name").val()==""){vBulletin.warning("edit_navigation_item","input_navigation_item_name",function(){AT("#navbar-edit-name").focus()})}else{if(AT("#navbar-edit-url").val()==""){vBulletin.warning("edit_navigation_item","input_target_url",function(){AT("#navbar-edit-url").focus()})}else{console.log("Saving new/edited navbar item");if(!Am){An("",AT("#navbar-edit-name").val(),AT("#navbar-edit-url").val(),AT("#navbar-edit-newwindow").prop("checked"),AT("#navbar-edit-item").data("edit-usergroups"),[],AT("#navbar-edit-attr").val())}else{Ar(Am,AT("#navbar-edit-name").val(),AT("#navbar-edit-url").val(),AT("#navbar-edit-newwindow").prop("checked"),AT("#navbar-edit-item").data("edit-usergroups"),AT("#navbar-edit-attr").val())}Am=null;Ak=null;AT("#navbar-edit-item").dialog("close");console.log("Done saving new/edited navbar item")}}return false});AT(document).on("click","#navbar-edit-cancel",function(){AT("#navbar-edit-item").dialog("close");return false});var Aq=false;AT(document).on("click","#navbar-edit-usergroups",function(){var A2=function(){var A6=AT("#navbar-edit-usergroups-dialog .select_all"),A3=AT("#navbar-edit-usergroups-dialog .navbar-usergroup-checkbox");A3.prop("checked",false);var A4=function(){var A7=(A3.filter(":checked").length==A3.length&&A3.eq(0).is(":checked"));A6.prop("checked",A7)};A3.off("change").on("change",A4);A6.off("change").on("change",function(){A3.prop("checked",AT(this).prop("checked"))});if(!Am){return false}console.log("Prefilling checked usergroups");console.log(Am.data("item-name"));console.log(Am.data("item-url"));console.log(Am.data("item-usergroups"));if(Am.data("item-usergroups-temp")){var A5=Am.data("item-usergroups-temp")}else{var A5=Am.data("item-usergroups")}console.log(A5);AT.each(A5,function(A7,A8){AT("#navbar-usergroup-checkbox-"+A8).prop("checked",true)});A4()};var A1=function(){var A3=[];AT("#navbar-edit-usergroups-dialog .dialog-body input[type=checkbox]").each(function(){if(AT(this).prop("checked")){A3.push(AT(this).val())}});AT("#navbar-edit-item").data("edit-usergroups",A3);if(Am){Am.data("item-usergroups-temp",A3)}console.log("Saving checked usergroups")};if(!Aq){AT("#navbar-edit-usergroups-dialog").dialog({title:vBulletin.phrase.get("user_group_settings"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:500,dialogClass:"dialog-container pagemap-dialog-container input-dialog",create:function(){AT("#navbar-edit-usergroups-dialog .cancel-button").on("click",function(){AT("#navbar-edit-usergroups-dialog").dialog("close")});AT("#navbar-edit-usergroups-dialog .save-button").on("click",function(){A1();AT("#navbar-edit-usergroups-dialog").dialog("close")});vBulletin.AJAX({call:"/ajax/api/usergroup/fetchUsergroupList",complete:function(){AT("body").css("cursor","auto")},success:function(A3){var A4=[];AT(A3).each(function(){A4.push('<div class="blockrow"><label><input type="checkbox" class="navbar-usergroup-checkbox" id="navbar-usergroup-checkbox-{0}" value="{0}"><span>{1}</span></label></div>'.format(this.usergroupid,this.title))});AT("#navbar-edit-usergroups-dialog .dialog-body").html(A4.join(""));AT("#navbar-edit-usergroups-dialog").dialog("option","position",{of:window});console.log("Done adding usergroups");A2()},error_phrase:"error_retrieving_list_user_groups",after_error:function(){AT("#navbar-edit-usergroups-dialog").dialog("close")}})},close:function(){},open:function(){A2()}});Aq=true}else{AT("#navbar-edit-usergroups-dialog").dialog("open")}return false});AT("#edit-navbar").on("click",".navbar-item-delete",function(){AT(this).closest("li").remove();Av();return false});AT("#edit-navbar").on("click",".navbar-item-edit",function(){var A1=AT(this).closest("li");console.log("Click to edit item... Name: "+A1.data("item-name")+" Url: "+A1.data("item-url")+" NewWindow: "+A1.data("item-newwindow")+" UserGroups: "+A1.data("item-usergroups"));Am=A1;Ak=A1.closest("ul");Am.data("item-usergroups-temp",null);AT("#navbar-edit-name").val(A1.data("item-name"));AT("#navbar-edit-url").val(A1.data("item-url"));AT("#navbar-edit-attr").val(A1.data("item-attr"));AT("#navbar-edit-newwindow").prop("checked",A1.data("item-newwindow"));Aj(AT(this).html());return false});AT("#edit-navbar").on("click",".navbar-item-opensubnav",function(){var A3=AT(this),A4=A3.closest("li"),A2=AT("#edit-navbar"),A1=A2.find(".subnavbar-ui-wrapper");console.log("Click to open item subnav ... Name: "+A4.data("item-name")+" Url: "+A4.data("item-url")+" NewWindow: "+A4.data("item-newwindow")+" UserGroups: "+A4.data("item-usergroups"));A2.find("li").removeClass("h-disabled selected");A2.find(".navbar-item-opensubnav").removeClass("b-icon--active");A4.addClass("selected");A3.addClass("b-icon--active");A1.find("ul").hide();AT(A4.data("subnav-element")).show();A1.show();Av();return false});AT(document).on("click",".navbar-navbar #admin-navbar-strip .lnkExitWithoutSaving, .navbar-footer #admin-navbar-strip .lnkExitWithoutSaving",function(){AT("#edit-navbar").slideUp();AT("#header").add("#header-axd").show();if(Ap=="navbar"){AT("#channel-tabbar ul").html(A0);AT("#channel-subtabbar ul").html(Aw).parent(".default-hide").toggleClass("h-hide default-hide")}else{AT("#footer-tabbar ul.nav-list").html(A0)}});var As=function(){var A1=[];AT("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var A5=AT(this);var A3=function(A6){return{phrase:A6.data("item-phrase"),title:A6.data("item-name"),url:A6.data("item-url"),newWindow:A6.data("item-newwindow"),usergroups:A6.data("item-usergroups"),attr:A6.data("item-attr")}};var A4=[];A5.data("subnav-element").find("li").each(function(){$subLi=AT(this);A4.push(A3($subLi))});var A2=A3(A5);A2.subnav=A4;A1.push(A2)});vBulletin.AJAX({call:"/ajax/api/site/"+(Ap=="navbar"?"saveHeaderNavbar":"saveFooterNavbar"),data:({siteId:1,data:A1}),success:function(A3){AT("#edit-navbar").slideUp();AT("#header").add("#header-axd").show();AT("#admin-navbar-strip-gutter").addClass("h-hide");AT(document.body).removeClass("edit-mode lnkEditPage lnkNewPage lnkHeader lnkNavBar lnkFooter").addClass("view-mode");L(null,{enableButtons:true,currentButton:null});if(Ap=="navbar"){var A2=false;AT("#edit-navbar .navbar-ui-wrapper ul li").each(function(){var A4=AT(this);if(Ay(A4.data("item-url"))==Ay(Au)){A2=true;AT("#edit-navbar .navbar-ui-wrapper ul li").removeClass("selected");A4.addClass("selected");return false}});if(A2){Av()}else{AT("#channel-tabbar ul li").removeClass("current");AT("#channel-subtabbar ul").html("")}}},error_phrase:"error_saving_navigation_bar_configuration"})};var At="#admin-navbar-strip .lnkSaveChanges";AT(document).on("click",".navbar-navbar "+At+", .navbar-footer "+At,function(){As()})}function AJ(){bindFormReset("#edit-page-dropdown form").trigger("reset",function(){AT("#save-content .template-name").addClass("h-hide");AT("input[type=hidden]",this).each(function(){this.value=this.defaultValue})});AT(".js-top-menu-sitebuilder--list .js-top-menu-link").removeClass("b-top-menu__item-link--disabled");AT(document).on("click","#sitebuilder-wrapper .lnkExitWithoutSaving",function(){if(AT(this).closest("#edit-page-dropdown").length==0){L(null,{enableButtons:true,currentButton:null})}});AT(document).on("vb-sitebuilder-panel--channels",function(){var Aq=AT(".js-top-menu-tab--channels").get(0);vBulletin.assertUserHasAdminPermission("canusesitebuilder",Aq,function(){d.apply(Aq);X(false);AT(".edit-mode .canvas-widget-list .canvas-widget").addClass("shadow");AT("#header, #header-axd, #save-content").hide();AT("#manage-page").show();AT("#edit-page-dropdown .lnkDeletePage").removeClass("h-hide");AT("#manage-page-dropdown").removeClass("h-hide").slideDown("slow",AC)});return false});function Ao(){var Aq=AT(".js-sbpanel-pagelist-wrapper");Aq.find(".tab-item a").on("click",function(Ar){Ar.preventDefault()});Aq.tabs()}function An(){var At=AT(".js-sbpanel-pagelist-wrapper"),Ar=At.find(".js-delayed-template-render-insert-here"),As=At.find(".js-loading-placeholder"),Aq={};At.find(".js-simple-pagination-wrapper").each(function(){var Au=AT(this);Aq[Au.attr("id")]=Au.find(".js-pagenum").val()||0});At.tabs("disable");Ar.html("");As.removeClass("h-hide");vBulletin.AJAX({call:"/ajax/render/admin_sbpanel_pagelist_content_wrapper",success:function(Au){Ar.html(Au);At.tabs("refresh");At.tabs("enable");At.find(".js-simple-pagination-wrapper").each(function(){var Av=AT(this);Am(Av,Aq[Av.attr("id")]);Aj(Av);Ap(Av)})},error_phrase:"error_fetching_dialog",complete:function(){As.addClass("h-hide")}})}AT(document).on("vb-sitebuilder-panel--pages",function(){var Aq=AT(".js-top-menu-tab--pages").get(0),Ar=AT(".js-sbpanel-pagelist-wrapper");if(!Ar.data("panel-initialized")){Ar.data("tabspanel-initialized",true);Ao()}vBulletin.assertUserHasAdminPermission("canusesitebuilder",Aq,function(){if(Ar.hasClass("h-hide")){d.apply(Aq);Ar.removeClass("h-hide").slideDown("slow");An()}else{D.apply(Aq);Ar.slideUp("fast",function(){Ar.addClass("h-hide")})}});return false});AT(document).on("click",".js-sbpanel-pagelist-wrapper .js-button--close-panel",function(){var Aq=AT("#lnkPageList")[0],Ar=AT(".js-sbpanel-pagelist-wrapper");if(!Ar.hasClass("h-hide")){D.apply(Aq);Ar.slideUp("fast",function(){Ar.addClass("h-hide")})}});function Aj(Ar){var Aq=Ar.data("select-all-checkboxes-initialized")||false;if(Aq){console.log({msg:"Skipping checkbox init because it's already done.",$wrapper:Ar,});return }else{Ar.data("select-all-checkboxes-initialized",true)}Ar.find(".js-checkbox--checkall").each(function(){var As=AT(this),Au=As.data("group-id"),Aw=Ar.find(".js-checkbox[data-group-id='"+Au+"']"),Av=Aw.length,At=Aw;As.on("change",function(Ax){var Ay=AT(this).prop("checked");As.prop("indeterminate",false);if(Ay){Aw.prop("checked",true)}else{Aw.prop("checked",false)}});Aw.on("change",function(Ax){var Az=AT(this).prop("checked"),Ay=Aw.filter(":checked").length;if(Av>Ay){if(As.prop("checked")&&Ay>0){As.prop("indeterminate",true)}As.prop("checked",false)}else{As.prop("indeterminate",false);As.prop("checked",true)}})})}function Ap(Ar){var Aq=Ar.data("actions-initialized")||false;if(Aq){console.log({msg:"Skipping actions init because it's already done.",$wrapper:Ar,});return }else{Ar.data("actions-initialized",true)}Ar.find(".js-delete-orphaned-pagetemplates").on("click",function(As){var Aw=AT(this),Au=Aw.data("group-id"),At=Ar.find(".js-checkbox[data-group-id='"+Au+"']:checked"),Av={};At.each(function(){Av[this.name]=AT(this).val()});if(At.length<1){vBulletin.error("error","delete_orphaned_pagetemplates_please_select_one")}else{openConfirmDialog({title:vBulletin.phrase.get("delete"),message:vBulletin.phrase.get("delete_orphaned_pagetemplates_prompt_x",At.length),iconType:"warning",onClickYes:function(){vBulletin.AJAX({call:"/ajax/api/page/deleteOrphanedPagetemplates",data:At.serializeArray(),success:function(Ax){console.log({msg:"/ajax/api/widget/deleteOrphanedPagetemplates success!",result:Ax,});An()}})}})}})}function Am(Av,Aw){var At=Av.data("pagination-initialized")||false;if(At){console.log({msg:"Skipping pagination init because it's already done.",$wrapper:Av,});return }else{Av.data("pagination-initialized",true)}var Aq=Av.find(".js-pagenav-goprev");var Ax=Av.find(".js-pagenav-gopost");var Ar=Av.find(".js-pagenum");var Aw=(Aw&&parseInt(Aw,10))||parseInt(Ar.val(),10);var Ay=Av.find(".js-paginated-page");var Au={};var Az=0;Ay.each(function(){Az++;Au[Az]=AT(this)});Ar.on("blur keyup",function(A1){if(A1.type=="blur"||A1.keyCode=="13"){var A0=parseInt(Ar.val(),10);As(A0)}});Aq.on("click",function(A1){var A0=parseInt(Ar.val(),10);A0--;As(A0)});Ax.on("click",function(A1){var A0=parseInt(Ar.val(),10);A0++;As(A0)});function As(A0){if(A0<1){A0=1}if(A0>Az){A0=Az}Ay.addClass("h-hide");if(Au[A0]){Au[A0].removeClass("h-hide")}Ar.val(A0)}As(Aw)}AT(document).on("vb-sitebuilder-panel--editpage",function(){var Aq=AT(".js-top-menu-tab--editpage").get(0);if(AT("#edit-page-dropdown-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",Aq,function(){function Ar(){s=false;As();M();X(false,".container-widget");AT(".edit-mode .canvas-widget-list .canvas-widget").addClass("shadow");e.tabs("option","active",0);AT("#header, #header-axd, #save-content").hide();AT("#edit-content").show();AT("#edit-page-dropdown .lnkSaveChanges .label").text(vBulletin.phrase.get("save_page"));AT("#edit-page-dropdown .lnkDeletePage").removeClass("h-hide");AT("#edit-page-dropdown-gutter").removeClass("h-hide").slideDown("slow",Q);AT(".canvas-widget.axd-widget .widget-content").each(function(){AT(this).html(Y(AT(this).html(),vBulletin.phrase.get("ad")))})}function As(){var At=[];AT(".hidden-widget-placeholder").each(function(){At.push(AT(this).attr("data-widget-instance-id"))});if(At.length<1){return }vBulletin.AJAX({call:"/ajax/fetch-hidden-modules",data:({modules:At}),complete:function(){Ar()},success:function(Au){if(Au.length>0){AT.each(Au,function(Av,Ax){var Aw=AT(Ax.template).addClass("hidden-widget");AT('.hidden-widget-placeholder[data-widget-instance-id="'+Ax.widgetinstanceid+'"]').replaceWith(Aw)})}}})}d.apply(Aq);I(false,Ar)})}return false});AT(document).on("vb-sitebuilder-panel--newpage",function(){var Aq=AT(".js-top-menu-tab--newpage").get(0);if(AT("#edit-page-dropdown-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",Aq,function(){function Ar(){s=true;AT(".canvas-widget-list").empty();e.tabs("option","active",0);AT("#change-layout .layout-border.selected").removeClass("selected");AT("#layout-wide-narrow").prev().trigger("click");r=false;AT("#header, #header-axd, #save-content").hide();AT("#edit-content").show();AT("#edit-page-dropdown .lnkSaveChanges .label").text(vBulletin.phrase.get("save_new_page"));AT("#edit-page-dropdown .lnkDeletePage").addClass("h-hide");AT("#edit-page-dropdown-gutter").removeClass("h-hide").slideDown("slow",Q)}d.apply(Aq);I(true,Ar)})}return false});var Al=false;AT(document).on("vb-sitebuilder-panel--header",function(){var Aq=AT(".js-top-menu-tab--header").get(0);if(AT("#admin-navbar-strip-gutter").is(":hidden")){vBulletin.assertUserHasAdminPermission("canusesitebuilder",Aq,function(){d.apply(Aq);Al=false;AT("#admin-navbar-strip-gutter").addClass("navbar-header").removeClass("h-hide").find(".prompt-text").text(vBulletin.phrase.get("select_edit_link_header"));var Ar=AT("#header"),As=AT(".header-cell",Ar);$siteLogoEditStrip=AT("> .admin-only",As).addClass("h-hide-imp"),w=As.outerWidth();AT(".disable-overlay",Ar).width(Ar.innerWidth()-w).height(Ar.innerHeight()).show();$siteLogoEditStrip.width(w-(parseInt($siteLogoEditStrip.css("padding-left"),10)+parseInt($siteLogoEditStrip.css("padding-right"),10))).removeClass("h-hide-imp");AT(document).on("focus click mousedown",".edit-mode.lnkHeader #header .site-logo > a",function(At){this.blur();At.stopPropagation();return false})})}return false});AR();AT(".js-top-menu-sitebuilder").removeClass("h-hide");AT(document).on("click",".lnkHeader #admin-navbar-strip .lnkSaveChanges",function(){AT("body").css("cursor","wait");if(Number(AT("#header .site-logo img").attr("data-fileid"))>0){var Aq=Al?function(){location.reload(true)}:null;AG(Aq)}else{if(Al){location.reload(true)}else{AT("body").css("cursor","auto");AT("#admin-navbar-strip-gutter").addClass("h-hide").find(".prompt-text").text("");AT(document.body).removeClass("edit-mode lnkHeader").addClass("view-mode");AT("#header .disable-overlay").hide();L(null,{enableButtons:true,currentButton:null})}}});AT(document).on("click",".lnkHeader #admin-navbar-strip .lnkExitWithoutSaving",function(Ar){if(Al){Ar.stopImmediatePropagation();location.reload(true);return false}else{var Aq=AT("#header .site-logo img");if(Aq.attr("src")!=Aq.attr("data-orig-src")){Aq.attr("src",Aq.attr("data-orig-src")).removeAttr("data-fileid")}AT("#admin-navbar-strip-gutter").find(".prompt-text").text("");AT("#header .disable-overlay").hide();L(null,{enableButtons:true,currentButton:null})}});AT(document).on("click","#admin-navbar-strip .lnkExitWithoutSaving",function(){AT("#admin-navbar-strip-gutter").addClass("h-hide");AT(document.body).removeClass("edit-mode lnkEditPage lnkNewPage lnkHeader lnkNavBar lnkFooter").addClass("view-mode");AT("#header").add("#header-axd").show();AT("#edit-navbar").hide();L(null,{enableButtons:true,currentButton:null})});AT("#header-axd .axdnum").change(function(){var Aq=AT(this),Ar=parseInt(Aq.val());window.vBulletin.loadingIndicator.show();vBulletin.AJAX({call:"/ajax/api/ad/saveNumberOfHeaderAds",data:{number:Ar},success:function(As){if(Ar==1){AT("#header-axd").removeClass("axdnum_2").addClass("axdnum_1")}else{AT("#header-axd").removeClass("axdnum_1").addClass("axdnum_2")}},complete:function(){window.vBulletin.loadingIndicator.hide()}})});AT(document).off("click",".axd-edit-button").on("click",".axd-edit-button",function(){var Ar=AT(this).attr("data-location"),Aw=AT(this).closest(".axd-container");if(Aw.length==0){Aw=AT('.axd-container[data-widget-instance-id="'+Ar+'"]')}Av();function Av(Ax){Ax=Ax||false;AT("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/ad/listAdsByLocation",data:{adlocation:Ar},cache:false,success:As,emptyResponse:function(){if(!Ax){At({adlocation:Ar})}else{As([])}},complete:function(){AT("body").css("cursor","default")}})}function As(Ax){if(typeof g.axd_list_dialog=="undefined"){vBulletin.AJAX({call:"/ajax/render/dialog_axd_list",success:function(Ay){g.axd_list_dialog=Ay;AT("body").append(Ay);As(Ax)},error_phrase:"error_fetching_dialog"});return }AT("#axd-list-dialog").dialog({title:vBulletin.phrase.get("manage_ads"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:600,dialogClass:"dialog-container ad-list-dialog-container input-dialog",open:function(){var Ay=AT(this),A0=[];var A1=function(){Ay.dialog("close");Ay.dialog("destroy")};for(var Az in Ax){A0.push([Ax[Az].title,Ax[Az].active,Ax[Az].displayorder,Ax[Az].adid])}AT(".title",Ay).text(vBulletin.phrase.get("ad_list_description"));AT(".axdtable",Ay).dataTable({bPaginate:false,bLengthChange:false,bInfo:false,bAutoWidth:false,bDestroy:true,aaSorting:[[2,"asc"]],aoColumns:[{sTitle:vBulletin.phrase.get("title")+"<span></span>",sClass:"axdtable-title axd-cell"},{sTitle:vBulletin.phrase.get("active"),sClass:"axdtable-active axd-cell",bSortable:false,bSearchable:false,fnRender:function(A3,A2){return'<input type="checkbox" class="isactive" data-id="{0}"{1} />'.format(A3.aData[3],((A2=="1")?' checked="checked"':""))}},{sTitle:vBulletin.phrase.get("display_order")+"<span></span>",sClass:"axdtable-display-order axd-cell",bSearchable:false,bUseRendered:false,fnRender:function(A3,A2){return'<input type="text" class="displayorder textbox" value="{0}" data-id="{1}" />'.format(A3.aData[2],A3.aData[3])}},{sTitle:vBulletin.phrase.get("action"),sClass:"axdtable-action axd-cell",bSearchable:false,bSortable:false,bUseRendered:false,fnRender:function(A3,A2){return'<a href="#" class="editlink" data-id="{0}" title="{1}"><span></span></a> <a href="#" class="deletelink" data-id="{0}" title="{2}"><span></span></a>'.format(A3.aData[3],vBulletin.phrase.get("edit"),vBulletin.phrase.get("delete"))}}],aaData:A0});AT(".dataTables_filter input[type=text]",Ay).addClass("axdfilter textbox").on("keyup",function(){AT(this).next()[this.value!=""?"removeClass":"addClass"]("h-hide")}).after('<button type="button" class="axdSearchBtn b-button b-button--secondary b-button--sitebuilder h-hide">{0}</button>'.format(vBulletin.phrase.get("reset")));AT(".axdSearchBtn",Ay).on("click",function(){AT(this).addClass("h-hide").prev().val("").trigger("keyup")});AT(".axdtable .editlink",Ay).off("click").on("click",function(){var A2=AT(this).attr("data-id");A1();At(Ax[A2]);return false});AT(".axdtable .deletelink",Ay).off("click").on("click",function(){var A2=AT(this).attr("data-id"),A3=AT(this).closest("tr").find(".isactive").prop("checked");A1();openConfirmDialog({title:vBulletin.phrase.get("confirm_deletion_x",Ax[A2].title),message:vBulletin.phrase.get("are_you_sure_want_to_delete_ad_x",Ax[A2].title,"adid",A2),iconType:"warning",onClickYes:function(){AT("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/ad/delete",data:{adid:A2},success:function(A4){Av(true);if(A3){Al=true}}})},onClickNo:function(){Av()}});return false});AT(".axdlist",Ay).show();AT(".btnAddAxd",Ay).off("click").on("click",function(){A1();At({adlocation:Ar});return false});AT(".btnCancelAxd",Ay).off("click").on("click",function(){A1()});AT(".btnSaveAxd",Ay).off("click").on("click",function(){if(AT(".isactive",Ay).length==0){A1();return false}AT("body").css("cursor","wait");var A2={},A3=[];AT(".isactive",Ay).each(function(){var A4=AT(this).attr("data-id");A2[A4]={};A2[A4]["displayorder"]=AT('.displayorder[data-id="'+A4+'"]',Ay).val();if(AT(this).is(":checked")){A2[A4]["active"]=1;var A5=A2[A4];A5.snippet=Ax[A4].snippet;A5.title=Ax[A4].title;A3.push(A5)}else{A2[A4]["active"]=0}});vBulletin.AJAX({call:"/ajax/api/ad/quickSave",data:{data:A2},success:function(A4){var A5=AT(".axd_"+Ar,Aw);if(A5.length==0){A5=AT(".widget-content",Aw)}if(A3.length>0){A3.sort(function(A9,A8){return A9.displayorder-A8.displayorder});var A7="",A6="";AT.map(A3,function(A9,A8){if(A9.snippet){A6+=Y(A9.snippet,A9.title);A7+=A9.snippet}});A5.html(A6);Al=Au(A7)}else{A5.html("")}A5.show();A1();AT("html,body").animate({scrollTop:0},"slow")},complete:function(){AT("body").css("cursor","default")}})})}})}function At(Ax){vBulletin.AJAX({call:"/ajax/render/dialog_axd_config",data:{isAjaxTemplateRenderWithData:true},success:function(Ay){g.axd_config_dialog=Ay.template;AT("body").append(Ay.template);Aq(Ax)},error_phrase:"error_fetching_dialog"})}function Aq(Ay){var Ax=Ay.adlocation;AT("#axd-config-dialog").dialog({title:vBulletin.phrase.get(Ay.adid?["edit_ad_x",Ay.title]:"create_ad"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:720,dialogClass:"dialog-container axd-dialog-container input-dialog",open:function(){var Az=AT(this);if(Ay.adid){AT(".title",Az).val(Ay.title);AT(".axd_html",Az).val(Ay.snippet);AT(".active",Az).prop("checked",(Ay.active=="1"));AT(".axdid",Az).val(Ay.adid);for(var A0 in Ay.criterias){var A1=Ay.criterias[A0],A2=A1.criteriaid;AT("[name=data\\[criteria\\]\\["+A2+"\\]\\[active\\]]",Az).prop("checked",true);AT("."+A2,Az).each(function(){var A5=AT(this),A4=A5.attr("name").match(/condition\d/);if(A4){A5.val(A1[A4[0]])}})}}else{AT(".axdid",Az).val(0);AT(".configform",Az).trigger("reset")}AT(".axd_location",Az).val(Ax);AT(".blockrow select.custom-dropdown",Az).selectBox();AT(".blockrow a.custom-dropdown, .blockrow input[type=text]",Az).on("click",function(A4){return false});AT(".btnAttachHtmlAxd",Az).off("click").on("click",function(){var A4=AT(".configform",Az).serialize();AT("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/ad/save",data:A4,success:function(A5){A3();Al=Au(AT(".configform .axd_html",Az).val())},complete:function(){AT("body").css("cursor","default")}})});AT(".btnCancelEditHtmlAxd",Az).off("click").on("click",function(){A3(true)});function A3(A4){A4=A4||false;AT(":checkbox",Az).prop("checked",false);AT("select",Az).val("");Az.dialog("close");Az.dialog("destroy");AT("#axd-config-dialog").remove();Av(A4)}}})}function Au(Az){var Ay=AT("<div>"+Az+"</div>");if(Ay.filter("script").length>0){return true}else{var Ax=Ay.find("*").filter(function(){return(this.nodeName.toLowerCase().indexOf("vb:")==0)?this:null});return(Ax.length>0||(/\{vb\s*\:\s*[a-z]+\s+.*\}/).test(Az))}}return false});AT("#header .header-cell .js-edit-logo").on("click",function(){AT(".header-edit-box.selected").removeClass("selected");AT(this).closest(".header-edit-box").addClass("selected");AT("#edit-site-logo-dialog").dialog({title:vBulletin.phrase.get("edit_site_logo"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:520,dialogClass:"dialog-container site-logo-dialog-container input-dialog",create:function(){var Aq=AT(this).closest(".ui-dialog").find(".ui-dialog-title");Aq.append('<span class="dialog-subtitle"></span>');Aq.children("span.dialog-subtitle").text(vBulletin.phrase.get("choose_options_site_logo"));AT("#btnCancelEditSiteLogo").on("click",function(){AT("#edit-site-logo-dialog").dialog("close")});AT("#btnSaveEditSiteLogo").on("click",function(){if(Number(AT("#header .site-logo img").attr("data-fileid"))>0){AG(function(){AT("#edit-site-logo-dialog").dialog("close")})}else{AT("#edit-site-logo-dialog").dialog("close")}});AT("#edit-site-logo-dialog .styleselection").change(function(){AT("#header .site-logo img").attr({"data-styleselection":AT(this).val()})});AT("#edit-site-logo-dialog").fileupload({dropZone:null,dataType:"json",add:function(As,Ar){AT("body").css("cursor","wait");AT(As.target).find(".js-upload-progress:first").removeClass("h-hide");Ar.submit()},done:function(As,Ar){if(Ar.result&&Ar.result.filedataid){AT("#header .site-logo img").attr({src:Ar.result.imageUrl,"data-fileid":Ar.result.filedataid,"data-styleselection":AT("#edit-site-logo-dialog .styleselection:checked").val()})}else{vBulletin.error("error","error_uploading_logo")}},fail:function(As,Ar){vBulletin.error("error","error_uploading_logo")},always:function(As,Ar){AT("body").css("cursor","auto");AT(As.target).find(".js-upload-progress:first").addClass("h-hide")}});AT("#edit-site-logo-dialog #btnAttachLogo").on("click",function(){var Ar=AT.trim(AT("#edit-site-logo-dialog #imageUrl").val());if(Ar){AT("body").css("cursor","wait");AT(this).closest(".dialog-content").find(".js-upload-progress:last").removeClass("h-hide");vBulletin.AJAX({call:"/uploader/Url",data:({urlupload:Ar}),complete:function(){AT("body").css("cursor","auto");AT("#edit-site-logo-dialog .js-upload-progress:last").addClass("h-hide")},success:function(As){AT("#header .site-logo img").attr({src:As.imageUrl,"data-fileid":As.filedataid,"data-styleselection":AT("#edit-site-logo-dialog .styleselection:checked").val()})},title_phrase:"edit_site_logo",error_phrase:"error_processing_site_logo",after_error:function(){AT("#edit-site-logo-dialog #imageUrl").focus()}})}else{AT("#edit-site-logo-dialog #imageUrl").focus()}})}})});AT(".admin-button-flat").disableSelection();var Ak=function(Aq){Ah()};e=AT("#edit-content .tabs").tabs({beforeActivate:function(Ar,As){AT("#save-content").hide();if(As.newTab.index()==1){if(k){AT("#edit-page-dropdown .layout-list .layout-border.selected").removeClass("selected");var Aq=AT("#edit-page-dropdown .layout-list input[type=radio][value={0}]".format(AT(".canvas-layout:visible").attr("data-layout-id")));Aq.prev().addClass("selected");Ab="canvas-"+Aq.attr("id")}}},create:function(Aq,Ar){Ak(Ar.tab.index())},activate:function(Aq,Ar){Ak(Ar.newTab.index())}});AT("#lnkAddModules").on("click",function(){e.tabs("option","active",0);return false});AQ();AT(document).on("click",".module-buttons .hide-icon input",function(){var Ar=AT(this);Ar.closest(".canvas-widget")[this.checked?"addClass":"removeClass"]("hidden-widget");var Aq=Ar.attr("title");Ar.attr("title",Ar.data("toggle-title")).data("toggle-title",Aq)});AT(".canvas-layout-container .canvas-layout").each(function(){z[this.id]=AT("#"+this.id+' div[class*="section-"]').length});if(!s){Ab="canvas-"+AT("#edit-page-dropdown .layout-list input[type=radio][value={0}]".format(AT(".canvas-layout:visible").attr("data-layout-id"))).prop("checked",true).attr("id")}AD=AT("#edit-page-dropdown .layout-list input[type=radio]").thumbnailRadioCheckbox({thumbnailClass:"layout-border"});AD.thumbnailRadioCheckbox("option","select",function(Ar,Aq){AT(".canvas-layout").addClass("h-hide");AT("#canvas-"+Aq.attr("id")).removeClass("h-hide");B("canvas-"+Aq.attr("id"));O();y();r=true})}function B(Am){if(!Ab){AT(".canvas-layout.h-hide input[type=hidden]").prop("disabled",true);AT("#"+Am+" input[type=hidden]").prop("disabled",false);Ab=Am;return }else{if(Ab==Am){return }else{AT(".canvas-layout.h-hide input[type=hidden]").prop("disabled",true);AT("#"+Am+" input[type=hidden]").prop("disabled",false);var Ak=z[Am];var Aj=false;var Al=0;AT("#"+Ab+" > .canvas-layout-row > .canvas-widget-list").each(function(){var Ar=AT(this);Aj=AP(Ar,AT("#"+Am+" > .canvas-layout-row > .canvas-widget-list"));if(!Aj.length){Al=J(this);Aj=AT("#"+Am+" > .canvas-layout-row > div.section-"+Al)}if(!Aj.length){var An=Ak;while(An>=0&&AT("#"+Am+" > .canvas-layout-row > div.section-"+An).length==0){An--}Aj=AT("#"+Am+" > .canvas-layout-row > div.section-"+An)}var Ap=Ar.children(".canvas-widget");var As=parseInt(Math.ceil(Ap.length/Aj.length),10);console.log("Moving {0} widgets to {1} sections; ChunkSize {2}".format(Ap.length,Aj.length,As));if(As>0){var Aq=0,Ao=0;Ap.each(function(){AT(this).appendTo(Aj.eq(Ao));++Aq;if(Aq>=As){Aq=0;++Ao}})}})}}Ab=Am}function AP(Aj,Al){var An=["js-sectiontype-notice","js-sectiontype-primary","js-sectiontype-secondary","js-sectiontype-extra"],Ak,Am;for(Ak in An){if(Aj.is("."+An[Ak])){Am=An[Ak];break}}return Al.filter(function(){return AT(this).is("."+Am)})}function J(Al){var Ak=/section-(\d+)/gi;var Aj=null;AT(AT(Al).attr("class").split(" ")).each(function(An,Ao){var Am=Ak.exec(Ao);if(Am&&!isNaN(Am[1])){Aj=Am[1]}});return Aj}function Ac(Aj){if(!AT.isArray(Aj)||Aj.length==0){return }vBulletin.AJAX({call:"/ajax/admin-template/widget",data:({widgets:Aj,pagetemplateid:AT("#save-page-form #pagetemplateid-yes").val()}),success:function(Ak){if(AT.isArray(Ak.widgets)){AT.each(Ak.widgets,function(Al,An){if(!An.widgetid||Number(An.widgetid)<1||!AT.trim(An.template)){return true}var Ao=(An.displaysection&&Number(An.displaysection)>0)?An.displaysection:0,Am=AT(An.template);Am.appendTo(AT(".canvas-layout:not(.h-hide) .canvas-widget-list.section-"+Ao).height("auto")).filter(":not(.container-widget)").find(".toggle-button").trigger("click",[true]);Am.find(".tabs").tabs()})}},error_phrase:"error_adding_widgets",});return false}function Aa(Aj,Ak){var Al=Aj.closest(".channel-item-container").children(".sub-channel-container").children(".channel-item-container");if(Aj.text()=="<"){Aj.text(">");Al.slideDown(150)}else{if(typeof (Ak)==="undefined"||!Ak){Aj.text("<");itemContainer.slideUp(150)}}}function K(){AT(".channel-config-dialog .channel-list").sortable({placeholder:"main-channel-container-highlight drag-highlight h-clear",update:function(Aj,Ak){Ak.item.css("z-index","0");n.forum=true;u=true},sort:function(Aj,Ak){},start:function(Aj,Ak){if(AT.browser.msie&&parseInt(AT.browser.version,10)==8){Ak.item.height(Ak.item.height()-4)}Ak.item.css("z-index","99999");Ak.placeholder.height(Ak.item.outerHeight())},over:function(Aj,Ak){},receive:function(Aj,Ak){},out:function(Aj,Ak){},handle:".grip-icon-main",items:".main-channel-container"})}function F(Aj){AB=Aj.find(".main-channel-container").sortable({connectWith:".sub-channel-container",placeholder:"channel-item-highlight drag-highlight",revert:true,update:function(Ak,Al){var Am=Al.item.closest(".main-channel-container");if(Al.sender&&Al.sender.hasClass("main-channel-container")){if(AT("> .channel-item-container",Al.sender).length==0){Al.sender.slideUp("fast",function(){AT(this).remove()})}}n.forum=true;u=true},sort:function(Ak,Al){},activate:function(Ak,Al){},start:function(Ak,Al){},stop:function(Ak,Al){AT(".main-channel-container, .sub-channel-container").height("auto")},over:function(Ak,Al){},receive:function(Ak,Al){},out:function(Ak,Al){},handle:".channel-item-inner > .grip-icon-item",items:".channel-item-container"})}function U(Aj){AH=Aj.find(".sub-channel-container").sortable({connectWith:".sub-channel-container",revert:true,placeholder:"channel-item-highlight drag-highlight",update:function(Ak,Al){if(Al.sender&&Al.sender.hasClass("main-channel-container")){if(AT("> .channel-item-container",Al.sender).length==0){Al.sender.slideUp("fast",function(){AT(this).remove()})}}n.forum=true;u=true},sort:function(Ak,Al){},start:function(Ak,Al){},stop:function(Ak,Al){AT(".main-channel-container, .sub-channel-container").height("auto")},over:function(Al,Am){var Ak=AT(this).closest(".channel-item-container").children(".channel-item").find(".toggle-button");Aa(Ak,true)},receive:function(Ak,Al){},out:function(Ak,Al){},handle:".channel-item-inner > .grip-icon-item",items:".channel-item-container"})}function Ad(Aj,Am,An,Ao,Ar,At,Aq){var Ap='<div class="'+(Ar?"category-to-channel":"channel-to-category")+'"><a href="#">'+vBulletin.phrase.get((Ar?"make_forum":"make_category"))+"</a></div>";var As=AT(('<div class="main-channel-container">				<div class="grip-icon grip-icon-main h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>				<div class="channel-item-container">					<div class="channel-item shadow" data-channel-id="{0}" data-parent-id="{2}">						<div class="channel-item-inner">							<div class="grip-icon grip-icon-item h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>							<div class="channel-title"><div title="'+vBulletin.phrase.get("click_text_edit_title")+'">{1}</div><input type="text" name="channeltitle" value="{1}" /></div>							<div class="close-button" title="'+vBulletin.phrase.get("remove_forum")+'">x</div>							<div class="toggle-button"><</div>							<div class="num-subchannels">'+Aq+'</div>							<div class="add-subchannel-button h-right" title="'+vBulletin.phrase.get("add_subforum")+'"><a href="#">+</a></div>							'+Ap+'							<div class="h-clear"></div>						</div>					</div>					<div class="sub-channel-container"></div>				</div>		 </div>').format(Am,Ao,An)).appendTo(Aj);if(At){var Ak=AT("#top-level-forum .channel-config-dialog .channel-list");var Al=Ak.find(".main-channel-container").last();AT("html, body").animate({scrollTop:Al.offset().top},"fast")}n.forum=true;u=true;return As}function AN(Al,Am,An,Aq,Ak,Ap){var Ao='<div class="'+(Aq?"category-to-channel":"channel-to-category")+'"><a href="#">'+vBulletin.phrase.get((Aq?"make_forum":"make_category"))+"</a></div>";var Ar=Ak.hasClass("main-channel-container")?AT("> .channel-item-container > .sub-channel-container",Ak):AT("> .sub-channel-container",Ak);var Aj=AT(('<div class="channel-item-container">				<div class="channel-item shadow" data-channel-id="{0}" data-parent-id="{2}">					<div class="channel-item-inner">						<div class="grip-icon grip-icon-item h-left"><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div><div>&uml;</div></div>						<div class="channel-title"><div title="Click text to edit title">{1}</div><input type="text" name="channeltitle" value="{1}" /></div>						<div class="close-button" title="'+vBulletin.phrase.get("remove_forum")+'">x</div>						<div class="toggle-button"><</div>						<div class="num-subchannels">'+Ap+'</div>						<div class="add-subchannel-button h-right" title="'+vBulletin.phrase.get("add_subforum")+'"><a href="#">+</a></div>						'+Ao+'						<div class="h-clear"></div>					</div>			 </div>			 <div class="sub-channel-container"></div>			</div>').format(Al,An,Am)).hide().appendTo(Ar);n.forum=true;u=true;return Aj}function AX(){vBulletin.AJAX({call:"/ajax/fetch-widget-admin-template-list",complete:function(){Ah();AT(window).resize(Ah)},success:function(Al){AE=true;if(AT.isArray(Al)){if(Al.length>0){var Am={},Ap=0;AT.each(Al,function(Ar,As){if(!As.widgetid||Number(As.widgetid)<1){return true}Ap++;if(!Am[As.category]){Am[As.category]={count:1,title:As.category_title}}else{Am[As.category].count++}var Aq=AT("#edit-page-dropdown .module-list .module-icon-template").clone();Aq.attr("data-widget-id",As.widgetid).attr("data-title",AT.trim(As.title).toLowerCase()).data("canbemultiple",As.canbemultiple).removeClass("module-icon-template").addClass(("module-item category-{0}"+(As.cloneable=="1"?" module-cloneable":"")).format(As.category));AT(".module-icon",Aq).html(AT("<img />").attr("src",pageData.baseurl+"/images/sitebuilder/"+AT.trim(As.icon)).attr("height",60).attr("width",60).attr("alt",vBulletin.phrase.get("module_icon")));AT(".module-title .main-title",Aq).html(AT.trim(As.title));Aq.appendTo("#edit-page-dropdown .module-list").removeClass("h-hide")});AT(('<div class="category-arrow-left h-left" title="'+vBulletin.phrase.get("previous")+'">&lsaquo;</div>							<div class="scroller category h-left">								<div class="categories h-left">									<div id="category-all" class="category selected">'+vBulletin.phrase.get("all")+' ({0})</div>									<div id="category-result" class="category h-hide">'+vBulletin.phrase.get("search_results")+' (<span></span>)</div>								</div>							</div>							<div class="category-arrow-right h-left" title="'+vBulletin.phrase.get("next")+'">&rsaquo;</div>							<div class="h-clear"></div>').format(Ap)).insertBefore("#edit-page-dropdown .module-list-container .scroller");var Ak=0;AT.each(Am,function(Ar,As){var Aq=AT('<div id="category-{0}" class="category">{1} ({2})</div>'.format(Ar,As.title,As.count)).insertBefore("#category-result");Ak+=Aq.outerWidth(true)});var Ao=Ak+AT("#category-all").outerWidth(true);AT(".categories").width(Ao);if(AT(".categories").width()<=AT(".scroller.category").width()){AT(".category-arrow-left, .category-arrow-right").css("visibility","hidden")}else{AT(".category-arrow-right").css("visibility","visible")}Ai();b=AT("#edit-page-dropdown .module-list .module-item").not(".non-module-item");b.draggable({connectToSortable:".canvas-layout-row > .canvas-widget-list:visible",helper:"clone",revert:"invalid",appendTo:"#add-modules .module-list-container",zIndex:2000,start:function(Aq,Ar){if(AT(this).data("canbemultiple")=="0"&&AT("#content .canvas-layout .canvas-widget[data-widget-id={0}]".format(AT(this).attr("data-widget-id"))).length>0){vBulletin.warning("move_not_allowed",["adding_multiple_modules_not_allowed",AT(".main-title",this).html()]);return false}t=true},stop:function(Aq,Ar){t=false}}).disableSelection();var Aj=false;AT("#search-module-keyword").on("keyup",function(Aq,Ay){var Ax=AT("#add-modules"),Au=AT("#category-result"),Ar=AT(".categories",Ax),As=AT(".scroller.category",Ax),At=false;AT(".module-item",Ax).hide();if(!Ay){AT(".category.selected",Ax).removeClass("selected")}var Aw=AT.trim(this.value.toLowerCase());if(Aw){AT('.module-item[data-title*="{0}"]'.format(Aw),Ax).show();Au.removeClass("h-hide").addClass("selected")}else{AT(".module-item",Ax).show();AT("#category-all").removeClass("h-hide").addClass("selected");Au.addClass("h-hide").removeClass("selected");At=true}var Az=AT(".module-item:visible",Ax).length;AT("span",Au).text(Az);Ai();if(Az==0){AT(".empty-module",Ax).show()}else{AT(".empty-module",Ax).hide()}if(At){Ar.width(Ao)}else{Ar.width(Ao+Au.outerWidth(true))}if(Ar.width()<=As.width()){AT(".category-arrow-left, .category-arrow-right",Ax).css("visibility","hidden");As.scrollLeft(0)}else{if(At){AT(".category-arrow-left",Ax).css("visibility","hidden");AT(".category-arrow-right",Ax).css("visibility","visible");As.scrollLeft(0)}else{AT(".category-arrow-left",Ax).css("visibility","visible");AT(".category-arrow-right",Ax).css("visibility","hidden");var Av=As.get(0);As.scrollLeft(Av.scrollWidth-Av.clientWidth)}}return true});AT("#add-modules .categories .category").on("click",function(As){As.stopPropagation();if(AT(this).hasClass("selected")){return false}var Aq=AT(this).closest(".module-list-container"),At=AT(".module-item",Aq);AT(".category.selected",Aq).removeClass("selected");AT(this).addClass("selected");At.hide();AT(".empty-module",Aq).hide();var Ar=this.id;if(Ar=="category-all"){At.show();AT(".non-module-item",Aq).hide()}else{if(Ar=="category-result"){AT("#search-module-keyword").triggerHandler("keyup",[true])}else{AT(".module-item.{0}".format(Ar),Aq).show()}}Ai();return false}).disableSelection();var An;AT(".category-arrow-left").on({mousedown:function(){AT(".category-arrow-right").css("visibility","visible");An=setInterval(function(){var Aq=AT(".scroller.category");Aq.scrollLeft(Aq.scrollLeft()-20);if(Aq.scrollLeft()==0){AT(".category-arrow-left").css("visibility","hidden");clearInterval(An)}},50)},mouseup:function(){clearInterval(An)}}).disableSelection();AT(".category-arrow-right").on({mousedown:function(){AT(".category-arrow-left").css("visibility","visible");An=setInterval(function(){var Ar=AT(".scroller.category");Ar.scrollLeft(Ar.scrollLeft()+20);var Aq=Ar.get(0);if(Ar.scrollLeft()==Aq.scrollWidth-Aq.clientWidth){AT(".category-arrow-right").css("visibility","hidden");clearInterval(An)}},50)},mouseup:function(){clearInterval(An)}}).disableSelection()}else{AT('<div class="empty-module">'+vBulletin.phrase.get("no_modules")+"</div>").appendTo("#edit-page-dropdown .module-list")}}},error_phrase:"error_retrieving_modules",})}function l(Ak,Aj){vBulletin.AJAX({call:"/ajax/api/widget/fetchWidgetGuidToWidgetidMap",success:function(Al){if(Al.map){AM=Al.map}else{AM={error_result:Al}}if(typeof Ak=="function"){Ak.apply(this,Aj)}}})}function o(){AT("#edit-page-dropdown .template-list").empty();vBulletin.AJAX({call:"/ajax/api/pagetemplate/fetchPageTemplateList",data:{pagetemplateid:AT("#save-page-form #pagetemplateid-yes").val()},success:function(Ak){x=true;if(AT.isArray(Ak)&&Ak.length>0){var Aj=false;AT.each(Ak,function(Al,Am){AT('<div class="template-item">								<input type="radio" id="pagetemplateid-{0}" name="pagetemplateid" value="{0}" data-thumbnail="{1}/images/sitebuilder/icon-layout-{4}.png"{2} />								<label class="label">{3}</label>							</div>'.format(Am.pagetemplateid,pageData.baseurl,(!s&&AT("#save-page-form #pagetemplateid-yes").val()==Am.pagetemplateid)?' checked="checked"':"",Am.title,Am.screenlayoutvarname)).appendTo("#edit-page-dropdown .template-list").data({screenlayoutid:Am.screenlayoutid,widgetinstances:Am.widgetinstances});if(AT("#save-page-form #pagetemplateid-yes").val()==Am.pagetemplateid){Aj=true;if(Am.title==""){window.console.warn("The page template for this page does not have a title.")}}});if(!s&&!Aj){window.console.error("The page template for this page was not in the list returned by fetchPageTemplateList! Expected pagetemplateid: {0}. Please ensure that this page template has a title.".format(AT("#save-page-form #pagetemplateid-yes").val()))}AT(".template-item",AT("#edit-page-dropdown .template-list")).each(function(Al){AT(this).attr("data-title",AT(".label",AT(this)).text().toLowerCase())});AT("#search-template-keyword").on("keyup",function(Ap){if(Ap.keyCode==13){Ap.preventDefault();return false}var Am=AT("#select-template"),Aq=AT(".scroller",Am),Ao=false;AT(".template-item",Am).hide();var Al=AT.trim(this.value.toLowerCase());if(Al){AT('.template-item[data-title*="{0}"]'.format(Al),Am).show()}else{AT(".template-item",Am).show();Ao=true}var An=AT(".template-item:visible",Am).length;Ai();AT(".empty-template",Am).toggle(An==0);return true});AT("#search-template-keyword").on("keydown",function(Al){if(Al.keyCode==13){Al.preventDefault();return false}});a=AT("#edit-page-dropdown .template-list .template-item input[type=radio]").thumbnailRadioCheckbox({thumbnailClass:"template-border",preselect:function(Am,Al){if(Al.is(":checked")){return false}if(r||u){openConfirmDialog({title:vBulletin.phrase.get("switch_template"),message:vBulletin.phrase.get("template_changes_will_be_lost"),iconType:"warning",onClickYes:function(){r=false;u=false;k=true;a.thumbnailRadioCheckbox("check",Al,true)}});return false}k=true;return true},select:function(Ap,Al){AT(".canvas-layout").addClass("h-hide");var An=Al.closest(".template-item").data("screenlayoutid");AT(".canvas-layout[data-layout-id="+An+"]").removeClass("h-hide");O();y();AT("#save-page-form #pagetemplateid-yes, #config_pagetemplateid").val(Al.val());AT("#save-page-form .page-template-name").html(vBulletin.phrase.get("page_template_name_id",Al.closest(".template-item").find(".label").html(),Al.val()));if(k){AT(".canvas-widget-list").empty();var Am=Al.closest(".template-item").data("widgetinstances");if(AT.isArray(Am)&&Am.length>0){var Ao=[];AT.each(Am,function(Aq,Ar){Ao.push({widgetid:Ar.widgetid,widgetinstanceid:Ar.widgetinstanceid})});Ac(Ao,true);M()}else{window.vBulletin.loadingIndicator.hide()}}AT("body").removeClass("lnkNewPage").addClass("lnkEditPage");AT("#save-page-form .new-page-template input").prop("disabled",true);AT("#save-page-form .edit-page-template input").prop("disabled",false);k=true},unselect:function(){}});Ai()}},})}function AG(Aj){vBulletin.AJAX({call:"/uploader/setlogo",data:({filedataid:AT("#header .site-logo img").attr("data-fileid"),styleselection:AT("#header .site-logo img").attr("data-styleselection")}),complete:function(){AT("body").css("cursor","auto")},success:function(Ak){if(AT.trim(Ak)==="true"){AT("#header .site-logo img").removeAttr("data-styleselection").removeAttr("data-fileid").attr("data-orig-src",AT("#header .site-logo img").attr("src"));AT("#admin-navbar-strip-gutter").addClass("h-hide").find(".prompt-text").text("");AT(document.body).removeClass("edit-mode lnkHeader").addClass("view-mode");AT("#header .disable-overlay").hide();L(null,{enableButtons:true,currentButton:null});if(typeof Aj=="function"){Aj()}}},error_phrase:"error_saving_site_logo"})}function N(Aj,Ak){AT.each(Aj,function(Am,Al){var An=AT(('<div class="sub-channel channel" data-channel-id="{0}" data-parent-id="{6}">				<div class="avatar h-left"></div>				<div class="title"><a href="{1}{2}">{3}</a></div>				<div class="info">					<span class="label">'+vBulletin.phrase.get("last_post")+':</span>					<span class="title">{4}</span>				</div>				<div class="h-clear"></div>').format(Al.nodeid,pageData.baseurl,Al.url,Al.title,(Al.lastPostTitle?Al.lastPostTitle:"<em>"+vBulletin.phrase.get("none")+"</em>"),pageData.baseurl_core,Al.parentid)).appendTo(Ak);N(Aj[Am].subchannels,An.eq(0))})}function AF(Ak,Aj){AT.each(Ak,function(Al,An){var Am=AT.map(An.subchannels,function(Aq,Ap){return Ap}).length;var Ao=AN(An.nodeid,An.parentid,An.title,An.category,Aj,Am);AF(An.subchannels,Ao)})}function AW(){e.tabs("option","active",0);var Ap=AT("#add-modules").height();e.tabs("option","active",1);var Aj=AT("#change-layout").height();e.tabs("option","active",2);var Ak=AT("#select-template").height();AT("#edit-page-dropdown .lnkSaveChanges").trigger("click");var Am=AT("#save-page-form").height();e.tabs("option","active",0);var Ao=Math.max(Ap,Aj,Ak,Am);var Al=AT("#edit-page-dropdown .panel-header-text");Al.each(function(){var Aq=AT(this);Aq.css("min-height",Ao-parseFloat(Aq.css("margin-top"))-parseFloat(Aq.css("margin-bottom"))-parseFloat(Aq.css("padding-top"))-parseFloat(Aq.css("padding-bottom")))});var An=AT("#edit-page-dropdown .panel-main-content");An.each(function(){var Aq=AT(this);Aq.css("min-height",Ao-parseFloat(Aq.css("margin-top"))-parseFloat(Aq.css("margin-bottom"))-parseFloat(Aq.css("padding-top"))-parseFloat(Aq.css("padding-bottom")))})}function X(Aj,Ak){var Al=(Ak&&Ak.length>0)?AT(".canvas-layout .canvas-widget").not(Ak).find(".widget-content"):AT(".canvas-layout .canvas-widget .widget-content");if(Aj){Al.each(function(){if(AT(this).is(":hidden")){AT(this).closest(".canvas-widget").find(".widget-header .toggle-button").trigger("click",[true])}})}else{Al.each(function(){if(!AT(this).is(":hidden")){AT(this).closest(".canvas-widget").find(".widget-header .toggle-button").trigger("click",[true])}})}}function j(Ak,Aj){if(Aj){if(Ak.find(".widget-content").is(":hidden")){Ak.find(".toggle-button").trigger("click",[true])}}else{if(!Ak.find(".widget-content").is(":hidden")){Ak.find(".toggle-button").trigger("click",[true])}}}function M(){if(!s){var Aj=AT(".canvas-layout:visible .canvas-widget.subchannel-widget");if(Aj.length==1){Aj.find(".close-button").hide()}else{Aj.find(".close-button").show()}}}function Ag(Al,Aj){var Ak=Al.attr("data-widget-id");if(v[Ak]==null){vBulletin.AJAX({call:"/ajax/fetch-widget-template",data:({widgetid:Ak}),success:function(Am){var Ao=AT.trim(Am);if(Ao){var An=AT(Ao.replace(/\<\s*script[^\>]*\>(.*?)\<\s*\/\s*script\>/g,""));An.attr("data-title",function(){var Ap=AT(".module-title",An).clone();Ap.find(".hide-on-viewmode").children().unwrap();Ap.find("*:hidden").remove();return AT.trim(Ap.text()).toLowerCase()});v[Ak]=An;if(typeof Aj=="function"){Aj(An.clone(true))}}},error_phrase:"error_retrieving_cloned_widget_template",})}else{if(typeof Aj=="function"){Aj(v[Ak].clone(true))}}}function E(Aj,Ak){AT(".edit-mode .canvas-widget.youtube-widget .widget-content").css("visibility",Aj);if(Ak){Ak.find(".widget-content").css("visibility",(Aj=="hidden"?"visible":"hidden"))}}function C(Aj){var Am="js-sb-module-config--viewpermissions--template";if(!Am.length){return""}if(!Aj.hasOwnProperty("defaultvalue")){Aj.defaultvalue={show:"all",}}var Aq=AT("."+Am).clone().removeClass(Am+" h-hide"),As=Aj.defaultvalue,Ar=(As.hasOwnProperty("hide")?"hide":"show"),Ao=(Ar=="show"&&typeof As[Ar]=="string"&&As[Ar]=="all"),Ak=Aq.find("input.js-module_viewpermissions__key[value='show_all']"),Ap=Aq.find("input.js-module_viewpermissions__key[value='show']"),Al=Aq.find("input.js-module_viewpermissions__key[value='hide']"),An=Aq.find(".js-module_viewpermissions_ugchecklist");if(Ar=="hide"){Ar="show";Ao=true;Ak.prop("checked",false);Ap.prop("checked",true)}if(Ar=="hide"){Ak.prop("checked",false);Ap.prop("checked",false);Al.prop("checked",true)}else{if(Ao){Ak.prop("checked",true);Ap.prop("checked",false);Al.prop("checked",false);An.addClass("h-hide")}else{Ak.prop("checked",false);Ap.prop("checked",true);Al.prop("checked",false)}}if(!Ao){AT.each(As[Ar],function(At,Au){An.find("input.js-module_viewpermissions__value[value='"+Au+"']").prop("checked",true)})}Aq.find("input.js-module_viewpermissions__key").on("change",function(At){if(this.value=="show_all"){An.addClass("h-hide")}else{An.removeClass("h-hide")}});return Aq}function AQ(){AT(document).off("click",".canvas-widget.default-widget:not(.js-search-widget) .edit-button").on("click",".canvas-widget.default-widget:not(.js-search-widget) .edit-button",function(){var Aq=AT(this).closest(".canvas-widget"),Ak=Aq;var Al=AT("> .widget-header .module-title",Aq);(function(){var Ar=Aq.data("widget-instance-id");if(vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+Ar]){if(AT("#sb-temp-module-cache").length==0){AT('<div id="sb-temp-module-cache" class="h-hide"></div>').appendTo("body")}var As=AT(vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+Ar]);if(As.find(".widget-tabs").length>0||As.is(".widget-tabs")){AT("#sb-temp-module-cache").append(As);delete vBulletin.sitebuilder.tempModuleHTMLCache["widgetinstance_"+Ar]}}var At=AT("#sb-temp-module-cache .canvas-widget").filter(function(){return AT(this).data("widget-instance-id")==Ar});if(At.length==1&&(At.find(".widget-tabs").length>0||At.is(".widget-tabs"))){Aq=At}})();if(Aq.is(".js-search-widget")){return }var An=Aq.attr("data-widget-id");var Am;if(AT("span.admin-only",Al).length>0){Am=AT("span.admin-only",Al).text()}else{Am=AT(".hide-on-viewmode",Al).length>0?AT(".hide-on-viewmode",Al).text():Al.text()}var Ap=Aq.data("widget-type")||"";AT("#config-dialog .loader").show();AT("#config-dialog .widget-name h1").html(Am);AT("#config-dialog .dialog-content .widget-config-container").hide().empty().removeClass("error notice");AT("#config-dialog").data("selected-module",Ak);E("hidden");AT("#config-dialog").dialog("open");var Ao=Ak.attr("data-widget-instance-id")||"";vBulletin.AJAX({call:"/ajax/api/widget/fetchConfigSchema",data:({widgetid:An,widgetinstanceid:Ao,pagetemplateid:W(),configtype:"admin"}),success:function(A6){AT("#config_widgetid").val(A6.widgetid);AT("#config_widgetinstanceid").val(A6.widgetinstanceid);c(A6.pagetemplateid);Ak.attr("data-widget-instance-id",A6.widgetinstanceid);if(!Ao){R(Ak)}if(!A6.configs||A6.configs.length==0){AT("#config-dialog .widget-config-container").html(vBulletin.phrase.get("no_configurations_found")).addClass("notice");AT("#btnSaveConfig").prop("disabled",true);AT("#btnCloseConfig").focus()}else{var A8=0;var A7=AT("#config-dialog .dialog-content .widget-config-container");AT('<input type="hidden" name="data[widget_type]" />').addClass("widget-type").val(Ap).appendTo(A7);var BD=false,At=false,A2=false,Aw=false,BF,BE=false,A1=Ak.data("is-tabbed-container"),A3={display_tabs:false,default_tab:false},A0=(AT("#debug-information").length==1);AT.each(A6.configs,function(BR,BK){var BJ=null;switch(BK.type){case"ChannelSetup":AT("#config-dialog .dialog-content .channel-config-dialog").css("display","block");return true;break;case"Text":var BL=typeof (BK.defaultvalue!="undefined")?BK.defaultvalue:"";BJ=AT('<input type="text" name="data[{0}]" id="data[{0}]" />'.format(BK.name)).addClass("textbox config-textbox").val(BL);break;case"LongText":var BL=typeof (BK.defaultvalue!="undefined")?BK.defaultvalue:"";BJ=AT('<textarea name="data[{0}]" id="data[{0}]" rows="3" />'.format(BK.name)).addClass("textbox config-textbox").val(BL);break;case"YesNo":var BP={option_1:AT('<input type="radio" value="1" name="data[{0}]" id="data[{0}_1]" />'.format(BK.name)),label_1:AT("<label />").attr({"for":"data["+BK.name+"_1]"}).text(vBulletin.phrase.get("yes")),option_0:AT('<input type="radio" value="0" name="data[{0}]" id="data[{0}_0]" />'.format(BK.name)),label_0:AT("<label />").attr({"for":"data["+BK.name+"_0]"}).text(vBulletin.phrase.get("no"))};var BV=BP["option_"+BK.defaultvalue];if(BV){BV.prop("checked",true)}BJ=AT("<div />").append(BP.option_1,BP.label_1,BP.option_0,BP.label_0);break;case"Checkboxes":BJ=AT("<div />");AT.each(BK.data,function(BX,BZ){var BY="";if(BK.defaultvalue&&typeof BK.defaultvalue[BX]!="undefined"&&BK.defaultvalue[BX]==1){BY=' checked="checked"'}var Ba=AT('<div><label><input type="checkbox" name="data[{0}][{1}]"{2} value="1" class="js-checkbox-always-send" /> {3}</label></div>'.format(BK.name,BX,BY,BZ));BJ.append(Ba)});break;case"Select":BE=true;BJ=AT('<select name="data[{0}]" />'.format(BK.name));var BO;if(BK.data!=""){for(BO in BK.data){if(BK.defaultvalue==BO){AT("<option />").attr("value",BO).attr("selected","selected").text(BK.data[BO]).appendTo(BJ)}else{AT("<option />").attr("value",BO).text(BK.data[BO]).appendTo(BJ)}}}break;case"ChannelSelect":BE=true;BJ=AT('<select name="data[{0}]" />'.format(BK.name));var BT=AT('<optgroup label="{0}" />'.format(vBulletin.phrase.get("special_options"))),BM=AT('<optgroup label="{0}" />'.format(vBulletin.phrase.get("channels"))),BS=false,BU=false;if(BK.data){AT.each(BK.data,function(BX,BY){var BZ=null;if(BK.defaultvalue==BY.nodeid){BZ=AT("<option />").attr("value",BY.nodeid).attr("selected","selected").html(BY.text)}else{BZ=AT("<option />").attr("value",BY.nodeid).html(BY.text)}if(BY.nodeid<1){BZ.appendTo(BT);BS=true}else{BZ.appendTo(BM);BU=true}});if(BS){BT.appendTo(BJ)}if(BU){BM.appendTo(BJ)}}break;case"ContentTypeSelect":BE=true;BJ=AT('<select name="data[{0}]" />'.format(BK.name));var BT=AT('<optgroup label="{0}" />'.format(vBulletin.phrase.get("special_options"))),BQ=AT('<optgroup label="{0}" />'.format(vBulletin.phrase.get("content_types"))),BS=false,BN=false;if(BK.data){AT.each(BK.data,function(BX,BZ){var BY=null;if(BK.defaultvalue==BZ.value){BY=AT("<option />").attr("value",BZ.value).attr("selected","selected").html(vBulletin.phrase.get(BZ.phrase))}else{BY=AT("<option />").attr("value",BZ.value).html(vBulletin.phrase.get(BZ.phrase))}if(BZ.special){BY.appendTo(BT);BS=true}else{BY.appendTo(BQ);BN=true}});if(BS){BT.appendTo(BJ)}if(BN){BQ.appendTo(BJ)}}break;case"ProfileFieldSelect":BE=true;BJ=AT('<select name="data[{0}]" />'.format(BK.name));if(BK.data){AT.each(BK.data,function(BX,BZ){var BY=null;if(BK.defaultvalue==BZ.field){BY=AT("<option />").attr("value",BZ.field).attr("selected","selected").html(BZ.title)}else{BY=AT("<option />").attr("value",BZ.field).html(BZ.title)}BY.appendTo(BJ)})}break;case"Custom":switch(BK.name){case"tab_data":BJ=AT("<div />");var BW=f(Ak),BI=AT("<div />");AT.each(BW,function(Ba,BX){var BY="[tab_data]["+Ba+"][title]",BZ=BX.title,Bb=AT('<input type="text" name="data{0}" id="data{0}" />'.format(BY)).addClass("textbox config-textbox").attr("value",BZ);BJ.append(Bb);AT.each(BX.widgets,function(Bc,Bd){AT.each(Bd,function(Bf,Be){BY="[tab_data]["+Ba+"][widgets]["+Bc+"]["+Bf+"]";BZ=Be;Bb=AT('<input type="text" name="data{0}" id="data{0}" />'.format(BY)).addClass("textbox config-textbox").attr("value",BZ);BJ.append(Bb)})})});break;case"module_viewpermissions":BJ=C(BK);break;default:break}break}$requiredMark=AT("<div />").addClass("config-required-mark h-left").append(function(){return(BK.isRequired==1)?"*":"&nbsp;"});if(BK.isEditable==0&&BJ){BJ.find("input").prop("readonly",true);if(!BJ.is("input")){BJ.prop("disabled",true)}}var BH=AT("<div />").addClass("config-label h-left").addClass(BK.name).html(BK.label);if(A0){BH.prop("title",BK.name)}if(BK.description){AT("<div />").addClass("config-description").html(BK.description).appendTo(BH)}if(BK.ishiddeninput&&BJ){BJ.attr("hidden",true);A7.append(BJ)}else{A7.append(AT("<div></div>").addClass(function(){return"h-clearfix config-row"+(((++A8)%2!=0)?" odd":"")}).append(BH,$requiredMark,AT("<div></div>").addClass("config-value h-left").addClass(BK.name).append(BJ)))}if(BK.name=="default_tab"){if(A1){A3.default_tab=BK}else{BD=true}}if(BK.name=="display_tabs"){if(A1){A3.display_tabs=BK}else{At=true}}if(BK.name=="tab_order"){if(!A1){A2=true}}if(BK.name=="axd"){Aw=true}});var BC=null;var Au=function(){BF=Aj(Aq);var BK=Aq.attr("data-widget-default-tab"),BI=AT('select[name="data[default_tab]"]',A7),BJ;BI.empty();for(var BH in BF){if(At){if(!AT('input:checkbox[value="'+BF[BH].selector+'"]',A9).is(":checked")){continue}}else{if(!BF[BH].displayed){continue}}BJ=AT('<option value="'+BF[BH].selector+'">'+BF[BH].label+"</option>");if(BC&&BC==BF[BH].selector){BJ.attr("selected","selected")}else{if(BK==BF[BH].selector){BJ.attr("selected","selected")}}BI.append(BJ)}};var BA=function(){BF=Aj(Aq);var BI=AT(".config-value.tab_order",A7),BJ,BK;BI.empty().append("<ul>");for(var BH in BF){if(At){if(!AT('input:checkbox[value="'+BF[BH].selector+'"]',A9).is(":checked")){continue}}else{if(!BF[BH].displayed){continue}}BJ=AT('<li id="'+BF[BH].selector+'">'+BF[BH].label+"</li>");AT("ul",BI).append(BJ);BK=AT('<input name="data[tab_order]['+BF[BH].selector.substring(1)+']" value="'+BH+'" type="hidden">');BI.append(BK)}AT("ul",BI).sortable({stop:function(){var BL=AT(this).sortable("toArray");BI.find("input:hidden").remove();for(BH in BL){BK=AT('<input name="data[tab_order]['+BL[BH].substring(1)+']" value="'+BH+'" type="hidden">');BI.append(BK)}}});AT("ul",BI).disableSelection()};if(At){BF=Aj(Aq);var A9=AT(".config-value.display_tabs",A7),Ax;for(var BB in BF){Ax=AT('<label><input type="checkbox" name="data[display_tabs][]" value="'+BF[BB].selector+'">'+BF[BB].label+"</label>");if(BF[BB].displayed){Ax.find("input:checkbox").attr("checked","checked")}A9.append(Ax)}if(BD){AT("input:checkbox",A9).on("click",function(){Au();BA()})}}if(A2){BA();AT('select[name="data[default_tab]"]',A7).change(function(){BC=AT(this).val()})}if(BD){Au()}var As=q(Ak);if(As){AT("<input type='hidden' name='data[containerinstanceid]' value='"+As+"' />").appendTo(A7)}if(A1){var Az=f(Ak),Av=AT('select[name="data[default_tab]"]',A7),BG=AT(".config-value.display_tabs",A7),Ar=A3.display_tabs&&A3.display_tabs.defaultvalue||"";if(Ar==""){Ar={};AT.each(Az,function(BI,BH){Ar[BI]="1"})}var A5=function(){var BH;Av.empty();AT.each(Az,function(BJ,BI){BH=AT('<option value="'+BJ+'">'+BI.title+"</option>");if(Ar[BJ]=="0"){BH.prop("disabled",true)}else{if(A3.default_tab.defaultvalue==BJ){BH.attr("selected","selected")}}Av.append(BH)});if(Av.is(".selectBox")){Av.selectBox("refresh")}};if(A3.default_tab){A5()}if(A3.display_tabs){var Ay;BG.empty();AT.each(Ar,function(BJ,BI){var BH="data[display_tabs]["+BJ+"]";Ay=AT("<label />").append(AT('<input type="hidden" name="'+BH+"\" value='0'/>")).append(AT('<input type="checkbox" name="'+BH+"\" value='1' data-tab-number=\""+BJ+'" />')).append(document.createTextNode(Az[BJ]["title"]));if(BI=="1"){Ay.find("input:checkbox").prop("checked",true)}BG.append(Ay)});AT("input:checkbox",BG).on("click",function(){var BL=AT(this),BI=BL.prop("checked"),BK=BL.data("tab-number"),BH=Av.find("option[value='"+BK+"']"),BJ=(BH.prop("disabled")!=!BI);Ar[BK]=BI;if(BJ){A5()}})}}if(Aw){var A4=AT(".config-value.axd",A7);A4.append('<button class="axd-edit-button b-button b-button--secondary b-button--sitebuilder" data-location="'+A6.widgetinstanceid+'">'+vBulletin.phrase.get("edit")+"</button>")}}AT("#config-dialog .dialog-content .widget-config-container").show();AT("#config-dialog .loader").hide();if(BE){AT("#config-dialog .dialog-content .widget-config-container select").selectBox()}(function(){function BH(){var BI=AT(this),BJ=BI.next(".js-checkbox-always-send-hidden");if(BJ.length==0&&!BI.prop("checked")){AT('<input type="hidden" name="{0}" class="js-checkbox-always-send-hidden" value="0" />'.format(BI.prop("name"))).insertAfter(BI)}else{BJ.remove()}}AT(".js-checkbox-always-send").off("click").on("click",BH);AT(".js-checkbox-always-send").each(BH)})();AT("#config-dialog .dialog-content .widget-config-container input,						#config-dialog .dialog-content .widget-config-container textarea,						#config-dialog .dialog-content .widget-config-container select,						#config-dialog .dialog-content .widget-config-container button").filter(function(){return AT(this).is(":visible")}).first().focus()},error_phrase:["error_retrieving_configuration",Am],after_error:function(){AT("#config-dialog .loader").hide();AT("#config-dialog").dialog("close")},});return false});function Aj(Al){var Ak=[];AT("ul.widget-tabs-nav li a, .widget-header ul.ui-tabs-nav li a, .widget-tabs-nav ul.ui-tabs-nav li a",Al).each(function(){var Am=AT(this),An;if(AT(this).closest("li").hasClass("h-hide")){An=false}else{An=true}Ak.push({selector:Am.attr("href"),label:Am.text(),displayed:An})});return Ak}}function O(){AT(".edit-mode .canvas-layout:visible > .canvas-widget-list").width("").each(function(){AT(this).width(AT(this).width())})}function y(){if(AT.browser.msie&&parseInt(AT.browser.version,10)==8){var Aj=AT(".edit-mode .canvas-layout:visible > .canvas-widget-list");Aj.each(function(){var Ak=AT(".canvas-widget",this),Aq=AT(this);var Al=Ak.outerHeight(true)||50;var Am=Ak.length*Ak.outerHeight(true);var Ap=Aq.height()-Am;console.log("offset:",Ap);if(Ap>=0&&Ap<Al){var Ao=AT(window);var An=Ao.scrollTop();Aq.height(Aq.height()+(Al-Ap));Ao.scrollTop(An);return false}else{if((Ap>Al&&Aq.height()>parseInt(Aq.css("min-height"),10))||Ap<0){var Ao=AT(window);var An=Ao.scrollTop();Aq.height(Am+Al);Ao.scrollTop(An);return false}}})}}function AI(){window.console.log("Fetching page manager forums (initializeForumEditor)");vBulletin.AJAX({call:"/ajax/api/widget/fetchPageManagerForums",complete:function(){AT("#config-dialog .loader").hide()},success:function(Aj){G=true;var Al=AT("<div>").addClass("channel-list");AT.each(Aj,function(An,Ap){var Ao=AT.map(Ap.subchannels,function(Ar,Aq){return Aq}).length;var Am=Ad(Al,Ap.nodeid,Ap.parentid,Ap.title,Ap.category,false,Ao);AF(Ap.subchannels,Am)});var Ak=AT("#top-level-forum .channel-config-dialog");Ak.find(".channel-list").remove();F(Al);U(Al);Ak.append(Al);AT(document).on("mousedown",".main-channel-container > .channel-item-container > .channel-item .grip-icon",function(){AT(this).closest(".main-channel-container").height(AT(this).closest(".main-channel-container").height())});AT(document).on("mousedown",".sub-channel-container > .channel-item-container > .channel-item .grip-icon",function(){AT(this).closest(".sub-channel-container").height(AT(this).closest(".sub-channel-container").height())});u=false;K()},error_phrase:"error_fetching_channels"});AT(document).on("click keydown",".channel-config-dialog .add-channel-fieldset .add-button, .channel-config-dialog .add-channel-fieldset input",function(Aj){if(((Aj.type=="click"||Aj.which!=13)&&this.type=="text")||(Aj.type=="keydown"&&this.type=="button"&&Aj.which!=13)){return true}var Am=(this.type=="text")?AT(this):AT(this).prev();var Ak=AT.trim(Am.val());if(Ak&&Ak!=Am.prop("defaultValue")){var Al=AT("#top-level-forum .channel-config-dialog .channel-list");Ad(Al,"","",vBulletin.htmlEntities(Ak),0,true,0);F(Al);K();Am.val("");if(this.type=="button"){Am.focus()}}else{vBulletin.warning("warning_gcpuser","please_enter_channel_title",function(){Am.focus()})}});AT(document).on("click",".channel-config-dialog .main-channel-container .channel-item .channel-title div",function(){AT(this).hide();var Aj=AT(this).next();Aj.show();Aj.select();Aj.focus()});AT(document).on("keydown blur",".channel-config-dialog .main-channel-container .channel-item .channel-title input",function(Aj){if(Aj.type=="focusout"||(Aj.type=="keydown"&&Aj.which==13)){if(!AT.trim(this.value)&&Aj.type=="focusout"){this.value=this.defaultValue}if(AT.trim(this.value)){AT(this).hide();AT(this).prev().text(this.value);AT(this).prev().show()}}});AT(document).on("click",".channel-config-dialog .channel-item .category-to-channel a",function(){var Aj=AT(this).closest(".channel-item");Aj.attr("data-switch-category",0);AT(this).parent().removeClass("category-to-channel").addClass("channel-to-category");AT(this).html(vBulletin.phrase.get("make_category"));return false});AT(document).on("click",".channel-config-dialog .channel-item .channel-to-category a",function(){var Aj=AT(this).closest(".channel-item");Aj.attr("data-switch-category",1);AT(this).parent().removeClass("channel-to-category").addClass("category-to-channel");AT(this).html(vBulletin.phrase.get("make_forum"));return false});AT(document).on("click",".channel-config-dialog .channel-item .toggle-button",function(){Aa(AT(this));return false});AT(document).on("click",".channel-config-dialog .channel-item .add-subchannel-button a",function(){var Aj=AT(this).parent().siblings(".toggle-button");Aa(Aj,true);var Al=AT(this).closest(".channel-item-container");var Ak=AN("","",vBulletin.phrase.get("new_channel"),0,Al,0);U(Al);Ak.slideDown(100,function(){var Am=Al.find(".channel-item-inner").first().find(".num-subchannels");Am.text(parseInt(Am.text())+1);AT(".channel-title div",Ak).click();AT(".channel-title input",Ak).get(0).scrollIntoView(false);K()});return false});AT(document).on("click",".channel-config-dialog .channel-list .channel-item .close-button",function(){var Ak=AT(this),Al=AT("> .sub-channel-container > .channel-item-container",Ak.closest(".channel-item-container")).length>0,Aj=vBulletin.htmlEntities(Ak.prev().text());openConfirmDialog({title:vBulletin.phrase.get("remove_forum_q"),message:vBulletin.phrase.get("do_you_want_to_remove_forum",Aj,(Al)?" "+vBulletin.phrase.get("subchannels_will_be_deleted"):""),iconType:"warning",onClickYes:function(){var Ap=Ak.closest(".channel-item-container"),Ao=Ap.parent(),An=Ak.closest(".channel-item").attr("data-channel-id");var Am=function(){Ap.remove();if(Ao.hasClass("main-channel-container")){Ao.slideUp("fast",function(){AT(this).remove()})}};if(An){vBulletin.AJAX({call:"/ajax/api/content_channel/delete",data:{nodeid:An},success:function(Aq){Am()},})}else{Am()}}})})}function Af(Ak){function Aj(Am,An,Al){vBulletin.AJAX({call:"/ajax/render/{0}_list".format(Am),data:{page:An,isAjaxTemplateRenderWithData:true},complete:function(){AT("#config-dialog .loader").hide();AT("body").css("cursor","auto")},success:function(Ao){AT(("#top-level-{0} .channel-config-dialog").format(Am)).html(Ao.template);if(Al){vBulletin.pagination({context:("#top-level-{0} .channel-config-dialog").format(Am),onPageChanged:function(Ap,Aq){Aj(Am,Ap)}})}},error_phrase:"error_fetching_channels"})}Aj(Ak,1,true);AT(document).on("click",".page_manager_table .channel_name div",function(){AT(this).hide();var Al=AT(this).next();Al.show();Al.select();Al.focus()});AT(document).on("keydown blur",".page_manager_table .channel_name input",function(An){if(An.type=="focusout"||(An.type=="keydown"&&An.which==13)){if(!AT.trim(this.value)&&An.type=="focusout"){this.value=this.defaultValue}var Am=AT.trim(this.value),Al=AT(this);if(Am&&Al.prev().html()!=Am){AT("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/Content_Channel/update",data:{nodeid:Al.parents(".channel_row").data("nodeid"),data:{title:Am}},complete:function(){AT("#config-dialog .loader").hide();AT("body").css("cursor","auto")},success:function(Ao){Al.hide();Al.prev().html(Am);Al.prev().show()},error_phrase:"error_saving_page"})}}});AT(document).on("click",".page_manager_table .delete",function(){var Al=AT(this);openConfirmDialog({title:vBulletin.phrase.get("remove_channel_q"),message:vBulletin.phrase.get("do_you_want_to_remove_channel",Al.parents(".channel_row").find(".channel_name_val").text()),iconType:"warning",onClickYes:function(){vBulletin.AJAX({call:"/ajax/api/content_channel/delete",data:{nodeid:Al.parents(".channel_row").data("nodeid")},success:function(Am){Al.parents(".channel_row").remove()}})}})})}var G=false;function AC(){AT("body").css("cursor","wait");var Aj=function(Al){var Ak=Al.index();if(Ak==0&&!G){AI()}if((Ak==1||Ak==2)){Af(AT(Al.context).data("top-level"))}};m=AT("#manage-pages").tabs({beforeActivate:function(Am,An){var Al=An.newTab.index();if(Al!=0&&u){var Ak=openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("forum_changes_will_be_lost"),iconType:"warning",onClickYes:function(){u=false;m.tabs("option","active",Al)}});return false}},create:function(Ak,Al){Aj(Al.tab)},activate:function(Ak,Al){Aj(Al.newTab)}});m.tabs("option","active",0);AT("#manage-page-dropdown .lnkSaveChanges").on("click",function(){console.log("Saving forum/channel data");var Ak=AT(this);if(Ak.hasClass("h-disabled")){console.log("We're busy saving already. Try again later.");return }Ak.addClass("h-disabled");vBulletin.loadingIndicator.show();AT("body").css("cursor","wait");var Al=[];function Am(Ap,An,Ao){var Aq=AT("> .channel-item-container",Ap);if(Aq.length>0){Aq.each(function(As){var Ar=AT("> .channel-item",this);var At=Ar.attr("data-channel-id");var Au=Ar.attr("data-parent-id");subchannelObj={nodeid:At||"0",previousParentId:Au,title:AT(".channel-title div",Ar).html(),displayorder:As+1,parentid:Ao||"0",subchannels:[]};if(Ar.attr("data-switch-category")!=null){subchannelObj.switchCategory=Ar.attr("data-switch-category")}An.subchannels.push(subchannelObj);Am(Ar.next(".sub-channel-container"),An.subchannels[As],At)})}}if(n.forum){AT(".channel-config-dialog .channel-list .main-channel-container").each(function(Ap){var Ao=AT("> .channel-item-container > .channel-item",this);var Aq=Ao.attr("data-channel-id");var Ar=Ao.attr("data-parent-id");var An={nodeid:Aq,previousParentId:Ar,title:AT(".channel-title div",Ao).html(),displayorder:Ap+1,subchannels:[]};if(Ao.attr("data-switch-category")!=null){An.switchCategory=Ao.attr("data-switch-category")}Am(Ao.next(".sub-channel-container"),An,Aq);Al.push(An)});vBulletin.AJAX({call:"/ajax/api/widget/saveForums",data:{data:JSON.stringify(Al)},complete:function(){AT("body").css("cursor","auto");vBulletin.loadingIndicator.hide();Ak.removeClass("h-disabled")},success:function(An){console.log("Forum/channel changes successfully saved");if(An&&An.forums&&An.forums.length>0){u=false;n.forum=false;location.reload(true)}else{openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_saving_forums"),iconType:"error"});return false}},error_phrase:"error_saving_channels_code"})}else{console.log("No forum/channel changes to save");vBulletin.loadingIndicator.hide();AT("body").css("cursor","auto");Ak.removeClass("h-disabled")}});AT(document).on("click","#manage-page-dropdown .lnkExitWithoutSaving",function(){if(u){openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("do_you_want_to_exit_without_saving_page"),iconType:"warning",onClickYes:function(){location.reload(true)}})}else{location.reload(true)}})}function Q(){AT(document).on("focus click",".edit-mode .widget-content a, .edit-mode #channel-tabbar a, .edit-mode #btnSearch, .edit-mode #q",function(Aq){this.blur();return false});if(!AE){AX()}if(!x){o()}else{a.thumbnailRadioCheckbox("check",AT("#select-template .template-border.selected").next("input"),false);if(!s){AT("#select-template .template-item input[value={0}]".format(AT("#pagetemplateid-yes").val())).prev().trigger("click")}}if(AT.isEmptyObject(AM)){l()}Ai();AT("#config_pagetemplateid").val("");p=undefined;if(s){AT("#save-page-form #pagetitle").val("");AT("#save-page-form #pageurl").val("");AT("#save-page-form #pagetemplateid").val("0");AT("#save-page-form #pageid").val("0")}AT("#edit-page-dropdown .lnkDeletePage").on("click",function(){openConfirmDialog({title:vBulletin.phrase.get("confirm_deletion_gcpglobal"),message:vBulletin.phrase.get("confirm_remove_page_desc"),buttonLabel:{yesLabel:vBulletin.phrase.get("delete_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){vBulletin.AJAX({call:"/ajax/api/page/delete",data:{pageid:pageData.pageid},dataType:"json",complete:function(){AT("body").css("cursor","auto")},success:function(Aq){console.log("deleted page "+pageData.pageid);window.location.href=pageData.baseurl},error:function(As,Ar,Aq){console.log("page delete  failed! result:"+Aq);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_deleting_page",As.status),iconType:"error"})}})}})});AT("#edit-page-dropdown .lnkSaveChanges").on("click",function(){AT("#edit-page-dropdown .tabs li").removeClass("ui-tabs-active ui-state-active");AT("#edit-page-dropdown .tabs .tab").addClass("ui-tabs-hide");AT("#save-content").show();AT("#save-page-form .edit-page-template").css("display","");AT("#save-page-form .edit-page-template").prev("label").css("display","");if(AT("body").hasClass("lnkNewPage")){AT("#save-page-form .new-page-template input").prop("disabled",false);AT("#save-page-form .edit-page-template input").prop("disabled",true)}else{if(!AT("#pagetemplateid-yes").prop("checked")&&!AT("#pagetemplateid-no").prop("checked")){AT("#pagetemplateid-yes").prop("checked",true)}AT("#save-page-form .edit-page-template input").prop("disabled",false);AT("#save-page-form .new-page-template input").prop("disabled",true);if(s&&(!r&&!u)){AT("#save-page-form .edit-page-template").css("display","none");AT("#save-page-form .edit-page-template").prev("label").css("display","none")}if(AT("#pagetemplateid-yes").prop("checked")){AT("#save-page-form #templatetitle").prop("disabled",false);AT("#save-page-form #templatetitle-edit").prop("disabled",true);AT("#save-page-form .page-template-name").removeClass("h-hide")}else{AT("#save-page-form #templatetitle").prop("disabled",true);AT("#save-page-form #templatetitle-edit").prop("disabled",false);AT("#save-page-form .page-template-name").addClass("h-hide")}}});AT(document).on("click","#edit-page-dropdown .lnkExitWithoutSaving",function(){if(r||u||k||(!s&&(AT("#pagetitle").val()!=AT("#pagetitle").prop("defaultValue")||AT("#pageurl").val()!=AT("#pageurl").prop("defaultValue")))||(s&&(AT("#pagetitle").val()!=""||AT("#pageurl").val()!=""))){openConfirmDialog({title:vBulletin.phrase.get("exit_without_saving_page"),message:vBulletin.phrase.get("do_you_want_to_exit_without_saving_page"),iconType:"warning",onClickYes:function(){var Aq=parseInt(AT("input#pagetemplateid-new").val(),10);if(!isNaN(Aq)&&Aq>0){vBulletin.AJAX({call:"/ajax/api/page/deleteOrphanedPagetemplates",data:{pagetemplateids:[Aq]},success:function(Ar){console.log({msg:"/ajax/api/widget/deleteOrphanedPagetemplates success!",result:Ar,})},complete:function(){location.reload(true)},})}else{location.reload(true)}}})}else{location.reload(true)}});var Aj=0;AT(window).on("resize.canvas",function(){clearTimeout(Aj);Aj=setTimeout(O,200)});var Am=function(Aq){return'<label class="hide-icon module-button-item"><input type="checkbox" title="{0}" data-toggle-title="{1}"{2} /></label>'.format(vBulletin.phrase.get("check_to_hide_module"),vBulletin.phrase.get("uncheck_to_unhide_module"),Aq?' checked="checked"':"")};AT(".canvas-widget.container-widget .canvas-widget:not(.dummy-widget)").each(function(){var Aq=AT(this).hasClass("hidden-widget");AT(".module-buttons .admin-only",this).prepend(Am(Aq));if(Aq){AT(".module-buttons .admin-only .hide-icon input",this).trigger("click").prop("checked",true)}});var Ap=function(As,At,Av){var Au=At.item,Av=At.item.hasClass("module-item");var Aq=AT("> .canvas-widget.container-widget {0}".format(Av?".module-item":".canvas-widget.container-widget"),this);if(Aq.length>0){var Ar=Aq.closest(".canvas-widget.container-widget");if(Ar.attr("data-widget-id")==Aq.attr("data-widget-id")){if(Av){Aq.remove()}else{if(At.sender){At.sender.sortable("cancel")}else{AT(this).sortable("cancel")}}An=true;openAlertDialog({title:vBulletin.phrase.get("move_not_allowed"),message:vBulletin.phrase.get("dropping_container_module_into_container_module_not_allowed"),iconType:"warning"});return true}return false}return false};var Al=function(Aq){if(Aq.parents(".canvas-widget.container-widget").length>0){if(AT(".module-buttons .admin-only .hide-icon",Aq).length==0){AT(".module-buttons .admin-only",Aq).prepend(Am())}}else{Aq.removeClass("hidden-widget").find("> .widget-header .module-buttons .admin-only .hide-icon").remove()}};var An=false;AL=AT(".edit-mode .canvas-layout .canvas-widget-list:not(.js-draggable-module-target)");AL.sortable({revert:true,tolerance:"pointer",connectWith:".edit-mode .canvas-layout:visible .canvas-widget-list",placeholder:"canvas-widget canvas-widget-highlight drag-highlight",create:function(){O();y()},update:function(Ar,As){var Av=this;if(AY){if(!An){Ag(As.item,function(Az){As.item.replaceWith(Az);Az.filter(":not(.container-widget)").find(".toggle-button").trigger("click",[true]);if(!Ap.apply(Av,[Ar,As])){Al(Az);Az.addClass("shadow").find(".widget-tabs").andSelf().filter(".widget-tabs").tabs();M();Az.parents(".canvas-widget.container-widget").find(".canvas-widget.dummy-widget").remove();var A0=Az.parents(".canvas-widget.container-widget");if(A0.length==1){A0.find(".canvas-widget-highlight").remove();A0.find(".module-item").remove()}}var Ax=Az.data("widget-id"),Aw=q(Az),Ay=function(A1){Az.attr("data-widget-instance-id",A1);if(Aw){R(Az)}h(Az)};if(Ax){i(Aw,Ax,{},Ay)}})}}else{if(!Ap.apply(Av,[Ar,As])){Al(As.item);M()}if(AT.contains(this,As.item[0])){var Au=As.item.closest(".canvas-widget"),Aq=q(Au),At=Au.data("widget-instance-id")||0;R(Au);if(At){vBulletin.AJAX({call:"/ajax/api/widget/saveWidgetinstanceContainerinstanceid",data:{widgetinstanceid:At,containerinstanceid:Aq},success:function(Aw){console.log("saveWidgetinstanceContainerinstanceid success: "+JSON.stringify(Aw))}})}}}if(As.sender){var Au=As.sender.closest(".canvas-widget");if(Au.length){R(Au)}}r=true},out:function(Aq,Ar){AT(this).css("overflow","")},sort:function(Aq,Ar){if(t){AY=true}var As=Ar.placeholder.closest(".canvas-widget.container-widget");if(As.length==1&&As.find(".canvas-widget:last-child").hasClass("canvas-widget-highlight")){Ar.placeholder.css({"margin-bottom":0,"margin-top":-3})}else{Ar.placeholder.css({"margin-bottom":"","margin-top":""})}},start:function(Aq,Ar){E("hidden",Ar.item)},over:function(Aq,Ar){},stop:function(Ar,As){AT(this).css("overflow","");An=false;y();AY=false;As.item.height("auto");E("visible");AT(".canvas-layout .canvas-widget-list .canvas-widget-highlight").remove();var Aq=AT(".canvas-layout > .canvas-layout-row .canvas-widget-list > .canvas-widget.container-widget");AT(".canvas-layout > .canvas-layout-row .canvas-widget-list > .canvas-widget.container-widget").each(function(){var At=AT(".canvas-widget-list",this);if(At.children().length==0){At.append('<div class="canvas-widget dummy-widget"><span>{0}</span></div>'.format(vBulletin.phrase.get("you_can_also_drag_and_drop_modules_here")))}else{if(At.find(".canvas-widget.dummy-widget").length>0&&At.find(".canvas-widget:not(.dummy-widget,.canvas-widget-highlight)").length>0){At.find(".canvas-widget.dummy-widget").remove()}}})},receive:function(Aq,Ar){if(Ar.item.hasClass("module-item")){Ap.apply(this,[Aq,Ar,true])}},handle:".move-icon",items:".canvas-widget:not(.js-widget-non-sortable,.js-widget-pinned-sortable)",}).find(".canvas-widget .widget-header").disableSelection();AT(document).on("click",".edit-mode .canvas-widget .js-pin-module-button",function(){var Av=AT(this),Au=Av.closest(".canvas-widget"),Aq=Au.find("js-move-button"),At="js-widget-pinned-sortable",As="pin-icon--pinned",Ar=Au.hasClass(At);Au.toggleClass(At,!Ar);Av.toggleClass(As,!Ar)});AT(document).on("click",".edit-mode .canvas-widget .close-button",function(){var Aq=AT(this);openConfirmDialog({title:vBulletin.phrase.get("remove_module_q"),message:vBulletin.phrase.get("do_you_want_to_remove_module",Aq.closest(".widget-header").find(".module-title").text()),iconType:"warning",onClickYes:function(){var Au=Aq.closest(".canvas-widget"),At=Au.data("widget-instance-id"),As=Au.parent(),Ar=Au.parents(".canvas-widget.container-widget");Au.remove();y();M();r=true;AO([At]);R(As);if(Ar.find(".canvas-widget").length==0){Ar.find(".canvas-widget-list").append('<div class="canvas-widget dummy-widget"><span>{0}</span></div>'.format(vBulletin.phrase.get("you_can_also_drag_and_drop_modules_here")))}}})});AT(document).on("click",".edit-mode .js-search-widget .edit-button",function(){E("hidden");Ak(AT(this).closest(".js-search-widget"));AT("#search-config-dialog").dialog("open");return false});function Ao(A0,Az){var Aq=AT("#edit-page-dropdown .lnkSaveChanges .label").text();if(!Az){if(!AT.trim(AT("#save-page-form #pagetitle").val())){openAlertDialog({title:Aq,message:vBulletin.phrase.get("please_enter_page_name"),iconType:"warning",onAfterClose:function(){AT("#save-page-form #pagetitle").focus()}});return false}if(AT("body").hasClass("lnkEditPage")){var Ay=AT("#save-page-form #pagetemplateid-yes");var Ar=AT("#save-page-form #pagetemplateid-no");if(!Ay.prop("checked")&&!Ar.prop("checked")){openAlertDialog({title:Aq,message:vBulletin.phrase.get("please_choose_overwrite_template_options"),iconType:"warning",onAfterClose:function(){AT("#save-page-form #pagetemplateid-yes").focus()}});return false}else{if(Ar.prop("checked")){var As=AT("#save-page-form #templatetitle-edit");var A4=AT.trim(As.val());if(!A4||A4==As.prop("defaultValue")){openAlertDialog({title:Aq,message:vBulletin.phrase.get("please_enter_new_template_name"),iconType:"warning",onAfterClose:function(){AT("#save-page-form #templatetitle-edit").focus()}});return false}openConfirmDialog({title:Aq,message:vBulletin.phrase.get("applying_new_template",AT("#save-page-form #templatetitle-edit").val()),buttonLabel:{yesLabel:vBulletin.phrase.get("save_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){},onAfterClose:function(){if(AT(this).attr("id")=="btnConfirmDialogYes"){AT("#save-page-form #btnOK").trigger("click",true)}}});return false}else{if(Ay.prop("checked")){if(s&&(!r&&!u)){AT("#save-page-form #btnOK").trigger("click",true)}else{openConfirmDialog({title:Aq,message:vBulletin.phrase.get("overwrite_template_continue"),buttonLabel:{yesLabel:vBulletin.phrase.get("save_page"),noLabel:vBulletin.phrase.get("cancel")},iconType:"warning",onClickYes:function(){},onAfterClose:function(){if(AT(this).attr("id")=="btnConfirmDialogYes"){AT("#save-page-form #btnOK").trigger("click",true)}}})}return false}}}}else{var As=AT("#save-page-form #templatetitle-new");var A4=AT.trim(As.val());if(!A4||A4==As.prop("defaultValue")){openAlertDialog({title:Aq,message:vBulletin.phrase.get("please_enter_new_template_name"),iconType:"warning",onAfterClose:function(){AT("#save-page-form #templatetitle-new").focus()}});return false}}}var A3=AT(".canvas-layout:visible");Ab=A3.attr("id");var Ax=parseInt(A3.attr("data-layout-id"),10);AT("#save-page-form #screenlayoutid").val(Ax);function At(A8){var A9={widgetId:A8.attr("data-widget-id"),widgetInstanceId:(A8.attr("data-widget-instance-id")||"0")};if(A8.hasClass("container-widget")){var A5=[];var A7=[];AT("div.canvas-widget-list > div.canvas-widget",A8).each(function(BA){if(!AT(this).hasClass("hidden-widget")){A7.push(AT(this).attr("data-widget-instance-id"))}A5.push(At(AT(this)))});A9.subModules=A5;A9.displaySubModules=A7}if(A8.data("is-tabbed-container")){var A6=[];A8.find("> .js-admin-widget-content > .js-admin-widget-tab").each(function(){var BA=AT(this);BA.find("> .widget-content > .canvas-layout-row > .canvas-widget-list > .canvas-widget:not(.dummy-widget)").each(function(){var BB=AT(this);A6.push(At(BB))})});A9.tabbedContainerSubModules=A6}return A9}AT('input[type=hidden][name*="displaysections"]',A3).clone().appendTo(AT("#moduleData").empty());AT("#"+Ab+" > .canvas-layout-row > div.canvas-widget-list").each(function(){var A5=[];var A6=J(this);AT(this).children("div.canvas-widget").each(function(){A5.push(At(AT(this)))});AT('#save-page-form input[name="displaysections['+A6+']"]').val(JSON.stringify(A5))});var A1={};var Aw=AT("#save-page-form").serializeArray();AT.each(Aw,function(A5,A6){A1[A6.name]=A6.value});function A2(A5){vBulletin.AJAX({call:"/admin/savepage",data:{input:A5,url:window.location.href},complete:function(){AT("body").css("cursor","auto")},success:function(A6){if(A6.url!=null){window.location.href=pageData.baseurl+A6.url}},error_phrase:"error_saving_page",})}var Au=AT("input[name='screenlayoutid'][value='"+Ax+"']");if(Au.length>0&&Au.attr("data-guid")=="vbulletin-screenlayout-bare-full-57433eecd10803.93763070"){var Av={title:vBulletin.phrase.get("warning"),message:vBulletin.phrase.get("you_cannot_revert_this_layout_confirm"),onClickYes:function(){A2(A1)}};openConfirmDialog(Av)}else{A2(A1)}}AT(document).on("click","#save-page-form #btnOK",Ao);AT("#config-dialog").dialog({title:vBulletin.phrase.get("module_configuration"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,height:500,width:800,dialogClass:"dialog-container config-dialog-container input-dialog",open:function(){AT("#config-dialog .loader").show();AT("body").css("cursor","wait")},create:function(){AT(document).on("submit",".sitebuilder-widget-form",function(){function Ar(At){AT("body").css("cursor","wait");AT("#config-dialog .js-button").prop("disabled",true);var Au=AT("#config-dialog").data("selected-module");var As=At.action;vBulletin.AJAX({url:As,type:At.method,data:(AT(At).serializeArray()),success:function(Aw){AT("body").css("cursor","auto");if(Aw.data){var Av=Aw.data.title||Aw.data.searchResultTitle||Aw.data.searchTitle;if(Av){Au.find(".module-title .admin-only").text(vBulletin.phrase.get("x_module",Av))}switch(Aw.data.widget_type){case"custom-html-widget":Au.find(".widget-content").html(Aw.data.html);j(Au,true);break;case"video-widget":var Ax=Aw.data.embed_data;if(Ax){var A0=Au.find(".widget-content .videocontainer");if(A0.length==0){A0=AT("<div />").addClass("videocontainer").appendTo(Au.find(".widget-content"))}var Az={code:Ax.code,provider:Ax.provider,width:"100%",height:260};AT.post(vBulletin.getAjaxBaseurl()+"/ajax/render/bbcode_video",Az,function(A1){if(A1){A0.empty().append(A1);j(Au,true)}},"json");Au.find(".widget-content").find(".note").addClass("h-hide")}break}var Ay=AT('select[name="data[default_tab]"]',AT(At));if(Ay.length>0){Au.attr("data-widget-default-tab",Ay.val())}u=true}AT("#config-dialog").dialog("close")},after_error:function(){AT("#config-dialog .loader").hide();AT("#config-dialog .js-button").prop("disabled",false)},error_phrase:["error_saving_configuration_module",AT("#config-dialog .widget-name h1").text()],})}var Aq=this;Ar(Aq);return false});AT("#btnCloseConfig").on("click",function(){AT(".channel-config-dialog .channel-list").empty();AT("#config-dialog").dialog("close")})},close:function(){E("visible");AT("#config-dialog .dialog-content .channel-config-dialog").css("display","none");AT("#config-dialog .js-button").prop("disabled",false)}});AT("#pagetitle").on("keyup blur",function(Aq){if(s){AT("#pageurl").val(this.value.replace(/[^\w-]+/g,""))}return true});AT("#save-page-form #pagetemplateid-yes").on("click",function(){AT("#save-page-form .template-name").addClass("h-hide");AT("#save-page-form #templatetitle").prop("disabled",false);AT("#save-page-form #templatetitle-edit").prop("disabled",true);AT("#save-page-form .page-template-name").removeClass("h-hide")});AT("#save-page-form #pagetemplateid-no").on("click",function(){AT("#save-page-form .template-name").removeClass("h-hide");AT("#save-page-form #templatetitle").prop("disabled",true);AT("#save-page-form #templatetitle-edit").prop("disabled",false);AT("#save-page-form .page-template-name").addClass("h-hide")});function Ak(Aq){if(typeof g.search_config_dialog=="undefined"){vBulletin.AJAX({call:"/ajax/render/dialog_search_config",success:function(Ar){g.search_config_dialog=Ar;AT("body").append(Ar);Ak(Aq)},error_phrase:"error_fetching_dialog"});return }if(Aq){AT("#search-config-dialog").data("search-widget",Aq)}AT("#search-config-dialog").dialog({title:vBulletin.phrase.get("edit_search_module"),autoOpen:true,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:800,dialogClass:"dialog-container search-config-dialog-container input-dialog",close:function(){E("visible")},open:function(){var Ar=this;AT("#customSearchDialog",Ar).addClass("h-invisible");AT("body").css("cursor","wait");setTimeout(function(){vBulletin.search=vBulletin.search||{};var Au=function(){S=new vBulletin.search.SearchControl("#customSearchDialog");T(S)};var At=AT("#search-config-dialog").data("search-widget");var Aw={id:At.attr("data-widget-id"),instanceid:At.attr("data-widget-instance-id")};if(typeof vBulletin.search.SearchControl=="undefined"){var Av=["/js/jquery/jquery.qtip.min.js","/js/tag-editor.js","/js/sb_search.js"];var As=function(){if(Av.length==0){AT("body").css("cursor","auto");AT("#customSearchDialog",Ar).removeClass("h-invisible");Au();return }var Ax=Av.shift();AT.getScript(vBulletin.getAjaxBaseurl()+Ax+"?"+pageData.simpleversion,As).error(function(A1,A0,Ay){var Az=(Ay&&Ay.message)?"{0}: {1}".format(vBulletin.phrase.get("error"),Ay.message):"HTTP {0}: {1}".format(A1.status,A1.statusText);AT("#search-config-dialog").dialog("close");openAlertDialog({title:vBulletin.phrase.get("error"),message:"{0}<br /><br />({1})".format(vBulletin.phrase.get("error_loading_search_config_script"),Az),iconType:"error"})}).complete(function(){})};As()}else{AT("#customSearchDialog",Ar).removeClass("h-invisible");Au()}},1);u=false},create:function(){AT("#btnSaveSearchConfig").on("click",function(){AT("body").css("cursor","wait");var At=AT("#search-config-dialog").data("search-widget");var A1={id:At.attr("data-widget-id"),instanceid:At.attr("data-widget-instance-id")};var Aw={pageid:pageData.pageid,widgetid:A1.id,widgetinstanceid:A1.instanceid,pagetemplateid:AT("#select-template input[type=radio]:checked").val(),searchJSON:{}};var A5=AT("#searchTitle");if(A5.length>0&&AT.trim(A5.val()).length>0){Aw.searchTitle=AT.trim(A5.val());A5.data("defaultValue",Aw.searchTitle)}var Ay=AT("#resultsPerPage");if(Ay.length>0&&AT.trim(Ay.val()).length>0){Aw.resultsPerPage=AT.trim(Ay.val());Ay.data("defaultValue",Aw.resultsPerPage)}var Au=["hide_avatars","hide_module_when_empty","displayFooter"];for(var Ax=0;Ax<Au.length;Ax++){var Ar=Au[Ax],Av=AT("input[name='"+Ar+"'][value='1']");if(Av.length>0&&Av.prop("checked")){Aw[Ar]="1";Av.data("defaultValue","1")}else{Aw[Ar]="0";Av.data("defaultValue","0")}}var A0=AT(".js-searchmodule-show-at-breakpoints");if(A0.length>0){Aw.show_at_breakpoints={desktop:1,small:1,xsmall:1};A0.find("input").each(function(){var A6=AT(this);switch(A6.prop("name")){case"show_at_breakpoints[desktop]":Aw.show_at_breakpoints.desktop=A6.prop("checked")?1:0;break;case"show_at_breakpoints[small]":Aw.show_at_breakpoints.small=A6.prop("checked")?1:0;break;case"show_at_breakpoints[xsmall]":Aw.show_at_breakpoints.xsmall=A6.prop("checked")?1:0;break}});A0.data("defaultValue",Aw.show_at_breakpoints)}var A4=AT("#search-config-dialog .js-sb-module-config--viewpermissions");if(A4.length>0){Aw.module_viewpermissions={};var Az=A4.find("input.js-module_viewpermissions__key:checked"),A3="show_all",As=A4.find("input.js-module_viewpermissions__value:checked"),A2="all";if(Az.length){A3=Az.prop("value")}if(As.length){A2=[];AT.each(As,function(A6,A7){A2.push(AT(A7).prop("value"))})}Aw.module_viewpermissions={key:A3,value:A2,}}Aw.searchJSON=S.load();vBulletin.AJAX({call:"/ajax/api/widget/saveSearchWidgetConfig",data:{data:JSON.stringify(Aw)},complete:function(){AT("body").css("cursor","auto")},success:function(A6){if(A6.widgetinstanceid>0&&A6.searchJSON){At.attr("data-widget-instance-id",A6.widgetinstanceid);At.find(".main-title").text(Aw.searchTitle);AT("#config_widgetinstanceid").val(A6.widgetinstanceid);AT("#config_pagetemplateid").val(A6.pagetemplateid);AT("#pagetemplateid-new").val(A6.pagetemplateid);AT("#search-config-dialog").dialog("close");j(At,true);u=true}},error_phrase:"error_saving_search_config",})});AT("#btnCancelSearchConfig").on("click",function(){function Ar(){AT("#search-config-dialog").dialog("close");S.set("{}");var A1=AT("#search-config-dialog #searchTitle");A1.val(A1.data("defaultValue"));var Ax=AT("#search-config-dialog #resultsPerPage");Ax.val(Ax.data("defaultValue"));var Au=["hide_avatars","hide_module_when_empty","displayFooter"];for(var Aw=0;Aw<Au.length;Aw++){var At=Au[Aw],Av=AT("#search-config-dialog input[name='"+At+"'][value='1']"),Ay=AT("#search-config-dialog input[name='"+At+"'][value='0']");if(Av.data("defaultValue")=="1"){Av.prop("checked",true)}else{Ay.prop("checked",true)}}var Az=AT("#search-config-dialog .js-searchmodule-show-at-breakpoints");if(Az.length>0){var A0=Az.data("defaultValue");if(typeof (A0)!="undefined"){Az.find("input").each(function(){var A2=AT(this);switch(A2.prop("name")){case"show_at_breakpoints[desktop]":A2.prop("checked",A0.desktop?"checked":"");break;case"show_at_breakpoints[small]":A2.prop("checked",A0.small?"checked":"");break;case"show_at_breakpoints[xsmall]":A2.prop("checked",A0.xsmall?"checked":"");break}})}}}if(u){var As=AT(this);openConfirmDialog({title:vBulletin.phrase.get("cancel_edit"),message:vBulletin.phrase.get("do_you_want_to_cancel_editing_search_module"),iconType:"warning",onClickYes:Ar})}else{Ar()}})}})}AT("#blog-category-dialog").dialog({title:vBulletin.phrase.get("edit_blog_categories"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:800,dialogClass:"dialog-container blog-category-dialog-container input-dialog",close:function(){E("visible")},open:function(){var Aq=this;u=false},create:function(){AT("#blog-category-dialog #btnSaveCategories").on("click",function(){AT("body").css("cursor","wait");AT("#blog-category-dialog dialog-content loader").show();var Aq=AT("#search-config-dialog").data("blog-category-widget");var Ar={id:Aq.attr("data-widget-id"),instanceid:Aq.attr("data-widget-instance-id")};vBulletin.AJAX({call:"/ajax/api/widget/saveBlogCategories",data:{},complete:function(){AT("body").css("cursor","auto");AT("#blog-category-dialog dialog-content loader").hide()},success:function(As){AT("#blog-category-dialog dialog-content widget-config-container").html(As)},error_phrase:"error_saving_blog_categories"})});AT("#blog-category-dialog #btnNewCategory").on("click",function(){});AT("#blog-category-dialog #btnCloseCategories").on("click",function(){if(u){var Aq=AT(this);openConfirmDialog({title:vBulletin.phrase.get("cancel_edit"),message:vBulletin.phrase.get("do_you_want_to_cancel_editing_blog_categories_module"),iconType:"warning",onClickYes:AT("#blog-category-dialog").dialog("close")})}else{AT("#blog-category-dialog").dialog("close")}})}})}function T(Aj){var Al=AT(this).closest(".canvas-widget"),Ak=AT("#search-config-dialog").data("search-widget"),Am={id:Ak.attr("data-widget-id"),instanceid:Ak.attr("data-widget-instance-id")};vBulletin.AJAX({call:"/ajax/api/widget/fetchSearchConfig",data:({widgetid:Am.id,widgetinstanceid:Am.instanceid||"",pagetemplateid:W(),configtype:"admin"}),complete:function(){AT("body").css("cursor","auto")},success:function(An){if(An.searchTitle){AT("#searchTitle").val(An.searchTitle)}if(An.resultsPerPage){AT("#resultsPerPage").val(An.resultsPerPage)}var As=["hide_avatars","hide_module_when_empty","displayFooter"];for(var Ar=0;Ar<As.length;Ar++){var Ap=As[Ar];value=((An[Ap]&&parseInt(An[Ap],10)==1)?1:0);AT("input[name='"+Ap+"'][value='"+value+"']").prop("checked",true)}if(An.show_at_breakpoints){var At=AT("#search-config-dialog .js-searchmodule-show-at-breakpoints");if(At.length>0){At.find("input").each(function(){var Au=AT(this);switch(Au.prop("name")){case"show_at_breakpoints[desktop]":Au.prop("checked",An.show_at_breakpoints.desktop?"checked":"");break;case"show_at_breakpoints[small]":Au.prop("checked",An.show_at_breakpoints.small?"checked":"");break;case"show_at_breakpoints[xsmall]":Au.prop("checked",An.show_at_breakpoints.xsmall?"checked":"");break}})}if(An.module_viewpermissions){var Ao=AT("#search-config-dialog .js-searchmodule-module_viewpermissions--replaceme"),Aq=C({defaultvalue:An.module_viewpermissions});Ao.replaceWith(Aq)}}Aj.set(An.searchJSON||{},An.contentTypes||{},An.channels||{});AT("#config-dialog .dialog-content .widget-config-container").show();AT("#search-config-dialog .form_layout .form_row .field_column select").selectBox();AT("#config-dialog .loader").hide()},after_error:function(){AT("#config-dialog .loader").hide();AT("#config-dialog").dialog("close")}})}AT(document).ready(function(){AJ()})})(jQuery);