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

99 lines
2.9 KiB
PHP
Raw Normal View History

2022-02-17 15:45:25 +01:00
/**
* 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 Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2022, Frédéric Tempez
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
*/
2022-05-19 18:26:04 +02:00
$(document).ready(function () {
var pluginLayout = getCookie("pluginLayout");
if (pluginLayout == null) {
pluginLayout = "module";
2022-05-19 18:26:04 +02:00
setCookie("pluginLayout", "module");
}
console.log(pluginLayout);
2022-05-19 18:26:04 +02:00
$("#moduleContainer").hide();
$("#dataContainer").hide();
$("#" + pluginLayout + "Container").show();
$("#plugin" + capitalizeFirstLetter(pluginLayout) + "Button").addClass("activeButton");
2022-05-19 18:26:04 +02:00
});
2022-02-17 15:45:25 +01:00
/**
* Confirmation de suppression
*/
$(".moduleDelete").on("click", function() {
var _this = $(this);
var message_delete = "<?php echo helper::translate('Confirmer la désinstallation du module'); ?>";
2022-09-17 17:49:19 +02:00
return core.confirm(message_delete, function() {
2022-02-17 15:45:25 +01:00
$(location).attr("href", _this.attr("href"));
});
});
/**
* Confirmation de suppression
*/
$(".dataDelete").on("click", function() {
var _this = $(this);
var message_unlink = "<?php echo helper::translate('Confirmer la dissociation du module de cette page'); ?>";
2022-09-17 17:49:19 +02:00
return core.confirm(message_unlink, function() {
2022-02-17 15:45:25 +01:00
$(location).attr("href", _this.attr("href"));
});
});
// Sélecteur de fonctions
$("#pluginModuleButton").on("click", function () {
2022-05-19 18:26:04 +02:00
$("#dataContainer").hide();
$("#moduleContainer").show();
$("#pluginModuleButton").addClass("activeButton");
$("#pluginDataButton").removeClass("activeButton");
2022-02-17 15:45:25 +01:00
setCookie("pluginLayout", "module");
});
$("#pluginDataButton").on("click", function () {
2022-05-19 18:26:04 +02:00
$("#moduleContainer").hide();
$("#dataContainer").show();
$("#pluginModuleButton").removeClass("activeButton");
$("#pluginDataButton").addClass("activeButton");
2022-02-17 15:45:25 +01:00
setCookie("pluginLayout", "data");
});
2022-05-19 18:26:04 +02:00
// 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);
}