ZwiiCMS/core/module/config/view/index/index.js.php

12 lines
6.8 KiB
PHP

/**
* This file is part of Zwii.
*
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
function setCookie(name,value,days){var expires="";if(days){var date=new Date;date.setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/; samesite=lax"}function getCookie(name){for(var nameEQ=name+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){for(var c=ca[i];" "==c.charAt(0);)c=c.substring(1,c.length);if(0==c.indexOf(nameEQ))return c.substring(nameEQ.length,c.length)}return null}function capitalizeFirstLetter(string){return string.charAt(0).toUpperCase()+string.slice(1)}$(document).ready((function(){$("#configBackupDelButton").on("click",(function(){var _this=$(this),message_warning="<?php echo helper::translate('Supprimer toutes les sauvegardes automatiques ?'); ?>";return core.confirm(message_warning,(function(){$(location).attr("href",_this.attr("href"))}))})),$("input[name=smtpEnable]").is(":checked")?($("#smtpParam").addClass("disabled"),$("#smtpParam").slideDown()):($("#smtpParam").removeClass("disabled"),$("#smtpParam").slideUp()),1==$("select[name=smtpAuth]").val()?($("#smtpAuthParam").addClass("disabled"),$("#smtpAuthParam").slideDown()):($("#smtpAuthParam").removeClass("disabled"),$("#smtpAuthParam").slideUp()),$("input[name=connectCaptcha]").is(":checked")?($("#connectCaptchaStrongWrapper").addClass("disabled"),$("#connectCaptchaStrongWrapper").slideDown(),$("#connectCaptchaTypeWrapper").addClass("disabled"),$("#connectCaptchaTypeWrapper").slideDown()):($("#connectCaptchaStrongWrapper").removeClass("disabled"),$("#connectCaptchaStrongWrapper").slideUp(),$("#connectCaptchaTypeWrapper").removeClass("disabled"),$("#connectCaptchaTypeWrapper").slideUp(),$("#connectCaptchaStrong").prop("checked",!1));var configLayout=getCookie("configLayout");null==configLayout&&(configLayout="setup",setCookie("configLayout","setup")),$("#localeContainer").hide(),$("#socialContainer").hide(),$("#connectContainer").hide(),$("#networkContainer").hide(),$("#setupContainer").hide(),$("#"+configLayout+"Container").show(),$("#config"+capitalizeFirstLetter(configLayout)+"Button").addClass("activeButton"),$("input[name=smtpEnable]").on("change",(function(){$("input[name=smtpEnable]").is(":checked")?($("#smtpParam").addClass("disabled"),$("#smtpParam").slideDown()):($("#smtpParam").removeClass("disabled"),$("#smtpParam").slideUp())})),$("select[name=smtpAuth]").on("change",(function(){1==$("select[name=smtpAuth]").val()?($("#smtpAuthParam").addClass("disabled"),$("#smtpAuthParam").slideDown()):($("#smtpAuthParam").removeClass("disabled"),$("#smtpAuthParam").slideUp())})),$("select[name=connectAttempt]").on("change",(function(){"999"===$("select[name=connectAttempt]").val()?$("select[name=connectTimeout]").val(0):"0"===$("select[name=connectTimeout]").val()&&$("select[name=connectTimeout]").val(300)})),$("select[name=connectTimeout]").on("change",(function(){"0"===$("select[name=connectTimeout]").val()?$("select[name=connectAttempt]").val(999):"999"===$("select[name=connectAttempt]").val()&&$("select[name=connectAttempt]").val(3)})),$("input[name=connectCaptcha]").on("change",(function(){$("input[name=connectCaptcha]").is(":checked")?($("#connectCaptchaStrongWrapper").addClass("disabled"),$("#connectCaptchaStrongWrapper").slideDown(),$("#connectCaptchaTypeWrapper").addClass("disabled"),$("#connectCaptchaTypeWrapper").slideDown()):($("#connectCaptchaStrongWrapper").removeClass("disabled"),$("#connectCaptchaStrongWrapper").slideUp(),$("#connectCaptchaTypeWrapper").removeClass("disabled"),$("#connectCaptchaTypeWrapper").slideUp(),$("#connectCaptchaStrong").prop("checked",!1))})),$("#configSetupButton").on("click",(function(){$("#localeContainer").hide(),$("#socialContainer").hide(),$("#connectContainer").hide(),$("#networkContainer").hide(),$("#setupContainer").show(),$("#configSetupButton").addClass("activeButton"),$("#configLocaleButton").removeClass("activeButton"),$("#configSocialButton").removeClass("activeButton"),$("#configConnectButton").removeClass("activeButton"),$("#configNetworkButton").removeClass("activeButton"),setCookie("configLayout","setup")})),$("#configLocaleButton").on("click",(function(){$("#setupContainer").hide(),$("#socialContainer").hide(),$("#connectContainer").hide(),$("#networkContainer").hide(),$("#localeContainer").show(),$("#configSetupButton").removeClass("activeButton"),$("#configLocaleButton").addClass("activeButton"),$("#configSocialButton").removeClass("activeButton"),$("#configConnectButton").removeClass("activeButton"),$("#configNetworkButton").removeClass("activeButton"),setCookie("configLayout","locale")})),$("#configSocialButton").on("click",(function(){$("#connectContainer").hide(),$("#setupContainer").hide(),$("#localeContainer").hide(),$("#networkContainer").hide(),$("#socialContainer").show(),$("#configSetupButton").removeClass("activeButton"),$("#configLocaleButton").removeClass("activeButton"),$("#configSocialButton").addClass("activeButton"),$("#configConnectButton").removeClass("activeButton"),$("#configNetworkButton").removeClass("activeButton"),setCookie("configLayout","social")})),$("#configConnectButton").on("click",(function(){$("#setupContainer").hide(),$("#localeContainer").hide(),$("#socialContainer").hide(),$("#networkContainer").hide(),$("#connectContainer").show(),$("#configSetupButton").removeClass("activeButton"),$("#configLocaleButton").removeClass("activeButton"),$("#configSocialButton").removeClass("activeButton"),$("#configConnectButton").addClass("activeButton"),$("#configNetworkButton").removeClass("activeButton"),setCookie("configLayout","connect")})),$("#configNetworkButton").on("click",(function(){$("#setupContainer").hide(),$("#localeContainer").hide(),$("#socialContainer").hide(),$("#connectContainer").hide(),$("#networkContainer").show(),$("#configSetupButton").removeClass("activeButton"),$("#configLocaleButton").removeClass("activeButton"),$("#configSocialButton").removeClass("activeButton"),$("#configConnectButton").removeClass("activeButton"),$("#configNetworkButton").addClass("activeButton"),setCookie("configLayout","network")})),$("#socialMetaImage, #socialSiteMap, #configBackupCopyButton").click((function(event){$("body, .button").css("cursor","wait")}));var containers=["setup","locale","social","connect","network"];$.each(containers,(function(index,value){var a;$("div#"+value+"Container").find("input.notice").not(".displayNone").length>0?$("#config"+capitalizeFirstLetter(value)+"Button").addClass("buttonNotice"):$("#config"+capitalizeFirstLetter(value)+"Button").removeClass("buttonNotice")}))}));