Clean code

This commit is contained in:
Fred Tempez 2022-12-31 15:42:58 +01:00
parent c45ef8ccf1
commit df041b2214

View File

@ -96,8 +96,8 @@ core.confirm = function(text, yesCallback, noCallback) {
lightbox.options('button', false);
$(document).on('lity:close', function(event, instance) {
if (
instance.options('button') === false
&& typeof noCallback !== "undefined"
instance.options('button') === false &&
typeof noCallback !== "undefined"
) {
noCallback();
}
@ -174,8 +174,7 @@ core.start = function() {
$(window).on("scroll", function() {
if ($(this).scrollTop() > 200) {
backToTopDOM.fadeIn();
}
else {
} else {
backToTopDOM.fadeOut();
}
});
@ -254,14 +253,14 @@ core.start = function() {
/**
* Sélection d'une langue du site
*/
$("#barSelectLanguage").on("change", function() {
var lang = $(this).val();
console.log (lang);
if(lang) {
$(location).attr("href", lang);
var langUrl = $(this).val();
var langCookie = getCookie('ZWII_CONTENT');
if (langUrl !== langCookie) {
$(location).attr("href", langUrl);
}
});
});*/
/**
* Choix de page dans la barre de membre
*/
@ -282,8 +281,7 @@ core.start = function() {
if (fileName === "") {
fileName = "Choisissez un fichier";
$(inputFileHiddenDOM).addClass("disabled");
}
else {
} else {
$(inputFileHiddenDOM).removeClass("disabled");
}
inputFileHiddenDOM.parent().find(".inputFileLabel").text(fileName);
@ -330,8 +328,7 @@ core.start = function() {
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 {
} else {
message = "<?php echo helper::translate('Format incorrect');?>";
core.noticeAdd(_this.attr("id"), message);
}
@ -378,6 +375,8 @@ core.start = function() {
}
}).trigger("resize");
};
@ -414,6 +413,32 @@ core.relativeLuminanceW3C = function(rgba) {
return .2126 * R + .7152 * G + .0722 * B;
};
// 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);
}
$(document).ready(function() {
@ -452,6 +477,7 @@ $(document).ready(function(){
item.addClass('active')
.find('.accordion-content').slideDown(speed);
}
function close(item, speed) {
accordion.find('.accordion-item').removeClass('active')
.find('.accordion-content').slideUp(speed);
@ -480,8 +506,7 @@ $(document).ready(function(){
var changeIcon = $('#toggle').children("span");
if ($(changeIcon).hasClass('zwiico-menu')) {
$(changeIcon).removeClass('zwiico-menu').addClass('zwiico-cancel');
}
else {
} else {
$(changeIcon).addClass('zwiico-menu');
};
});
@ -491,4 +516,5 @@ $(document).ready(function(){
*/
if (/^\?fbclid=/.test(location.search))
location.replace(location.href.replace(/\?fbclid.+/, ""));
});