Modules Persistance tab sélection

This commit is contained in:
Fred Tempez 2022-05-19 18:26:04 +02:00
parent c605d31e48
commit 4697bd581f
2 changed files with 61 additions and 15 deletions

View File

@ -11,6 +11,22 @@
* @link http://zwiicms.fr/
*/
$(document).ready(function () {
var configLayout = getCookie("pluginLayout");
if (configLayout == null) {
configLayout = "module";
setCookie("pluginLayout", "module");
}
$("#moduleContainer").hide();
$("#dataContainer").hide();
$("#" + configLayout + "Container").show();
$("#config" + capitalizeFirstLetter(configLayout) + "Button").addClass("activeButton");
});
/**
* Confirmation de suppression
*/
@ -33,18 +49,48 @@ $(".moduleDelete").on("click", function() {
// Sélecteur de fonctions
$("#configManageModuleButton").on("click", function () {
$("#configModuleButton").on("click", function () {
console.log("clic");
$("#manageDatas").hide();
$("#manageModules").show();
$("#configManageModuleButton").addClass("activeButton");
$("#configManageDatasButton").removeClass("activeButton");
$("#dataContainer").hide();
$("#moduleContainer").show();
$("#configModuleButton").addClass("activeButton");
$("#configDataButton").removeClass("activeButton");
setCookie("pluginLayout", "module");
});
$("#configManageDatasButton").on("click", function () {
$("#manageModules").hide();
$("#manageDatas").show();
$("#configManageModuleButton").removeClass("activeButton");
$("#configManageDatasButton").addClass("activeButton");
$("#configDataButton").on("click", function () {
$("#moduleContainer").hide();
$("#dataContainer").show();
$("#configModuleButton").removeClass("activeButton");
$("#configDataButton").addClass("activeButton");
setCookie("pluginLayout", "data");
});
// Fonctions
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
// Define function to capitalize the first letter of a string
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

View File

@ -31,16 +31,16 @@
</div>
</div>
<div class="tab">
<?php echo template::button('configManageModuleButton', [
<?php echo template::button('configModuleButton', [
'value' => 'Modules installés',
'class' => ' buttonTab activeButton'
'class' => ' buttonTab'
]); ?>
<?php echo template::button('configManageDatasButton', [
<?php echo template::button('configDataButton', [
'value' => 'Données des modules',
'class' => 'buttonTab'
]); ?>
</div>
<div class="tabContent" id="manageModules">
<div class="tabContent" id="moduleContainer">
<?php if($module::$modulesInstalled): ?>
<div class="row">
<div class="col12">
@ -64,7 +64,7 @@
</div>
<?php endif; ?>
</div>
<div class="tabContent displayNone" id="manageDatas">
<div class="tabContent displayNone" id="dataContainer">
<?php if($module::$modulesData): ?>
<div class="row">
<div class="col12">