PageSourceSearch

https://www.ville-vezinlecoquet.fr/wp-content/plugins/creasit-annuaire-contacts/js/prop-modif-contact.js

js ville-vezinlecoquet.fr collected 2026-10-02 06:09:43 UTC 11,945 bytes, 283 lines download raw bytes

1jQuery(function ($)
2{
3    // Masque des champs SIRET et RNA
4    // ---------------------------------------------------------------
5    $("#siret-contact").inputmask("999-999-999-99999");
6    $("#rna-contact").inputmask("999999999");
7
8
9    // Au click sur le btn "proposer une manifestation"
10    // ---------------------------------------------------------------
11
12    $('.single-contacts .soumettre-fiche, .div-prop-contact, .wrapper-panel .propose-contact a').not('.disabled').click(function ()
13    {
14        $('form#soumettre-fiche-form').show();
15        $('#overlay-back').fadeIn('fast');
16        $('#proposition-contact, #proposition-publication').fadeIn('fast');
17        $('html,body').animate({scrollTop: heightProp}, 'slow');
18    });
19
20    // Au click sur l'overlay
21    // ---------------------------------------------------------------
22
23    $('#overlay-back').click(function ()
24    {
25        $(this).fadeOut('fast');
26        $('#proposition-contact, #proposition-publication').fadeOut('fast');
27    });
28
29    // Au click sur la croix
30    // ---------------------------------------------------------------
31
32    $('a.close-popup').click(function ()
33    {
34        $('#overlay-back').fadeOut('fast');
35        $('#proposition-contact, #proposition-publication').fadeOut('fast');
36        return false;
37    });
38
39    // Au click sur Suivant
40    // ---------------------------------------------------------------
41
42    $('a.btn-suivant-form').click(function ()
43    {
44        $('#proposition-contact .information-contact, #proposition-publication .information-contact').css('display', 'none');
45        $('#proposition-contact .information-contact-suite, #proposition-publication .information-contact-suite').css('display', 'block');
46        $('html,body').animate({scrollTop: heightProp}, 'slow');
47    });
48
49    // Au click sur Précédent
50    // ---------------------------------------------------------------
51
52    $('a.btn-precedent-form').click(function ()
53    {
54        $('#proposition-contact .information-contact, #proposition-publication .information-contact').css('display', 'block');
55        $('#proposition-contact .information-contact-suite, #proposition-publication .information-contact-suite').css('display', 'none');
56        $('html,body').animate({scrollTop: heightProp}, 'slow');
57    });
58
59    // Au click sur la checkbox googlemap
60    // ---------------------------------------------------------------
61    var gmapCheckbox = $('.checkboxgmap input');
62    let html = ' <span style="color: #E20C0C">*</span>';
63
64    $(gmapCheckbox).on('change', function ()
65    {
66        if ($(this).is(':checked')) {
67            $('#proposition-publication .bloc-form.hideStart, .class-commune-form-prop .bloc-form.hideStart').slideToggle('slow');
68        } else {
69            $('#proposition-publication .bloc-form.hideStart, .class-commune-form-prop .bloc-form.hideStart').slideUp('slow');
70        }
71
72        // Rendre le label Commune(s) concernée(s) obligatoire si la checkbox coché GoogleMap est "Oui".
73        // ---------------------------------------------------------------
74
75        if ($('.checkboxgmap input:checked').val() === 'oui') {
76            $('.commune-contacts label').append(html);
77        } else {
78            $('.commune-contacts label span').remove();
79        }
80    });
81
82    // Stock les id des communes délégées sélectionnées
83    // ---------------------------------------------------------------
84
85    let selected_Commune = [];
86
87    $(".commune-contacts input[type='radio']:checked").each(function ()
88    {
89        selected_Commune.push($(this).val());
90    });
91
92    $('.communes-deleguees input').on('click', function ()
93    {
94        if ($(this).is(":checked")) // "this" refers to the element that fired the event
95        {
96            selected_Commune.push($(this).attr('id'));
97        } else {
98            selected_Commune.splice($.inArray($(this).attr('id'), selected_Commune), 1);
99        }
100    });
101
102    // Désactiver la touche entrée sur le champ "Mot clé"
103    // ---------------------------------------------------------------
104    $('#keywords_annuaire').on('keyup keypress', function (e)
105    {
106        var keyCode = e.keyCode || e.which;
107        if (keyCode === 13) {
108            e.preventDefault();
109            return false;
110        }
111    });
112
113    // Au click sur "Soumettre"
114    // ---------------------------------------------------------------
115
116    $('form#soumettre-fiche-form').submit(function ()
117    {
118
119        let $form = $(this);
120        let $inputs = $form.find("input, select, button, textarea");
121
122        console.log($inputs);
123
124        $('#soumettre-fiche').attr("disabled", "disabled");
125
126        $('form#soumettre-fiche-form .error').remove();
127        let hasError = false;
128
129        // Vérification checkbox RGPD
130        let hasErrorRgpd;
131        if ($('.checkbox-rgpd').is(':checked')) {
132            // hasError = false;
133            hasErrorRgpd = false;
134            $('.checkbox-rgpd').parent().removeClass('error-form');
135            $('.error').remove();
136        } else {
137            // hasError = true;
138            hasErrorRgpd = true;
139            $('.checkbox-rgpd').parent().addClass('error-form');
140            $('.checkbox-rgpd').parent().after('<p class="error">Veuillez cocher la case afin d\'accepter le partage de vos données personnelles.</p>');
141        }
142
143        $('form#soumettre-fiche-form label span.obligatoire').parent().next().each(function ()
144        {
145            if (!$(this).hasClass('cats-contact')) {
146                if (jQuery.trim($(this).val()) === '') {
147                    let labelText = $(this).prev('label').text();
148                    $(this).parent().append('<p class="error">Ce champ est obligatoire.</p>');
149                    hasError = true;
150                } else if ($(this).hasClass('email')) {
151                    let emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
152                    if (!emailReg.test(jQuery.trim($(this).val()))) {
153                        let labelText = $(this).prev('label').text();
154                        $(this).parent().append('<p class="error">Votre ' + labelText + ' est invalide.</p>');
155                        hasError = true;
156                    }
157                }
158            }
159        });
160
161        let boxGmapYes = $('#checkbox-google-map.oui');
162        if ($('.commune-contacts').length && (selected_Commune.length === 0 && boxGmapYes.is(':checked'))) {
163            let commune = $('.commune-contacts label');
164            let labelCommune = $(commune).text();
165            $(commune).parent().append('<p class="error">Ce champ est obligatoire.</p>');
166            hasError = true;
167        }
168
169        // valSite = $('form#soumettre-fiche-form #site-internet-contact').val();
170        // http = valSite.substr(0,7)
171        // troiswww = valSite.substr(0,4);
172        // if(valSite != ""){
173        //     if(http == "http://" || troiswww == "www."){
174        //         hasError = false;
175        //     } else {
176        //         $(this).parent().find('p.error').remove();
177        //         $(this).parent().append('<p class="error">Votre site internet est invalide. Un site internet doit commencer par http:// ou www.</p>');
178        //         hasError = true;
179        //     }
180        // }
181
182        // var catContacts = '';
183        // var categoriesContact = [];
184        // $("input[type='checkbox']:checked").each(function() {
185        //     catContacts = $(this).attr('id');
186        //     categoriesContact.push(catContacts);
187        // });
188
189        // if(catContacts.length == 0 || catContacts == undefined) {
190        //     $(this).parent().find('p.error').remove();
191        //     $('.cats-contact').parent().append('<p class="error">Séléctionnez au moins une catégorie.</p>');
192        //     hasError = true;
193        // }
194
195
196        if (hasError && !hasErrorRgpd) {
197            $('#proposition-contact .information-contact, #proposition-publication .information-contact').css('display', 'block');
198            $('#proposition-contact .information-contact-suite, #proposition-publication .information-contact-suite').css('display', 'none');
199            $('html,body').animate({scrollTop: heightProp}, 'slow');
200        }
201
202
203        // Vérifier si le champ nepasremplir est rempli (anti-span)
204        var spam = true;
205        if (jQuery.trim($('form#soumettre-fiche-form #nepasremplir').val()) == '') {
206            spam = false;
207        }
208
209        if (!hasError && !hasErrorRgpd && !spam) {
210
211            $form.parent().append('<span class="loader"></span>');
212
213            var imagePrincipale = []
214            if ($('form#soumettre-fiche-form #image-principale-contact').val() != '') {
215                var imageContact = $('form#soumettre-fiche-form #image-principale-contact').prop('files')[0];
216                imagePrincipale.push(imageContact.name);
217                imagePrincipale.push(imageContact.size);
218                imagePrincipale.push(imageContact.type);
219            }
220
221
222            var form = $(this)[0];
223            var form_data = new FormData(form);
224            if (imageContact) {
225                form_data.append('file', imageContact);
226            }
227            form_data.append('action', 'traitement_prop_modif_contact');
228            $.ajax({
229                type: 'POST',
230                url: document.location.origin + '/wp-admin/admin-ajax.php',
231                processData: false,
232                contentType: false,
233                data: form_data,
234                dataType: 'JSON',
235
236                success: function (statut)
237                {
238                    $('.error').empty();
239                    $('span.loader').remove();
240                    $('html,body').animate({scrollTop: heightProp}, 'slow');
241                    if ($('body').hasClass('single-contacts')) {
242                        $('form#soumettre-fiche-form').before('<p class="thanks">Merci pour votre proposition de modification. Elle sera étudiée par l\'équipe en charge du site avant d\'être mise en ligne.');
243                    } else {
244                        $('form#soumettre-fiche-form').before('<p class="thanks">Merci pour votre proposition. Elle sera étudiée par l\'équipe en charge du site avant d\'être mise en ligne.');
245                    }
246                    $('#proposition-contact .intro, #proposition-publication .intro').hide();
247                    $('form#soumettre-fiche-form').hide();
248                    $('#soumettre-fiche').removeAttr("disabled");
249                },
250
251                error: function (resultat, statut, erreur)
252                {
253                    console.log(resultat);
254                    console.log(statut);
255                    console.log(erreur);
256                    $('span.loader').remove();
257                    if ($('body').hasClass('single-contacts')) {
258                        $('form#soumettre-fiche-form').before('<p class="error">Une erreur s\'est produite lors de l\'envoi de votre modification de contact. Merci de contacter l\'administrateur.</p>');
259                    } else {
260                        $('form#soumettre-fiche-form').before('<p class="error">Une erreur s\'est produite lors de l\'envoi de votre proposition de contact. Merci de contacter l\'administrateur.</p>');
261                    }
262                    $('#proposition-contact .intro, #proposition-publication .intro').hide();
263                    $('#soumettre-fiche').removeAttr("disabled");
264                },
265
266                complete: function (resultat, statut)
267                {
268                    let btn_submit_form = $('.soumettre-fiche');
269                    $(btn_submit_form).attr("disabled");
270                    $(btn_submit_form).text('Demande de modifications en cours...');
271                    $(btn_submit_form).css('pointer-events', 'none');
272                    $(btn_submit_form).addClass('disabled');
273                }
274            });
275        } else {
276            $('#soumettre-fiche').removeAttr("disabled");
277        }
278
279        return false;
280
281    });
282
283});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.