PageSourceSearch

https://exchile.com/wp-content/themes/inspiro/js/functions.js?ver=4.0

js exchile.com collected 2026-10-02 07:49:55 UTC 68,599 bytes, 1,783 lines download raw bytes

1/**
2 * Theme functions file
3 */
4(function ($) {
5    'use strict';
6
7    $.fn.magnificPopupCallbackforPortfolios = function(){
8
9        this.magnificPopup({
10            disableOn: function() { if( $(window).width() < 0) { return false; } return true; },
11            type: 'image',
12            gallery: {
13                enabled: true,
14            },
15            image: {
16                titleSrc: function (item) {
17
18                    var $el = this.currItem.el;
19                    var $popover_content = $el.closest('.entry-thumbnail-popover-content');
20                    var $link = $popover_content.find('.portfolio_item-title a');
21                    var $title = $link.html();
22                    var $href = $link.attr('href');
23                    var show_caption = $popover_content.data('show-caption');
24
25                    if (show_caption) {
26                        return '<a href="' + $href + '">' + $title + '</a>';
27                    }
28                }
29            },
30            iframe: {
31                markup: '<div class="mfp-iframe-scaler">'+
32                '<div class="mfp-close"></div>'+
33                '<iframe class="mfp-iframe" frameborder="0" allow="autoplay" allowfullscreen></iframe>'+
34                '<div class="mfp-bottom-bar"><div class="mfp-title"></div></div>'+
35                '</div>',
36                callbacks: {
37
38                },
39                patterns: {
40                    vimeo: {
41                        index: 'vimeo.com/',
42                        id: function(url) {
43                            var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
44                            if ( !m || !m[5] ) return null;
45                            return m[5];
46                        },
47                        src: '//player.vimeo.com/video/%id%?autoplay=1'
48                    },
49                    youtu: {
50                        index: 'youtu.be',
51                        id: function( url ) {
52                            // Capture everything after the hostname, excluding possible querystrings.
53                            var m = url.match( /^.+youtu.be\/([^?]+)/ );
54
55                            if ( null !== m ) {
56                                return m[1];
57                            }
58
59                            return null;
60                        },
61                        // Use the captured video ID in an embed URL.
62                        // Add/remove querystrings as desired.
63                        src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
64                    }
65                }
66            },
67            mainClass: 'mfp-fade',
68            removalDelay: 160,
69            preloader: false,
70            fixedContentPos: false,
71            callbacks: {
72                change: function() {
73                    if(this.currItem.type === 'inline'){
74                        $(this.content).find('video')[0].play();
75                    }
76                },
77                beforeClose: function () {
78                    if (this.currItem.type === 'inline') {
79                        var $video = $(this.content).find('video');
80
81                        if ($video.length) {
82                            var videoElement = $video[0];
83
84                            var currentSrc = videoElement.currentSrc;
85                            videoElement.pause();
86                            videoElement.currentTime = 0;
87                            videoElement.src = '';
88                            videoElement.src = currentSrc;
89                        }
90                    }
91                },
92                markupParse: function (template, values, item) {
93
94                    if (item.type === 'iframe') {
95
96                        var $el = item.el;
97                        var $popover_content = $el.closest('.entry-thumbnail-popover-content');
98                        var $link = $el.closest('.entry-thumbnail-popover-content').find('.portfolio_item-title a');
99                        var $title = $link.html();
100                        var $href = $link.attr('href');
101                        var show_caption = $popover_content.data('show-caption');
102
103                        if (show_caption) {
104                            values.title = '<a href="' + $href + '">' + $title + '</a>';
105                        }
106                    }
107
108                }
109            }
110        });
111    };
112
113    var $document = $(document);
114    var $window = $(window);
115
116
117    /**
118     * Document ready (jQuery)
119     */
120    $(function () {
121        /**
122         * Header style.
123         */
124        if ($('.slides > li, .single .has-post-cover, .page .has-post-cover, .single-portfolio_item .slide-background-overlay, .page .is-vimeo-pro-slide, .page .portfolio-header-cover-image, .portfolio-with-post-cover, .blog-with-post-cover').length) {
125            $('.navbar').addClass('page-with-cover');
126            $('#main').addClass('page-with-cover');
127        } else {
128            $('.navbar').removeClass('page-with-cover');
129        }
130
131
132        /**
133         * Activate superfish menu.
134         */
135        $('.sf-menu').superfish({
136            'speed': 'fast',
137            'animation': {
138                'height': 'show'
139            },
140            'animationOut': {
141               'height': 'hide'
142           }
143        });
144
145
146        var sticky_menu = zoomOptions.navbar_sticky_menu;
147
148        if (sticky_menu) {
149
150            $.fn.TopMenuMargin();
151
152            /**
153             * Activate Headroom.
154             */
155            $('.site-header').headroom({
156               tolerance: {
157                   up: 0,
158                   down: 0
159               },
160               offset : 70
161            });
162
163
164        }
165
166        $('<span class="child-arrow"><svg fill="none" height="24" stroke-width="1.5" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L12 15L18 9" stroke="#fff" stroke-linecap="round" stroke-linejoin="round"/></svg></span>')
167            .on('click', function(e){
168                e.preventDefault();
169
170                var $li = $(this).closest('li'),
171                    $sub = $li.find('> ul');
172
173                if ( $sub.is(':visible') ) {
174                    $sub.slideUp();
175                    $li.removeClass('open');
176                } else {
177                    $sub.slideDown();
178                    $li.addClass('open');
179                }
180            })
181            .appendTo('.side-nav .navbar-nav li.menu-item-has-children > a');
182
183
184
185        /**
186         * Activate main slider.
187         */
188        $('#slider').sllider();
189
190
191        /**
192         * Search form in header.
193         */
194        $(".sb-search").sbSearch();
195
196        /**
197         * FitVids - Responsive Videos in posts
198         */
199        $(".wpzlb-layout, .builder-wrap, .entry-content, .video_cover, .featured_page_content").fitVids();
200
201        /* Fix for Elementor */
202
203        $('.elementor-widget').each(function () {
204             if ($(this).hasClass('elementor-widget-wp-widget-wpzoom-portfolio-showcase')) {
205                 $(this).addClass("portfolio-showcase");
206             }
207         });
208
209
210        /**
211         * Masonry on Posts
212         */
213        var $grid = $('#portfolio-masonry, .portfolio-masonry').find( '.portfolio-grid').masonry({
214            itemSelector: '.portfolio_item',
215            columnWidth: '.portfolio_item'
216        });
217
218        $('.entry-cover').find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
219
220        $('.portfolio-showcase').each(function(){
221            $(this).find('.portfolio_item .portfolio-popup-video').magnificPopupCallbackforPortfolios();
222        });
223
224        $('.portfolio-archive .portfolio_item').find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
225
226        // layout Masonry after each image loads
227        $grid.imagesLoaded().progress( function() {
228            $grid.masonry('layout');
229        }).done(function(){
230            $grid.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
231        });
232
233        /**
234         * Reload masonry after image was loaded by jetpack.
235         */
236
237        $(document).on('jetpack-lazy-loaded-image', function () {
238            $grid.imagesLoaded().progress().done(function () {
239                $grid.masonry('layout');
240            });
241        });
242
243		$.fn.playBackgroundVideo = function() {
244			/**
245			* Background video on hover.
246			*/
247			$('.portfolio-grid:not(.always-play-background-video)').on({
248				mouseenter: function (event) {
249					var $video = $(this).find('.portfolio-gallery-video-background');
250
251					if ($video.length > 0) {
252						if (event.data.promise == null) {
253							event.data.promise = $video[0].play();
254
255						} else {
256							event.data.promise.then(function () {
257								event.data.promise = $video[0].play();
258							}).catch(function () {
259								console.log('mouseenter IN Catch Video play failed');
260
261								event.data.promise = $video[0].play();
262							});
263						}
264					}
265				},
266				mouseleave: function (event) {
267					var $video = $(this).find('.portfolio-gallery-video-background');
268
269					if ($video.length > 0) {
270						if (event.data.promise !== null) {
271							event.data.promise.then(function () {
272
273								$video[0].addEventListener('pause', function(event){
274									$video[0].load();
275							});
276								$video[0].pause();
277
278							}).catch(function (event) {
279								console.log('mouseleave IN Catch Video play failed');
280							});
281						}
282					}
283				}
284			}, '.is-portfolio-gallery-video-background', {promise: null});
285		}
286
287
288
289        /**
290         *
291         */
292        $.fn.fullWidthContent();
293        $.fn.responsiveSliderImages();
294        $.fn.responsiveImagesHeader();
295        $.fn.paralised();
296        $.fn.sideNav();
297        $.fn.singlePageWidgetBackground();
298        $.fn.singleportfolio();
299		$.fn.playBackgroundVideo();
300
301
302
303        /**
304         * Portfolio items popover.
305         */
306        $('.portfolio-archive .portfolio_item').thumbnailPopover();
307        $('.portfolio-showcase .portfolio_item').thumbnailPopover();
308        $('.carousel_widget_wrapper .portfolio_item').thumbnailPopover();
309
310        /**
311         * Isotope filter for Portfolio Isotope template.
312         */
313        $('.portfolio-taxonomies-filter-by').portfolioIsotopeFilter();
314
315        /**
316         * Clickable divs.
317         */
318        $('.clickable').on('click', function () {
319            window.location.href = $(this).data('href');
320        });
321
322        /**
323         * Portfolio ajax loading support when isotope is disabled.
324         */
325        var $portfoliosForLoadMore = $('.portfolio-showcase');
326
327        $portfoliosForLoadMore.each(function () {
328            var $portfolioWrapper = $(this);
329            var $portfolio = $portfolioWrapper.find('.portfolio-grid');
330            if(!$portfolio.attr('data-instance')){
331                return;
332            }
333            var $loadMoreBtnWrapper = $portfolioWrapper.find('.portfolio-view_all-link');
334            var $loadMoreBtn = $loadMoreBtnWrapper.find('a');
335            var itemsCount = $portfolio.attr('data-items-count');
336            var widget_settings = JSON.parse($portfolio.attr('data-instance'));
337            var tmpl = $portfolio.attr('data-callback-template');
338            var nonce = $portfolio.data('nonce');
339            var callback = 'wpz_get_portfolio_items';
340            var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
341
342
343            if (widget_settings.show_categories == true) {
344                return false;
345            }
346
347            if (!$loadMoreBtn.attr('data-ajax-loading')) {
348                return false;
349            }
350
351            if (portfolioLengthAll == itemsCount) {
352                $loadMoreBtn.hide();
353            }
354
355            $loadMoreBtn.on('click', function (e) {
356                e.preventDefault();
357
358                var category_id = 'all';
359
360                if (category_id == 'all' && $portfolio.attr('data-subcategory')) {
361                    category_id = $portfolio.attr('data-subcategory');
362                }
363
364                $(this).text('Loading...');
365
366                var post_not_in = $portfolio.find('.type-portfolio_item').map(function (index, el) {
367                    return $(el).attr('id').split('post-').pop();
368                }).toArray().join(',');
369
370                wp.ajax.post(
371                    callback,
372                    {
373                        category_id: category_id,
374                        widget_settings: widget_settings,
375                        nonce: nonce,
376                        tmpl: tmpl,
377                        post_not_in: post_not_in,
378                        'show_all': true
379                    }).done(function (response) {
380
381                    if (_.isEmpty(response.content)) {
382                        return;
383                    }
384
385                    var $nodes = $.parseHTML(response.content).filter(function ($element) {
386                        $($element).addClass('wpz-portfolio-item-added-dynamic');
387                        return $($element).is('article') && ($portfolio.find('#' + $($element).attr('id')).length === 0);
388                    });
389
390                    $($nodes).imagesLoaded(function () {
391                        $portfolio.append($($nodes)).isotope('appended', $($nodes));
392
393                        var items_number = parseInt($taxs.siblings('.current-cat').attr('data-counter'));
394                        var portfolioLength = parseInt($portfolio.find(filter).length);
395                        var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
396
397                        $loadMoreBtn.text($loadMoreBtn.attr('title'));
398
399                        if (portfolioLength >= items_number) {
400                            $loadMoreBtn.hide();
401                        }
402
403                        if (portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')) {
404                            $loadMoreBtnWrapper.remove();
405                        }
406
407                        $portfolio.find('.portfolio_item').thumbnailPopover();
408                        $portfolio.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
409                        $portfolio.find('.wpz-portfolio-item-added-dynamic video[autoplay]').each(function () {
410                            this.play();
411                        });
412						$.fn.playBackgroundVideo();
413
414                        $portfolio.isotope({
415                            'filter': filter
416                        });
417
418                    }).progress(function () {
419                        $portfolio.isotope('layout');
420                    });
421                });
422            })
423        });
424
425        /**
426         * Portfolio infinite loading support.
427         */
428        var $folioitems = $('.portfolio-grid');
429        if (typeof wpz_currPage != 'undefined' && wpz_currPage < wpz_maxPages) {
430            $('.navigation').empty().append('<a class="btn btn-primary" id="load-more" href="#">Load More&hellip;</a>');
431
432            $('#load-more').on('click', function (e) {
433                e.preventDefault();
434                if (wpz_currPage < wpz_maxPages) {
435                    $(this).text('Loading...');
436                    wpz_currPage++;
437
438                    $.get( wpz_pagingURL.replace('%page%', wpz_currPage ) , function (data) {
439                        var $newItems = $('.portfolio-grid article', data);
440
441
442                        if ($folioitems.parent().is('#portfolio-masonry')) {
443                            $grid.append($newItems).masonry('appended', $newItems);
444
445                            $newItems.imagesLoaded().progress(function () {
446                                $grid.masonry('layout');
447                            }).done(function(){
448
449                                $grid.masonry('layout');
450								$.fn.playBackgroundVideo();
451
452                                //trigger jetpack lazy images event
453                                $( 'body' ).trigger( 'jetpack-lazy-images-load');
454                                $grid.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
455                            });
456                        } else {
457                            $newItems.addClass('hidden').hide();
458                            $folioitems.append($newItems);
459                            $folioitems.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
460                            $folioitems.find('article.hidden').fadeIn().removeClass('hidden');
461
462                            if ($.fn.mediaelementplayer) {
463                                $('.wp-audio-shortcode, .wp-video-shortcode').not('.mejs-container').filter(function(){return!$(this).parent().hasClass('.mejs-mediaelement')}).mediaelementplayer();
464                            }
465                            //trigger jetpack lazy images event
466                            $( 'body' ).trigger( 'jetpack-lazy-images-load');
467                        }
468
469                        if ((wpz_currPage + 1) <= wpz_maxPages) {
470                            $('#load-more').text('Load More\u2026');
471                        } else {
472                            $('#load-more').animate({height: 'hide', opacity: 'hide'}, 'slow', function () {
473                                $(this).remove();
474                            });
475                        }
476                    });
477                }
478            });
479        }
480    });
481
482
483    $.fn.TopMenuMargin = function () {
484        $(window).on('resize orientationchange', update);
485
486        function update() {
487
488            var windowWidth = $(window).width();
489
490            var $header = $('.site-header');
491            var $main_content = $('#main, .PP_Wrapper');
492
493             $main_content.css('paddingTop',$header.outerHeight());
494
495             var $adminbar = $('#wpadminbar');
496
497             var isHidden = true;
498             var size = [ $(window).width(), $(window).height() ];
499
500        }
501
502        update();
503    };
504
505
506    $.fn.singleportfolio = function () {
507        var $singlePort = $('.full-noslider');
508        $singlePort.each(function (i) {
509            var $this = $(this);
510
511            $window.on('resize focus', dynamicHeightSingle);
512
513            dynamicHeightSingle();
514
515            function dynamicHeightSingle() {
516                var height = $(window).height() - $('.full-noslider').offset().top - parseInt($('.full-noslider').css('padding-top'), 10);
517
518                /* use different min-height for different borwser widths */
519                if (height < 300) {
520                    height = 300;
521                } else if (height < 500 && $window.width() > 768) {
522                    height = 500;
523                }
524
525                $this.find('.entry-cover.cover-fullheight').height(height);
526            }
527
528        });
529    };
530
531    $.fn.thumbnailPopover = function () {
532        return this.on('mousemove', function (event) {
533            var $this = $(this);
534            var $popoverContent = $this.find('.entry-thumbnail-popover-content');
535
536            var itemHeight = $this.outerHeight();
537            var contentHeight = $popoverContent.outerHeight();
538            var y = event.pageY - $this.offset().top;
539
540            if (contentHeight <= itemHeight) {
541                $popoverContent.addClass('popover-content--animated');
542                $popoverContent.css('bottom', '');
543                return;
544            }
545
546            $popoverContent.removeClass('popover-content--animated');
547
548            $popoverContent.css({
549                'bottom': (1 - y / itemHeight) * (itemHeight - contentHeight)
550            });
551        });
552    };
553
554    $.fn.sllider = function () {
555        var countedElements = parseInt($(this).data('posts'), 10);
556        return this.each(function () {
557            var $this = $(this);
558            var userAgent = navigator.userAgent || navigator.vendor || window.opera;
559
560            var video_on_mobile = zoomOptions.featured_video_mobile;
561
562            if (video_on_mobile) { /* play on all devices, excluding these ones: */
563                 var handHeldDevice = (/webOS|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
564            }
565            else { /* when true disable video on mobile */
566                var handHeldDevice = (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
567            }
568
569            var slideshow_arrows = (typeof zoomOptions.slideshow_arrows == 'string') ? (zoomOptions.slideshow_arrows != '0' && zoomOptions.slideshow_arrows != '') : zoomOptions.slideshow_arrows != false;
570            var slideshow_auto = (typeof zoomOptions.slideshow_auto == 'string') ? (zoomOptions.slideshow_auto != '0' && zoomOptions.slideshow_auto != '') : zoomOptions.slideshow_auto != false;
571
572            $this.flexslider({
573                controlNav: false,
574                directionNav: slideshow_arrows,
575                animationLoop: true,
576                useCSS: true,
577                smoothHeight: false,
578                touch: countedElements > 1 ? true : false,
579                keyboard: false,
580                pauseOnAction: true,
581                fadeFirstSlide: false,
582                slideshow: slideshow_auto,
583                animationSpeed: 300,
584                animation: zoomOptions.slideshow_effect,
585                slideshowSpeed: parseInt(zoomOptions.slideshow_speed, 10),
586                start: function(slider){ videoBackground(slider, 'start') },
587                before: videoBackground
588            });
589
590            $this.find('.wpzoom-button-video-background-play').on('click', function (e) {
591                e.preventDefault();
592                var $currentSlide = $(e.currentTarget).parents('li');
593
594                if ($currentSlide.attr('data-formstone-options')) {
595                   $currentSlide.background('play');
596                }
597
598                if ($currentSlide.attr('data-vimeo-options')) {
599                   var vimeoPlayer = new Vimeo.Player($currentSlide);
600                   vimeoPlayer.play();
601                }
602                $this.find('.wpzoom-button-video-background-pause').show();
603                $(this).hide();
604            });
605            $this.find('.wpzoom-button-video-background-pause').on('click', function(e){
606                e.preventDefault();
607                var $currentSlide = $(e.currentTarget).parents('li');
608
609                if ($currentSlide.attr('data-formstone-options')) {
610                    $currentSlide.background('pause');
611                }
612
613                if ($currentSlide.attr('data-vimeo-options')) {
614                    var vimeoPlayer = new Vimeo.Player($currentSlide);
615                    vimeoPlayer.pause();
616                }
617                $this.find('.wpzoom-button-video-background-play').show();
618                $(this).hide();
619            });
620            $this.find('.wpzoom-button-sound-background-mute').on('click', function(e){
621                e.preventDefault();
622                var $currentSlide = $(e.currentTarget).parents('li');
623
624                if ($currentSlide.attr('data-formstone-options')) {
625                    $currentSlide.background('mute');
626                }
627
628                if ($currentSlide.attr('data-vimeo-options')) {
629                    var vimeoPlayer = new Vimeo.Player($currentSlide);
630                    vimeoPlayer.setVolume(0);
631                }
632                $this.find('.wpzoom-button-sound-background-unmute').show();
633                $(this).hide();
634            });
635            $this.find('.wpzoom-button-sound-background-unmute').on('click', function(e){
636                e.preventDefault();
637                var $currentSlide = $(e.currentTarget).parents('li');
638
639                if ($currentSlide.attr('data-formstone-options')) {
640                   $currentSlide.background('unmute');
641                }
642
643                if ($currentSlide.attr('data-vimeo-options')) {
644                   var vimeoPlayer = new Vimeo.Player($currentSlide);
645                   vimeoPlayer.setVolume(1);
646                }
647                $this.find('.wpzoom-button-sound-background-mute').show();
648                $(this).hide();
649            });
650
651            $this.find('.popup-video').each(function(){
652				let $popupinstance = $(this),
653					$type = $popupinstance.data('popup-type'),
654					$videoOpts = $popupinstance.data('popup-video-options');
655
656				var autoplay = $videoOpts.autoplay ? 1 : 0;
657				var mute = $videoOpts.mute ? 1 : 0;
658				var loop = $videoOpts.loop ? 1 : 0;
659
660                $(this).magnificPopup({
661                    disableOn: function() { if( $(window).width() < 0) { return false; } return true; },
662                    type: $type,
663					iframe: {
664						patterns: {
665							vimeo: {
666								index: 'vimeo.com/',
667								id: function(url) {
668									var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
669									if ( !m || !m[5] ) return null;
670									return m[5];
671								},
672								src: '//player.vimeo.com/video/%id%?autoplay=' + autoplay + '&muted=' + mute + '&loop=' + loop
673							},
674							youtube: {
675								index: 'youtube.com/',
676								id: 'v=',
677								// Use the captured video ID in an embed URL.
678								// Add/remove querystrings as desired.
679								src: '//www.youtube.com/embed/%id%?autoplay=' + autoplay + '&rel=0&mute=' + mute + '&loop=' + loop
680							}
681						}
682					},
683                    mainClass: 'mfp-fade',
684                    removalDelay: 160,
685                    preloader: false,
686                    fixedContentPos: false,
687                    callbacks: {
688                        beforeOpen : function(first){
689
690                            if( $this.data('flexslider') && $this.data('flexslider').playing){
691                                $this.flexslider('pause');
692                            }
693
694                            var $activeSlide = $this.find('.flex-active-slide');
695                            $activeSlide.background('pause');
696
697                            if ($activeSlide.attr('data-vimeo-options')) {
698
699                                var currentVimeoPlayer = new Vimeo.Player($activeSlide);
700
701                                currentVimeoPlayer.getPaused().then(function(paused) {
702                                    if(!paused){
703                                        currentVimeoPlayer.pause();
704                                    }
705                                });
706                            }
707                        },
708                        open : function(){
709                            if( $type === 'inline' && autoplay ){
710                                var container = $.magnificPopup.instance.contentContainer.first();
711                                container.find('video')[0].play();
712                            }
713                        },
714                        beforeClose : function(){
715                            if($type === 'inline'){
716
717                                var $video = $(this.content).find('video');
718
719                                if ($video.length) {
720                                    var videoElement = $video[0];
721
722                                    var currentSrc = videoElement.currentSrc;
723                                    videoElement.pause();
724                                    videoElement.currentTime = 0;
725                                    videoElement.src = '';
726                                    videoElement.src = currentSrc;
727                                }
728                            }
729                        },
730                        afterClose: function(){
731
732                            if( $this.data('flexslider') && $this.data('flexslider').playing){
733                                $this.flexslider('play');
734                            }
735
736                            var $activeSlide = $this.find('.flex-active-slide');
737                            $activeSlide.background('play');
738
739                            if ($activeSlide.attr('data-vimeo-options')) {
740                                var options = JSON.parse($activeSlide.attr('data-vimeo-options'));
741                                var currentVimeoPlayer = new Vimeo.Player($activeSlide);
742                                var backgroundAutoplay = options.autoplay;
743
744                                currentVimeoPlayer.getPaused().then(function (paused) {
745                                    if (backgroundAutoplay && paused) {
746                                        currentVimeoPlayer.play();
747                                    }
748                                });
749                            }
750                        }
751                    }
752                });
753            });
754
755
756            $('#slider .slides .li-wrap').css({'margin-top':0,'opacity':0});
757
758            $window.on('resize focus', dynamicHeight);
759
760            dynamicHeight();
761
762            $('#scroll-to-content').on('click', function () {
763                $('html, body').animate({
764                    scrollTop: $('#slider').offset().top + $('#slider').outerHeight() - $('.navbar').outerHeight()
765
766                }, 600);
767            });
768
769            function dynamicHeight() {
770                var height = $(window).height() - $('#slider').offset().top - parseInt($('#slider').css('padding-top'), 10);
771
772                /* use different min-height for different borwser widths */
773                if (height < 300) {
774                    height = 300;
775                } else if (height < 500 && $window.width() > 768) {
776                    height = 500;
777                }
778
779                $this.find('.slides, .slides > li').height(height);
780            }
781
782
783
784            function videoBackground(slider, called_from) {
785
786                var $slides = slider.find('.slides > li');
787                var $currentSlide = $slides.not('.clone').eq(slider.currentSlide);
788                var $nextSlide = $slides.not('.clone').eq(slider.animatingTo);
789
790                if ($currentSlide.attr('data-vimeo-options') && 'start' !== called_from && !handHeldDevice) {
791
792                    var options = JSON.parse($currentSlide.attr('data-vimeo-options'));
793                    var currentVimeoPlayer = new Vimeo.Player($currentSlide, options);
794
795                    currentVimeoPlayer.on('timeupdate', function () {
796                        currentVimeoPlayer.pause();
797                        currentVimeoPlayer.off('timeupdate');
798                    });
799                }
800
801                if ($nextSlide.attr('data-vimeo-options') && !handHeldDevice) {
802                    var options = JSON.parse($nextSlide.attr('data-vimeo-options'));
803                    var nextVimeoPlayer = new Vimeo.Player($nextSlide, options);
804                    var backgroundAutoplay = options.autoplay;
805                    var backgroundMute = options.muted;
806
807
808                    nextVimeoPlayer.setCurrentTime(0.0).then(function () {
809
810                        if (!backgroundAutoplay) {
811                            nextVimeoPlayer.pause();
812                        } else{
813                            nextVimeoPlayer.play();
814                        }
815
816                        if (!backgroundMute) {
817                            nextVimeoPlayer.setVolume(1);
818                        }
819
820                    });
821
822
823                    nextVimeoPlayer.on('play', function () {
824
825                        if (!handHeldDevice) {
826                            $nextSlide.find('.wpzoom-button-video-background-play')[backgroundAutoplay ? 'hide' : 'show']();
827                            $nextSlide.find('.wpzoom-button-video-background-pause')[backgroundAutoplay ? 'show' : 'hide']();
828                            $nextSlide.find('.wpzoom-button-sound-background-mute')[backgroundMute ? 'hide' : 'show']();
829                            $nextSlide.find('.wpzoom-button-sound-background-unmute')[backgroundMute ? 'show' : 'hide']();
830                        }
831
832                        $nextSlide.css('background-image', 'none');
833                    });
834                }
835
836                if ($currentSlide.attr('data-formstone-options')) {
837
838                    if ($currentSlide.data('fsBackground')) {
839                        if ($currentSlide.data('fsBackground').playing) {
840                            $currentSlide.background('pause');
841                        }
842                        $currentSlide.background('unload');
843                    }
844                }
845
846                if ($nextSlide.attr('data-formstone-options')) {
847
848                    if ($nextSlide.data('fsBackground')) {
849                        var currentSource = $nextSlide.data('formstoneOptions').source;
850
851                        if (!_.isEmpty($nextSlide.data('formstoneOptions').mobileSource.mp4) &&
852                            window.matchMedia('(max-width:460px)').matches) {
853                            currentSource = {
854                                'poster': $nextSlide.data('formstoneOptions').source.poster,
855                                'mp4': $nextSlide.data('formstoneOptions').mobileSource.mp4,
856                            };
857                        }
858
859                        if (!handHeldDevice) {
860                            $nextSlide.background('load', currentSource);
861                        } else {
862                            $nextSlide.background('load', {poster: $nextSlide.data('formstoneOptions').source.poster});
863                        }
864                    } else {
865                        var options = JSON.parse($nextSlide.attr('data-formstone-options'));
866
867                        if (!_.isEmpty(options.mobileSource.mp4) &&
868                            window.matchMedia('(max-width:460px)').matches) {
869                            options.source = {
870                                'poster': options.source.poster,
871                                'mp4': options.mobileSource.mp4
872                            };
873                        }
874
875                        if (!handHeldDevice) {
876                            $nextSlide.background(options);
877                        } else {
878                            options.source = {poster: options.source.poster};
879                            $nextSlide.background(options);
880                        }
881                    }
882
883                    var backgroundAutoplay = $nextSlide.data('fsBackgroun
883d').autoPlay;
884                    var backgroundMute = $nextSlide.data('fsBackground').mute;
885
886
887                    if (!handHeldDevice) {
888                        $nextSlide.find('.wpzoom-button-video-background-play')[backgroundAutoplay ? 'hide' : 'show']();
889                        $nextSlide.find('.wpzoom-button-video-background-pause')[backgroundAutoplay ? 'show' : 'hide']();
890                        $nextSlide.find('.wpzoom-button-sound-background-mute')[backgroundMute ? 'hide' : 'show']();
891                        $nextSlide.find('.wpzoom-button-sound-background-unmute')[backgroundMute ? 'show' : 'hide']();
892                    }
893                }
894
895
896                if (slider.vars.animation == 'swing' && typeof slider.direction !== 'undefined') {
897                    if (slider.count == slider.currentSlide + 1 && slider.direction == 'next') {
898                        $nextSlide = $nextSlide.add(slider.find('.clone:last'));
899                    } else if (slider.currentSlide == 0 && slider.direction == 'prev') {
900                        $nextSlide = $nextSlide.add(slider.find('.clone:first'));
901                    } else {
902                        slider.find('.clone .li-wrap').css({ 'margin-top': 0, 'opacity': 0 });
903                    }
904                }
905
906                /* Text animation for slide that is dissapearing */
907                $currentSlide.find('.li-wrap').stop().animate({'margin-top': 0, 'opacity': 0}, 800);
908
909                /* Text animation for slide that is appearing */
910                $nextSlide.find('.li-wrap').stop(true, true).css('opacity', 0).animate({'margin-top': '50px', 'opacity': 1}, 800);
911
912            }
913
914        });
915    };
916
917
918
919
920    /**
921     * Simple Parallax plugin.
922     */
923    $.fn.paralised = function () {
924        var features = {
925            bind: !!(function () {
926            }.bind),
927            rAF: !!(window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame)
928        };
929
930        if (typeof features === 'undefined' || !features.rAF || !features.bind) return;
931
932        /**
933         * Handles debouncing of events via requestAnimationFrame
934         * @see http://www.html5rocks.com/en/tutorials/speed/animations/
935         * @param {Function} callback The callback to handle whichever event
936         */
937        function Debouncer(e) {
938            this.callback = e;
939            this.ticking = false
940        }
941
942        Debouncer.prototype = {
943            constructor: Debouncer, update: function () {
944                this.callback && this.callback();
945                this.ticking = false
946            }, requestTick: function () {
947                if (!this.ticking) {
948                    requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this)));
949                    this.ticking = true
950                }
951            }, handleEvent: function () {
952                this.requestTick()
953            }
954        }
955
956        var debouncer = new Debouncer(update.bind(this));
957
958        $(window).on('scroll', debouncer.handleEvent.bind(debouncer));
959        debouncer.handleEvent();
960
961        function update() {
962            var scrollPos = $(document).scrollTop();
963
964            var $postCover = $('.has-post-cover .entry-cover');
965            var $singlePage = $('.featured_page_wrap--with-background');
966
967            if ($postCover.length) {
968                var $postCover = $('.entry-cover');
969                var postCoverBottom = $postCover.position().top + $postCover.outerHeight();
970
971                if (scrollPos < postCoverBottom) {
972                    var x = easeOutSine(scrollPos, 0, 1, postCoverBottom);
973
974                    $postCover.find('.entry-header').css({
975                        'bottom': 30 * (1 - x),
976                        'opacity': 1 - easeInQuad(scrollPos, 0, 1, postCoverBottom)
977                    });
978                }
979            }
980
981            $singlePage.each(function (i) {
982                var $this = $(this);
983                var bottom = $this.position().top + $this.outerHeight();
984
985                var inViewport = (scrollPos + $window.height()) > $this.position().top && scrollPos < bottom;
986
987                if (!inViewport) return;
988
989                var x = easeOutSine(scrollPos + $window.height() - $this.position().top, -1, 2, bottom);
990
991                $this.find('.wpzoom-singlepage').css({
992                    '-webkit-transform': 'translateY(' + (-x * 80) + 'px)',
993                        'moz-transform': 'translateY(' + (-x * 80) + 'px)',
994                            'transform': 'translateY(' + (-x * 80) + 'px)'
995                });
996            });
997        }
998
999        function easeOutSine(t, b, c, d) {
1000            return c * Math.sin(t / d * (Math.PI / 2)) + b;
1001        }
1002
1003        function easeInQuad(t, b, c, d) {
1004            return c * (t /= d) * t + b;
1005        }
1006    };
1007
1008    $.fn.portfolioIsotopeFilter = function () {
1009        return this.each(function () {
1010            var $this = $(this);
1011            var $taxs = $this.find('li');
1012            var $portfolioWrapper = $(this).closest('.portfolio-showcase');
1013            var callback = 'wpz_get_portfolio_items';
1014
1015            if($portfolioWrapper.length == 0){
1016                callback = 'wpz_get_portfolio_filtered_items';
1017                $portfolioWrapper = $(this).closest('.portfolio-archive');
1018            }
1019
1020            var $portfolio= $portfolioWrapper.find('.portfolio-grid');
1021            var $loadMoreBtnWrapper = $portfolioWrapper.find('.portfolio-view_all-link');
1022            var $loadMoreBtn = $loadMoreBtnWrapper.find('a');
1023            var widget_settings = $portfolio.data('instance');
1024            var tmpl = $portfolio.attr('data-callback-template');
1025            var nonce = $portfolio.data('nonce');
1026            var count_nonce = $portfolio.data('count-nonce');
1027
1028            //Check if instance already exists skip create isotope instance.
1029            if ($portfolio.data('masonry') === undefined) {
1030
1031                $(window).on('load', function () {
1032
1033                    // reload items after jetpack render for isotope instance
1034                    $(document).on('jetpack-lazy-loaded-image', function () {
1035                        $portfolio.imagesLoaded().progress(function () {
1036                            $portfolio.isotope('reloadItems').isotope('layout');
1037                        });
1038                    });
1039
1040                    $portfolio.fadeIn().isotope({
1041                        itemSelector: 'article',
1042                        layoutMode: 'fitRows',
1043                    }).isotope('layout');
1044                });
1045
1046            }
1047
1048
1049
1050
1051            $portfolio.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
1052
1053            var tax_filter_regex = /cat-item-([0-9]+)/gi;
1054
1055            if($portfolio.attr('data-ajax-items-loading')){
1056                var ajaxRequestRunning = false;
1057
1058                $taxs.on('click', function (e) {
1059                    e.preventDefault();
1060                    if (ajaxRequestRunning) {
1061                        e.stopImmediatePropagation();
1062                    }
1063                });
1064
1065                $taxs.one('click', function (e) {
1066                    e.preventDefault();
1067
1068                    if ($(this).hasClass('cat-item-all')) {
1069                        return;
1070                    }
1071
1072                    e.stopImmediatePropagation();
1073                    ajaxRequestRunning = true;
1074
1075
1076                    var $this = $(this);
1077                    var catID = tax_filter_regex.exec($this.attr('class'));
1078                    tax_filter_regex.lastIndex = 0;
1079
1080                    var filter = (catID === null) ? '.type-portfolio_item' : '.portfolio_' + catID[1] + '_item';
1081
1082                    $loadMoreBtn.hide();
1083                    $this.css('position', 'relative');
1084                    $this.append("<div class='pulse-circle'></div>");
1085                    $taxs.removeClass('current-cat');
1086                    $this.addClass('current-cat animated slow pulse');
1087
1088                    if (null == catID) {
1089                        if ($this.attr('data-subcategory')) {
1090                            catID = $this.attr('data-subcategory');
1091                        } else {
1092                            catID = 'all'
1093                        }
1094
1095                    } else {
1096                        catID = catID[1];
1097                    }
1098
1099                    wp.ajax.post(
1100                        callback,
1101                        {
1102                            category_id: catID,
1103                            widget_settings: widget_settings,
1104                            nonce: nonce,
1105                            tmpl: tmpl
1106                        }).done(function (response) {
1107
1108                        $this.attr('data-counter', response.count);
1109
1110                        if (_.isEmpty(response.content)) {
1111                            return;
1112                        }
1113
1114                        var $nodes = $.parseHTML(response.content).filter(function ($element) {
1115                            $($element).addClass('wpz-portfolio-item-ad
1115ded-dynamic');
1116                            return $($element).is('article') && ($portfolio.find('#' + $($element).attr('id')).length === 0);
1117                        });
1118
1119                        $($nodes).imagesLoaded(function () {
1120                            $portfolio.append($($nodes))
1121                                .isotope('appended', $($nodes));
1122                        }).progress(function () {
1123                            $portfolio.isotope('layout');
1124                        }).done(function () {
1125							$portfolio.isotope('layout');
1126                            //start
1127                            var items_number = parseInt($this.attr('data-counter'));
1128                            var portfolioLength = parseInt($portfolio.find(filter).length);
1129                            var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
1130
1131                            if (portfolioLength < items_number) {
1132                                $loadMoreBtn.show();
1133                            }
1134
1135                            if(portfolioLength == items_number){
1136                                $loadMoreBtn.hide();
1137                            }
1138
1139                            if(portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')){
1140                                $loadMoreBtnWrapper.remove();
1141                            }
1142                            //end
1143                            $portfolio.find('.portfolio_item').thumbnailPopover();
1144                            $portfolio.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
1145                            $portfolio.find('.wpz-portfolio-item-added-dynamic video[autoplay]').each(function(){
1146                                this.play();
1147                            });
1148
1149                            if ($.fn.mediaelementplayer) {
1150                                $('.wp-audio-shortcode, .wp-video-shortcode').not('.mejs-container').filter(function(){return!$(this).parent().hasClass('.mejs-mediaelement')}).mediaelementplayer();
1151                            }
1152                        });
1153                    }).always(function () {
1154                        $this.find('.pulse-circle').remove();
1155                        $this.removeClass('animated slow pulse');
1156                        $portfolio.isotope({
1157                            'filter': filter
1158                        });
1159
1160                        ajaxRequestRunning = false;
1161
1162
1163                    });
1164                });
1165            }
1166
1167            if ($loadMoreBtn.attr('data-ajax-loading')) {
1168
1169                //hide on first load
1170                var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
1171
1172                if(portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')){
1173                    $loadMoreBtnWrapper.remove();
1174                }
1175
1176                $loadMoreBtn.on('click', function (e) {
1177                    e.preventDefault();
1178
1179                    var catID = tax_filter_regex.exec($taxs.siblings('.current-cat').attr('class'));
1180                    tax_filter_regex.lastIndex = 0;
1181                    var filter = (null == catID) ? '.type-portfolio_item': '.portfolio_' + catID[1] + '_item';
1182                    var category_id = ( null == catID) ? 'all' :catID[1];
1183
1184                    if (category_id == 'all' && $portfolio.attr('data-subcategory')) {
1185                        category_id = $portfolio.attr('data-subcategory');
1186                    }
1187
1188                    $(this).text('Loading...');
1189
1190                    var post_not_in = $portfolio.find('.type-portfolio_item').map(function(index, el){
1191                        return $(el).attr('id').split('post-').pop();
1192                    }).toArray().join(',');
1193
1194                    wp.ajax.post(
1195                        callback,
1196                        {
1197                            category_id: category_id,
1198                            widget_settings: widget_settings,
1199                            nonce: nonce,
1200                            tmpl: tmpl,
1201                            post_not_in: post_not_in,
1202                            'show_all': true
1203                        }).done(function (response) {
1204
1205                        if (_.isEmpty(response.content)) {
1206                            return;
1207                        }
1208
1209                        var $nodes = $.parseHTML(response.content).filter(function ($element) {
1210                            $($element).addClass('wpz-portfolio-item-ad
1210ded-dynamic');
1211                            return $($element).is('article') && ($portfolio.find('#' + $($element).attr('id')).length === 0);
1212                        });
1213
1214                        $($nodes).imagesLoaded(function () {
1215                            $portfolio.append($($nodes))
1216                                .isotope('appended', $($nodes));
1217                        }).progress(function () {
1218                            $portfolio.isotope('layout');
1219                        }).done(function () {
1220							$portfolio.isotope('layout');
1221                            var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
1222
1223                            $loadMoreBtn.text($loadMoreBtn.attr('title'));
1224
1225                            if( parseInt($portfolio.find(filter).length) == $taxs.siblings('.current-cat').attr('data-counter')){
1226                                $loadMoreBtn.hide();
1227                            }
1228
1229                            if(portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')){
1230                                $loadMoreBtnWrapper.remove();
1231                            }
1232							$.fn.playBackgroundVideo();
1233                            $portfolio.find('.portfolio_item').thumbnailPopover();
1234                            $portfolio.find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
1235                            $portfolio.find('.wpz-portfolio-item-added-dynamic video[autoplay]').each(function(){
1236                                this.play();
1237                            });
1238							$(filter).find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
1239
1240                        });
1241                    }).always(function () {
1242                        $portfolio.isotope({
1243                            'filter': filter
1244                        });
1245                    });
1246                });
1247            }
1248
1249            $taxs.on('click', function (event) {
1250                event.preventDefault();
1251
1252                $this = $(this);
1253
1254                $taxs.removeClass('current-cat');
1255                $this.addClass('current-cat');
1256
1257
1258                var catID = tax_filter_regex.exec($this.attr('class'));
1259                tax_filter_regex.lastIndex = 0;
1260
1261                var filter;
1262
1263                if (catID === null) {
1264                    filter = '.type-portfolio_item';
1265                } else {
1266                    filter = '.portfolio_' + catID[1] + '_item';
1267                }
1268
1269                var category_id = ( null == catID) ? 'all' :catID[1];
1270
1271                if (category_id == 'all' && $portfolio.attr('data-subcategory')) {
1272                    category_id = $portfolio.attr('data-subcategory');
1273                }
1274
1275                var items_number = $taxs.siblings('.current-cat').attr('data-counter');
1276
1277                if (items_number === undefined) {
1278
1279                    wp.ajax.post('wpz_count_portfolio_items', {
1280                        nonce: count_nonce,
1281                        category_id: category_id
1282                    }).done(function (response) {
1283                        $this.attr('data-counter', response.count);
1284
1285                        var items_number = response.count;
1286                        var portfolioLength = parseInt($portfolio.find(filter).length);
1287                        var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
1288
1289                        if (portfolioLength < items_number) {
1290                            $loadMoreBtn.show();
1291                        }
1292
1293                        if (portfolioLength == items_number) {
1294                            $loadMoreBtn.hide();
1295                        }
1296
1297                        if(portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')){
1298                            $loadMoreBtnWrapper.remove();
1299                        }
1300                    });
1301
1302                } else {
1303                    var portfolioLength = parseInt($portfolio.find(filter).length);
1304                    var portfolioLengthAll = parseInt($portfolio.find('.type-portfolio_item').length);
1305
1306                    if (portfolioLength < items_number ) {
1307                        $loadMoreBtn.show();
1308                    }
1309
1310                    if (portfolioLength == items_number ) {
1311                        $loadMoreBtn.hide();
1312                    }
1313
1314                    if(portfolioLengthAll == $taxs.siblings('.cat-item-all').attr('data-counter')){
1315                        $loadMoreBtnWrapper.remove();
1316                    }
1317                }
1318
1319                $portfolio.isotope({
1320                    'filter': filter
1321                });
1322				$(filter).find('.portfolio-popup-video').magnificPopupCallbackforPortfolios();
1323            });
1324        });
1325    };
1326
1327
1328
1329
1330    $.fn.fullWidthContent = function () {
1331        $(window).on('resize', update);
1332
1333        function update() {
1334            var windowWidth = $(window).width();
1335            var containerWidth = $('.entry-content').width();
1336            var marginLeft = (windowWidth - containerWidth) / 2;
1337
1338            $('.fullimg').css({
1339                'width': windowWidth,
1340                'margin-left': -marginLeft
1341            });
1342
1343            $('.fullimg .wp-caption').css({
1344                'width': windowWidth
1345            });
1346        }
1347
1348        update();
1349    };
1350
1351    $.fn.responsiveSliderImages = function () {
1352        var forceCssRule = true;
1353
1354        $(window).on('resize orientationchange', update);
1355
1356        function update() {
1357            var windowWidth = $(window).width();
1358
1359            if (windowWidth <= 680) {
1360                $('#slider .slides li').each(function () {
1361                    var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/);
1362                    var smallimg = $(this).data('smallimg');
1363
1364                    if (bgurl) {
1365                        bgurl = bgurl[1];
1366                    }
1367
1368                    if (bgurl == smallimg) return;
1369
1370                    if (!forceCssRule && $(this).attr('data-vimeo-options')) return;
1371
1372                    $(this).css('background-image', 'url("' + smallimg + '")');
1373                });
1374            }
1375
1376            if (windowWidth > 680) {
1377                $('#slider .slides li').each(function () {
1378                    var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/);
1379                    var bigimg = $(this).data('bigimg');
1380
1381                    if (bgurl) {
1382                        bgurl = bgurl[1];
1383                    }
1384
1385                    if (bgurl == bigimg) return;
1386
1387                    if (!forceCssRule && $(this).attr('data-vimeo-options')) return;
1388
1389
1390                    $(this).css('background-image', 'url("' + bigimg + '")');
1391                });
1392            }
1393
1394            forceCssRule = false;
1395        }
1396
1397        update();
1398    };
1399
1400
1401
1402    $.fn.responsiveImagesHeader = function () {
1403        var forceCssRule = true;
1404        $(window).on('resize orientationchange', update);
1405
1406        function update() {
1407            var windowWidth = $(window).width();
1408
1409            if (windowWidth <= 680) {
1410
1411                $('.entry-cover-image, .portfolio-header-cover-image').each(function () {
1412                    var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/);
1413                    var smallimg = $(this).data('smallimg');
1414
1415                    if (bgurl) {
1416                        bgurl = bgurl[1];
1417                    }
1418
1419                    if (bgurl == smallimg) return;
1420
1421                    $(this).css('background-image', 'url("' + smallimg + '")');
1422                });
1423
1424            }
1425
1426            if (windowWidth > 680) {
1427
1428                $('.entry-cover-image, .portfolio-header-cover-image').each(function () {
1429                    var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/);
1430                    var bigimg = $(this).data('bigimg');
1431
1432                    if (bgurl) {
1433                        bgurl = bgurl[1];
1434                    }
1435
1436                    if (bgurl == bigimg) return;
1437
1438                    $(this).css('background-image', 'url("' + bigimg + '")');
1439                });
1440
1441            }
1442        }
1443
1444        update();
1445    };
1446
1447
1448
1449
1450    $.fn.sideNav = function() {
1451        var wasPlaying = false;
1452
1453        function toggleNav() {
1454            $('body').toggleClass('side-nav-open').addClass('side-nav-transitioning');
1455
1456            var flex = $('#slider').data('flexslider');
1457            if (flex) {
1458                if ($('body').hasClass('side-nav-open')) {
1459                    wasPlaying = flex.playing;
1460                    if (flex.playing)  {
1461                        flex.pause();
1462                    }
1463                } else {
1464                    if (wasPlaying) {
1465                        flex.play();
1466                    }
1467                }
1468            }
1469
1470            var called = false;
1471            $('.site').one('transitionend', function () {
1472                $('body').removeClass('side-nav-transitioning');
1473                called = true;
1474            });
1475
1476            setTimeout(function() {
1477                if (!called) {
1478                    $('body').removeClass('side-nav-transitioning');
1479                }
1480
1481                $window.trigger('resize');
1482            }, 230);
1483        }
1484
1485        /* touchstart: do not allow scrolling main section then overlay is enabled (this is done via css) */
1486        $('.navbar-toggle, .side-nav-overlay').on('click touchend', function (event) {
1487            if ($(document.body).hasClass('side-nav-transitioning')) {
1488                return;
1489            }
1490
1491            toggleNav();
1492        });
1493
1494        /* allow closing sidenav with escape key */
1495        $document.on('keyup', function (event) {
1496            if (event.keyCode == 27 && $('body').hasClass('side-nav-open')) {
1497                toggleNav();
1498            }
1499        });
1500
1501        /**
1502         * ScrollFix
1503         *
1504         * https://github.com/joelambert/ScrollFix
1505         */
1506        $('.side-nav__scrollable-container').on('touchstart', function (event) {
1507            var startTopScroll = this.scrollTop;
1508
1509            if (startTopScroll <= 0) {
1510                this.scrollTop = 1;
1511            }
1512
1513            if (startTopScroll + this.offsetHeight >= this.scrollHeight) {
1514                this.scrollTop = this.scrollHeight - this.offsetHeight - 1;
1515            }
1516        });
1517    };
1518
1519    $.fn.singlePageWidgetBackground = function() {
1520        $('.featured_page_wrap[data-background]').each(function () {
1521            var $this = $(this);
1522            $this.css('background-image', 'url(' + $this.data('background') + ')');
1523            $this.addClass('featured_page_wrap--with-background');
1524        });
1525    };
1526
1527    $.fn.sbSearch = function() {
1528
1529    /* allow closing sidenav with escape key */
1530    $document.on('keydown', function (event) {
1531
1532        if (event.keyCode == 27 && $('#sb-search').hasClass('sb-search-open')) {
1533            $( "#sb-search" ).removeClass( "sb-search-open" )
1534        }
1535
1536    });
1537
1538       return this.each(function() {
1539           new UISearch( this );
1540       });
1541    };
1542
1543    $.fn.backgroundVideoSingle = function () {
1544        $(this).each(function (index, el) {
1545            var entryHeader = $(el);
1546            if (entryHeader.length) {
1547
1548                var userAgent = navigator.userAgent || navigator.vendor || window.opera;
1549
1550                var video_on_mobile = zoomOptions.featured_video_mobile;
1551
1552                if (video_on_mobile) { /* play on all devices, excluding these ones: */
1553                    var handHeldDevice = (/webOS|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
1554                }
1555                else { /* when true disable video on mobile */
1556                    var handHeldDevice = (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent));
1557                }
1558
1559                if (entryHeader.attr('data-formstone-options')) {
1560
1561                    var options = JSON.parse(entryHeader.attr('data-formstone-options'));
1562
1563                    if (!handHeldDevice) {
1564                        entryHeader.background(options);
1565                    } else {
1566                        options.source = {poster: options.source.poster};
1567                        entryHeader.background(options);
1568                    }
1569
1570
1571                    var backgroundAutoplay = entryHeader.data('fsBackground').autoPlay;
1572                    var backgroundMute = entryHeader.data('fsBackground').mute;
1573
1574                    if (!handHeldDevice) {
1575                        entryHeader.find('.wpzoom-button-video-background-play')[backgroundAutoplay ? 'hide' : 'show']();
1576                        entryHeader.find('.wpzoom-button-video-background-pause')[backgroundAutoplay ? 'show' : 'hide']();
1577                        entryHeader.find('.wpzoom-button-sound-background-mute')[backgroundMute ? 'hide' : 'show']();
1578                        entryHeader.find('.wpzoom-button-sound-background-unmute')[backgroundMute ? 'show' : 'hide']();
1579                    }
1580                }
1581
1582                if (entryHeader.attr('data-vimeo-options')  && !handHeldDevice) {
1583                    var options = JSON.parse(entryHeader.attr('data-vimeo-options'));
1584                    var vimeoPlayer = new Vimeo.Player(entryHeader, options);
1585                    var backgroundAutoplay = options.autoplay;
1586                    var backgroundMute = options.muted;
1587
1588                    vimeoPlayer.play().then(function () {
1589
1590                        if (!backgroundAutoplay) {
1591                            vimeoPlayer.pause();
1592                        }
1593
1594                        if (!backgroundMute) {
1595                            vimeoPlayer.setVolume(1);
1596                        }
1597
1598                        if (!handHeldDevice) {
1599                            entryHeader.find('.wpzoom-button-video-background-play')[backgroundAutoplay ? 'hide' : 'show']();
1600                            entryHeader.find('.wpzoom-button-video-background-pause')[backgroundAutoplay ? 'show' : 'hide']();
1601                            entryHeader.find('.wpzoom-button-sound-background-mute')[backgroundMute ? 'hide' : 'show']();
1602                            entryHeader.find('.wpzoom-button-sound-background-unmute')[backgroundMute ? 'show' : 'hide']();
1603                        }
1604
1605                    });
1606                }
1607
1608                entryHeader.find('.wpzoom-button-video-background-play').on('click', function (e) {
1609                    e.preventDefault();
1610                    var $currentSlide = $(e.currentTarget).closest('div.entry-cover');
1611
1612                    if ($currentSlide.attr('data-formstone-options')) {
1613                        $currentSlide.background('play');
1614                    }
1615
1616                    if ($currentSlide.attr('data-vimeo-options')) {
1617                        var vimeoPlayer = new Vimeo.Player($currentSlide);
1618                        vimeoPlayer.play();
1619                    }
1620                    entryHeader.find('.wpzoom-button-video-background-pause').show();
1621                    $(this).hide();
1622                });
1623
1624                entryHeader.find('.wpzoom-button-video-background-pause').on('click', function (e) {
1625                    e.preventDefault();
1626                    var $currentSlide = $(e.currentTarget).closest('div.entry-cover');
1627
1628                    if ($currentSlide.attr('data-formstone-options')) {
1629                        $currentSlide.background('pause');
1630                    }
1631
1632                    if ($currentSlide.attr('data-vimeo-options')) {
1633                        var vimeoPlayer = new Vimeo.Player($currentSlide);
1634                        vimeoPlayer.pause();
1635                    }
1636                    entryHeader.find('.wpzoom-button-video-background-play').show();
1637                    $(this).hide();
1638                });
1639
1640                entryHeader.find('.wpzoom-button-sound-background-mute').on('click', function (e) {
1641                    e.preventDefault();
1642                    var $currentSlide = $(e.currentTarget).closest('div.entry-cover');
1643
1644                    if ($currentSlide.attr('data-formstone-options')) {
1645                        $currentSlide.background('mute');
1646                    }
1647
1648                    if ($currentSlide.attr('data-vimeo-options')) {
1649                        var vimeoPlayer = new Vimeo.Player($currentSlide);
1650                        vimeoPlayer.setVolume(0);
1651                    }
1652                    entryHeader.find('.wpzoom-button-sound-background-unmute').show();
1653                    $(this).hide();
1654                });
1655
1656                entryHeader.find('.wpzoom-button-sound-background-unmute').on('click', function (e) {
1657                    e.preventDefault();
1658                    var $currentSlide = $(e.currentTarget).closest('div.entry-cover');
1659
1660                    if ($currentSlide.attr('data-formstone-options')) {
1661                        $currentSlide.background('unmute');
1662                    }
1663
1664                    if ($currentSlide.attr('data-vimeo-options')) {
1665                        var vimeoPlayer = new Vimeo.Player($currentSlide);
1666                        vimeoPlayer.setVolume(1);
1667                    }
1668                    entryHeader.find('.wpzoom-button-sound-background-mute').show();
1669                    $(this).hide();
1670                });
1671            }
1672
1673        });
1674    };
1675
1676
1677    $(document).ready(function () {
1678
1679        //init for portfolio
1680        $('.single-portfolio_item article.portfolio_item .entry-cover').backgroundVideoSingle();
1681        //init for posts
1682        $('.single-post article.post .entry-cover').backgroundVideoSingle();
1683        //init for pages
1684        $('.page article.page .entry-cover').backgroundVideoSingle();
1685        $('.page .portfolio-header-cover .entry-cover').backgroundVideoSingle();
1686
1687    });
1688
1689    jQuery(function($) {
1690
1691        $('.widget.wpzoom-portfolio-scroller').each(function(){
1692            var $this = $(this);
1693            var $c = $this.find('.flickity-wrapper');
1694            var autoScroll = $c.attr('data-auto-scroll');
1695            var scrollInfinitely = $c.attr('data-scroll-infinitely');
1696
1697            $c.imagesLoaded( function(){
1698
1699                $this.find('.carousel_widget_wrapper').show();
1700                $this.find('.loading-wrapper').hide();
1701
1702                $c.flickity({
1703                    autoPlay: autoScroll,
1704                    cellAlign: 'left',
1705                    contain: true,
1706                    percentPosition: false,
1707                    pageDots: false,
1708                    wrapAround: scrollInfinitely,
1709                    freeScroll: true,
1710                    imagesLoaded: true,
1711                    accessibility: false,
1712                    arrowShape: {
1713                        x0: 10,
1714                        x1: 60, y1: 50,
1715                        x2: 65, y2: 50,
1716                        x3: 15
1717                    }
1718                });
1719
1720            });
1721        });
1722
1723    });
1724
1725	$(window).on(
1726        'elementor/frontend/init',
1727        function () {
1728            elementorFrontend.hooks.addAction('frontend/element_ready/widget', function ($scope) {
1729
1730                if ($scope.data('widget_type') == "wp-widget-wpzoom-portfolio-scroller.default") {
1731
1732                    var $selector = $('.elementor-widget-wp-widget-wpzoom-portfolio-scroller .elementor-widget-container');
1733
1734                    $selector.each(function () {
1735
1736						console.log( 'check' );
1737                        var $this = $(this);
1738                        var $c = $this.find('.flickity-wrapper');
1739                        var autoScroll = $c.attr('data-auto-scroll');
1740                        var scrollInfinitely = $c.attr('data-scroll-infinitely');
1741
1742                        $c.imagesLoaded(function () {
1743
1744                            $this.find('.carousel_widget_wrapper').show();
1745                            $this.find('.loading-wrapper').hide();
1746
1747                            $c.flickity({
1748                                autoPlay: autoScroll,
1749                                cellAlign: 'left',
1750                                contain: true,
1751                                percentPosition: false,
1752                                pageDots: false,
1753                                wrapAround: scrollInfinitely,
1754                                freeScroll: true,
1755                                imagesLoaded: true,
1756                                accessibility: false,
1757                                arrowShape: {
1758                                    x0: 10,
1759                                    x1: 60, y1: 50,
1760                                    x2: 65, y2: 50,
1761                                    x3: 15
1762                                }
1763                            });
1764
1765                        });
1766                    });
1767                }
1768				
1769				//Init the Slider PRO widget
1770				if ( $scope.data('widget_type') == "wpzoom-elementor-addons-slider-pro.default" ) {
1771					$('.flexslider').sllider();
1772					$.fn.responsiveSliderImages();
1773				}
1774
1775                if ($scope.data('widget_type') == "wp-widget-wpzoom-portfolio-showcase.default") {
1776                    $('.portfolio-taxonomies-filter-by').portfolioIsotopeFilter();
1777                }
1778
1779            });
1780        }
1781    );
1782
1783})(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.