const previewModele1Footer = $('#modele1-footer');
const previewModele2Footer = $('#modele2-footer');
const previewModele3Footer = $('#modele3-footer');
// Liste des options
const logoFooterCheckbox = $('#theme_option_actif_logo_footer');
const logoPositionGauche = $('#theme_option_position_logo_footer_0');
const logoPositionDroite = $('#theme_option_position_logo_footer_1');
const logoPositionDessus = $('#theme_option_position_logo_footer_2');
const telFooterCheckbox = $('#theme_option_actif_tel_footer');
const titreTelFooterCheckbox = $('#theme_option_actif_titre_tel_footer');
const emailFooterCheckbox = $('#theme_option_actif_email_footer');
const titreEmailFooterCheckbox = $('#theme_option_actif_titre_email_footer');
const adresseFooterCheckbox = $('#theme_option_actif_adresse_footer');
const titreAdresseFooterCheckbox = $('#theme_option_actif_titre_adresse_footer');
const horairesFooterCheckbox = $('#theme_option_actif_horaires_footer');
const titreHorairesFooterCheckbox = $('#theme_option_actif_titre_horaires_footer');
const socialFooterCheckbox = $('#theme_option_actif_reseaux_sociaux_footer');
const button1FooterCheckbox = $('#theme_option_actif_bouton1_footer');
const pictosInfosFooterCheckbox = $('#theme_option_actif_pictos_info_footer');
const codeqrFooterCheckbox = $('#theme_option_actif_codeqr_footer');
const texteFooterCheckbox = $('#theme_option_actif_texte_footer');
const nbrContactsInput = $('#theme_option_nbr_contacts_footer');
const logoCopyrightCheckbox = $('#theme_option_actif_logo_copyright');
const dateCopyrightCheckbox = $('#theme_option_actif_date_copyright');
const bgTopFooter = $('#theme_option_bg_color_top_footer');
const colorTopFooter = $('#theme_option_color_top_footer');
const colorTopFooterHover = $('#theme_option_color_top_footer_hover');
const bgSubFooter = $('#theme_option_bg_color_sub_footer');
const colorSubFooter = $('#theme_option_color_sub_footer');
// Liste des elements
const logo_footer = $('#logo-footer').val();
const logoFooterElement = $('
').html('
');
const telFooterElement = $('').text('01 23 45 67 89');
const titreTelFooterElement = $('').text('Tél : ');
const emailFooterElement = $('').text('info@example.com');
const titreEmailFooterElement = $('').text('Email : ');
const adresseFooterElement = $('').text('Num rue, 1234 Ville');
const titreAdresseFooterElement = $('').text('Adresse : ');
const horairesFooterElement = $('').text('Lundi : 08h00-18h00');
const titreHorairesFooterElement = $('').text('Horaires : ');
const socialFooterElement = $('').html(' ');
const button1FooterElement = $('').html('Bouton 1');
const codeqrFooterElement = $('').html('
Le Lorem Ipsum est simplement du faux texte');
const texteFooterElement = $('').html('Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression.
');
const pictoTelFooter = $('').addClass('fa fa-phone mx-2');
const pictoEmailFooter = $('').addClass('fa fa-envelope mx-2');
const pictoAdresseFooter = $('').addClass('fa fa-map-marker mx-2');
const pictoHorairesFooter = $('').addClass('fa fa-clock mx-2');
const footerLeft = $('.footer-left');
const footerRight = $('.footer-right');
const logoCopyRightElement = $('').html('
');
const imageMapElement = $('.map-footer');
var date = new Date();
//var formattedDate = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
var formattedDate = date.getFullYear();
const dateCopyRightElement = $('').text(" | "+formattedDate);
// Déclaration des fonctions
function previewFooterModele1() {
//console.log('exec 1');
previewFooterGeneralOptions(previewModele1Footer);
}
function previewFooterModele2() {
//console.log('exec 2');
previewFooterGeneralOptions(previewModele2Footer);
}
function previewFooterModele3() {
//console.log('exec 2');
previewFooterGeneralOptions(previewModele3Footer);
}
function addRemoveInfoFooter(checkboxName, elementName, ParentElement){
let classElement;
if(elementName.attr("class") !== undefined){
classElement = "."+elementName.attr("class").replace(' ','.');
}else{
classElement = "."+ParentElement.attr("class").replace(' ','.')+" "+elementName.prop("tagName");
}
if (checkboxName.prop('checked')) {
if(elementName.prop("tagName") !== "SPAN"){
(!$(classElement).length) ? ParentElement.append(elementName) : "";
}else{
(!$(classElement).length) ? ParentElement.prepend(elementName) : "";
}
}else{
(elementName.length) ? elementName.remove() : "";
}
}
function previewFooterGeneralOptions(previewModele){
const footerTop = previewModele.find('.top-footer');
const footerBottom = previewModele.find('.sub-footer');
const copyright = previewModele.find('.sub-footer .footer-bottom .copyright');
let infosFooterElement;
if(!$('.items-top').length){
infosFooterElement = $('').addClass('items-top');
}else{
infosFooterElement = $('.items-top');
}
// Ajouter / supprimer les informations
let contactsFooterElement;
if(!$('.infos-contact-footer').length){
contactsFooterElement = $('').addClass('infos-contact-footer');
}else{
contactsFooterElement = $('.infos-contact-footer');
}
contactsFooterElement.html("");
let itemContactsFooterElement;
if(!$('.item-infos-contact-footer').length){
itemContactsFooterElement = $('').addClass('item-infos-contact-footer');
}else{
itemContactsFooterElement = $('.item-infos-contact-footer');
}
addRemoveInfoFooter(adresseFooterCheckbox,adresseFooterElement,itemContactsFooterElement);
//if(previewModele !== previewModele2Footer ){
addRemoveInfoFooter(titreAdresseFooterCheckbox,titreAdresseFooterElement,adresseFooterElement);
//}else{
// Traitement titre adresse pour le modele footer 2 (Ajout du titre au dessus de bloc)
//}
addRemoveInfoFooter(horairesFooterCheckbox,horairesFooterElement,itemContactsFooterElement);
addRemoveInfoFooter(titreHorairesFooterCheckbox,titreHorairesFooterElement,horairesFooterElement);
addRemoveInfoFooter(telFooterCheckbox,telFooterElement,itemContactsFooterElement);
addRemoveInfoFooter(titreTelFooterCheckbox,titreTelFooterElement,telFooterElement);
addRemoveInfoFooter(emailFooterCheckbox,emailFooterElement,itemContactsFooterElement);
addRemoveInfoFooter(titreEmailFooterCheckbox,titreEmailFooterElement,emailFooterElement);
if (pictosInfosFooterCheckbox.prop('checked')) {
telFooterElement.prepend(pictoTelFooter);
emailFooterElement.prepend(pictoEmailFooter);
adresseFooterElement.prepend(pictoAdresseFooter);
horairesFooterElement.prepend(pictoHorairesFooter);
}else{
(pictoTelFooter.length) ? pictoTelFooter.remove() : "";
(pictoEmailFooter.length) ? pictoEmailFooter.remove() : "";
(pictoAdresseFooter.length) ? pictoAdresseFooter.remove() : "";
(pictoHorairesFooter.length) ? pictoHorairesFooter.remove() : "";
}
contactsFooterElement.append(itemContactsFooterElement);
for (let nbContacts = 1; nbContacts <= nbrContactsInput.val(); nbContacts++) {
if(itemContactsFooterElement.length