PageSourceSearch

https://www.detailcar.fr/Wagaia/views/assets/js/custom.js

js detailcar.fr collected 2026-10-08 12:19:05 UTC 16,882 bytes, 557 lines download raw bytes

1
2$(document).ready( function () {
3
4    let windowWidth = $(window).width();
5
6
7    // NAV GENERALE
8    // On centre les bordures
9    // let mainNav = $('.navs');
10
11    // HOMEPAGE => home_slider => Slider
12    let sliderHome =  $('.slider-home');
13    if(sliderHome.length > 0) {
14
15        sliderHome.bxSlider({
16            auto: true,
17            touchEnabled: false,
18            controls: false
19        });
20
21    }
22
23    // HOMEPAGE => list-testimonials => Slider
24    let sliderTestimonial =  $('.slider-testimonial');
25    if(sliderTestimonial.length > 0) {
26
27        let sWidth = '400px';
28        let minSl = 3;
29        let maxSl = 3;
30
31        if(windowWidth <= 992) {
32            minSl = 2;
33            maxSl = 2;
34        }
35
36        if(windowWidth <= 768) {
37            sWidth = 0;
38            minSl = 2;
39            maxSl = 1;
40        }
41
42        sliderTestimonial.bxSlider({
43            pager: false,
44            minSlides: minSl,
45            maxSlides: maxSl,
46            moveSlides: 1,
47            slideWidth: sWidth,
48            slideMargin: 70,
49            nextSelector: '#nextSel',
50            prevSelector: '#prevSel',
51            nextText: '',
52            prevText: ''
53        });
54
55    }
56
57    // HOMEPAGE => list-news => Links articles
58    let listNews =  $('.list-news');
59    if(listNews.length > 0) {
60
61        listNews.on('click', 'article', function () {
62            document.location = $(this).find('h3 a').attr('href');
63        });
64
65    }
66
67    // HOMEPAGE => bloc description => toggle
68    $(document).on('click', '#toggleDesc', function () {
69        $(this).text('Découvrir Detail Car').addClass('active').removeAttr('id').parents('.row').prev('.row').removeClass('hidden').slideDown();
70        return false;
71    });
72
73    $('.list-nav .navs > .col.active').prev().addClass('removeBorder');
74    $('.list-nav .navs > .col').hover(
75        function() {
76            $(this).prev().addClass('removeBorder');
77            $('.list-nav .navs > .col.active').prev().addClass('removeBorder');
78        }, function() {
79            $(this).prev().removeClass('removeBorder');
80            $('.list-nav .navs > .col.active').prev().addClass('removeBorder');
81        }
82    );
83
84
85    // LISTE PRESTATION
86    // Pour que les vignettes des prestations fasse la même hauteur
87    let blocService = $('.list-service');
88    if(blocService.length > 0) {
89
90        let elemsBlueBlock = $('.blue-block');
91
92        let maxHeight = Math.max.apply(null, elemsBlueBlock.map(function () {
93            return $(this).height();
94        }).get());
95
96        elemsBlueBlock.find('div.row').height(maxHeight);
97
98    }
99
100    // PRESTATION => rendre tout un bloc clickable
101    $(document).on('click', '.clickable', function () {
102        window.location.href = $(this).data('url');
103    });
104
105
106    // PRESTATION => comparaison 2 images Avant / aprés
107    let comparePicture =  $('#compare');
108    if(comparePicture.length > 0) {
109        new BeerSlider( document.getElementById( "compare" ) );
110    }
111
112    // PRESTATION
113    // Bouton qui permet d'afficher le numéro de téléphone du point de vente lors d'un clic
114    if($('.show-tel').length > 0) {
115
116        $(document).on('click', '.show-tel', function () {
117
118            let btn = $(this);
119
120            if(btn.attr('href') != '#') {
121                return true;
122            }
123
124            let phone = btn.data('tel');
125            btn.attr('href', 'tel:'+phone).text(phone);
126
127            return false;
128        });
129
130    }
131
132    // Bouton qui permet d'afficher une modal avec un formulaire de contact
133    if($('#modal-contact-form').length > 0) {
134
135        $(document).on('submit', '#modal-contact-form', function (e) {
136            e.preventDefault();
137
138            let recaptchaSiteKey = $(this).find('input#sitekey').val();
139            let form = $(this);
140
141            grecaptcha.ready(function () {
142                grecaptcha.execute(recaptchaSiteKey).then(function (token) {
143
144                    $('#g-recaptcha-response').val(token);
145
146                    $.ajax({
147                        url: '/Wagaia/views/ajax/contact-form.php',
148                        type: 'POST',
149                        dataType: 'json',
150                        data: form.serialize(),
151                        success: function (data) {
152
153                            if(data.status === 'error') {
154                                form.find('.alert-danger').html(data.message).removeClass('hidden');
155                            }
156
157                            if(data.status === 'success') {
158
159                                form.find('.b-send').remove();
160                                form.find('.alert-danger').remove();
161                                form.find('input, textarea').remove();
162                                form.find('.alert-success').html(data.message).removeClass('hidden');
163                                form.find('.b-close').text('Fermer');
164                            }
165                        }
166                    });
167
168
169                });
170            });
171
172            return false;
173
174        });
175    }
176
177
178
179    // DEVENIR FRANCHISE
180    let sliderGallery =  $('.slider-gallery');
181    if(sliderGallery.length > 0) {
182
183        sliderGallery.bxSlider({
184            mode: 'fade',
185            pager: true,
186            controls: false
187        });
188
189    }
190
191    // PAGES OU SE TROUVE LA LISTE DES CATEGORIES
192    let listCategoriesNav =  $('.list-categories-slider');
193    if(listCategoriesNav.length > 0) {
194
195        let owlc = listCategoriesNav.owlCarousel({
196            loop: false,
197            nav: false,
198            dots: false,
199            items: 2,
200            stagePadding: 80,
201            responsive : {
202                // breakpoint from 768 up
203                768 : {
204                    items : 3,
205                    stagePadding: 50,
206                }
207            }
208        });
209
210        let activeItem = listCategoriesNav.find('.owl-item:not(.cloned)').find('.current').parent().index();
211
212        owlc.trigger('to.owl.carousel', activeItem-2);
213        return false;
214
215    }
216
217    // FORMULAIRE DE CONTACT
218    $("#agency-select").change(function () {
219        if($(this).val() == "0") $(this).addClass("empty");
220        else $(this).removeClass("empty")
221    });
222    $("#agency-select").change();
223
224
225    if ($(window).width() < 768) {
226
227        let elemListNav = $('.list-nav .navs > div');
228        let widthTotal = 0;
229
230        elemListNav.each(function (index) {
231            widthTotal += $(this).width();
232        });
233
234        $('.list-nav .navs').width(widthTotal);
235    }
236
237    // Pour que le scroll prenne en compte la hauteur du menu
238    // Pour que le scroll prenne en compte la hauteur du menu
239    $(".scroll-animate").click(function() {
240
241        let target = $(this).attr('href'); //.replace(/#/g, ".");
242        let navHeight = $("header").outerHeight();
243
244       $('body').scrollTo($(target).offset().top - navHeight -30);
245
246        return false;
247    });
248
249    // MOBILE => SUR TOUTES LES PAGES
250    $(document).on('submit', '#findAgencyForm', function () {
251        if($(this).find('input[name=cartStatus]').length > 0) {
252            $('#warningStoreModal').modal('show');
253            return false;
254        }
255    });
256
257    // Wizard
258    if($('.chosen-select-car').length > 0) {
259
260        $('.chosen-select-car').chosen({
261            allow_single_deselect: true,
262            placeholder_text_single: "Rechercher un véhicule",
263            no_results_text: "Pas de résultat",
264            include_group_label_in_selected: true,
265        });
266
267    }
268
269    if($('#btn-immat').length > 0) {
270
271        $('#btn-immat').on('click', function (e) {
272
273            let licenseNumber = $('#license_number').val();
274            let carId = $('.chosen-select-car').val();
275            let validation = true;
276
277            // Sauvegarde en session de la plaque d'immatriculation
278            if(licenseNumber) {
279
280                $.ajax({
281                    url: '/Wagaia/views/ajax/save-licence-number.php',
282                    type: 'POST',
283                    dataType: 'json',
284                    data: "licence_number="+licenseNumber,
285                    success: function (data) {
286
287                        if (data.status === 1) {
288
289                            $('.error-container').find('div')
290                                .html("Veuillez renseigner l'immatriculation de votre véhicule")
291                                .parent().removeClass('hidden');
292                            $('#btn-add-to-cart').addClass('hidden');
293                            $('.no-available').addClass('hidden');
294                            $('#bloc-info').hide();
295
296                            validation = false;
297
298                        }
299                    }
300                });
301
302            }
303
304            if(isEmpty(licenseNumber) || licenseNumber == '' || licenseNumber == ' ' || licenseNumber == '  ') {
305
306                $('.error-container').find('div')
307                    .html("Veuillez renseigner l'immatriculation de votre véhicule")
308                    .parent().removeClass('hidden');
309                $('#btn-add-to-cart').addClass('hidden');
310                $('.no-available').addClass('hidden');
311                $('#bloc-info').hide();
312
313                validation = false;
314            }
315
316
317            if(carId == 0) {
318
319                $('.error-container').find('div')
320                    .html('Veuillez sélectionner votre type de véhicule')
321                    .parent().removeClass('hidden');
322                $('#btn-add-to-cart').addClass('hidden');
323                $('.no-available').addClass('hidden');
324                $('#bloc-info').hide();
325
326                validation = false;
327            }
328
329            if(validation) {
330
331                $.ajax({
332                    url: '/Wagaia/views/ajax/get-service.php',
333                    type: 'POST',
334                    dataType: 'json',
335                    data: "car_id=" + carId,
336                    success: function (data) {
337
338                        if(data.status === 1) {
339
340                            $('#bloc-info').html(data.message).show();
341                            $('#btn-add-to-cart').removeClass('hidden').show();
342                            $('.no-available').addClass('hidden');
343                            $('.error-container').addClass('hidden');
344                        }
345                        if(data.status === 2) {
346
347                            $('.no-available').removeClass('hidden').find('a').attr('href', data.message);
348                            $('#bloc-info').hide();
349                            $('#btn-add-to-cart').hide();
350                            $('.error-container').addClass('hidden');
351                        }
352                        if(data.status === 3) {
353
354                            $('.no-available').addClass('hidden');
355                            $('#bloc-info').hide();
356                            $('#btn-add-to-cart').hide();
357                            $('.error-container').addClass('hidden');
358
359                            $('.linkstore').removeClass('hidden').html(data.message);
360                        }
361
362                        if ($(window).width() < 768) {
363                            $('html, body').animate({
364                                scrollTop: $("#aba").offset().top - 100
365                            });
366                        }
367
368                    },
369                    error: function (xhr, ajaxOptions, thrownError) {
370                        console.log(thrownError);
371                    }
372                });
373
374            }
375
376            return false;
377
378        });
379
380
381
382        /*$(document).on('change', '.chosen-select-car', function () {
383
384            let carId = $(this).val();
385
386            $.ajax({
387                url: '/Wagaia/views/ajax/get-service.php',
388                type: 'POST',
389                dataType: 'json',
390                data: "car_id=" + carId,
391                success: function (data) {
392
393                    if(data.status === 1) {
394
395                        $('#bloc-info').html(data.message).show();
396                        $('#btn-add-to-cart').removeClass('hidden').show();
397                        $('.no-available').addClass('hidden');
398                    }
399                    if(data.status === 2) {
400
401                        $('.no-available').removeClass('hidden').find('a').attr('href', data.message);
402                        $('#bloc-info').hide();
403                        $('#btn-add-to-cart').hide();
404                    }
405                    if(data.status === 3) {
406
407                        $('.no-available').addClass('hidden');
408                        $('#bloc-info').hide();
409                        $('#btn-add-to-cart').hide();
410
411                        $('.linkstore').removeClass('hidden').html(data.message);
412                    }
413
414                },
415                error: function (xhr, ajaxOptions, thrownError) {
416                    console.log(thrownError);
417                }
418            });
419
420        });*/
421
422        //$('.chosen-select-car').trigger('change');
423    }
424
425    // Step 3 du panier
426    // Choix de l'horaire du rendez-vous
427    if($('.schedule-slider').length > 0) {
428
429        let owl = $('.schedule-slider').owlCarousel({
430            dots: false,
431            nav: false,
432            responsive:{
433                0:{
434                    items: 3
435                },
436                600:{
437                    items: 3
438                },
439                1000:{
440                    items: 5
441                }
442            }
443        });
444
445        //let countItem = $('.schedule-slider').find('.item.active');
446        //console.log(countItem);
447
448
449        // resized.owl.carousel
450        /*owl.on('initialized.owl.carousel', function(e) {
451            console.log(e);
452            alert('ok');
453            //$(e.target).toggleClass('hide-nav', e.item.count <= e.page.size);
454        });*/
455
456
457        $('.next-btn').click(function() {
458            owl.trigger('next.owl.carousel');
459            return false;
460        });
461
462        $('.prev-btn').click(function() {
463            owl.trigger('prev.owl.carousel');
464            return false;
465        });
466
467        let heights = $(owl).find('.item').map(function () {
468            return $(this).height();
469        }).get();
470
471        maxHeight = Math.max.apply(null, heights);
472        $(owl).find('.item').height((maxHeight/2)+100);
473
474        $(owl).find('.active:last .time').addClass('no-border');
475
476        //translate.owl.carousel
477        owl.on('translated.owl.carousel', function(event) {
478
479            $(this).find('.owl-item .time').removeClass('no-border');
480            $(this).find('.active:last .time').addClass('no-border');
481            $(this).find('.active:first ').prev().find('.time').addClass('no-border');
482
483        });
484
485    }
486
487    $('#type').on('change', function () {
488
489        let val = $(this).val();
490
491        if(val === 'Pro') {
492            $('.row-pro').removeClass('hidden');
493        }
494        else {
495            $('.row-pro').addClass('hidden');
496        }
497
498    });
499
500    // Step 4 du panier
501    // Il faut accepter les CGV avant de pouvoir aller sur le paiement
502    $(document).on('click', '#btn-payment', function () {
503
504        let isCgvChecked = $('#cgv:checked').val();
505        let isEarlyExecutionChecked = !$('#early-execution').length || $('#early-execution:checked').val();
506
507        if(!isCgvChecked || !isEarlyExecutionChecked) {
508            $('#accepteCgvModal').modal('show');
509            return false;
510        }
511
512        //alert(isCgvChecked);
513        //return false;
514    });
515
516
517    // PAGE CREATION DE COMPTE
518    // Permet de vérifier si il y a bien rattachement
519    if($('.check-fusion').length > 0) {
520        setTimeout(checkFusionClient, 2000);
521    }
522
523    function checkFusionClient()
524    {
525        let params = $('#params').data('params');
526
527        $.ajax({
528            type: 'POST',
529            dataType: 'json',
530            url: 'Wagaia/views/ajax/check-fusion-client.php',
531            data: {params: params},
532            success: function (data) {
533                if(data.state === 'merged') {
534                    window.location.href = data.link;
535                }
536            },
537            complete: function () {
538                setTimeout(checkFusionClient, 4000);
539            }
540        });
541    }
542
543});
544
545
546
547
548$.fn.extend({
549    toggleText: function(a, b){
550        return this.text(this.text() == b ? a : b);
551    }
552});
553
554
555function isEmpty(str) {
556    return (!str || str.length === 0 );
557}

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.