diff --git a/core/core.js.php b/core/core.js.php index 5e529d34..0156b10a 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -10,474 +10,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -var core = {}; - -/** - * Crée un message d'alerte - */ -core.alert = function(text) { - var lightbox = lity(function($) { - return $("
") - .addClass("lightbox") - .append( - $("").text(text), - $("
") - .addClass("lightboxButtons") - .append( - $("") - .addClass("button") - .text("Ok") - .on("click", function() { - lightbox.close(); - }) - ) - ) - }(jQuery)); - // Validation de la lightbox avec le bouton entrée - $(document).on("keyup", function(event) { - if(event.keyCode === 13) { - lightbox.close(); - } - }); - return false; -}; - -/** - * Génère des variations d'une couleur - */ -core.colorVariants = function(rgba) { - rgba = rgba.match(/\(+(.*)\)/); - rgba = rgba[1].split(", "); - return { - "normal": "rgba(" + rgba[0] + "," + rgba[1] + "," + rgba[2] + "," + rgba[3] + ")", - "darken": "rgba(" + Math.max(0, rgba[0] - 15) + "," + Math.max(0, rgba[1] - 15) + "," + Math.max(0, rgba[2] - 15) + "," + rgba[3] + ")", - "veryDarken": "rgba(" + Math.max(0, rgba[0] - 20) + "," + Math.max(0, rgba[1] - 20) + "," + Math.max(0, rgba[2] - 20) + "," + rgba[3] + ")", - "text": core.relativeLuminanceW3C(rgba) > .22 ? "#222" : "#DDD" - }; -}; - -/** - * Crée un message de confirmation - */ -core.confirm = function(text, yesCallback, noCallback) { - var lightbox = lity(function($) { - return $("
") - .addClass("lightbox") - .append( - $("").text(text), - $("
") - .addClass("lightboxButtons") - .append( - $("") - .addClass("button grey") - .text("") - .on("click", function() { - lightbox.options('button', true); - lightbox.close(); - if(typeof noCallback !== "undefined") { - noCallback(); - } - }), - $("") - .addClass("button") - .text("") - .on("click", function() { - lightbox.options('button', true); - lightbox.close(); - if(typeof yesCallback !== "undefined") { - yesCallback(); - } - }) - ) - ) - }(jQuery)); - // Callback lors d'un clic sur le fond et sur la croix de fermeture - lightbox.options('button', false); - $(document).on('lity:close', function(event, instance) { - if( - instance.options('button') === false - && typeof noCallback !== "undefined" - ) { - noCallback(); - } - }); - // Validation de la lightbox avec le bouton entrée - $(document).on("keyup", function(event) { - if(event.keyCode === 13) { - lightbox.close(); - if(typeof yesCallback !== "undefined") { - yesCallback(); - } - } - }); - return false; -}; - -/** - * Scripts à exécuter en dernier - */ -core.end = function() { - /** - * Modifications non enregistrées du formulaire - */ - var formDOM = $("form"); - // Ignore : - // - TinyMCE car il gère lui même le message - // - Les champs avec data-no-dirty - var inputsDOM = formDOM.find("input:not([data-no-dirty]), select:not([data-no-dirty]), textarea:not(.editorWysiwyg):not([data-no-dirty])"); - var inputSerialize = inputsDOM.serialize(); - $(window).on("beforeunload", function() { - if(inputsDOM.serialize() !== inputSerialize) { - message = ""; - return message; - } - }); - formDOM.submit(function() { - $(window).off("beforeunload"); - }); -}; -$(function() { - core.end(); -}); - -/** - * Ajoute une notice - */ -core.noticeAdd = function(id, notice) { - $("#" + id + "Notice").text(notice).removeClass("displayNone"); - $("#" + id).addClass("notice"); -}; - -/** - * Supprime une notice - */ -core.noticeRemove = function(id) { - $("#" + id + "Notice").text("").addClass("displayNone"); - $("#" + id).removeClass("notice"); -}; - -/** - * Scripts à exécuter en premier - */ -core.start = function() { - /** - * Remonter en haut au clic sur le bouton - */ - var backToTopDOM = $("#backToTop"); - backToTopDOM.on("click", function() { - $("body, html").animate({scrollTop: 0}, "400"); - }); - /** - * Affiche / Cache le bouton pour remonter en haut - */ - $(window).on("scroll", function() { - if($(this).scrollTop() > 200) { - backToTopDOM.fadeIn(); - } - else { - backToTopDOM.fadeOut(); - } - }); - /** - * Cache les notifications - */ - var notificationTimer; - $("#notification") - .on("mouseenter", function() { - clearTimeout(notificationTimer); - $("#notificationProgress") - .stop() - .width("100%"); - }) - .on("mouseleave", function() { - // Disparition de la notification - notificationTimer = setTimeout(function() { - $("#notification").fadeOut(); - }, 3000); - // Barre de progression - $("#notificationProgress").animate({ - "width": "0%" - }, 3000, "linear"); - }) - .trigger("mouseleave"); - $("#notificationClose").on("click", function() { - clearTimeout(notificationTimer); - $("#notification").fadeOut(); - $("#notificationProgress").stop(); - }); - - /** - * Traitement du formulaire cookies - */ - $("#cookieForm").submit(function(event){ - - // Variables des cookies - var getUrl = window.location; - var domain = "domain=" + getUrl.hostname + ";"; - var e = new Date(); - e.setFullYear(e.getFullYear() + 1); - var expires = "expires=" + e.toUTCString(); - - // Stocke le cookie d'acceptation - document.cookie = "ZWII_COOKIE_CONSENT=true;samesite=strict;" + domain + expires; - }); - - - /** - * Fermeture de la popup des cookies - */ - $("#cookieConsent .cookieClose").on("click", function() { - $('#cookieConsent').addClass("displayNone"); - }); - - /** - * Commande de gestion des cookies dans le footer - */ - - $("#footerLinkCookie").on("click", function() { - $("#cookieConsent").removeClass("displayNone"); - }); - - /** - * Affiche / Cache le menu en mode responsive - */ - var menuDOM = $("#menu"); - $("#toggle").on("click", function() { - menuDOM.slideToggle(); - }); - $(window).on("resize", function() { - if($(window).width() > 768) { - menuDOM.css("display", ""); - } - }); - - /** - * Choix de page dans la barre de membre - */ - $("#barSelectPage").on("change", function() { - var pageUrl = $(this).val(); - if(pageUrl) { - $(location).attr("href", pageUrl); - } - }); - /** - * Champs d'upload de fichiers - */ - // Mise à jour de l'affichage des champs d'upload - $(".inputFileHidden").on("change", function() { - var inputFileHiddenDOM = $(this); - var fileName = inputFileHiddenDOM.val(); - if(fileName === "") { - fileName = "Choisissez un fichier"; - $(inputFileHiddenDOM).addClass("disabled"); - } - else { - $(inputFileHiddenDOM).removeClass("disabled"); - } - inputFileHiddenDOM.parent().find(".inputFileLabel").text(fileName); - }).trigger("change"); - // Suppression du fichier contenu dans le champ - $(".inputFileDelete").on("click", function() { - $(this).parents(".inputWrapper").find(".inputFileHidden").val("").trigger("change"); - }); - // Suppression de la date contenu dans le champ - $(".inputDateDelete").on("click", function() { - $(this).parents(".inputWrapper").find(".datepicker").val("").trigger("change"); - }); - // Confirmation de mise à jour - $("#barUpdate").on("click", function() { - message = ""; - return core.confirm(message, function() { - $(location).attr("href", $("#barUpdate").attr("href")); - }); - }); - // Confirmation de déconnexion - $("#barLogout").on("click", function() { - message = ""; - return core.confirm(message, function() { - $(location).attr("href", $("#barLogout").attr("href")); - }); - }); - /** - * Bloque la multi-soumission des boutons - */ - $("form").on("submit", function() { - $(this).find(".uniqueSubmission") - .addClass("disabled") - .prop("disabled", true) - .empty() - .append( - $("").addClass("zwiico-spin animate-spin") - ) - }); - /** - * Check adresse email - */ - $("[type=email]").on("change", function() { - var _this = $(this); - var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i; - if(pattern.test(_this.val())) { - core.noticeRemove(_this.attr("id")); - } - else { - message = ""; - core.noticeAdd(_this.attr("id"), message); - } - }); - - /** - * Iframes et vidéos responsives - */ - var elementDOM = $("iframe, video, embed, object"); - // Calcul du ratio et suppression de la hauteur / largeur des iframes - elementDOM.each(function() { - var _this = $(this); - _this - .data("ratio", _this.height() / _this.width()) - .data("maxwidth", _this.width()) - .removeAttr("width height"); - }); - // Prend la largeur du parent et détermine la hauteur à l'aide du ratio lors du resize de la fenêtre - $(window).on("resize", function() { - elementDOM.each(function() { - var _this = $(this); - var width = _this.parent().first().width(); - if (width > _this.data("maxwidth")){ width = _this.data("maxwidth");} - _this - .width(width) - .height(width * _this.data("ratio")); - }); - }).trigger("resize"); - - /* - * Header responsive - */ - $(window).on("resize", function() { - var responsive = "getdata(['theme','header','imageContainer']);?>"; - if (responsive === "cover" || responsive === "contain" ) { - var widthpx = "getdata(['theme','site','width']);?>"; - var width = widthpx.substr(0,widthpx.length-2); - var heightpx = "getdata(['theme','header','height']);?>"; - var height = heightpx.substr(0,heightpx.length-2); - var ratio = width / height; - if ( ($(window).width() / ratio) <= height) { - $("header").height( $(window).width() / ratio ); - } - } - }).trigger("resize"); - -}; - - -core.start(); - -/** - * Confirmation de suppression -*/ -$("#pageDelete").on("click", function() { - var _this = $(this); - message = ""; - return core.confirm(message, function() { - $(location).attr("href", _this.attr("href")); - }); -}); - - -/** - * Calcul de la luminance relative d'une couleur - */ -core.relativeLuminanceW3C = function(rgba) { - // Conversion en sRGB - var RsRGB = rgba[0] / 255; - var GsRGB = rgba[1] / 255; - var BsRGB = rgba[2] / 255; - // Ajout de la transparence - var RsRGBA = rgba[3] * RsRGB + (1 - rgba[3]); - var GsRGBA = rgba[3] * GsRGB + (1 - rgba[3]); - var BsRGBA = rgba[3] * BsRGB + (1 - rgba[3]); - // Calcul de la luminance - var R = (RsRGBA <= .03928) ? RsRGBA / 12.92 : Math.pow((RsRGBA + .055) / 1.055, 2.4); - var G = (GsRGBA <= .03928) ? GsRGBA / 12.92 : Math.pow((GsRGBA + .055) / 1.055, 2.4); - var B = (BsRGBA <= .03928) ? BsRGBA / 12.92 : Math.pow((BsRGBA + .055) / 1.055, 2.4); - return .2126 * R + .7152 * G + .0722 * B; -}; - - - -$(document).ready(function(){ - /** - * Affiche le sous-menu quand il est sticky - */ - $("nav").mouseenter(function(){ - $("#navfixedlogout .navSub").css({ 'pointer-events' : 'auto' }); - $("#navfixedconnected .navSub").css({ 'pointer-events' : 'auto' }); - }); - $("nav").mouseleave(function(){ - $("#navfixedlogout .navSub").css({ 'pointer-events' : 'none' }); - $("#navfixedconnected .navSub").css({ 'pointer-events' : 'none' }); - }); - - /** - * Chargement paresseux des images et des iframes - */ - $("img,picture,iframe").attr("loading","lazy"); - - /** - * Effet accordéon - */ - $('.accordion').each(function(e) { - // on stocke l'accordéon dans une variable locale - var accordion = $(this); - // on récupère la valeur data-speed si elle existe - var toggleSpeed = accordion.attr('data-speed') || 100; - - // fonction pour afficher un élément - function open(item, speed) { - // on récupère tous les éléments, on enlève l'élément actif de ce résultat, et on les cache - accordion.find('.accordion-item').not(item).removeClass('active') - .find('.accordion-content').slideUp(speed); - // on affiche l'élément actif - item.addClass('active') - .find('.accordion-content').slideDown(speed); - } - function close(item, speed) { - accordion.find('.accordion-item').removeClass('active') - .find('.accordion-content').slideUp(speed); - } - - // on initialise l'accordéon, sans animation - open(accordion.find('.active:first'), 0); - - // au clic sur un titre... - accordion.on('click', '.accordion-title', function(ev) { - ev.preventDefault(); - // Masquer l'élément déjà actif - if ($(this).closest('.accordion-item').hasClass('active')) { - close($(this).closest('.accordion-item'), toggleSpeed); - } else { - // ...on lance l'affichage de l'élément, avec animation - open($(this).closest('.accordion-item'), toggleSpeed); - } - }); - }); - - /** - * Icône du Menu Burger - */ - $("#toggle").click(function() { - var changeIcon = $('#toggle').children("span"); - if ( $(changeIcon).hasClass('zwiico-menu') ) { - $(changeIcon).removeClass('zwiico-menu').addClass('zwiico-cancel'); - } - else { - $(changeIcon).addClass('zwiico-menu'); - }; - }); - - /** - * Remove ID Facebook from URL - */ - if(/^\?fbclid=/.test(location.search)) - location.replace(location.href.replace(/\?fbclid.+/, "")); -}); +var core={alert:function(text){var lightbox=lity(function($){return $("
").addClass("lightbox").append($("").text(text),$("
").addClass("lightboxButtons").append($("").addClass("button").text("Ok").on("click",(function(){lightbox.close()}))))}(jQuery));return $(document).on("keyup",(function(event){13===event.keyCode&&lightbox.close()})),!1},colorVariants:function(rgba){return{normal:"rgba("+(rgba=(rgba=rgba.match(/\(+(.*)\)/))[1].split(", "))[0]+","+rgba[1]+","+rgba[2]+","+rgba[3]+")",darken:"rgba("+Math.max(0,rgba[0]-15)+","+Math.max(0,rgba[1]-15)+","+Math.max(0,rgba[2]-15)+","+rgba[3]+")",veryDarken:"rgba("+Math.max(0,rgba[0]-20)+","+Math.max(0,rgba[1]-20)+","+Math.max(0,rgba[2]-20)+","+rgba[3]+")",text:core.relativeLuminanceW3C(rgba)>.22?"#222":"#DDD"}},confirm:function(text,yesCallback,noCallback){var lightbox=lity(function($){return $("
").addClass("lightbox").append($("").text(text),$("
").addClass("lightboxButtons").append($("").addClass("button grey").text("").on("click",(function(){lightbox.options("button",!0),lightbox.close(),void 0!==noCallback&&noCallback()})),$("").addClass("button").text("").on("click",(function(){lightbox.options("button",!0),lightbox.close(),void 0!==yesCallback&&yesCallback()}))))}(jQuery));return lightbox.options("button",!1),$(document).on("lity:close",(function(event,instance){!1===instance.options("button")&&void 0!==noCallback&&noCallback()})),$(document).on("keyup",(function(event){13===event.keyCode&&(lightbox.close(),void 0!==yesCallback&&yesCallback())})),!1},end:function(){var formDOM=$("form"),inputsDOM=formDOM.find("input:not([data-no-dirty]), select:not([data-no-dirty]), textarea:not(.editorWysiwyg):not([data-no-dirty])"),inputSerialize=inputsDOM.serialize();$(window).on("beforeunload",(function(){if(inputsDOM.serialize()!==inputSerialize)return message="",message})),formDOM.submit((function(){$(window).off("beforeunload")}))}};$((function(){core.end()})),core.noticeAdd=function(id,notice){$("#"+id+"Notice").text(notice).removeClass("displayNone"),$("#"+id).addClass("notice")},core.noticeRemove=function(id){$("#"+id+"Notice").text("").addClass("displayNone"),$("#"+id).removeClass("notice")},core.start=function(){var backToTopDOM=$("#backToTop"),notificationTimer;backToTopDOM.on("click",(function(){$("body, html").animate({scrollTop:0},"400")})),$(window).on("scroll",(function(){$(this).scrollTop()>200?backToTopDOM.fadeIn():backToTopDOM.fadeOut()})),$("#notification").on("mouseenter",(function(){clearTimeout(notificationTimer),$("#notificationProgress").stop().width("100%")})).on("mouseleave",(function(){notificationTimer=setTimeout((function(){$("#notification").fadeOut()}),3e3),$("#notificationProgress").animate({width:"0%"},3e3,"linear")})).trigger("mouseleave"),$("#notificationClose").on("click",(function(){clearTimeout(notificationTimer),$("#notification").fadeOut(),$("#notificationProgress").stop()})),$("#cookieForm").submit((function(event){var getUrl,domain="domain="+window.location.hostname+";",e=new Date;e.setFullYear(e.getFullYear()+1);var expires="expires="+e.toUTCString();document.cookie="ZWII_COOKIE_CONSENT=true;samesite=strict;"+domain+expires})),$("#cookieConsent .cookieClose").on("click",(function(){$("#cookieConsent").addClass("displayNone")})),$("#footerLinkCookie").on("click",(function(){$("#cookieConsent").removeClass("displayNone")}));var menuDOM=$("#menu");$("#toggle").on("click",(function(){menuDOM.slideToggle()})),$(window).on("resize",(function(){$(window).width()>768&&menuDOM.css("display","")})),$("#barSelectPage").on("change",(function(){var pageUrl=$(this).val();pageUrl&&$(location).attr("href",pageUrl)})),$(".inputFileHidden").on("change",(function(){var inputFileHiddenDOM=$(this),fileName=inputFileHiddenDOM.val();""===fileName?(fileName="Choisissez un fichier",$(inputFileHiddenDOM).addClass("disabled")):$(inputFileHiddenDOM).removeClass("disabled"),inputFileHiddenDOM.parent().find(".inputFileLabel").text(fileName)})).trigger("change"),$(".inputFileDelete").on("click",(function(){$(this).parents(".inputWrapper").find(".inputFileHidden").val("").trigger("change")})),$(".inputDateDelete").on("click",(function(){$(this).parents(".inputWrapper").find(".datepicker").val("").trigger("change")})),$("#barUpdate").on("click",(function(){return message="",core.confirm(message,(function(){$(location).attr("href",$("#barUpdate").attr("href"))}))})),$("#barLogout").on("click",(function(){return message="",core.confirm(message,(function(){$(location).attr("href",$("#barLogout").attr("href"))}))})),$("form").on("submit",(function(){$(this).find(".uniqueSubmission").addClass("disabled").prop("disabled",!0).empty().append($("").addClass("zwiico-spin animate-spin"))})),$("[type=email]").on("change",(function(){var _this=$(this),pattern;/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i.test(_this.val())?core.noticeRemove(_this.attr("id")):(message="",core.noticeAdd(_this.attr("id"),message))}));var elementDOM=$("iframe, video, embed, object");elementDOM.each((function(){var _this=$(this);_this.data("ratio",_this.height()/_this.width()).data("maxwidth",_this.width()).removeAttr("width height")})),$(window).on("resize",(function(){elementDOM.each((function(){var _this=$(this),width=_this.parent().first().width();width>_this.data("maxwidth")&&(width=_this.data("maxwidth")),_this.width(width).height(width*_this.data("ratio"))}))})).trigger("resize"),$(window).on("resize",(function(){var responsive="getdata(['theme','header','imageContainer']);?>",widthpx,width,heightpx,height,ratio})).trigger("resize")},core.start(),$("#pageDelete").on("click",(function(){var _this=$(this);return message="",core.confirm(message,(function(){$(location).attr("href",_this.attr("href"))}))})),core.relativeLuminanceW3C=function(rgba){var RsRGB=rgba[0]/255,GsRGB=rgba[1]/255,BsRGB=rgba[2]/255,RsRGBA=rgba[3]*RsRGB+(1-rgba[3]),GsRGBA=rgba[3]*GsRGB+(1-rgba[3]),BsRGBA=rgba[3]*BsRGB+(1-rgba[3]),R,G,B;return.2126*(RsRGBA<=.03928?RsRGBA/12.92:Math.pow((RsRGBA+.055)/1.055,2.4))+.7152*(GsRGBA<=.03928?GsRGBA/12.92:Math.pow((GsRGBA+.055)/1.055,2.4))+.0722*(BsRGBA<=.03928?BsRGBA/12.92:Math.pow((BsRGBA+.055)/1.055,2.4))},$(document).ready((function(){$("nav").mouseenter((function(){$("#navfixedlogout .navSub").css({"pointer-events":"auto"}),$("#navfixedconnected .navSub").css({"pointer-events":"auto"})})),$("nav").mouseleave((function(){$("#navfixedlogout .navSub").css({"pointer-events":"none"}),$("#navfixedconnected .navSub").css({"pointer-events":"none"})})),$("img,picture,iframe").attr("loading","lazy"),$(".accordion").each((function(e){var accordion=$(this),toggleSpeed=accordion.attr("data-speed")||100;function open(item,speed){accordion.find(".accordion-item").not(item).removeClass("active").find(".accordion-content").slideUp(speed),item.addClass("active").find(".accordion-content").slideDown(speed)}function close(item,speed){accordion.find(".accordion-item").removeClass("active").find(".accordion-content").slideUp(speed)}open(accordion.find(".active:first"),0),accordion.on("click",".accordion-title",(function(ev){ev.preventDefault(),$(this).closest(".accordion-item").hasClass("active")?close($(this).closest(".accordion-item"),toggleSpeed):open($(this).closest(".accordion-item"),toggleSpeed)}))})),$("#toggle").click((function(){var changeIcon=$("#toggle").children("span");$(changeIcon).hasClass("zwiico-menu")?$(changeIcon).removeClass("zwiico-menu").addClass("zwiico-cancel"):$(changeIcon).addClass("zwiico-menu")})),/^\?fbclid=/.test(location.search)&&location.replace(location.href.replace(/\?fbclid.+/,""))})); \ No newline at end of file diff --git a/core/module/config/view/backup/backup.js.php b/core/module/config/view/backup/backup.js.php index 9095d251..295d152c 100644 --- a/core/module/config/view/backup/backup.js.php +++ b/core/module/config/view/backup/backup.js.php @@ -9,50 +9,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -$(document).ready(function () { - $("#configBackupForm").submit(function (e) { - //$("#configBackupSubmit").addClass("disabled").prop("disabled", true); - e.preventDefault(); - var url = "getUrl(0); ?>/backup"; - var message_success = ""; - var message_error = ""; - var message_title = ""; - $.ajax({ - type: "POST", - url: url, - data: $("form").serialize(), - success: function (data) { - $('body, .button').css('cursor', 'default'); - core.alert(message_success); - }, - error: function (data) { - $('body, .button').css('cursor', 'default'); - core.alert(message_error); - }, - complete: function () { - $("#configBackupSubmit").removeClass("disabled").prop("disabled", false); - $("#configBackupSubmit").removeClass("uniqueSubmission").prop("uniqueSubmission", false); - $("#configBackupSubmit span").removeClass("zwiico-spin animate-spin"); - $("#configBackupSubmit span").addClass("zwiico-check zwiico-margin-right").text(message_title); - } - }); - }); - - - /** - * Confirmation de sauvegarde complète - */ - $("#configBackupSubmit").on("click", function () { - if ($("input[name=configBackupOption]").is(':checked')) { - var message_warning = ""; - return core.confirm(message_warning, function () { - //$(location).attr("href", _this.attr("href")); - $('body, .button').css('cursor', 'wait'); - $('form#configBackupForm').submit(); - }); - } - }); - -}); - +$(document).ready((function(){$("#configBackupForm").submit((function(e){e.preventDefault();var url="getUrl(0); ?>/backup",message_success="",message_error="",message_title="";$.ajax({type:"POST",url:url,data:$("form").serialize(),success:function(data){$("body, .button").css("cursor","default"),core.alert(message_success)},error:function(data){$("body, .button").css("cursor","default"),core.alert(message_error)},complete:function(){$("#configBackupSubmit").removeClass("disabled").prop("disabled",!1),$("#configBackupSubmit").removeClass("uniqueSubmission").prop("uniqueSubmission",!1),$("#configBackupSubmit span").removeClass("zwiico-spin animate-spin"),$("#configBackupSubmit span").addClass("zwiico-check zwiico-margin-right").text(message_title)}})})),$("#configBackupSubmit").on("click",(function(){if($("input[name=configBackupOption]").is(":checked")){var message_warning="";return core.confirm(message_warning,(function(){$("body, .button").css("cursor","wait"),$("form#configBackupForm").submit()}))}}))})); \ No newline at end of file diff --git a/core/module/config/view/index/index.js.php b/core/module/config/view/index/index.js.php index 093e6f03..59e1427e 100644 --- a/core/module/config/view/index/index.js.php +++ b/core/module/config/view/index/index.js.php @@ -9,264 +9,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -$(document).ready(function () { - - /** - * Confirmation de suppression - */ - $("#configBackupDelButton").on("click", function () { - var _this = $(this); - var message_warning = ""; - return core.confirm(message_warning, function () { - $(location).attr("href", _this.attr("href")); - }); - }); - - // Positionnement inital des options - //----------------------------------------------------------------------------------------------------- - - /** - * Afficher et masquer options smtp - */ - if ($("input[name=smtpEnable]").is(':checked')) { - $("#smtpParam").addClass("disabled"); - $("#smtpParam").slideDown(); - } else { - $("#smtpParam").removeClass("disabled"); - $("#smtpParam").slideUp(); - } - /** - * Afficher et masquer options Auth - */ - - if ($("select[name=smtpAuth]").val() == true) { - $("#smtpAuthParam").addClass("disabled"); - $("#smtpAuthParam").slideDown(); - } else { - $("#smtpAuthParam").removeClass("disabled"); - $("#smtpAuthParam").slideUp(); - } - - /** - * Afficher et masquer les options de captcha - */ - - if ($("input[name=connectCaptcha]").is(':checked')) { - $("#connectCaptchaStrongWrapper").addClass("disabled"); - $("#connectCaptchaStrongWrapper").slideDown(); - $("#connectCaptchaTypeWrapper").addClass("disabled"); - $("#connectCaptchaTypeWrapper").slideDown(); - } else { - $("#connectCaptchaStrongWrapper").removeClass("disabled"); - $("#connectCaptchaStrongWrapper").slideUp(); - $("#connectCaptchaTypeWrapper").removeClass("disabled"); - $("#connectCaptchaTypeWrapper").slideUp(); - $("#connectCaptchaStrong").prop("checked", false); - } - - var configLayout = getCookie("configLayout"); - if (configLayout == null) { - configLayout = "setup"; - setCookie("configLayout", "setup"); - } - $("#localeContainer").hide(); - $("#socialContainer").hide(); - $("#connectContainer").hide(); - $("#networkContainer").hide(); - $("#setupContainer").hide(); - $("#" + configLayout + "Container").show(); - $("#config" + capitalizeFirstLetter(configLayout) + "Button").addClass("activeButton"); - - - // Gestion des événements - //--------------------------------------------------------------------------------------------------------------------- - - /** - * Afficher et masquer options smtp - */ - $("input[name=smtpEnable]").on("change", function () { - if ($("input[name=smtpEnable]").is(':checked')) { - $("#smtpParam").addClass("disabled"); - $("#smtpParam").slideDown(); - } else { - $("#smtpParam").removeClass("disabled"); - $("#smtpParam").slideUp(); - } - }); - - /** - * Afficher et masquer options Auth - */ - - $("select[name=smtpAuth]").on("change", function () { - if ($("select[name=smtpAuth]").val() == true) { - $("#smtpAuthParam").addClass("disabled"); - $("#smtpAuthParam").slideDown(); - } else { - $("#smtpAuthParam").removeClass("disabled"); - $("#smtpAuthParam").slideUp(); - } - }); - - /** - * Options de blocage de connexions - * Contrôle la cohérence des sélections et interdit une seule valeur Aucune - */ - $("select[name=connectAttempt]").on("change", function () { - if ($("select[name=connectAttempt]").val() === "999") { - $("select[name=connectTimeout]").val(0); - } else { - if ($("select[name=connectTimeout]").val() === "0") { - $("select[name=connectTimeout]").val(300); - } - } - }); - $("select[name=connectTimeout]").on("change", function () { - if ($("select[name=connectTimeout]").val() === "0") { - $("select[name=connectAttempt]").val(999); - } else { - if ($("select[name=connectAttempt]").val() === "999") { - $("select[name=connectAttempt]").val(3); - } - } - }); - - /** - * Captcha strong si captcha sélectionné - */ - $("input[name=connectCaptcha]").on("change", function () { - - if ($("input[name=connectCaptcha]").is(':checked')) { - $("#connectCaptchaStrongWrapper").addClass("disabled"); - $("#connectCaptchaStrongWrapper").slideDown(); - $("#connectCaptchaTypeWrapper").addClass("disabled"); - $("#connectCaptchaTypeWrapper").slideDown(); - - } else { - $("#connectCaptchaStrongWrapper").removeClass("disabled"); - $("#connectCaptchaStrongWrapper").slideUp(); - $("#connectCaptchaTypeWrapper").removeClass("disabled"); - $("#connectCaptchaTypeWrapper").slideUp(); - $("#connectCaptchaStrong").prop("checked", false); - } - }); - - - /** - * Sélection de la page de configuration à afficher - */ - $("#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"); - }); - - - /** - * Aspect de la souris - */ - $("#socialMetaImage, #socialSiteMap, #configBackupCopyButton").click(function (event) { - $('body, .button').css('cursor', 'wait'); - }); - - - // Mise en évidence des erreurs de saisie dans les boutons de sélection - var containers = ["setup", "locale", "social", "connect", "network"]; - $.each(containers, function (index, value) { - var a = $("div#" + value + "Container").find("input.notice").not(".displayNone"); - if (a.length > 0) { - $("#config" + capitalizeFirstLetter(value) + "Button").addClass("buttonNotice"); - } else { - $("#config" + capitalizeFirstLetter(value) + "Button").removeClass("buttonNotice"); - } - }); - -}); - - -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); -} \ No newline at end of file +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";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")}))})); \ No newline at end of file diff --git a/core/module/config/view/restore/restore.js.php b/core/module/config/view/restore/restore.js.php index ca5042d8..1ff3882d 100644 --- a/core/module/config/view/restore/restore.js.php +++ b/core/module/config/view/restore/restore.js.php @@ -9,14 +9,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -$( document).ready(function() { - - /** - * Aspect de la souris - */ - $("#configRestoreSubmit").click(function(event) { - $('body, .button').css('cursor', 'wait'); - }); - -}); \ No newline at end of file +$(document).ready((function(){$("#configRestoreSubmit").click((function(event){$("body, .button").css("cursor","wait")}))})); \ No newline at end of file diff --git a/core/module/install/view/postinstall/postinstall.js.php b/core/module/install/view/postinstall/postinstall.js.php index e27f7ac5..7150fd86 100644 --- a/core/module/install/view/postinstall/postinstall.js.php +++ b/core/module/install/view/postinstall/postinstall.js.php @@ -10,28 +10,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -/** - * Affichage de l'id en simulant FILTER_ID - */ -$("#installId").on("change keydown keyup", function(event) { - var userId = $(this).val(); - if( - event.keyCode !== 8 // BACKSPACE - && event.keyCode !== 37 // LEFT - && event.keyCode !== 39 // RIGHT - && event.keyCode !== 46 // DELETE - && window.getSelection().toString() !== userId // Texte sélectionné - ) { - var searchReplace = { - "á": "a", "à": "a", "â": "a", "ä": "a", "ã": "a", "å": "a", "ç": "c", "é": "e", "è": "e", "ê": "e", "ë": "e", "í": "i", "ì": "i", "î": "i", "ï": "i", "ñ": "n", "ó": "o", "ò": "o", "ô": "o", "ö": "o", "õ": "o", "ú": "u", "ù": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", - "Á": "A", "À": "A", "Â": "A", "Ä": "A", "Ã": "A", "Å": "A", "Ç": "C", "É": "E", "È": "E", "Ê": "E", "Ë": "E", "Í": "I", "Ì": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ó": "O", "Ò": "O", "Ô": "O", "Ö": "O", "Õ": "O", "Ú": "U", "Ù": "U", "Û": "U", "Ü": "U", "Ý": "Y", "Ÿ": "Y", - "'": "-", "\"": "-", " ": "-" - }; - userId = userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/ig, function(match) { - return searchReplace[match]; - }); - userId = userId.replace(/[^a-z0-9-]/ig, ""); - $(this).val(userId); - } -}); \ No newline at end of file +$("#installId").on("change keydown keyup",(function(event){var userId=$(this).val();if(8!==event.keyCode&&37!==event.keyCode&&39!==event.keyCode&&46!==event.keyCode&&window.getSelection().toString()!==userId){var searchReplace={"á":"a","à":"a","â":"a","ä":"a","ã":"a","å":"a","ç":"c","é":"e","è":"e","ê":"e","ë":"e","í":"i","ì":"i","î":"i","ï":"i","ñ":"n","ó":"o","ò":"o","ô":"o","ö":"o","õ":"o","ú":"u","ù":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Á":"A","À":"A","Â":"A","Ä":"A","Ã":"A","Å":"A","Ç":"C","É":"E","È":"E","Ê":"E","Ë":"E","Í":"I","Ì":"I","Î":"I","Ï":"I","Ñ":"N","Ó":"O","Ò":"O","Ô":"O","Ö":"O","Õ":"O","Ú":"U","Ù":"U","Û":"U","Ü":"U","Ý":"Y","Ÿ":"Y","'":"-",'"':"-"," ":"-"};userId=(userId=userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/gi,(function(match){return searchReplace[match]}))).replace(/[^a-z0-9-]/gi,""),$(this).val(userId)}})); \ No newline at end of file diff --git a/core/module/install/view/update/update.js.php b/core/module/install/view/update/update.js.php index 2fa72559..55239fa0 100644 --- a/core/module/install/view/update/update.js.php +++ b/core/module/install/view/update/update.js.php @@ -1,72 +1 @@ -/** - * Exécution des différentes étapes de mise à jour - */ -function step(i, data) { - // tableau des erreurs - var errors = [ - "", - "", - "", - "" - ]; - // Affiche le texte de progression - $(".installUpdateProgressText").hide(); - $(".installUpdateProgressText[data-id=" + i + "]").show(); - // Requête ajax - $.ajax({ - type: "POST", - url: "?install/steps", // Ignore la réécriture d'URL - data: { - step: i, - data: data - }, - // Succès de la requête - success: function(result) { - setTimeout(function() { - // Succès - if(result.success === true) { - // Fin de la mise à jour - if(i === 4) { - // Affiche le message de succès - $("#installUpdateSuccess").show(); - // Déverrouille le bouton "Terminer" - $("#installUpdateEnd").removeClass("disabled"); - // Cache le texte de progression - $("#installUpdateProgress").hide(); - } - // Prochaine étape - else { - step(i + 1, result.data); - } - } - // Échec - else { - // Affiche le message d'erreur - $("#installUpdateErrorStep").text(errors[i]); - $("#installUpdateError").show(); - // Déverrouille le bouton "Terminer" - $("#installUpdateEnd").removeClass("disabled"); - // Cache le texte de progression - $("#installUpdateProgress").hide(); - // Affiche le résultat dans la console - console.error(result); - $("#installUpdateErrorMessage").text(result.replace( /<[^p].*?>/g, '' )); - } - }, 2000); - }, - // Échec de la requête - error: function(xhr) { - // Affiche le message d'erreur - $("#installUpdateErrorStep").text(errors[1]); - $("#installUpdateError").show(); - // Déverrouille le bouton "Terminer" - $("#installUpdateEnd").removeClass("disabled"); - // Cache le texte de progression - $("#installUpdateProgress").hide(); - // Affiche l'erreur dans la console - console.error(xhr.responseText); - $("#installUpdateErrorMessage").text(xhr.responseText.replace( /<[^p].*?>/g, '' )); - } - }); -} -$(window).on("load", step(1, null)); \ No newline at end of file +function step(i,data){var errors=["","","",""];$(".installUpdateProgressText").hide(),$(".installUpdateProgressText[data-id="+i+"]").show(),$.ajax({type:"POST",url:"?install/steps",data:{step:i,data:data},success:function(result){setTimeout((function(){!0===result.success?4===i?($("#installUpdateSuccess").show(),$("#installUpdateEnd").removeClass("disabled"),$("#installUpdateProgress").hide()):step(i+1,result.data):($("#installUpdateErrorStep").text(errors[i]),$("#installUpdateError").show(),$("#installUpdateEnd").removeClass("disabled"),$("#installUpdateProgress").hide(),console.error(result),$("#installUpdateErrorMessage").text(result.replace(/<[^p].*?>/g,"")))}),2e3)},error:function(xhr){$("#installUpdateErrorStep").text(errors[1]),$("#installUpdateError").show(),$("#installUpdateEnd").removeClass("disabled"),$("#installUpdateProgress").hide(),console.error(xhr.responseText),$("#installUpdateErrorMessage").text(xhr.responseText.replace(/<[^p].*?>/g,""))}})}$(window).on("load",step(1,null)); \ No newline at end of file diff --git a/core/module/plugin/view/index/index.js.php b/core/module/plugin/view/index/index.js.php index ef39f90c..d0250765 100644 --- a/core/module/plugin/view/index/index.js.php +++ b/core/module/plugin/view/index/index.js.php @@ -10,89 +10,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - - - $(document).ready(function () { - var pluginLayout = getCookie("pluginLayout"); - if (pluginLayout == null) { - pluginLayout = "module"; - setCookie("pluginLayout", "module"); - } - console.log(pluginLayout); - $("#moduleContainer").hide(); - $("#dataContainer").hide(); - $("#" + pluginLayout + "Container").show(); - $("#plugin" + capitalizeFirstLetter(pluginLayout) + "Button").addClass("activeButton"); - - }); - - - -/** - * Confirmation de suppression - */ -$(".moduleDelete").on("click", function() { - var _this = $(this); - var message_delete = ""; - return core.confirm(message_delete, function() { - $(location).attr("href", _this.attr("href")); - }); -}); - -/** - * Confirmation de suppression - */ - $(".dataDelete").on("click", function() { - var _this = $(this); - var message_unlink = ""; - return core.confirm(message_unlink, function() { - $(location).attr("href", _this.attr("href")); - }); -}); - -// Sélecteur de fonctions - -$("#pluginModuleButton").on("click", function () { - $("#dataContainer").hide(); - $("#moduleContainer").show(); - $("#pluginModuleButton").addClass("activeButton"); - $("#pluginDataButton").removeClass("activeButton"); - setCookie("pluginLayout", "module"); -}); -$("#pluginDataButton").on("click", function () { - $("#moduleContainer").hide(); - $("#dataContainer").show(); - $("#pluginModuleButton").removeClass("activeButton"); - $("#pluginDataButton").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); -} +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";return core.confirm(message_delete,(function(){$(location).attr("href",_this.attr("href"))}))})),$(".dataDelete").on("click",(function(){var _this=$(this),message_unlink="";return core.confirm(message_unlink,(function(){$(location).attr("href",_this.attr("href"))}))})),$("#pluginModuleButton").on("click",(function(){$("#dataContainer").hide(),$("#moduleContainer").show(),$("#pluginModuleButton").addClass("activeButton"),$("#pluginDataButton").removeClass("activeButton"),setCookie("pluginLayout","module")})),$("#pluginDataButton").on("click",(function(){$("#moduleContainer").hide(),$("#dataContainer").show(),$("#pluginModuleButton").removeClass("activeButton"),$("#pluginDataButton").addClass("activeButton"),setCookie("pluginLayout","data")})); \ No newline at end of file diff --git a/core/module/theme/view/admin/admin.js.php b/core/module/theme/view/admin/admin.js.php index 3240b396..798e0e36 100644 --- a/core/module/theme/view/admin/admin.js.php +++ b/core/module/theme/view/admin/admin.js.php @@ -9,51 +9,4 @@ * @license GNU General Public License, version 3 * @link http://zwiicms.fr/ */ - -/** -* Aperçu en direct -*/ -$("input, select").on("change", function () { - - var titleFont = $("#adminFontTitle").val(); - var textFont = $("#adminFontText").val(); - var css = "@import url('https://fonts.cdnfonts.com/css/" + titleFont + "');"; - var css = "@import url('https://fonts.cdnfonts.com/css/" + textFont + "');"; - var colors = core.colorVariants($("#adminBackgroundColor").val()); - var css = "#site{background-color:" + colors.normal + ";}"; - css += "body, .row > div {font:" + $("#adminFontTextSize").val() + " '" + textFont + "', sans-serif;}"; - css += "body h1, h2, h3, h4, h5, h6 {font-family:'" + titleFont + "', sans-serif; color:" + $("#adminColorTitle").val() + ";}"; - css += "body:not(.editorWysiwyg),span .zwiico-help {color:" + $("#adminColorText").val() + ";}"; - var colors = core.colorVariants($("#adminColorButton").val()); - css += "input[type='checkbox']:checked + label::before,.speechBubble{ background-color:" + colors.normal + "; color:" + $("#adminColorButtonText").val() + ";}"; - css += ".speechBubble::before {border-color:" + colors.normal + " transparent transparent transparent;}"; - css += ".button {background-color:" + colors.normal + ";color:" + colors.text + ";}.button:hover {background-color:" + colors.darken + ";color:" + colors.text + ";}.button:active {background-color:" + colors.veryDarken + ";color:" + colors.text + ";}"; - var colors = core.colorVariants($("#adminColorGrey").val()); - css += ".button.buttonGrey {background-color: " + colors.normal + ";color:" + colors.text + ";}.button.buttonGrey:hover {background-color:" + colors.darken + ";color:" + colors.text + "}.button.buttonGrey:active {background-color:" + colors.veryDarken + ";color:" + colors.text + ";}"; - var colors = core.colorVariants($("#adminColorRed").val()); - css += ".button.buttonRed {background-color: " + colors.normal + ";color:" + colors.text + ";}.button.buttonRed:hover {background-color:" + colors.darken + ";color:" + colors.text + "}.button.buttonRed:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}"; - var colors = core.colorVariants($("#adminColorGreen").val()); - css += ".button.buttonGreen, button[type=submit] {background-color: " + colors.normal + ";color: " + ";color:" + colors.text + "}.button.buttonGreen:hover, button[type=submit]:hover {background-color: " + colors.darken + ";color:" + colors.text + ";}.button.buttonGreen:active, button[type=submit]:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}"; - var colors = core.colorVariants($("#adminBackGroundBlockColor").val()); - css += ".block {border: 1px solid " + $("#adminBorderBlockColor").val() + ";}.block h4 {background-color: " + colors.normal + ";color:" + colors.text + ";}"; - css += "input[type=email],input[type=text],input[type=password],select:not(#barSelectPage),textarea:not(.editorWysiwyg),.inputFile{background-color: " + colors.normal + ";color:" + colors.text + ";border: 1px solid " + $("#adminBorderBlockColor").val() + ";}"; - - // Ajout du css au DOM - $("#themePreview").remove(); - $("