/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.1
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2018 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["error_x","error_saving_customizations","profile_style_customizations","saving","style_applied_as_site_default","kilobytes","set_to_default","profile_theme_reset_confirmation","reverting"]);var cssMappings={profcustom_navbar_background_active:[".profileTabs .widget-tabs-nav li.ui-tabs-active a"],profcustom_navbar_border_active:[".profileTabs .widget-tabs-nav li.ui-tabs-active a"],profcustom_navbar_text_color_active:[".profileTabs .widget-tabs-nav li.ui-tabs-active a"],profcustom_navbar_background:[".profileTabs .widget-tabs-nav li.ui-state-default:not(.ui-state-active) a"],profcustom_navbar_border:[".profileTabs .widget-tabs-nav li.ui-state-default:not(.ui-state-active) a"],profcustom_navbar_text_color:[".profileTabs .widget-tabs-nav li.ui-state-default:not(.ui-state-active) a"],toolbar_background:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar",".forum-list-container .forum-list-header"],side_nav_divider_border:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar",".forum-list-container .forum-list-header"],profcustom_navbar_toolbar_text_color:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar",".forum-list-container .forum-list-header"],profcustom_navbarbutton_background:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.primary"],profcustom_navbarbutton_border:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.primary"],profcustom_navbarbutton_color:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.primary"],profile_button_secondary_background:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.secondary"],profcustom_navbarbuttonsecondary_border:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.secondary"],profcustom_navbarbuttonsecondary_color:[".profileTabs .conversation-toolbar-wrapper .conversation-toolbar .button.secondary"],profile_content_background:["#profileTabs","#profileTabs .conversation-list.stream-view .list-item"],profile_content_border:[".profileTabs .tab .list-container","#profileTabs .conversation-list.stream-view"],profile_content_divider_border:[".profileTabs .post-footer-wrapper .post-footer .divider"],profile_section_background:[".profileTabs .section .section-header"],profile_section_border:[".profileTabs .section .section-header"],profile_section_text_color:[".profileTabs .section .section-header"],profile_section_font:[".profileTabs .section .section-header"],profile_content_primarytext:["#profileTabs.profileTabs","#profileTabs.profileTabs .conversation-list.stream-view .list-item","#profileTabs.profileTabs .widget-content","#profileTabs.profileTabs .post-content"],profile_content_secondarytext:[".profile-widget .post-footer-wrapper .post-footer ul li",".profile-widget .conversation-list.stream-view .list-item-header .info .subscribed",".canvas-layout-container .canvas-widget .widget-content .profileTabs .post-date"],profile_content_linktext:[".profile-widget .widget-tabs.ui-tabs .ui-widget-content a",".profile-widget .widget-tabs.ui-tabs .ui-widget-content a:active",".profile-widget  .widget-tabs.ui-tabs .ui-widget-content a:visited"],profile_content_font:["#profileTabs"],side_nav_background:[".profile_sidebar_content"],form_dropdown_border:[".profile_sidebar_content"],side_nav_avatar_border:[".profile-sidebar-widget .profileContainer .profile-photo-wrapper .profile-photo"],side_nav_divider_border:[".profile-sidebar-widget .profile-menulist .profile-menulist-item"],profile_userpanel_textcolor:[".profile_sidebar_content",".profile_sidebar_content .profile-menulist-item a label"],profile_userpanel_linkcolor:[".profile_sidebar_content .profile-menulist-item a .subscriptions-count, .profile_sidebar_content .profile-menulist-item a .subscriptions-count:hover, .profile_sidebar_content .profile-menulist-item a .subscriptions-count:visited"],profile_userpanel_font:[".profile_sidebar_content"],profilesidebar_button_background:[".profile_sidebar_content .button.primary"],profilesidebar_button_border:[".profile_sidebar_content .button.primary"],profilesidebar_button_text_color:[".profile_sidebar_content .button.primary"],button_primary_text_color:[".profileTabs .button.primary",".profileTabs .button.primary:hover"],button_primary_border:[".profileTabs .button.primary",".profileTabs .button.primary:hover"],profile_button_primary_background:[".profileTabs .button.primary",".profileTabs .button.primary:hover"]};var colorTypes={profcustom_navbar_background_active:3,profcustom_navbar_background:3,profile_button_primary_background:3,profile_button_secondary_background:3,toolbar_background:3,profile_content_background:3,profile_section_background:3,side_nav_background:3,profilesidebar_button_background:3,module_tab_border_active:2,module_tab_border:2,button_primary_border:2,button_secondary_border:2,side_nav_divider_border:2,profile_content_border:2,profile_section_border:2,profile_content_divider_border:2,profile_section_border:2,form_dropdown_border:2,side_nav_avatar_border:2,side_nav_divider_border:2,profilesidebar_button_border:2,profcustom_navbar_text_color_active:1,profcustom_navbar_text_color:1,button_secondary_text_color:1,profcustom_navbar_toolbar_text_color:1,profile_section_color:1,profile_section_text_color:1,profile_content_primarytext:1,profile_content_secondarytext:1,profile_content_linktext:1,profile_userpanel_textcolor:1,profile_userpanel_linkcolor:1,profilesidebar_button_text_color:1,button_primary_text_color:1,button_primary_border:2,profile_button_primary_background:3,profcustom_navbarbutton_color:1,profcustom_navbarbutton_border:2,profcustom_navbarbutton_background:3,profcustom_navbarbuttonsecondary_color:1,profcustom_navbarbuttonsecondary_border:2,profile_button_secondary_background:3};var newSettings={};var revertChanges=function(A){$.each(A,function(C,B){targetEl=$("[name="+C+"]");$.each(B,function(D,E){if(E&&E!=""){switch(D){case"color":targetEl.val(E);targetEl.trigger("keyup");break;case"image":setBackgroundImage("",E,C);break;case"family":if(targetEl.length>1){$.each(targetEl,function(G,F){if($(F).attr("data-type")=="family"){$(F).val(E);$(F).trigger("change")}})}else{targetEl.val(E);targetEl.trigger("change")}break;case"size":if(targetEl.length>1){$.each(targetEl,function(G,F){if($(F).attr("data-type")=="size"){$(F).val(E);$(F).trigger("change")}})}else{targetEl.val(E);targetEl.trigger("change")}break;case"repeat":targetEl=$("[name=repeat_type]");if(targetEl.length>1){$.each(targetEl,function(G,F){if($(F).attr("data")==C){$(F).val(E);$(F).trigger("change")}})}else{targetEl.val(E);targetEl.trigger("change")}break;default:break}}})})};var uploadFromUrl=function(A){form=$(A.target).closest(".frmBgImageUrl");form.find(".js-upload-progress").removeClass("h-hide");if(form.length){remoteUrl=$(form).find(".profCustomBgImageUrl");if(remoteUrl&&$(remoteUrl).val()){$.ajax({url:vBulletin.getAjaxBaseurl()+"/uploader/url",data:{urlupload:remoteUrl.val()},type:"POST",dataType:"json",success:function(B){if(B){if(B.errors){if(typeof (B.errors[0])=="undefined"){vBulletin.error("profile_style_customizations",B.errors)}else{vBulletin.error("profile_style_customizations",B.errors[0][0])}}else{if(B.imageUrl){setBackgroundImage(A,B.imageUrl)}else{vBulletin.error("profile_style_customizations","unable_to_upload_file")}}}else{vBulletin.error("profile_style_customizations","invalid_server_response_please_try_again")}},fail:function(C){var D="error_uploading_image";var B="error";if(C&&C.files.length>0){switch(C.files[0].error){case"acceptFileTypes":D="invalid_image_allowed_filetypes_are";B="warning";break}}vBulletin.alert("upload",D,B,function(){$editProfilePhotoDlg.find(".fileText").val("");$editProfilePhotoDlg.find(".browse-option").focus()})},complete:function(){form.find(".js-upload-progress").addClass("h-hide")}})}}};var setBgRepeat=function(A){ident=$(A.target).attr("data");repeat=A.target.value;if(typeof (cssMappings[ident])!="undefined"){selectors=cssMappings[ident];addNewSetting(ident,"repeat",repeat);if(typeof newSettings[ident]["image"]=="undefined"){newSettings[ident]["image"]=$(selectors[0]).css("background-image")}for(i=0;i<selectors.length;i++){$(selectors[i]).css("background-repeat",repeat)}}};var clearBgImage=function(A){ident=$(A.target).attr("data");if(typeof (cssMappings[ident])!="undefined"){selectors=cssMappings[ident];addNewSetting(ident,"image","none");for(i=0;i<selectors.length;i++){$(selectors[i]).css("background-image","none")}}};var clearBgColor=function(B){$element=$(B.target);ident=$element.attr("data");checked=$element.is(":checked");if(typeof (cssMappings[ident])!="undefined"){selectors=cssMappings[ident];if(checked){addNewSetting(ident,"color","transparent");val="transparent"}else{val="none";var A=$('input.colorPicker[name="'+ident+'"]').val();if(typeof A=="string"&&A.indexOf("#")===0){val=A}addNewSetting(ident,"color",val)}for(i=0;i<selectors.length;i++){$(selectors[i]).css("background-color",val)}}};var setBackgroundImage=function(C,A,F){var E,B;if(typeof F!=="undefined"){E=F;B=A}else{E=$(C.target).attr("data");var D=A.indexOf("?")==-1?"?":"&";B='url("'+A+D+"random="+Math.random()+'")'}if(typeof (cssMappings[E])!="undefined"){selectors=cssMappings[E];addNewSetting(E,"image",B);for(i=0;i<selectors.length;i++){$(selectors[i]).css("background-image",B)}}};var makeServerRequest=function(C,B,A,E){window.vBulletin.loadingIndicator.show();var D=$.post(vBulletin.getAjaxBaseurl()+C,B,function(F){if(F&&F.error){if($.isArray(F.error)){$.each(F.error,function(H,I){F.error[H]=vBulletin.phrase.get(I)});var G=F.error.join("<br />")}else{var G=vBulletin.phrase.get(F.error)}openAlertDialog({title:vBulletin.phrase.get("profile_customization"),message:G,iconType:"error"});return }else{if(typeof E==="function"){E(F)}}},"json").error(function(){vBulletin.error("profile_style_customizations","error_saving_customizations")}).complete(function(){window.vBulletin.loadingIndicator.hide()})};function addNewSetting(C,A,B){if(newSettings[C]){newSettings[C][A]=B}else{newSettings[C]={};newSettings[C][A]=B}}function toggleBgType(A){imgRadio=$(A.target).closest(".profCustomBackgroundEdit").find(".profCustomBgTypeColor");if(A.target.value=="color"){$(A.target).closest(".profCustomBackgroundEdit").find(".profCustomBgImage").addClass("h-hide");$(A.target).closest(".profCustomBackgroundEdit").find(".profCustomBgColor").removeClass("h-hide")}else{$(A.target).closest(".profCustomBackgroundEdit").find(".profCustomBgColor").addClass("h-hide");$(A.target).closest(".profCustomBackgroundEdit").find(".profCustomBgImage").removeClass("h-hide")}}function toggleImgSource(A){if(A.target.value=="file"){$(A.target).closest(".profCustomBackgroundEdit").find(".frmBgImageUrl").addClass("h-hide");$(A.target).closest(".profCustomBackgroundEdit").find(".frmBgImageFile, .ProfCustomBgRepeat").removeClass("h-hide")}else{if(A.target.value=="url"){$(A.target).closest(".profCustomBackgroundEdit").find(".frmBgImageFile").addClass("h-hide");$(A.target).closest(".profCustomBackgroundEdit").find(".frmBgImageUrl, .ProfCustomBgRepeat").removeClass("h-hide")}else{$(A.target).closest(".profCustomBackgroundEdit").find(".frmBgImageFile, .frmBgImageUrl, .ProfCustomBgRepeat").addClass("h-hide")}}}function updateColorFromComponent(A){addNewSetting($(this).attr("data"),"color",A);$(this).parent().find(".rdProfCustomBgColorClear").prop("checked",false);if(typeof (cssMappings[$(this).attr("data")])!="undefined"){selectors=cssMappings[$(this).attr("data")];for(selector in selectors){switch(colorTypes[$(this).attr("data")]){case 1:$(selectors[selector]).css("color",A);break;case 2:$(selectors[selector]).css("border-color",A);break;case 3:$(selectors[selector]).css("background-color",A);$(selectors[selector]).css("background-image","none");break}}}}function setFontFamily(A){fontname=$(A.target).find(">option:selected").text();ident=$(A.target).attr("data");addNewSetting(ident,"family",fontname);displayname=A.target.options[A.target.selectedIndex].innerHTML;$(A.target).closest(".fontselectorWrapper").find(".fontDisplay").css("font-family",fontname).html(fontname);if(typeof (cssMappings[ident])!="undefined"){selectors=cssMappings[ident];for(selector in selectors){$(selectors[selector]).css("font-family",fontname)}}}function setFontSize(A){ident=$(A.target).attr("data");$(A.target).closest(".fontselectorWrapper").find(".fontDisplay").css("font-size",A.target.value);addNewSetting(ident,"size",A.target.value);if(typeof (cssMappings[ident])!="undefined"){selectors=cssMappings[ident];for(selector in selectors){$(selectors[selector]).css("font-size",A.target.value)}}}function rgb2hex(A){A=A.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return"#"+hex(A[1])+hex(A[2])+hex(A[3])}function rgba2hex(B){B=B.match(/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+)\)$/);var A={};if(B[4]==0){A.transparent=true}else{if(B[4]==1){A.transparent=false}else{return false}}A.hex="#"+hex(B[1])+hex(B[2])+hex(B[3]);return A}function hex(A){var B=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");return isNaN(A)?"00":B[(A-A%16)/16]+B[A%16]}function setCurrentBgValues(F){var G=F.attr("data");if(typeof cssMappings[G]!="undefined"){selector=cssMappings[G][0];var C=$(selector),A={},H="";A.color=C.css("background-color");A.image=C.css("background-image");A.repeat=C.css("background-repeat");if((typeof A.image!="undefined")&&(A.image!="none")){var B=A.image.lastIndexOf("/")+1,J=A.image.length,I=J-B-2;H=A.image.substr(B,I);F.find(".fileText").val(H);if(A.repeat!=""){F.find(".ProfCustomBgRepeatType").val(A.repeat)}}else{if(A.color=="transparent"){F.find(".rdProfCustomBgColorClear").prop("checked",true)}else{if(typeof A.color=="string"){var E=A.color;if(E.indexOf("rgba")===0){var D=rgba2hex(E);if(D){E=D.hex;F.find(".rdProfCustomBgColorClear").prop("checked",D.transparent)}}else{if(E.indexOf("rgb")===0){E=rgb2hex(E)}}F.find('input[name="'+G+'"].colorPicker').val(E)}}}if(H!=""){F.find(".rdProfCustomBgTypeImage").trigger("click")}else{F.find(".rdProfCustomBgTypeColor").trigger("click")}}}(function(A){var B=[".profileEditContent"];if(!vBulletin.pageHasSelectors(B)){return false}A(document).ready(function(){var C=0;A(".profile_custom_edit .profileTabs").tabs({activate:function(E,D){A().add(D.oldTab).add(D.newTab).find(".b-icon").toggleClass("b-icon--active")},});A(".profCustomBackgroundEdit").each(function(E){C++;content=A(".profCustomBgTemplate").clone();var D=A(this);A(content).removeClass("h-hide profCustomBgTemplate");A(content).css("display","block");D.append(content);D.find(".colorPicker").attr("data",D.attr("data"));D.find(".colorPicker").attr("name",D.attr("data"));D.find(".colorPicker").removeClass("template");D.find(".rdProfCustomBgTypeColor, .rdProfCustomBgTypeImage").off("click").on("click",toggleBgType);D.find(".rdProfCustomBgTypeColor, .rdProfCustomBgTypeImage").prop("name","profCustomBgType"+C);D.find(".rdProfCustomFile, .rdProfCustomUrl, .rdProfCustomBgImageNone").off("click").on("click",toggleImgSource);D.find(".rdProfCustomFile, .rdProfCustomUrl, .rdProfCustomBgImageNone").attr("name","profCustomBgSrc"+C);D.find(".profCustomBgImageFile, .profCustomBgImageUrl, .rdProfCustomBgColorClear, .rdProfCustomBgImageNone, .ProfCustomBgRepeatType, .profCustomUploadUrl").attr("data",A(this).attr("data"));setCurrentBgValues(D);A(this).find(".profCustomBgImageFile").fileupload({url:vBulletin.getAjaxBaseurl()+"/uploader/upload-file",type:"POST",dataType:"json",add:function(G,F){D.find(".js-upload-progress").removeClass("h-hide");F.submit()},done:function(G,F){if(F){if(F.result.errors){if(typeof (F.result.errors[0])=="undefined"){vBulletin.error("profile_style_customizations",F.result.errors)}else{vBulletin.error("profile_style_customizations",F.result.errors[0][0])}}else{if(F.result.imageUrl){D.find(".profile-img-option-container .profile-img-option-field input.fileText").val(F.result.filename);setBackgroundImage(G,F.result.imageUrl)}else{vBulletin.error("profile_style_customizations","unable_to_upload_file")}}}else{vBulletin.error("profile_style_customizations","invalid_server_response_please_try_again")}},fail:function(I,G){var H="error_uploading_image";var F="error";if(G&&G.files.length>0){switch(G.files[0].error){case"acceptFileTypes":H="invalid_image_allowed_filetypes_are";F="warning";break}}vBulletin.alert("upload",H,F,function(){$editProfilePhotoDlg.find(".fileText").val("");$editProfilePhotoDlg.find(".browse-option").focus()})},always:function(){D.find(".js-upload-progress").addClass("h-hide")}})});if(A("body").is(".view-mode")){vBulletin_ColorPicker(".colorPicker",{onChange:updateColorFromComponent});A(".selectCustomProfFontfamily").off("change").on("change",setFontFamily);A(".selectCustomProfFontsize").off("change").on("change",setFontSize);A(".rdProfCustomBgImageNone").off("click").on("click",clearBgImage);A(".rdProfCustomBgColorClear").off("click").on("click",clearBgColor);A(".ProfCustomBgRepeatType").off("change").on("change",setBgRepeat);A(".profCustomUploadUrl").off("click").on("click",uploadFromUrl)}A(".profCustomSave").off("click").on("click",function(){if(A.isEmptyObject(newSettings)){vBulletin.error("profile_customization","there_are_no_changes_to_save");return }var D=newSettings;newSettings={};makeServerRequest("/profile/save-stylevar",{stylevars:D,userid:pageData.userid},vBulletin.phrase.get("saving")+"...",function(E){vBulletin.alert("profile_customization","usercss_saved")})});A(".profCustomRevert").off("click").on("click",function(){var D=[],E=0;if(A.isEmptyObject(newSettings)){vBulletin.error("profile_customization","there_are_no_changes_to_revert");return }A.each(newSettings,function(F,G){D[E]=F;E++});makeServerRequest("/profile/revert-stylevars",{stylevars:D,userid:pageData.userid},"Reverting...",function(F){revertChanges(F)});newSettings={}});A(".profCustomDefault").off("click").on("click",function(){var D=[],E=0;if(!A.isEmptyObject(newSettings)){A.each(newSettings,function(F,G){D[E]=F;E++})}openConfirmDialog({title:vBulletin.phrase.get("set_to_default"),message:vBulletin.phrase.get("profile_theme_reset_confirmation"),iconType:"warning",onClickYes:function(){makeServerRequest("/profile/reset-default",{stylevars:D,userid:pageData.userid},vBulletin.phrase.get("reverting")+"...",function(F){window.location.reload()});newSettings={}}})});A(".profCustomApplyAll").off("click").on("click",function(){makeServerRequest("/profile/save-default",{stylevars:newSettings,userid:pageData.userid},"Saving...",function(D){vBulletin.alert("profile_customization","style_applied_as_site_default")})});A(".profCustomCancel").off("click").on("click",function(){A(".profile_custom_edit").addClass("h-hide")})})})(jQuery);