PageSourceSearch

https://www.renater.fr/wp-content/themes/jetpress/js/scripts.js?ver=0.2.0

js renater.fr collected 2026-09-24 08:34:27 UTC 18,913 bytes, 447 lines download raw bytes

1/**
2 * Created by glejoncour on 13/06/2017.
3 */
4
5 (function ($) {
6
7    $(document).ready(function () {
8
9        // Responsive menu
10        if (mobileAndTabletcheck() || $(window).width() <= 992) {
11            $('.burger-menu').removeClass('hide');
12            $('#main-menu').addClass('hide');
13            $('#mobile-menu').removeClass('hide');
14        } else {
15            $('.burger-menu').addClass('hide');
16            $('#main-menu').removeClass('hide');
17            $('#mobile-menu').addClass('hide');
18        }
19
20        // Menu Mobile
21        new mlPushMenu( document.getElementById( 'mp-menu' ), document.getElementById( 'burger-menu' ) );
22
23        if($('form[data-activate-open-close="1"]').length > 0) {
24            $('form[data-activate-open-close="1"]').addClass('sb-search--absolute');
25
26            new UISearch($('form[data-activate-open-close="1"]').get(0));
27        } else {
28            $('form[data-activate-open-close]').addClass('sb-search-open');
29        }
30
31        // Change background menu on Scroll by in overlay
32        var bgColors = $(".home_bg_menu_transition").attr("data-bgColor"),
33            scroll_pos = 0;
34
35        $(window).scroll(function () {
36            if ($(this).scrollTop() > 300) {
37                $('#back-top').fadeIn();
38            } else {
39                $('#back-top').fadeOut();
40            }
41
42            scroll_pos = $(this).scrollTop();
43            if(scroll_pos > 210) {
44                $(".home_bg_menu_transition").css('background-color', 'rgb('+ bgColors +')');
45            } else {
46                $(".home_bg_menu_transition").css('background-color', 'transparent');
47            }
48        });
49
50        // scroll body to 0px on click
51        $('#back-top').click(function () {
52            $('body,html').animate({
53                scrollTop: 0
54            }, 1000);
55            return false;
56        });
57
58        $(window).on('resize', function (e) {
59            if (mobileAndTabletcheck() || $(window).width() <= 992) {
60                $('.burger-menu').removeClass('hide');
61                $('#main-menu').addClass('hide');
62                $('#mobile-menu').removeClass('hide');
63            } else {
64                $('.burger-menu').addClass('hide');
65                $('#main-menu').removeClass('hide');
66                $('#mobile-menu').addClass('hide');
67            }
68        });
69        set_header_height();
70        $(window).resize(set_header_height);
71        $('#archive-filters').on('change', 'input[type="checkbox"]', function(){
72            var url = '<?php echo home_url(); ?>',
73                args = {};
74
75            // loop over filters
76            $('#archive-filters .filter').each(function(){
77                var filter = $(this).data('filter'),
78                    vals = [];
79
80                // find checked inputs
81                $(this).find('input:checked').each(function(){
82                    vals.push( $(this).val() );
83                });
84
85                // append to args
86                args[ filter ] = vals.join(',');
87            });
88
89            // update url
90            url += '?';
91
92            // loop over args
93            $.each(args, function( name, value ){
94                url += name + '=' + value + '&';
95            });
96
97            // remove last &
98            url = url.slice(0, -1);
99
100            // reload page
101            window.location.replace( url );
102        });
103    });
104    
105    function set_header_height() {
106        var $headerWrapper = $('#header'),
107            $mainWrapper = $('#page-wrapper'),
108            $footerWrapper = $('#wrapper-footer'),
109            $adminBar = $('#wpadminbar'),
110            headerHeight = 0 || $headerWrapper.outerHeight(),
111            footerHeight = 0 || $footerWrapper.outerHeight();
112
113        if($adminBar.length > 0){
114            headerHeight = headerHeight + $adminBar.outerHeight();
115        }
116
117        $mainWrapper.get(0).style.minHeight = 'calc(100vh - ' + (headerHeight + footerHeight) + 'px)';
118
119        //Sticky-menu
120        var adminbarHeight = $adminBar.height(),
121            navbarHeight = $( '.navbar' ).height();
122
123        $('body.admin-bar .fixed-top').css('top', adminbarHeight);
124
125        // Spec for TitleTwo without background menu
126        // @todo Add switch to choose if menu is transparent
127        if (false){
128            $('.nav-fixed-top .cover').css('padding-top', navbarHeight);
129        }else{
130             $('.nav-fixed-top #page-wrapper').css('margin-top', navbarHeight);
131        }
132    }
133
134    function hasParent( e, id ) {
135        if (!e) {return false;}
136        var el = e.target||e.srcElement||e||false;
137        while (el && el.id !== id) {
138            el = el.parentNode||false;
139        }
140        return (el!==false);
141    }
142
143    // returns the depth of the element "e" relative to element with id=id
144    // for this calculation only parents with classname = waypoint are considered
145    function getLevelDepth( element, parents ) {
146        var cnt = 0;
147
148        cnt = $(element).parents('.' + parents).length + 1;
149
150        return cnt;
151    }
152
153    function  mobileAndTabletcheck() {
154        var check = false;
155        (function (a) {
156            if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
157        })(navigator.userAgent || navigator.vendor || window.opera);
158        return check;
159    }
160
161    function UISearch( element, options ) {
162        this.element = element;
163        this.$element = $(element);
164        this.$inputEl = this.$element.find( '> input.sb-search-input' );
165        this._initEvents();
166    }
167
168    UISearch.prototype = {
169        _initEvents : function() {
170            var self = this,
171                initSearchFn = function( ev ) {
172                    ev.stopPropagation();
173                    // trim its value
174
175                    if(typeof self.$inputEl.value !== "undefined") {
176                        self.$inputEl.value = self.$inputEl.value.trim();
177                    }
178
179                    if( !self.$element.hasClass( 'sb-search-open' ) ) { // open it
180                        ev.preventDefault();
181                        self.open();
182                    }
183                    else if( self.$element.hasClass( 'sb-search-open' ) && /^\s*$/.test( self.$inputEl.value ) ) { // close it
184                        ev.preventDefault();
185                        self.close();
186                    }
187                };
188
189            this.$element.bind( 'click', initSearchFn );
190            this.$element.bind( 'touchstart', initSearchFn );
191            this.$inputEl.bind( 'click', function( ev ) { ev.stopPropagation(); });
192            this.$inputEl.bind( 'touchstart', function( ev ) { ev.stopPropagation(); } );
193        },
194        open : function() {
195            var self = this;
196
197            this.$element.addClass( 'sb-search-open' );
198            // focus the input
199            if( !mobileAndTabletcheck() ) {
200                this.$inputEl.focus();
201            }
202            // close the search input if body is clicked
203            var bodyFn = function( ev ) {
204                self.close();
205                $(this).unbind( 'click', bodyFn );
206                $(this).unbind( 'touchstart', bodyFn );
207            };
208            $(document).bind( 'click', bodyFn );
209            $(document).bind( 'touchstart', bodyFn );
210        },
211        close : function() {
212            this.$inputEl.blur();
213            this.$element.removeClass( 'sb-search-open' );
214        }
215    }
216
217    // add to global namespace
218    window.UISearch = UISearch;
219
220    function mlPushMenu( el, trigger, options ) {
221        this.el = el;
222        this.$el = $(el);
223        this.trigger = trigger;
224        this.options = $.extend( this.defaults, options );
225        this._init();
226    }
227
228    mlPushMenu.prototype = {
229        defaults : {
230            // overlap: there will be a gap between open levels
231            // cover: the open levels will be on top of any previous open level
232            type : 'overlap', // overlap || cover
233            // space between each overlaped level
234            levelSpacing : 40,
235            // classname for the element (if any) that when clicked closes the current level
236            backClass : 'mp-back',
237
238            moveType : 'normal'
239        },
240        _init : function() {
241            // if menu is open or not
242            this.open = false;
243            // level depth
244            this.level = 0;
245            // the moving wrapper
246            this.wrapper = document.getElementById( 'mp-pusher' );
247            // the mp-level elements
248            this.levels = Array.prototype.slice.call( this.$el.find( 'div.mp-level' ) );
249            // save the depth of each of these mp-level elements
250            var self = this;
251            this.levels.forEach( function( el, i ) { $(el).attr( 'data-level', getLevelDepth( el, 'mp-level' ) ); } );
252            // the menu items
253            this.menuItems = Array.prototype.slice.call( this.$el.find( 'li' ) );
254            // if type == "cover" these will serve as hooks to move back to the previous level
255            this.levelBack = Array.prototype.slice.call( this.$el.find( '.' + this.options.backClass ) );
256            // event type (if mobile use touch events)
257            this.eventtype = mobileAndTabletcheck() ? 'touchstart' : 'click';
258            // add the class mp-overlap or mp-cover to the main element depending on options.type
259            this.$el.addClass('mp-' + this.options.type );
260            // initialize / bind the necessary events
261            this._initEvents();
262        },
263        _initEvents : function() {
264            var self = this;
265
266            // the menu should close if clicking somewhere on the body
267            var bodyClickFn = function( el ) {
268                self._resetMenu();
269                $(self.trigger).removeClass('active');
270                el.removeEventListener( self.eventtype, bodyClickFn );
271            };
272
273            // open (or close) the menu
274            $(this.trigger).on( this.eventtype, function( ev ) {
275                ev.stopPropagation();
276                ev.preventDefault();
277                if( self.open ) {
278                    self._resetMenu();
279                }
280                else {
281                    self._openMenu();
282                    // the menu should close if clicking somewhere on the body (excluding clicks on the menu)
283                    document.addEventListener( self.eventtype, function( ev ) {
284                        if( self.open && !hasParent( ev.target, self.el.id ) ) {
285                            bodyClickFn( this );
286                        }
287                    } );
288                }
289            } );
290
291            // opening a sub level menu
292            this.menuItems.forEach( function( el, i ) {
293                // check if it has a sub level
294                var subLevel = $(el).find( 'div.mp-level' );
295                if( subLevel  && $(el).hasClass('has-child')) {
296                    $(el).find( '> a' ).on( self.eventtype, function( ev ) {
297                        var target = $(this).attr('href');
298                        if (target.indexOf('#') != -1) {
299                            ev.preventDefault();
300                            var level = $(this).closest( '.mp-level' ).attr( 'data-level' );
301
302                            if( self.level <= level ) {
303                                ev.stopPropagation();
304                                $(this).closest( '.mp-level' ).addClass( 'mp-level-overlay' );
305                                self._openMenu( subLevel.get(0) );
306                            }
307                        }
308
309                    } );
310                    $(el).find( '> span' ).on( self.eventtype, function( ev ) {
311
312                            ev.preventDefault();
313                            var level = $(this).closest( '.mp-level' ).attr( 'data-level' );
314
315                            if( self.level <= level ) {
316                                ev.stopPropagation();
317                                $(this).closest( '.mp-level' ).addClass( 'mp-level-overlay' );
318                                self._openMenu( subLevel.get(0) );
319                            }
320
321
322                    } );
323                }
324            } );
325
326            // closing the sub levels :
327            // by clicking on the visible part of the level element
328            this.levels.forEach( function( el, i ) {
329                $(el).on( self.eventtype, function( ev ) {
330                    ev.stopPropagation();
331                    if(!$(ev.target).is('a')) {
332                        ev.preventDefault();
333                        var level = $(this).attr('data-level');
334                        if (self.level > level) {
335                            self.level = parseInt(level) + 1;
336                            self._closeMenu();
337                        }
338                    }
339                } );
340            } );
341
342            // by clicking on a specific element
343            this.levelBack.forEach( function( el, i ) {
344                $(el).on( self.eventtype, function( ev ) {
345                    ev.preventDefault();
346                    var level = $(this).closest( '.mp-level' ).attr( 'data-level' );
347
348                    if( self.level <= level ) {
349                        ev.stopPropagation();
350                        self.level = $(this).closest('.mp-level' ).attr( 'data-level' );
351                        self.level === 0 ? self._resetMenu() : self._closeMenu();
352                    }
353                } );
354            } );
355        },
356        _openMenu : function( subLevel ) {
357            // increment level depth
358            ++this.level;
359
360            // move the main wrapper
361            var levelFactor = ( this.level - 1 ) * this.options.levelSpacing,
362                translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + levelFactor : this.el.offsetWidth;
363
364            if(this.options.moveType !== 'push') {
365                translateVal = translateVal - 300;
366            }
367
368            this._setTransform('translate3d(' + translateVal + 'px,0,0)');
369
370            if( subLevel ) {
371                // reset transform for sublevel
372                this._setTransform( '', subLevel );
373                // need to reset the translate value for the level menus that have the same level depth and are not open
374                for( var i = 0, len = this.levels.length; i < len; ++i ) {
375                    var levelEl = this.levels[i];
376                    if( levelEl !== subLevel && !$(levelEl).hasClass( 'mp-level-open' ) ) {
377                        this._setTransform( 'translate3d(-100%,0,0) translate3d(' + -1*levelFactor + 'px,0,0)', levelEl );
378                    }
379                }
380            }
381            // add class mp-pushed to main wrapper if opening the first time
382            if( this.level === 1 ) {
383                $(this.wrapper).addClass( 'mp-pushed' );
384                this.open = true;
385            }
386            var element = subLevel || this.levels[0];
387            // add class mp-level-open to the opening level element
388            $(element).addClass( 'mp-level-open' );
389            $(this.trigger).addClass('active');
390        },
391
392        // close the menu
393        _resetMenu : function() {
394            this._setTransform('');
395            this.level = 0;
396            this._toggleLevels();
397            // remove class mp-pushed from main wrapper
398            $(this.wrapper).removeClass( 'mp-pushed' );
399            $(this.trigger).removeClass('active');
400            this.open = false;
401        },
402
403        // close sub menus
404        _closeMenu : function() {
405            --this.level;
406
407            var levelFactor = ( this.level -1 ) * this.options.levelSpacing,
408                translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + levelFactor : this.el.offsetWidth;
409
410            if(this.options.moveType !== 'push') {
411                translateVal = translateVal - 300;
412            }
413
414            this._setTransform( 'translate3d(' + translateVal + 'px,0,0)' );
415            this._toggleLevels();
416        },
417
418        // translate the el
419        _setTransform : function( val, el ) {
420            var wrapper = this.options.moveType === 'push' ? this.wrapper : this.el;
421            el = el || wrapper;
422            el.style.WebkitTransform = val;
423            el.style.MozTransform = val;
424            el.style.transform = val;
425        },
426
427        // removes classes mp-level-open from closing levels
428        _toggleLevels : function() {
429            for( var i = 0, len = this.levels.length; i < len; ++i ) {
430                var levelEl = this.levels[i];
431                if( $(levelEl).attr( 'data-level' ) >= this.level + 1 ) {
432                    $(levelEl).removeClass( 'mp-level-open' );
433                    $(levelEl).removeClass( 'mp-level-overlay' );
434                }
435                else if( Number( $(levelEl).attr( 'data-level' ) ) === this.level ) {
436                    $(levelEl).removeClass( 'mp-level-overlay' );
437                }
438            }
439        }
440    };
441
442    // add to global namespace
443    window.mlPushMenu = mlPushMenu;
444
445     $('p:empty').remove();
446
447})(jQuery);

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.