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

136 lines
4.3 KiB
PHP
Raw Normal View History

/**
* 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>
2021-02-17 13:49:58 +01:00
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
*/
$( document).ready(function() {
/**
* Afficher et masquer options SMTP
*/
2021-04-12 18:29:10 +02:00
if ($("input[name=configAdvancedSmtpEnable]").is(':checked')) {
$("#configAdvancedSmtpParam").addClass("disabled");
$("#configAdvancedSmtpParam").slideDown();
} else {
2021-04-12 18:29:10 +02:00
$("#configAdvancedSmtpParam").removeClass("disabled");
$("#configAdvancedSmtpParam").slideUp();
}
/**
* Afficher et masquer options Auth
*/
2021-04-12 18:29:10 +02:00
if ($("select[name=configAdvancedSmtpEnable]").val() == true) {
$("#configAdvancedSmtpAuthParam").addClass("disabled");
$("#configAdvancedSmtpAuthParam").slideDown();
} else {
2021-04-12 18:29:10 +02:00
$("#configAdvancedSmtpAuthParam").removeClass("disabled");
$("#configAdvancedSmtpAuthParam").slideUp();
}
/**
* Initialisation des blocs
*/
2020-09-27 12:32:34 +02:00
var i = [ "social", "ceo", "network", "smtp", "login", "logs", "script" ];
$.each(i,function(e) {
if (getCookie(i[e]) === "true") {
2020-09-19 18:14:06 +02:00
$("#" + i[e]).find(".zwiico-plus-circled").hide();
$("#" + i[e]).find(".zwiico-minus-circled").show();
$("#" + i[e]).find(".blockContainer").show();
}
});
/**
2020-08-08 10:17:16 +02:00
*
* Blocs dépliants
*/
$("div .block").click(function(e) {
2020-09-19 18:14:06 +02:00
$(this).find(".zwiico-plus-circled").toggle();
$(this).find(".zwiico-minus-circled").toggle();
$(this).find(".blockContainer").slideToggle();
2020-08-08 10:17:16 +02:00
/*
* Sauvegarder la position des blocs
* true = bloc déplié
*/
document.cookie = $(this).attr('id') + "=" + $(this).find(".zwiico-minus-circled").is(":visible") + ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;SameSite=Lax";
2020-07-06 19:50:53 +02:00
}).on("click", "span > input, input, textarea, label, option, button, a:not(.inputFile), .blockContainer", function(e) {
// Empêcher les déclenchements dans les blocs
e.stopPropagation();
});
/**
* Afficher et masquer options SMTP
*/
2021-04-12 18:29:10 +02:00
$("input[name=configAdvancedSmtpEnable]").on("change", function() {
if ($("input[name=configAdvancedSmtpEnable]").is(':checked')) {
$("#configAdvancedSmtpParam").addClass("disabled");
$("#configAdvancedSmtpParam").slideDown();
} else {
2021-04-12 18:29:10 +02:00
$("#configAdvancedSmtpParam").removeClass("disabled");
$("#configAdvancedSmtpParam").slideUp();
}
});
/**
* Afficher et masquer options Auth
*/
2021-04-12 18:29:10 +02:00
$("select[name=configAdvancedSmtpAuth]").on("change", function() {
if ($("select[name=configAdvancedSmtpAuth]").val() == true) {
$("#configAdvancedSmtpAuthParam").addClass("disabled");
$("#configAdvancedSmtpAuthParam").slideDown();
} else {
2021-04-12 18:29:10 +02:00
$("#configAdvancedSmtpAuthParam").removeClass("disabled");
$("#configAdvancedSmtpAuthParam").slideUp();
}
});
/**
* Options de blocage de connexions
* Contrôle la cohérence des sélections et interdit une seule valeur Aucune
*/
$("select[name=configConnectAttempt]").on("change", function() {
if ($("select[name=configConnectAttempt]").val() === "999") {
$("select[name=configConnectTimeout]").val(0);
} else {
if ($("select[name=configConnectTimeout]").val() === "0") {
$("select[name=configConnectTimeout]").val(300);
}
}
});
$("select[name=configConnectTimeout]").on("change", function() {
if ($("select[name=configConnectTimeout]").val() === "0") {
$("select[name=configConnectAttempt]").val(999);
} else {
if ($("select[name=configConnectAttempt]").val() === "999") {
$("select[name=configConnectAttempt]").val(3);
}
}
});
});
/**
* Lire un cookie s'il existe
*/
function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}