PageSourceSearch

http://stranieriinitalia.it/wp-content/themes/bimber/js/global.js?ver=9.2.1

js stranieriinitalia.it collected 2026-09-24 09:29:40 UTC 47,419 bytes, 1,602 lines download raw bytes

1/* global window */
2/* global document */
3/* global jQuery */
4/* global g1 */
5/* global bimber_front_config */
6/* global SuperGif */
7/* global Waypoint */
8/* global enquire */
9/* global mashsb */
10/* global auto_load_next_post_params */
11/* global FB */
12/* global mejs */
13/* global ga */
14/* global embedly */
15/* global console */
16
17/*************
18 *
19 * Init env
20 *
21 *************/
22
23(function($) {
24    'use strict';
25
26    var config = bimber_front_config;
27
28    // namespace
29    var g1 = {
30        'config': config
31    };
32
33    g1.getWindowWidth = function () {
34        if (typeof window.innerWidth !== 'undefined') {
35            return window.innerWidth;
36        }
37
38        return $(window).width();
39    };
40
41    g1.isDesktopDevice = function () {
42        return g1.getWindowWidth() > g1.getDesktopBreakpoint();
43    };
44
45    g1.getDesktopBreakpoint = function () {
46        var desktopBreakPoint = $('#g1-breakpoint-desktop').css('min-width');
47
48        if ( ! desktopBreakPoint ) {
49            return 9999;
50        }
51
52        desktopBreakPoint = parseInt( desktopBreakPoint, 10 );
53
54        // not set explicitly via css
55        if (desktopBreakPoint === 0) {
56            return 9999;
57        }
58
59        return desktopBreakPoint;
60    };
61
62    g1.isTouchDevice = function () {
63        return ('ontouchstart' in window) || navigator.msMaxTouchPoints;
64    };
65
66    g1.isStickySupported = function () {
67        var prefixes = ['', '-webkit-', '-moz-', '-ms-'];
68        var block = document.createElement('div');
69        var supported = false;
70        var i;
71
72        // Test for native support.
73        for (i = prefixes.length - 1; i >= 0; i--) {
74            try {
75                block.style.position = prefixes[i] + 'sticky';
76            }
77            catch(e) {}
78            if (block.style.position !== '') {
79                supported = true;
80            }
81        }
82
83        return supported;
84    };
85
86    g1.isRTL = function () {
87        return $('body').is('.rtl');
88    };
89
90    g1.log = function(data) {
91        if ((g1.config.debug_mode || window.bimberDebugMode) && typeof console !== 'undefined') {
92            if ($.isArray(data)) {
93                for (var i in data) {
94                    console.log(data[i]);
95                }
96            } else {
97                console.log(data);
98            }
99        }
100    };
101
102    g1.createCookie = function (name,value,time) {
103        var expires;
104
105        if (time) {
106            var date = new Date();
107            var ms = time;
108
109            if (typeof time === 'object') {
110                ms = time.value;
111
112                switch (time.type) {
113                    case 'days':
114                        ms = ms * 24 * 60 * 60 * 1000;
115                        break;
116                }
117            }
118
119            date.setTime(date.getTime() + ms);
120            expires = '; expires=' + date.toGMTString();
121        }
122        else {
123            expires = '';
124        }
125
126        document.cookie = name + '=' + value + expires + '; path=/';
127    };
128
129	g1.readCookie = function (name) {
130        var nameEQ = name + '=';
131        var ca = document.cookie.split(';');
132
133        for(var i = 0; i < ca.length; i += 1) {
134            var c = ca[i];
135            while (c.charAt(0) === ' ') {
136                c = c.substring(1,c.length);
137            }
138
139            if (c.indexOf(nameEQ) === 0) {
140                return c.substring(nameEQ.length,c.length);
141            }
142        }
143
144        return null;
145    };
146
147	g1.removeCookie = function (name) {
148        g1.createCookie(name, '', -1);
149    };
150
151    // expose to the world
152    window.g1 = g1;
153})(jQuery);
154
155/*************
156 *
157 * UI Helpers
158 *
159 ************/
160
161(function ($) {
162
163    'use strict';
164
165    g1.uiHelpers = function () {
166        if (g1.isTouchDevice()) {
167            $('body').removeClass( 'g1-hoverable' );
168        }
169
170        // -----------------
171        // Mailchimp widget.
172        // -----------------
173
174        var mc4wpClasses = [
175            'g1-box',
176            'g1-box-tpl-frame',
177            'g1-newsletter'
178        ];
179
180        var mc4wpBackgroundClasses = [
181            'g1-box-background'
182        ];
183
184        if ('original-2018' === g1.config.stack || 'food' === g1.config.stack ) {
185            mc4wpBackgroundClasses.push('g1-current-background');
186        }
187
188        if ( 'miami' === g1.config.stack || 'music' === g1.config.stack ) {
189            mc4wpClasses.push('g1-dark');
190        }
191
192        $('.widget_mc4wp_form_widget').
193            addClass(mc4wpClasses.join(' ')).
194            wrapInner('<div class="g1-box-inner"></div>').
195            prepend('<div class="g1-box-icon"></div>').
196            append('<div class="' + mc4wpBackgroundClasses.join(' ') + '"></div>');
197
198
199
200        // -----------
201        // bbPress.
202        // -----------
203
204        var bbPressBackgroundClasses = [
205            'g1-box-background'
206        ];
207
208        if ('original-2018' === g1.config.stack || 'food' === g1.config.stack ) {
209            bbPressBackgroundClasses.push('g1-current-background');
210        }
211
212        $('.bbp_widget_login').
213            addClass('g1-box g1-box-tpl-frame').
214            wrapInner('<div class="g1-box-inner"></div>').
215            append('<div class="' + bbPressBackgroundClasses.join(' ') + '"></div>');
216
217
218        // ----------
219        // Search UI.
220        // ----------
221
222        $('.g1-drop-the-search').on('click', '.g1-drop-toggle', function (e) {
223            e.preventDefault();
224
225           $('.g1-drop-the-search input.search-field').focus();
226        });
227
228        $('.search-submit').on('click', function(e){
229            var $form = $(this).closest('form');
230            var $input = $('input.search-field', $form);
231            if ( ! $input.val()){
232               e.preventDefault();
233            }
234        });
235
236        $('#buddypress .load-more').click(function() {
237            var i = 0;
238            var intervalID = setInterval( function() {
239                $('body').trigger( 'g1PageHeightChanged' );
240                i++;
241                if (i === 5){
242                    window.clearInterval(intervalID);
243                }
244            },1000);
245        });
246    };
247
248})(jQuery);
249
250/****************
251 *
252 * Facebook SDK
253 *
254 ****************/
255
256(function ($) {
257
258    'use strict';
259
260    g1.resetFacebookSDK = function () {
261        $('script#facebook-jssdk').remove();
262        $('#fb-root').remove();
263        if (window.FB) {
264            delete window.FB;
265        }
266    };
267
268    $('body').on( 'g1BeforeNewContentReady', function ( e, $newContent ) {
269        if ($newContent.find('.fb-video').length > 0) {
270            g1.resetFacebookSDK();
271        }
272    } );
273
274})(jQuery);
275
276/****************
277 *
278 * Instagram SDK
279 *
280 ****************/
281
282(function ($) {
283
284    'use strict';
285
286    $('body').on( 'g1NewContentLoaded', function ( e, $newContent ) {
287        if ($newContent.find('.instagram-media').length > 0) {
288            if (typeof instgrm !== 'undefined' && typeof instgrm.Embeds !== 'undefined') {
289                instgrm.Embeds.process();
290            }
291        }
292    } );
293
294})(jQuery);
295
296/********************
297 *
298 * Load More Button
299 *
300 ********************/
301
302(function ($) {
303
304    'use strict';
305
306    // prevent triggering the action more than once at the time
307    var loading = false;
308    var startingUrl = window.location.href;
309    var setTargetBlank = g1.config.setTargetBlank;
310    var useWaypoints = g1.config.useWaypoints;
311
312    g1.loadMoreButton = function () {
313        $('.g1-load-more').on('click', function (e) {
314            if (loading) {
315                return;
316            }
317
318            loading = true;
319
320            e.preventDefault();
321
322            var $button = $(this);
323            var $collectionMore = $button.parents('.g1-collection-more');
324            var url = $button.attr('data-g1-next-page-url');
325            var $endMessage = $('.g1-pagination-end');
326
327            $collectionMore.addClass('g1-collection-more-loading');
328
329            // load page
330            var xhr = $.get(url);
331
332            // on success
333            xhr.done(function (data) {
334                var collectionSelector = '#primary > .g1-collection .g1-collection-items';
335
336                // find elements in response
337                var $resCollectionItems = $(data).find(collectionSelector).find('.g1-collection-item');
338                var $resButton = $(data).find('.g1-load-more');
339
340                // find collection on page
341                var $collection = $(collectionSelector);
342
343                // add extra classes to new loaded items
344                $resCollectionItems.addClass('g1-collection-item-ad
344ded');
345
346                // If there are insta embeds BEFORE the load, we will force to refresh them AFTER the load
347                var $insta = $('script[src="//platform.instagram.com/en_US/embeds.js"]');
348
349                // make sure that mejs is loaded
350                if (window.wp && typeof window.wp.mediaelement === 'undefined') {
351                    var matches = data.match(/<script(.|\n)*?<\/script>/g);
352                    var mejsCode = '';
353                    matches.forEach(function( match ) {
354                        if ( match.indexOf('mejs') > 0 || match.indexOf('mediaelement') > 0 ){
355                            match = match.replace('<script','<script async');
356                            mejsCode+=match;
357                        }
358                    });
359                    matches = data.match(/<link(.|\n)*?\/>/g);
360                    matches.forEach(function( match ) {
361                        if ( match.indexOf('mejs') > 0 || match.indexOf('mediaelement') > 0 ){
362                            mejsCode+=match;
363                        }
364                    });
365                    $collection.after(mejsCode);
366                }
367                if (setTargetBlank) {
368                    $('a',$resCollectionItems).attr('target','_blank');
369                }
370
371                var $collection_waypoint = '<span class="bimber-collection-waypoint" data-bimber-archive-url="' + url + '"></span>';
372                $collection.append($collection_waypoint);
373                // add new elements to collection
374                $collection.append($resCollectionItems);
375
376                // Google Analytics.
377                if ( typeof ga !== 'undefined' && typeof ga.getAll !== 'undefined') {
378                    ga('create', ga.getAll()[0].get('trackingId'), 'auto');
379                    ga('set', { location: url });
380                    ga('send', 'pageview');
381                }
382
383                if ( $insta.length > 0) {
384                    window.instgrm.Embeds.process();
385                }
386
387                if (window.wp && typeof window.wp.mediaelement !== 'undefined') {
388                    window.wp.mediaelement.initialize();
389                }
390
391                // load all dependent functions
392                $('body').trigger( 'g1PageHeightChanged' );
393                $('body').trigger( 'g1NewContentLoaded', [ $resCollectionItems ] );
394
395                // update more button
396                if ($resButton.length > 0) {
397                    $button.attr('data-g1-next-page-url', $resButton.attr('data-g1-next-page-url'));
398                } else {
399                    $collectionMore.remove();
400                }
401
402                //bind auto play video events
403                if (typeof g1.autoPlayVideo === 'function') {
404                    g1.autoPlayVideo();
405                }
406
407                if ( useWaypoints ){
408                    $('.bimber-collection-waypoint').waypoint(function(direction) {
409                        var $waypoint = $(this.element);
410                        if('up' === direction) {
411                            var $waypointUp = $waypoint.prevAll('.bimber-collection-waypoint');
412                            if ($waypointUp.length > 0){
413                                $waypoint = $($waypointUp[0]);
414                            } else {
415                                window.history.replaceState( {} , '', startingUrl );
416                                return;
417                            }
418                        }
419                        var waypointUrl = $waypoint.attr('data-bimber-archive-url');
420                        var currentUrl = window.location.href;
421                        if ( waypointUrl !== currentUrl ){
422                            window.history.replaceState( {} , '', waypointUrl );
423                        }
424                    }, {
425                        offset: '-5%'
426                    });
427                }
428            });
429
430            xhr.fail(function () {
431                $button.addClass('g1-info-error');
432                $button.remove();
433                $endMessage.show();
434            });
435
436            xhr.always(function () {
437                $collectionMore.removeClass('g1-collection-more-loading');
438                loading = false;
439            });
440        });
441    };
442
443})(jQuery);
444
445
446/*******************
447 *
448 * Infinite scroll
449 *
450 ******************/
451
452(function ($) {
453
454    'use strict';
455
456    g1.infiniteScrollConfig = {
457        'offset': '150%'
458    };
459
460    var triggeredByClick = false;
461
462    g1.infiniteScroll = function () {
463        $('.g1-collection-more.infinite-scroll').each(function () {
464            var $this = $(this);
465
466            if ($this.is('.on-demand') && !triggeredByClick) {
467                return false;
468            }
469
470            $this.waypoint(function(direction) {
471                if('down' === direction) {
472                    $this.find('.g1-load-more').trigger('click');
473                }
474            }, {
475                // trigger when the "Load More" container is 10% under the browser window
476                offset: g1.infiniteScrollConfig.offset
477            });
478        });
479    };
480
481    // wait for new content and apply infinite scroll events to it
482    $('body').on( 'g1NewContentLoaded', function () {
483        triggeredByClick = true;
484        g1.infiniteScroll();
485    } );
486
487})(jQuery);
488
489
490
491/*******************
492 *
493 * Date > Time ago
494 *
495 ******************/
496
497(function ($) {
498
499    'use strict';
500
501    g1.dateToTimeago = function () {
502        if (!$.fn.timeago) {
503            return;
504        }
505
506        var $body = $('body');
507
508        $('time.entry-date, span.entry-date > time, .comment-metadata time, time.snax-item-date').timeago();
509
510        $body.on( 'g1NewContentLoaded', function (e, $newContent) {
511            if ($newContent) {
512                $newContent.find('time.entry-date, .comment-metadata time, time.snax-item-date').timeago();
513            }
514        } );
515
516        // CommentAce integration.
517        $body.on( 'caceWpCommentInitialized', function (e) {
518            $(e.detail).find('time.entry-date, .comment-metadata time, time.snax-item-date').timeago();
519        } );
520    };
521
522})(jQuery);
523
524
525/**********
526 *
527 * Canvas
528 *
529 *********/
530
531(function($) {
532    'use strict';
533
534    var selectors = {
535        'toggle':   '.g1-hamburger'
536    };
537
538    g1.globalCanvasSelectors = selectors;
539
540    var canvas;
541
542    g1.canvas = function() {
543        canvas = Canvas();
544
545        // Allow global access.
546        g1.canvasInstance = canvas;
547
548        $(selectors.toggle).on('click', function (e) {
549            e.preventDefault();
550
551            //$('html, body').animate({ // @maybe
552            //    scrollTop: 0 // @maybe
553            //}, 10); // @maybe
554
555            canvas.toggle();
556        });
557    };
558
559    function Canvas () {
560        var that = {};
561        var listeners = {
562            'open': [],
563            'close': []
564        };
565
566        var currentContent = '';
567
568        var currentScroll = 0; // @maybe
569
570        var _clientY;
571
572        var init = function () {
573            var $overlay = $( '.g1-canvas-overlay');
574
575            // toogle canvas events
576            $overlay.on('click', that.toggle);
577
578            $('.g1-canvas').on('toggle-canvas', function () {
579                that.toggle();
580            });
581
582            $('.g1-canvas .g1-canvas-toggle').on('click', that.toggle);
583
584
585            if ( $('html.g1-off-outside').length ) {
586                enquire.register('screen and ( min-width: 700px )', {
587                    match : function() {
588                        that.close();
589                    }
590                });
591            }
592
593            if ( $('html.g1-off-inside').length ) {
594                enquire.register('screen and ( max-width: 1024px )', {
595                    match : function() {
596                        that.close();
597                    }
598                });
599
600                enquire.register('screen and ( min-width: 1025px )', {
601                    match : function() {
602                        that.lazyload();
603                    }
604                });
605            }
606
607            return that;
608        };
609
610        that.getContent = function() {
611            return $('.g1-canvas-global .g1-canvas-content');
612        };
613
614        that.captureClientY = function (event) {
615            // only respond to a single touch
616            //if (event.targetTouches.length === 1) {
617                _clientY = event.targetTouches[0].clientY;
618            //}
619        };
620
621        that.disableCanvasScroll = function( e ) {
622            // only respond to a single touch
623            //if (e.targetTouches.length !== 1) {
624            //   return;
625            //}
626
627            var _element = $('.g1-canvas');
628
629            var clientY = e.targetTouches[0].clientY - _clientY;
630
631            // The element at the top of its scroll,
632            // and the user scrolls down
633            if (_element.scrollTop === 0 && clientY > 0) {
634
635                alert('top scroll');
636
637                e.preventDefault();
638                e.stopPropagation();
639                return false;
640            }
641
642            // The element at the bottom of its scroll,
643            // and the user scrolls up
644            // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
645            if ((_element.scrollHeight - _element.scrollTop <= _element.clientHeight) && clientY < 0) {
646                alert('bottom scroll');
647
648                e.preventDefault();
649                e.stopPropagation();
650                return false;
651            }
652        };
653
654        that.disableBodyScroll = function( e ) {
655            //e.preventDefault();
656            //e.stopPropagation();
657            //return false;
658        };
659
660        that.lazyload = function() {
661            $('.g1-canvas-background[data-bg]:not(.lazyloaded)').addClass('lazyload');
662        };
663
664        that.open = function (content) {
665            //$('.g1-canvas').on('touchstart', that.captureClientY);
666            //$('.g1-canvas').on('touchmove', that.disableCanvasScroll);
667
668            that.lazyload();
669
670            window.requestAnimationFrame(function () {
671                var breakpoint = $(document).width();
672                var cssClass = breakpoint >= 1025 ? 'g1-off-global-desktop' : 'g1-off-global';
673                $('html').addClass(cssClass);
674
675                currentContent = content;
676                var $canvas = $('.g1-canvas-global');
677
678                if (content) {
679                    if (typeof content === 'string') {
680                        $canvas.find('.g1-canvas-content').html(content);
681                    } else {
682                        $canvas.find('.g1-canvas-content').empty().append(content);
683                    }
684
685                    // notify about adding new content to DOM so other elements can be reloaded
686                    $canvas.find('.g1-canvas-content').trigger('g1-new-content');
687
688                }
689
690                that.notify('open');
691            });
692        };
693
694        that.close = function () {
695            //$('.g1-canvas').off('touchmove', that.disableCanvasScroll);
696            //$('.g1-canvas').off('touchstart', that.captureClientY);
697
698            window.requestAnimationFrame(function () {
699                $('html').removeClass('g1-off-global g1-off-global-desktop');
700
701                that.notify('close');
702            });
703        };
704
705        that.toggle = function (e) {
706            if (e) {
707                e.preventDefault();
708            }
709
710            // is opened?
711            if ( $('html').is('.g1-off-global, .g1-off-global-desktop') ) {
712                that.close();
713            } else {
714                that.open(null);
715            }
716        };
717
718        that.notify = function (eventType) {
719            var callbacks = listeners[eventType];
720
721            for (var i = 0; i < callbacks.length; i++) {
722                callbacks[i](that.getContent());
723            }
724        };
725
726        that.on = function (eventType, listener, priority) {
727            listeners[eventType][priority] = listener;
728        };
729
730        return init();
731    }
732
733})(jQuery);
734
735
736/********************
737 *
738 * Sticky sidebar
739 *
740 ********************/
741
742(function($) {
743    'use strict';
744
745    var $waypointElem = false;
746
747    var selectors = {
748        'stickyWidgetWrapper': '.g1-sticky-widget-wrapper',
749        'stickyWidget':        '.g1-sticky-widget',
750        'widget':              '.widget',
751        'content':             '#primary .entry-content'
752    };
753
754    var sidebarSelectors = [
755        '#secondary',
756        '#tertiary'
757    ];
758
759    g1.stickyTopOffsetSelectors = [
760        '#wpadminbar',
761        '.g1-iframe-bar',
762        '.g1-sharebar-loaded',
763        '.g1-sticky-top-wrapper'
764    ];
765
766    g1.resetStickyElements = function() {
767        $(selectors.stickyWidgetWrapper).css('height', '');
768        $(selectors.stickyWidget).css('position', 'block');
769    };
770
771    g1.stickySidebar = function() {
772        if (!g1.isDesktopDevice()) {
773            g1.resetStickyElements();
774            return;
775        }
776
777        var $widgets = $(selectors.stickyWidget);
778
779        if ($widgets.length === 0) {
780            return;
781        }
782
783        // Calc top offset for sticky elements.
784        var topOffset = 0;
785
786        $(g1.stickyTopOffsetSelectors).each(function() {
787            var $element = $(this);
788
789            if ($element.length > 0 && $element.is(':visible')) {
790                topOffset += parseInt($element.outerHeight(), 10);
791            }
792        });
793
794        // Adjust widgets top offset to keep them always fully visible.
795        $widgets.each(function() {
796            var $widget = $(this);
797            var top = parseInt($widget.css('top'), 10);
798
799            if (topOffset > 0) {
800                top += topOffset;
801
802                $widget.css('top', top + 'px');
803            }
804        });
805
806        // Apply "position: sticky" pollyfill (IE9+).
807        if (typeof Stickyfill !== 'undefined') {
808            Stickyfill.add($widgets);
809        }
810
811        /**
812         * Increase the last widget height to cover entire sidebar.
813         *
814         * @param {Boolean} isVariableContent  - Determines which element is used for widget height calculation.
815         */
816        var adjustLastWidgetHeight = function(isVariableContent) {
817            $(sidebarSelectors).each(function() {
818                var $sidebar = $(this);
819                var $widgets = $sidebar.children(selectors.widget + ',' + selectors.stickyWidgetWrapper);
820                var $lastWidget = $widgets.last();
821
822                if ($lastWidget.is(selectors.stickyWidgetWrapper)) {
823                    // Reset height (if previously set) to calculate it from scratch.
824                    $lastWidget.css('height', '');
825
826                    var sidebarHeight;
827
828                    // Lazy loaded dynamic content elements (like embeds) affects its height.
829                    // At this point, we don't know what will be the final height.
830                    // So when we calculate the first time the last widget height, we do this based on current content height,
831                    // and then when we reach the end of the content, we recalculate (assuming that all elements
832                    // have already thier final size) the widget height based on current sidebar height (flexbox gives us a certainty
833                    // that both #primary and #secondary/#tetriary elements have the same height).
834                    if (isVariableContent) {
835                        sidebarHeight = parseInt($(selectors.content).outerHeight(), 10);
836                    } else {
837                        sidebarHeight = parseInt($sidebar.outerHeight(), 10);
838                    }
839
840                    var widgetsHeight = 0;
841
842                    $widgets.each(function() {
843                        widgetsHeight += parseInt($(this).outerHeight(true), 10);
844                    });
845
846                    // Increase last widget height if exists a space to cover.
847                    if (widgetsHeight < sidebarHeight) {
848                        var diffHeight = sidebarHeight - widgetsHeight;
849
850                        var lastWidgetHeight = parseInt($lastWidget.css('height'), 10);
851
852                        lastWidgetHeight += diffHeight;
853
854                        $lastWidget.css('height', lastWidgetHeight + 'px');
855                    }
856
857                    $waypointElem = $lastWidget;
858                }
859            });
860        };
861
862        var $body = $('body');
863
864        // For a single post, use entry content height to calculate the last widget height at first.
865        var isVariableContent = $body.is('.single');
866
867        adjustLastWidgetHeight(isVariableContent);
868
869        // Listen to page height changes.
870        // ------------------------------
871
872        // New content is added (e.g. via auto-load next post) or dynamic element is fully loaded (e.g. Facebook widget).
873        $body.on( 'g1NewContentLoaded g1PageHeightChanged', function(e) {
874            adjustLastWidgetHeight();
875        } );
876
877        // Entry content is entirely in the viewport (all inside elements should have final size), adjust widget height.
878        if (false !== $waypointElem) {
879            $waypointElem.waypoint(function(direction) {
880                if ('down' === direction) {
881                    adjustLastWidgetHeight();
882                }
883            }, {
884                // When the bottom of the element hits the bottom of the viewport.
885                offset: 'bottom-in-view'
886            });
887        }
888    };
889
890})(jQuery);
891
892
893/*****************
894 *
895 * Sticky Elements
896 *
897 ****************/
898
899(function ($) {
900
901    'use strict';
902
903    var selectors = [
904        '#wpadminbar',
905        '.g1-iframe-bar',
906        '.g1-sharebar-loaded',
907        '.g1-sticky-top-wrapper'
908    ];
909
910    // Accessible globally.
911    g1.stickyElementsTopOffsetSelectors = selectors;
912
913    g1.stickyPosition = function ($context) {
914        $context = $context || $('body');
915
916        // Sticky top.
917        var $stickyTop = $('.g1-sticky-top-wrapper');
918
919        // If exists and not loaded already.
920        if ($stickyTop.length > 0 && !$stickyTop.is('.g1-loaded')) {
921            var disableStickyHeader = false;
922            var isDesktop = g1.getWindowWidth() > 800;
923
924
925
926            // Disable if sharebar enabled.
927            var sharebarLoaded = $('.g1-sharebar-loaded').length > 0 || $('.essb_topbar').length > 0;
928
929            if (sharebarLoaded && isDesktop) {
930                disableStickyHeader = true;
931            }
932
933            if (disableStickyHeader) {
934                // Prevent native sticky support, like on FF.
935                $stickyTop.removeClass('g1-sticky-top-wrapper');
936            } else {
937                // Apply pollyfill only if not supported.
938                if (!g1.isStickySupported()) {
939                    Stickyfill.add($stickyTop);
940                }
941
942                $stickyTop.addClass('g1-loaded');
943            }
944        }
945
946        // Calculate topOffset after disabling the sticky header!
947        var topOffset = 0;
948        for (var i = 0; i < selectors.length; i++) {
949            var $elem = $(selectors[i]);
950
951            if ($elem.length > 0 && $elem.is(':visible')) {
952                topOffset += $elem.outerHeight();
953            }
954        }
955
956
957        // Sticky Item Actions (shares, votes etc).
958        $context.find('.g1-wrapper-with-stickies > .entry-actions').each(function() {
959            var $this = $(this);
960
961            $this.css('top', topOffset);
962
963            Stickyfill.add($this);
964        });
965
966        // Sticky snax form sidebar.
967        Stickyfill.add($('.snax-form-frontend .snax-form-side'));
968
969
970        // Sticky Item Actions (shares, votes etc).
971        $context.find('.entry-tpl-index-stickies > .entry-actions, .entry-tpl-feat-stickies .entry-actions').each(function() {
972            var $this = $(this);
973
974            $this.css('top', topOffset + 10);
975
976            Stickyfill.add($this);
977        });
978    };
979
980    $('body').on( 'g1NewContentLoaded', function ( e, $newContent ) {
981        if ($newContent) {
982            g1.stickyPosition($newContent);
983        }
984    } );
985
986})(jQuery);
987
988
989/**********************
990 *
991 * Droppable Elements
992 *
993 **********************/
994
995(function ($) {
996
997    'use strict';
998
999    var selectors = {
1000        'drop' :        '.g1-drop',
1001        'dropExpanded': '.g1-drop-expanded',
1002        'dropToggle':   '.g1-drop-toggle'
1003    };
1004
1005    var classes = {
1006        'dropExpanded': 'g1-drop-expanded'
1007    };
1008
1009    g1.droppableElements = function () {
1010        // Hide drop on focus out.
1011        $('body').on('click touchstart', function (e) {
1012            var $activeDrop = $(e.target).parents('.g1-drop-expanded');
1013
1014            // Collapse all except active.
1015            $(selectors.dropExpanded).not($activeDrop).removeClass(classes.dropExpanded);
1016        });
1017
1018        // Handle drop state (expanded | collapsed).
1019
1020        // For touch devices we need to toggle CSS class to trigger state change.
1021        if ( g1.isTouchDevice() ) {
1022            $('body').on( 'click', selectors.drop, function(e) {
1023                var $drop = $(this);
1024
1025                // If there is no drop-content inside, skip.
1026                if ($drop.find('.g1-drop-content').length === 0) {
1027                    return;
1028                }
1029
1030                // Drop is expanded, collapse it on toggle click.
1031                if ($drop.is(selectors.dropExpanded)) {
1032                    var $clickedElement = $(e.target);
1033
1034                    var toggleClicked = $clickedElement.parents(selectors.dropToggle).length > 0;
1035
1036                    if (toggleClicked) {
1037                        $drop.removeClass(classes.dropExpanded);
1038                        e.preventDefault();
1039                    }
1040                // Drop is collapsed, expand it.
1041                } else {
1042                    $drop.addClass(classes.dropExpanded);
1043                    e.preventDefault();
1044                }
1045            } );
1046        // Devices without touch events, state is handled via CSS :hover
1047        } else {
1048            // Prevent click on toggle.
1049            $(selectors.dropToggle).on( 'click', function() {});
1050        }
1051    };
1052
1053})(jQuery);
1054
1055/********************************
1056 *
1057 * Mailchimp for WP Integration
1058 *
1059 *******************************/
1060
1061(function ($) {
1062
1063    'use strict';
1064
1065    $('body').on('submit', '.mc4wp-form', function (e) {
1066        var submissionType = 'ajax';
1067
1068        // Allow filtering the type.
1069        if (typeof bimberMc4wpFormSubmissionType === 'function') {
1070            submissionType = bimberMc4wpFormSubmissionType(submissionType);
1071        }
1072
1073        if (submissionType !== 'ajax') {
1074            return;
1075        }
1076
1077        e.preventDefault();
1078
1079        var $form = $(this);
1080
1081        $.ajax({
1082            'type': 'POST',
1083            'url':  window.location.href,
1084            'data': $form.serialize()
1085         }).done(function (res) {
1086            var $response = $(res).find('#' + $form.attr('id') + ' .mc4wp-response');
1087
1088            $response.prependTo($form);
1089        });
1090    });
1091
1092})(jQuery);
1093
1094/*******************
1095 *
1096 * Snax Integration
1097 *
1098 ******************/
1099
1100(function ($) {
1101
1102    'use strict';
1103
1104    g1.snax = function () {
1105        var $body = $('body');
1106
1107        $body.on('snaxFullFormLoaded', function(e, $post) {
1108            $post.find('.g1-button-m.g1-button-solid').removeClass('g1-button-m  g1-button-solid').addClass('g1-button-s  g1-button-simple');
1109            $post.find('.g1-beta.g1-beta-1st').removeClass('g1-beta g1-beta-1st').addClass('g1-gamma g1-gamma-1st');
1110        });
1111    };
1112
1113    // Integration between Snax and CommentAce.
1114    window.caceWpCommentListPropsFilter = function (props, comments) {
1115        if ($(comments).parents('.snax-item').length > 0) {
1116            props.loadMoreType = 'load_more';
1117        }
1118
1119        return props;
1120    }
1121
1122})(jQuery);
1123
1124/*******************
1125 *
1126 * Media Ace Integration
1127 *
1128 ******************/
1129
1130(function ($) {
1131
1132    'use strict';
1133
1134    g1.mediaAce = function () {
1135
1136        $('body').on('g1NewContentLoaded', function() {
1137            $('body').trigger('maceLoadYoutube');
1138        });
1139
1140        $(document).on('lazybeforeunveil', function(e) {
1141            var $target = $(e.target);
1142            var targetSrc = $target.attr('data-src');
1143
1144            if (targetSrc && targetSrc.endsWith('.gif')) {
1145                // Wait till image fully loaded.
1146                $target.on('load', function() {
1147                    $target.addClass('g1-enable-gif-player');
1148
1149                    // Wait a while before applying player.
1150                    setTimeout(function() {
1151                        if (typeof g1.gifPlayer === 'function') {
1152                            g1.gifPlayer($target.parent());
1153                        }
1154                    }, 100);
1155                });
1156            }
1157        });
1158
1159        $(document).on('bimberGifPlayerLoaded', function(e, $canvasWrapper) {
1160            if ($canvasWrapper.hasClass('lazyloading')) {
1161                $canvasWrapper.removeClass('lazyloading');
1162                $canvasWrapper.addClass('lazyloaded');
1163            }
1164        });
1165    };
1166
1167})(jQuery);
1168
1169
1170/*******
1171 *
1172 * Menu
1173 *
1174 *******/
1175(function (context, $, i18n) {
1176
1177    'use strict';
1178
1179    $(document).ready(function () {
1180        PrimaryMenu();
1181    });
1182
1183    function PrimaryMenu () {
1184        var that = {};
1185
1186        that.init = function () {
1187            that.registerEventsHandlers();
1188
1189            // add toggle to menu
1190            $('.menu-item-has-children > a, .menu-item-g1-mega > a').append( '<span class="g1-link-toggle"></span>' );
1191
1192            return that;
1193        };
1194
1195        that.registerEventsHandlers = function () {
1196            that.handleMenuItemClick();
1197            that.handleMenuItemFocusOut();
1198        };
1199
1200        that.handleMenuItemFocusOut = function () {
1201            $('body').on('click', function (e) {
1202                if ($(e.target).parents('.mtm-drop-expanded').length === 0 ) {
1203
1204                    // Only horizontal menus.
1205                    if ($(e.target).parents('.g1-menu-h').length ) {
1206                        that.collapseAllOpenedSubmenus();
1207                    }
1208                }
1209            });
1210        };
1211
1212        that.handleMenuItemClick = function () {
1213            $('.g1-primary-nav, .g1-secondary-nav').on('click', '.menu-item > a', function (e) {
1214                var $menu = $(this).parents('.g1-primary-nav');
1215
1216                if ($menu.length === 0) {
1217                    $menu = $(this).parents('.g1-secondary-nav');
1218                }
1219
1220                var isSimpleList = $menu.is('#g1-canvas-primary-nav') || $menu.is('#g1-canvas-secondary-nav');
1221
1222                if (g1.isTouchDevice() || isSimpleList) {
1223                    that.handleMenuTouchEvent($(this), e);
1224                }
1225            });
1226        };
1227
1228        that.handleMenuTouchEvent = function ($link, event) {
1229            var $li = $link.parent('li');
1230
1231            that.collapseAllOpenedSubmenus($li);
1232
1233            if ($li.hasClass('menu-item-has-children')) {
1234                event.preventDefault();
1235
1236                var $helper = $li.find('ul.sub-menu:first > li.g1-menu-item-helper');
1237
1238                if ($helper.length === 0) {
1239                    var href = $link.attr('href');
1240
1241                    if ( href && href.length ) {
1242                        var anchor = i18n.go_to + ' <span class="mtm-item-helper-title">'+ $link.html() +'</span>';
1243
1244                        $helper = $('<li class="menu-item g1-menu-item-helper"><a class="mtm-link" href="'+ href +'"><span class="mtm-link-text"><span class="mtm-link-title">' + anchor +'</span></span></a></li>');
1245
1246                        $li.find('ul.sub-menu:first').prepend($helper);
1247                    }
1248                }
1249
1250                if (!$li.is('.mtm-drop-expanded')) {
1251                    $li.find('.mtm-drop-expanded .g1-menu-item-helper').remove();
1252                    $li.addClass('mtm-drop-expanded');
1253                } else {
1254                    $li.find('.mtm-drop-expanded').removeClass('mtm-drop-expanded');
1255                    $li.removeClass('mtm-drop-expanded');
1256                }
1257            }
1258        };
1259
1260        that.collapseAllOpenedSubmenus = function ($currentItem) {
1261            if ($currentItem) {
1262                var $currentMenu = $currentItem.parents('nav');
1263                var $topLevelLi = $currentItem.parents('li.menu-item');
1264
1265                // We are at top level of menu
1266                if($topLevelLi.length === 0) {
1267                    // Collapse all, except current.
1268                    // This will collapse current item subtree items but not item itself. Item will be collapse by the "handleMenuTouchEvent" handler.
1269                    $currentMenu.find('.mtm-drop-expanded').not($currentItem).removeClass('mtm-drop-expanded');
1270                } else {
1271                    // Collapse all opened submenus in current menu, except current subtree.
1272                    $topLevelLi.siblings('li').find('.mtm-drop-expanded').removeClass('mtm-drop-expanded');
1273                }
1274
1275                // Collapse all opened submenus in all other menus.
1276                $('nav').not($currentMenu).find('.mtm-drop-expanded').removeClass('mtm-drop-expanded');
1277            } else {
1278                // collapse all opened, site wide, submenus
1279                $('.mtm-drop-expanded').removeClass('mtm-drop-expanded');
1280            }
1281        };
1282
1283        return that.init();
1284    }
1285
1286})(window, jQuery, g1.config.i18n.menu);
1287
1288// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
1289// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
1290// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
1291// MIT license
1292
1293(function() {
1294    var lastTime = 0;
1295    var vendors = ['ms', 'moz', 'webkit', 'o'];
1296    for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
1297        window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
1298        window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
1299    }
1300
1301    if (!window.requestAnimationFrame) {
1302        window.requestAnimationFrame = function(callback) {
1303            var currTime = new Date().getTime();
1304            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
1305            var id = window.setTimeout(function() { callback(currTime + timeToCall); },
1306                timeToCall);
1307            lastTime = currTime + timeToCall;
1308            return id;
1309        };
1310    }
1311
1312    if (!window.cancelAnimationFrame) {
1313        window.cancelAnimationFrame = function(id) {
1314            clearTimeout(id);
1315        };
1316    }
1317}());
1318
1319
1320
1321/****************
1322 *
1323 * Popup/Slideup
1324 *
1325 ****************/
1326
1327(function ($) {
1328    'use strict';
1329    g1.popup = function () {
1330		var
1331		HTMLBase          = $('html'),
1332		Popup             = $('.g1-popup-newsletter'),
1333		PopupCookie       = g1.readCookie('g1_popup_disabled'),
1334		PopupCloser       = $('.g1-popup-base, .g1-popup-closer');
1335		// If we dont have popup exit.
1336		if( PopupCookie ){ HTMLBase.addClass('exit-intent-disabled'); }
1337		if( Popup.length <= 0 ){ return; }
1338		$(document).on('mouseleave', function(e){
1339			if( e.clientY < 10 && ! HTMLBase.hasClass('exit-intent-disabled') && ! HTMLBase.hasClass('g1-slideup-visible') ){
1340                HTMLBase.addClass('g1-popup-ready');
1341                setTimeout(function(){
1342                    HTMLBase.addClass('g1-popup-visible').addClass('exit-intent-disabled');
1343                }, 50);
1344			}
1345		});
1346		PopupCloser.on('click', function(e){
1347			e.preventDefault();
1348			HTMLBase.removeClass('g1-popup-visible');
1349	        g1.createCookie('g1_popup_disabled', 1, 24 * 60 * 60 * 1000);
1350		});
1351    }
1352
1353
1354
1355    g1.slideup = function () {
1356		var
1357		HTMLBase           = $('html'),
1358		Slideup            = $('.g1-slideup-newsletter'),
1359		SlideupCloser      = $('.g1-slideup-newsletter-closer'),
1360		SlideupCookie      = g1.readCookie('g1_slideup_disabled'),
1361		ScrollPositon      = $(document).scrollTop(),
1362		ScrollTarget       = $('.single-post article .entry-content'),
1363		ScrollTargetOffset = ScrollTarget.offset(),
1364		ScrollTargetHeight = ScrollTarget.height(),
1365		ShowOn             = 50;
1366		// If we dont have popup exit.
1367		SlideupCloser.on('click', function(e){
1368			e.preventDefault();
1369			HTMLBase.removeClass('g1-slideup-visible').addClass('slideup-intent-disabled');
1370	        g1.createCookie('g1_slideup_disabled', 1, 24 * 60 * 60 * 1000);
1371		});
1372		if( SlideupCookie ){ HTMLBase.addClass('slideup-intent-disabled'); }
1373		if( Slideup.length <= 0 ){ return; }
1374		if( ScrollTarget.length <= 0 ){ return; }
1375		$(window).on('scroll', function(){
1376			ScrollPositon      = $(document).scrollTop();
1377			ScrollTargetOffset = ScrollTarget.offset();
1378			ScrollTargetHeight = ScrollTarget.height();
1379			if( ( (ScrollPositon - ScrollTargetOffset.top) / (ScrollTargetHeight) ).toFixed(6) * 100 >= ShowOn && ! HTMLBase.hasClass('slideup-intent-disabled') && ! HTMLBase.hasClass('g1-popup-visible') ){
1380				HTMLBase.addClass('g1-slideup-visible');
1381			}
1382		});
1383    }
1384})(jQuery);
1385
1386/****************
1387 *
1388 * GDPR
1389 *
1390 ****************/
1391
1392(function ($) {
1393    'use strict';
1394    $(document).ready(function () {
1395        $('.wp-social-login-provider-list').on('click', function() {
1396                if ($(this).hasClass('wp-social-login-provider-list-active')){
1397                    return;
1398                }
1399                $('.snax-wpsl-gdpr-consent').addClass('snax-wpsl-gdpr-consent-blink');
1400                setTimeout(function(){
1401                    $('.snax-wpsl-gdpr-consent').removeClass('snax-wpsl-gdpr-consent-blink');
1402                },
1403                2000);
1404        });
1405        $('.snax-wpsl-gdpr-consent input').on('click', function() {
1406            var enabled = $(this).is(':checked');
1407            if (enabled) {
1408                $('.wp-social-login-provider-list').addClass('wp-social-login-provider-list-active');
1409            } else {
1410                $('.wp-social-login-provider-list').removeClass('wp-social-login-provider-list-active');
1411            }
1412        });
1413    });
1414})(jQuery);
1415
1416/**************************
1417 *
1418 * WordPress Popular Posts
1419 *
1420 **************************/
1421
1422(function ($) {
1423
1424    'use strict';
1425
1426    g1.updatePostViews = function(nonce,postId) {
1427        $.ajax({
1428            'type': 'POST',
1429            'url': g1.config.ajax_url,
1430            'data': {
1431                'action':   'update_views_ajax',
1432                'wpp_id':   postId,
1433                'token':    nonce
1434            }
1435        });
1436    };
1437
1438    // ------------
1439    // Update views
1440    // ------------
1441
1442    $('.bimber-count-view').on('click', function() {
1443        var postId;
1444        var $body = $('body');
1445
1446        if ( $body.is('.single-format-link') ) {
1447            var res = $body.attr('class').match(/postid-(\d+)/);
1448
1449            if (res) {
1450                postId = res[1];
1451            }
1452        } else {
1453            var $article = $(this).parents('article.format-link');
1454            if ( $article.length > 0 ) {
1455                postId = $article.attr('class').match(/post\-(\d+)/)[1];
1456            }
1457        }
1458
1459        if (postId) {
1460            $.ajax({
1461                'type': 'POST',
1462                'url': g1.config.ajax_url,
1463                'data': {
1464                    //'action':   'bimber_update_post_views',
1465                    //'post_id':   postId
1466                    'action':   'update_views_ajax',
1467                    'wpp_id':   postId,
1468                    'token':    g1.config.wpp.token
1469                }
1470            });
1471        }
1472    });
1473
1474})(jQuery);
1475
1476/*******************
1477 *
1478 * Flickity
1479 *
1480 ******************/
1481
1482
1483(function ($) {
1484
1485    'use strict';
1486
1487    g1.flickity = function ($context) {
1488        $context = $context || $('body');
1489
1490        var
1491            FlickitySpots = $context.find('.adace-shop-the-post-wrap.carousel-wrap .woocommerce .products, .g1-products-widget-carousel .product_list_widget');
1492
1493        FlickitySpots.each(function () {
1494            if ($(this).hasClass('.flickity-enabled')) {
1495                return;
1496            }
1497
1498            var
1499                ThisFlickityItems = $(this).children(),
1500                ThisFlickityItemsWidth = ThisFlickityItems.outerWidth() * ThisFlickityItems.length,
1501                ThisFlickityArgs = {
1502                    cellAlign: 'left',
1503                    wrapAround: true,
1504                    prevNextButtons: true,
1505                    pageDots: false,
1506                    groupCells: true,
1507                    rightToLeft: g1.isRTL(),
1508                    imagesLoaded: true
1509                };
1510            if (ThisFlickityItemsWidth <= $(this).outerWidth()) {
1511                ThisFlickityArgs.cellAlign = 'center';
1512                ThisFlickityArgs.wrapAround = false;
1513            } else {
1514                var ThisRequiredNumber = Math.round($(this).outerWidth() / ThisFlickityItems.outerWidth()) * ThisFlickityItems.length;
1515
1516                while (ThisFlickityItems.length < ThisRequiredNumber) {
1517                    $(this).append(ThisFlickityItems.clone(true));
1518                    ThisFlickityItems = $(this).children();
1519                }
1520            }
1521            $(this).flickity(ThisFlickityArgs);
1522        });
1523    };
1524
1525    $('body').on('g1NewContentLoaded', function (e, $newContent) {
1526        g1.flickity($newContent);
1527    });
1528})(jQuery);
1529
1530
1531// Sticky off-canvas top offset adjustments.
1532(function ($) {
1533    'use strict';
1534
1535    $(document).ready(function () {
1536        var selectors = [
1537            '#wpadminbar',
1538            '.g1-iframe-bar',
1539            '.g1-sticky-top-wrapper'
1540        ];
1541
1542        var applyOffset = function() {
1543            // Calculate the total height of all sticky elements.
1544            var topOffset = 0;
1545            for (var i = 0; i < selectors.length; i++) {
1546                var $elem = $(selectors[i]);
1547
1548                if ($elem.length > 0 && $elem.is(':visible')) {
1549                    topOffset += $elem.outerHeight();
1550                }
1551            }
1552
1553
1554            var cssRule = 'html.g1-off-inside.g1-off-global-desktop .g1-canvas {top:' + topOffset + 'px;'
1555
1556            $('#g1-canvas-js-css').remove();
1557            $('head').append( '<style id="g1-canvas-js-css">' + cssRule + '</style>' );
1558            $('html.g1-off-inside .g1-canvas').removeClass('g1-canvas-no-js').addClass('g1-canvas-js');
1559        };
1560
1561        $('body').on( 'g1PageHeightChanged', function(e) {
1562            applyOffset();
1563        } );
1564
1565        $('html.g1-off-inside .g1-canvas.g1-canvas-no-js').each(function() {
1566            applyOffset();
1567        });
1568    } );
1569})(jQuery);
1570
1571
1572/**************************
1573 *
1574 * document ready functions (keep this at the end for better compatibillity with optimizing plugins)
1575 *
1576 *************************/
1577
1578(function ($) {
1579
1580    'use strict';
1581
1582    $(document).ready(function () {
1583        g1.uiHelpers();
1584
1585        if (g1.config.timeago === 'on') {
1586            g1.dateToTimeago();
1587        }
1588
1589        g1.loadMoreButton();
1590        g1.infiniteScroll();
1591        g1.stickyPosition();
1592        g1.droppableElements();
1593        g1.canvas();
1594        g1.snax();
1595        g1.mediaAce();
1596        g1.flickity();
1597        g1.popup();
1598        g1.slideup();
1599        g1.stickySidebar();
1600    });
1601
1602})(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.