PageSourceSearch

https://www.ville-pacy-sur-eure.fr/wp-content/themes/citeo-2/assets/js/citeo.utilities.js

js ville-pacy-sur-eure.fr collected 2026-10-02 12:19:43 UTC 13,028 bytes, 431 lines download raw bytes

1// ==========================================================================
2// FUNCTIONS
3// ==========================================================================
4
5/*
6* Permet de transformer une string en camel case
7*/
8function toCamelCase(string) {
9    return string.replace(/[-_]([a-z])/g, function (g) { return g[1].toUpperCase(); });
10}
11
12
13/*
14* Permet de merger 2 tableaux de paramètres
15*/
16function dataAttrToParams(initParams, newParams) {
17    delete newParams.ride;
18    delete newParams.toggle;
19
20    $.each(newParams, function(index, val) {
21        var newIndex = toCamelCase(index);
22        initParams[newIndex] = newParams[index];
23    });
24
25    return initParams;
26}
27
28
29function throttle(callback, delay) {
30    var last;
31    var timer;
32    return function () {
33        var context = this;
34        var now = +new Date();
35        var args = arguments;
36        if (last && now < last + delay) {
37            clearTimeout(timer);
38            timer = setTimeout(function () {
39                last = now;
40                callback.apply(context, args);
41            }, delay);
42        } else {
43            last = now;
44            callback.apply(context, args);
45        }
46    };
47}
48
49function debounce(callback, delay){
50    var timer;
51    return function(){
52        var args = arguments;
53        var context = this;
54        clearTimeout(timer);
55        timer = setTimeout(function(){
56            callback.apply(context, args);
57        }, delay);
58    };
59}
60
61function is_front_page() {
62    if ( $('body').hasClass('home')) {
63        return true;
64    } else {
65        return false;
66    }
67}
68
69/*
70* Permet d'égaliser la hauteur des éléments passés en paramètre
71*/
72function equalize( $items, resizable ) {
73
74    if ( typeof resizable == 'undefined') {
75        resizable = true;
76    }
77
78    if ( resizable ) {
79        $(window).on('load', function() {
80            $items.css( 'height', 'auto' );
81            var maxHeight = 0;
82            $items.each(function(index, el) {
83                if ($(el).outerHeight() > maxHeight) {
84                    maxHeight = $(el).outerHeight();
85                }
86            });
87            $items.css('height', maxHeight);
88        });
89
90        window.addEventListener('resize', debounce(function(e){
91            equalize( $items, false );
92        }, 300));
93
94    } else {
95
96        $items.css( 'height', 'auto' );
97        var maxHeight = 0;
98        $items.each(function(index, el) {
99            if ($(el).outerHeight() > maxHeight) {
100                maxHeight = $(el).outerHeight();
101            }
102        });
103        $items.css('height', maxHeight);
104    }
105}
106
107
108/*
109* Permet d'afficher un coverflow sur owlcarousel
110*/
111function coverflowCarousel( $carousel, breakpoint ) {
112    if (typeof breakpoint == 'undefined') {
113        breakpoint = 1200;
114    }
115    if (typeof $carousel !== 'undefined') {
116        if ($(window).width() > (breakpoint - 1) ) {
117            if (!$carousel.hasClass('owl-carousel-coverflow')) {
118                $carousel.addClass('owl-carousel-coverflow');
119            }
120            $carousel
121                .removeClass('owl-carousel-inline')
122                .find('.main-active').removeClass('main-active');
123
124            setTimeout(function() {
125                var $activeItem = $carousel.find('.owl-item.active'),
126                activeLength = $activeItem.length;
127
128                if ( activeLength > 1 ) {
129                    $activeItem.eq( Math.ceil(activeLength / 2 - 1)).addClass('main-active');
130                }
131            }, 1);
132
133        } else {
134            $carousel.removeClass('owl-carousel-coverflow').addClass('owl-carousel-inline');
135        }
136    }
137}
138
139
140
141// ==========================================================================
142// CUSTOMS SCRIPTS
143// ==========================================================================
144$(function() {
145
146
147    /*
148     * Instance du plugin OWL Carousel (v2)
149     */
150    if ( $.fn.owlCarousel ) {
151        $('[data-ride="owl-carousel"]').each(function() {
152
153            var initParams = {
154                    autoplaySpeed: 750,
155                    dotsSpeed: 450,
156                    autoplayTimeout: 5000,
157                    autoplayHoverPause : true,
158                    autoplay: false,
159                    dots: false,
160                    navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
161                    nav: true,
162                    items: 1,
163                    loop: true
164                },
165                newParams = $(this).data();
166
167            newParams = dataAttrToParams(initParams, newParams);
168            $(this).owlCarousel(newParams);
169        });
170    }
171
172
173    /*
174    * Instance (via data-attrs) du plugin FatMenu
175    */
176    if($.fn.FatMenu) {
177        $('[data-toggle="fatmenu"]').each(function(index, el) {
178            var initParams = {
179                    pushOnShow          : false,
180                    overlay             : true,
181                    mobileBreakpoint    : 1200,
182                    BackButtonContent   : '<i class="fa fa-angle-left"></i> Retour',
183                },
184                newParams = $(this).data();
185
186            newParams = dataAttrToParams(initParams, newParams);
187            $(this).FatMenu(newParams);
188        });
189    }
190
191
192    /*
193    * Instance de la fonction de hauteur d'élement automatique
194    */
195    $('[data-equalize]').each(function(index, el) {
196        var $el = $(el),
197            children = $(el).data('equalize'),
198            $modals = $el.parents('.modal');
199
200        if ( $el.find(children).length ) {
201            if ( $modals.length > 0 ) {
202                $modals.on('shown.bs.modal', function (event) {
203                    equalize( $el.find(children) );
204                });
205            } else {
206                equalize( $el.find(children) );
207            }
208        }
209    });
210
211
212    /*
213    * Instance du plugin outdated browser
214    */
215    outdatedBrowser({
216        bgColor: '#f25648',
217        color: '#ffffff',
218        lowerThan: 'transform',
219        languagePath: '../libs/outdatedbrowser/outdatedbrowser/lang/fr.html'
220    });
221
222
223    /*
224    * Permet d'éviter de remonter en haut de la page lors de l'ouverture du offcanvas
225    */
226    $('[data-toggle="offcanvas"]').on('click', function(event) {
227        event.preventDefault();
228    });
229
230
231    /*
232    * Permet d'instancier les popover
233    */
234    $('[data-toggle="popover"]').popover();
235
236
237    /*
238    * Ajoute une classe sur le bouton (déclencheur) quand un élément collaspe est affiché
239    */
240    $('.panel-collapse')
241        .on('show.bs.collapse', function () {
242            var id = $(this).attr('id');
243            $('[href="#' + id + '"]').addClass('active');
244        })
245        .on('hide.bs.collapse', function () {
246            var id = $(this).attr('id');
247            $('[href="#' + id + '"]').removeClass('active');
248        });
249
250
251
252
253    /*
254    * Gestion de l'élement fixe social-toolbar
255    */
256    function fixSocialShare() {
257
258    	var $socialFixed = $('.social-toolbar-fixed'),
259            $article = $('.article'),
260            breakpoint = $socialFixed.data('breakpoint');
261
262            if (typeof breakpoint == 'undefined') {
263                breakpoint = 1350;
264            }
265
266        $socialFixed.each(function(index, el) {
267            var $el = $(el);
268
269            if ( $el.parents('.modal').length ) {
270
271                $el
272                    .removeClass('social-toolbar-fixed')
273                    .removeData("bs.affix")
274                    .removeClass("affix affix-top affix-bottom")
275                    .removeAttr("style");
276                    
277            } else {
278
279                // Si la fenêtre est plus large que le breakpoint défini en data-attr
280                if ( $(window).width() > breakpoint ) {
281
282                    // Si il y a un article sur la page
283                    if ($article.length) {
284
285                        var affixTop = 130,
286                            articleHeight = $article.outerHeight(),
287                            articleTop = $article.offset().top - affixTop,
288                            articleBottom = articleTop + affixTop - 15 + articleHeight,
289                            documentLength = $(document).outerHeight(),
290
291                            aTop = articleTop,
292                            aBottom = documentLength - articleBottom;
293
294                        // Si l'article fait plus de 360 pixels de hauteur
295                        if (articleHeight > 360) {
296
297                            $el
298                                .addClass('social-toolbar-fixed')
299                                .affix({
300                                    offset: {
301                                        top: aTop,
302                                        bottom: aBottom,
303                                    }
304                                }).on('affix.bs.affix', function () { // before affix
305                                    $(this).css({
306                                        /*'top': headerHeight,*/    // for fixed height
307                                        'width': $(this).outerWidth()  // variable widths
308                                    });
309                                });
310
311                        } else {
312
313                            $el
314                                .removeClass('social-toolbar-fixed');
315
316                        }
317
318                    }
319
320                } else {
321
322                    // $(window).off('.affix');
323                    $el
324                        .removeClass('social-toolbar-fixed')
325                        .removeData("bs.affix")
326                        .removeClass("affix affix-top affix-bottom")
327                        .removeAttr("style");
328
329                }
330            }
331            
332        });
333
334    }
335
336
337    /*
338    * Gestion de l'élement fixe back to top
339    */
340    function fixBackToTop() {
341
342        var $backToTop = $('#back-to-top');
343
344        // Si il y a l'élement back to top
345        if ( $backToTop.length ) {
346            if ( ($(window).height() + 100) < $(document).height() ) {
347                $backToTop.removeClass('hidden').affix({
348                    offset: {
349                        top: 100,
350                    }
351                });
352            }
353        }
354
355    }
356
357
358    /*
359    * Gestion de l'élement fixe navigation
360    */
361    function fixNavigation() {
362
363        var $nav = $('#layout-navigation');
364
365        // Si le data-attr affix est égal à true
366        if ( $nav.data('affix') ) {
367
368            var top = $nav.offset().top;
369            $nav.affix({ offset: { top: top } });
370            
371        }
372
373    }
374
375
376    /*
377    * Lancement de différente fonction (attends le chargement de toutes les images)
378    */
379    $(window).on('load', function(event) {
380
381        fixNavigation();
382
383        fixBackToTop();
384
385        fixSocialShare();
386        
387        // Recalcule les éléments si la fenêtre est resizée
388        $(window).on('resize', throttle(function(e){
389            fixSocialShare();
390        }, 100)).resize();
391
392    });
393
394
395
396
397    // Permet d'activer les fonctions de partage sur la classe .sharer
398    $('.sharer').click(function(e){
399        e.preventDefault();
400        v_this = $(this);
401
402        var leftPosition, topPosition;
403        leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
404        topPosition = (window.screen.height / 2) - ((height / 2) + 50);
405        var width = 520;
406        var height = 350;
407        var windowFeatures = 'status=no,height=' + height + ',width=' + width + ',resizable=yes,left=' + leftPosition + ',top=' + topPosition + ',screenX=' + leftPosition + ',screenY=' + topPosition + ',toolbar=no,menubar=no,scrollbars=no,location=no,directories=no';
408        var t = document.title;
409
410        if( v_this.data('share-network') == 'facebook'){
411            window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(v_this.data('share-link'))+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
412        }
413        if( v_this.data('share-network') == 'google'){
414            window.open('https://plus.google.com/share?url=='+encodeURIComponent(v_this.data('share-link')),'sharer', windowFeatures);
415        }
416        if( v_this.data('share-network') == 'twitter'){
417            window.open('http://twitter.com/home?status='+encodeURIComponent(v_this.data('share-title'))+' '+encodeURIComponent(v_this.data('share-link')),'sharer', windowFeatures);
418        }
419        if( v_this.data('share-network') == 'linkedin'){
420            window.open('https://www.linkedin.com/shareArticle?mini=true&url=' + encodeURIComponent(v_this.data('share-link')) + '&title=' + encodeURIComponent(v_this.data('share-title')),'sharer', windowFeatures);
421        }
422        // if( v_this.data('share-network') == 'twitter-2'){
423        //     window.open('http://twitter.com/home?status='+encodeURIComponent('Participez aux Etats Généraux du Parti Socialiste #egps ')+encodeURIComponent(v_this.data('share-link')),'sharer', windowFeatures);
424        //     if( v_this.data('share-ref-stats') !== '')
425        //         updateTwitterCount(v_this.data('share-ref-stats'));
426        // }
427
428        return false;
429    });
430
431});

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.