PageSourceSearch

https://www.summitgroupsolutions.com/wp-content/themes/cesis/js/cesis_custom.js?ver=4.9.8

js summitgroupsolutions.com collected 2026-10-08 08:01:25 UTC 97,523 bytes, 2,514 lines download raw bytes

1/**
2 * cesis_custom.js
3 *
4 **/
5
6var jc = jQuery;
7
8jc.noConflict();
9
10'use strict';
11
12
13jc(document).ready(function() {
14    vc_rowBehaviour();
15    cesis_initVideoBackgrounds();
16    cesis_row();
17    cesis_owl_carousel();
18    cesis_text_resize();
19    set_center_logo();
20    cesis_section_swipe();
21    cesis_scroll_fn();
22    cesis_to_top();
23    cesis_tabs();
24    vc_progress_bar();
25    vc_waypoints();
26    cesis_circular_progress_bar();
27    cesis_animated_number();
28    cesis_accordion();
29    cesis_video();
30    cesis_lightbox();
31    cesis_like();
32    cesis_menu();
33    cesis_gmaps();
34    cesis_isotope();
35    cesis_fixed_footer();
36    cesis_sticky();
37    window.setTimeout(vc_waypoints, 500);
38    cesis_resize();
39
40
41
42});
43
44if ('function' !== typeof(window['cesis_resize'])) {
45
46window.cesis_resize = function() {
47    jc(window).resize(function () {
48            setTimeout(function () {
49              vc_rowBehaviour();
50              cesis_text_resize();
51            }, 500);
52    });
53    document.addEventListener("visibilitychange", function() {
54            setTimeout(function () {
55              vc_rowBehaviour();
56              cesis_text_resize();
57            }, 500);
58    });
59  }
60}
61
62if ('function' !== typeof(window['cesis_initVideoBackgrounds'])) {
63
64window.cesis_initVideoBackgrounds = function() {
65    jc("[data-vc-vimeo-video-bg]").each(function() {
66        var vimeoUrl, vimeoId, $element = jc(this);
67        $element.data("vc-vimeo-video-bg") ? (vimeoUrl = $element.data("vc-vimeo-video-bg"), vimeoId = ttExtractVimeoId(vimeoUrl), vimeoId && ($element.find(".vc_video-bg").remove(), insertVimeoVideoAsBackground($element, vimeoId)), jc(window).on("grid:items:added", function(event, $grid) {
68            $element.has($grid).length && vcResizeVideoBackground($element)
69        })) : $element.find(".vc_video-bg").remove()
70    })
71    jc("[data-vc-sh-video-bg]").each(function() {
72        var $element = jc(this);
73        var videoUrl = $element.data("vc-sh-video-bg");
74         $element.find(".vc_video-bg").remove();
75         $element.prepend('<video playsinline class="cesis_sh_video_bg" preload="auto" autoplay="true" loop="loop" muted="muted" data-top-default="0" style="top: 0px;"><source src="'+videoUrl+'"></video>');
76    })
77
78  }
79}
80
81
82
83function insertVimeoVideoAsBackground($element, vimeoId, counter) {
84    if ("undefined" == typeof YT || void 0 === YT.Player) return 100 < (counter = void 0 === counter ? 0 : counter) ? void console.warn("Too many attempts to load Vimeo api") : void setTimeout(function() {
85        insertVimeoVideoAsBackground($element, vimeoId, counter++)
86    }, 100);
87    var $container = $element.prepend('<div class="vc_video-bg vc_hidden-xs"><div class="inner"><iframe frameborder="0" allow="autoplay" src="//player.vimeo.com/video/'+vimeoId+'?background=1&amp;api=1&amp;title=0&amp;byline=0&amp;portrait=0&amp;playbar=0&amp;loop=1&amp;autoplay=1"></iframe></div></div>').find(".inner");
88    vcResizeVideoBackground($element), jc(window).on('resize', function() {
89        vcResizeVideoBackground($element)
90    })
91}
92
93
94function vcResizeVideoBackground($element) {
95    var iframeW, iframeH, marginLeft, marginTop, containerW = $element.innerWidth(),
96        containerH = $element.innerHeight();
97    containerW / containerH < 16 / 9 ? (iframeW = containerH * (16 / 9), iframeH = containerH, marginLeft = -Math.round((iframeW - containerW) / 2) + "px", marginTop = -Math.round((iframeH - containerH) / 2) + "px", iframeW += "px", iframeH += "px") : (iframeW = containerW, iframeH = containerW * (9 / 16), marginTop = -Math.round((iframeH - containerH) / 2) + "px", marginLeft = -Math.round((iframeW - containerW) / 2) + "px", iframeW += "px", iframeH += "px"), $element.find(".vc_video-bg iframe").css({
98        maxWidth: "1000%",
99        marginLeft: marginLeft,
100        marginTop: marginTop,
101        width: iframeW,
102        height: iframeH
103    })
104}
105
106function ttExtractVimeoId(url) {
107    if (void 0 === url) return !1;
108    var id = url.match(/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([‌​0-9]{6,11})[?]?.*/);
109    return null !== id && id[5]
110
111}
112
113
114//////////////////////////
115//***      Menu     ***//
116////////////////////////
117
118
119if ('function' !== typeof(window['cesis_menu'])) {
120  window.cesis_menu = function() {
121    var isMobile = jc('body').hasClass('touch') ? true : false;
122    if(jc('.admin-bar').length && jc('.header_vertical').length){
123        jc('.header_vertical').css('top', '32px')
124    }
125    if(jc('.cesis_menu_overlay').length || jc('.cesis_offcanvas_switch').length || jc('.header_vertical').length  ){
126      jc('.cesis_megamenu').removeClass('cesis_megamenu');
127      jc('.mega_no_heading').removeClass('mega_no_heading');
128
129    }
130    if(jc('.cesis_megamenu').length){
131      jc('.tt-main-navigation .cesis_megamenu > ul').addClass('mega-menu');
132    }
133		if (jc('[class*="smart_menu"]').length > 0) {
134			jc('[class*="smart_menu"]').smartmenus({
135        mainMenuSubOffsetX: -1,
136		    subMenusSubOffsetX: 0,
137		    subMenusSubOffsetY: 0,
138        subMenusMaxWidth:'200px',
139        subMenusMinWidth:'13em',
140        subIndicators:false,
141        hideFunction:null,
142        hideDuration:0,
143        hideTimeout:400,
144        showFunction:null,
145        showDuration:0,
146        showTimeout:0,
147      });
148
149      jc('.mobile-menu').smartmenus({
150        mainMenuSubOffsetX: -1,
151		    subMenusSubOffsetX: 0,
152		    subMenusSubOffsetY: 0,
153        subMenusMaxWidth:'200px',
154        subMenusMinWidth:'13em',
155        subIndicators:true,
156        hideFunction:null,
157        hideDuration:0,
158        hideTimeout:400,
159        showFunction:null,
160        showDuration:0,
161        showTimeout:0,
162      });
163
164		}
165    if (jc('.menu_fill').length > 0) {
166      var total_menu_items = jc('nav.menu_fill .menu-main-ct > ul > li').length;
167      if (jc('.header_sub').length) {
168        var logo_size = 0;
169        if(jc('.tt-sub-additional').length){
170          var add_size = jc('.tt-sub-additional .tt-left-additional').outerWidth()+jc('.tt-sub-additional .tt-right-additional').outerWidth();
171        }else {
172          var add_size = 0;
173        }
174      }else{
175        if (jc('.header_logo').length) {
176        var logo_size = jc('.header_logo').width();
177        }else {
178        var logo_size = 0;
179        }
180        if(jc('.tt-main-additional').length){
181          var add_size = jc('.tt-main-additional').outerWidth();
182        }else {
183          var add_size = 0;
184        }
185      }
186      jc('nav.menu_fill .menu-main-ct > ul').css('width','calc(100% - '+(logo_size+add_size+80)+'px)');
187      jc('nav.menu_fill .menu-main-ct > ul > li').css('width','calc((100% - 1px) / '+total_menu_items+')');
188    }
189    if (jc('.search-menu a').length > 0) {
190
191      jc('.search-menu:not(.cesis_search_dropdown) a').on('click', function(e){
192        e.preventDefault()
193        jc('.cesis_search_overlay').addClass('overlay_on');
194        setTimeout(function() {
195          jc( ".search-field" ).focus();
196        }, 400);
197
198      })
199    }
200    if (jc('.cesis_search_close').length > 0) {
201      jc('.cesis_search_close').on('click', function(e){
202        e.preventDefault()
203        jc('.cesis_search_overlay').removeClass('overlay_on');
204      })
205    }
206    if (jc('.cesis_menu_button').length > 0) {
207      jc('.cesis_mobile_menu_switch').on('click', function(){
208      var admin_bar;
209      if(jc('.admin-bar').length && !window.matchMedia('(max-width: 600px)').matches){
210        admin_bar = jc('#wpadminbar').outerHeight();
211      }else if(document.body.scrollTop === 0 && jc('.admin-bar').length && window.matchMedia('(max-width: 600px)').matches){
212        admin_bar = jc('#wpadminbar').outerHeight();
213      }else{
214        admin_bar = 0;
215      }
216      var differencial_height = jc('#cesis_header').outerHeight() + admin_bar;
217      var mobile_height = 'calc( 100vh - '+differencial_height+'px)';
218      jc('.header_mobile').css('max-height', mobile_height);
219      if(isMobile == true){ jc('.header_mobile').css('height', mobile_height); }
220      if (jc(this).hasClass('open')) {
221        jc(this).removeClass('open');
222        jc(this).addClass('closing');
223        jc('.header_mobile').slideToggle(400);
224        setTimeout(function() {
225          jc('.closing').removeClass('closing');
226        }, 400);
227      } else{
228        jc(this).addClass('open');
229        jc('.header_mobile').slideToggle(400);
230      }
231      })
232
233      jc('.cesis_offcanvas_switch').on('click', function(){
234        var oc_ctn =  jc('body.cesis_offcanvas_header .header_top_bar,body.cesis_offcanvas_header .header_main,body.cesis_offcanvas_header .header_offcanvas,body.cesis_offcanvas_header #main-content,body.cesis_offcanvas_header #cesis_colophon');
235        oc_ctn.addClass('cesis_offcanvas_opened');
236        if (jc(this).hasClass('open')) {
237					jc(this).removeClass('open');
238					jc(this).addClass('closing');
239          oc_ctn.removeClass('cesis_offcanvas_opened');
240					setTimeout(function() {
241						jc('.closing').removeClass('closing');
242					}, 400);
243				} else jc(this).addClass('open');
244      })
245
246      jc('.cesis_menu_overlay').on('click', function(){
247        if (jc(this).hasClass('open')) {
248					jc(this).removeClass('open');
249          jc('.cesis_menu_overlay_close').removeClass('open');
250          jc('.header_overlay').removeClass('overlay_on');
251					jc(this).addClass('closing');
252					setTimeout(function() {
253						jc('.closing').removeClass('closing');
254          }, 400);
255          setTimeout(function() {
256            jc('#cesis_header').removeClass('overlay_menu_on');
257          }, 600);
258				} else{
259         jc('#cesis_header').addClass('overlay_menu_on');
260         jc(this).addClass('open');
261         var pos_top   = jc(this)[0].getBoundingClientRect().top;
262         var pos_right = (jc(window).width() - (jc(this).offset().left + jc(this).outerWidth()));
263         jc('.cesis_menu_overlay_close').css('top', pos_top);
264         if(jc('.logo_left').length > 0){
265          jc('.cesis_menu_overlay_close').css('right',pos_right);
266        }else jc('.cesis_menu_overlay_close').css('left',jc(this).offset().left);
267         jc('.cesis_menu_overlay_close').addClass('open');
268         jc('.header_overlay').addClass('overlay_on');
269        }
270      })
271      jc('.cesis_menu_overlay_close').on('click', function(){
272        if (jc(this).hasClass('open')) {
273					jc(this).removeClass('open');
274          jc('.cesis_menu_overlay').removeClass('open');
275          jc('.header_overlay').removeClass('overlay_on');
276					jc(this).addClass('closing');
277          jc('.cesis_search_overlay').removeClass('overlay_on');
278					setTimeout(function() {
279						jc('.closing').removeClass('closing');
280					}, 400);
281          setTimeout(function() {
282            jc('#cesis_header').removeClass('overlay_menu_on');
283          }, 600);
284
285				}else{
286          jc('#cesis_header').addClass('overlay_menu_on');
287          jc(this).addClass('open');
288          jc('.cesis_menu_overlay').addClass('open');
289          jc('.header_overlay').addClass('overlay_on');
290        }
291      })
292	   };
293	 };
294}
295
296
297
298////////////////////////////////
299//***    Sticky  footer   ***//
300//////////////////////////////
301
302
303
304if ('function' !== typeof(window['cesis_fixed_footer'])) {
305      window.cesis_fixed_footer = function() {
306        if(jc('.cesis_fixed_footer').length){
307          var footer_height = jc('.site-footer').outerHeight();
308          jc('#wrap_all').css('margin-bottom', footer_height );
309          jc( window ).resize(function () {
310            var footer_height = jc('.site-footer').outerHeight();
311            jc('#wrap_all').css('margin-bottom', footer_height );
312          })
313        }
314      };
315}
316
317//////////////////////////
318//***    Sticky     ***//
319////////////////////////
320
321
322
323if ('function' !== typeof(window['cesis_sticky'])) {
324      window.cesis_sticky = function() {
325        var isMobile = jc('body').hasClass('touch') ? true : false;
326        if(jc('.cesis_sticky').length){
327          var menuposition;
328          var menu_content_offset = jc('#header_container').outerHeight() - jc('.cesis_sticky').outerHeight();
329          jc('#header_container').css('min-height', jc('#header_container').outerHeight() );
330          if(jc('.admin-bar').length && !window.matchMedia('(max-width: 600px)').matches){
331            menuposition = jc('#header_container').offset().top - jc('#wpadminbar').outerHeight() + menu_content_offset;
332          }else{
333            menuposition = jc('#header_container').offset().top + menu_content_offset;
334          }
335          jc( window ).resize(function () {
336  					setTimeout(function() {
337              if(jc('.header_top_bar').length){
338                jc('#header_container').css('min-height', jc('#header_container').outerHeight() );
339              }else{
340                jc('#header_container').css('min-height', jc('.cesis_sticky').outerHeight() );
341              }
342            }, 400);
343            if(jc('.admin-bar').length && !window.matchMedia('(max-width: 600px)').matches){
344              menuposition = jc('#header_container').offset().top - jc('#wpadminbar').outerHeight() + menu_content_offset;
345            }else{
346              menuposition = jc('#header_container').offset().top + menu_content_offset;
347            }
348          })
349          jc( window ).scroll(function(event) {
350            if (jc(window).scrollTop() > menuposition) {
351              jc('.cesis_sticky').addClass('cesis_stuck');
352            } else {
353              jc('.cesis_sticky').removeClass('cesis_stuck');
354            }
355          });
356        }
357        if(jc('.cesis_header_hiding').length && isMobile == false){
358          // Hide Header on on scroll down
359          var didScroll;
360          var delta = 5;
361          var navbarHeight = jc('#header_container').outerHeight() + jc('.cesis_header_hiding').outerHeight();
362          var lastScrollTop = jc('#header_container').offset().top + jc('.cesis_header_hiding').outerHeight();
363          var firstTop = jc('#header_container').offset().top + jc('.cesis_sticky').outerHeight();
364          /* var lastScrollTop = 0; */
365
366          jc(window).scroll(function(event){
367            if (jc(window).scrollTop() > menuposition) {
368              didScroll = true;
369              hasScrolled();
370            }
371          });
372
373          function hasScrolled() {
374              var st = jc(window).scrollTop();
375              // Make sure they scroll more than delta
376              if(Math.abs(lastScrollTop - st) <= delta){
377                  return;
378                }
379
380              // If they scrolled down and are past the navbar, add class .nav-up.
381              // This is necessary so you never see what is "behind" the navbar.
382              if (st > lastScrollTop && st > navbarHeight){
383                  // Scroll Down
384                  jc('.cesis_header_hiding').css('margin-top', -jc('.cesis_header_hiding').outerHeight());
385                  jc('.cesis_header_hiding').addClass('.cesis_header_hidden');
386              } else {
387                  // Scroll Up
388                  if(st + jc(window).height() < jc(document).height()) {
389                  jc('.cesis_header_hiding').removeClass('.cesis_header_hidden');
390                  jc('.cesis_header_hiding').css('margin-top', '0');
391                  }
392              }
393              if (st > firstTop){
394                lastScrollTop = st;
395              }else{
396                lastScrollTop = firstTop;
397              }
398          }
399        }
400
401      };
402}
403
404//////////////////////////
405//***   Google map  ***//
406////////////////////////
407
408
409
410
411
412if ('function' !== typeof(window['cesis_gmaps'])) {
413      window.cesis_gmaps = function() {
414
415        buildMap = function(e, config) {
416          e.addClass('-map-was-initiated');
417
418          var mapOptions = {
419            zoom: Number(config.zoom),
420            center: new google.maps.LatLng(Number(config.center.latitude), Number(config.center.longitude)),
421
422            zoomControl: config.controls.zoom,
423            mapTypeControl: config.controls.maptype,
424            scaleControl: config.controls.scale,
425            streetViewControl: config.controls.streetview,
426            rotateControl: config.controls.rotate,
427            fullscreenControl: config.controls.fullscreen,
428            scrollwheel: config.controls.scrollwheel
429          };
430
431          if( config.style != '' ) {  mapOptions.styles = JSON.parse(config.style) }
432
433          var mapElement = e.get(0);
434          var map = new google.maps.Map(mapElement, mapOptions);
435
436          // Add Markers
437          if ( config.markers != '' ) {
438            var infowindow = [];
439            var eee =  config.markers;
440            jc.each(eee, function( index, value ) {
441              var _marker = {
442                position: new google.maps.LatLng(value.marker_latitude, value.marker_longitude),
443                map: map,
444                animation: google.maps.Animation.DROP
445              };
446
447              // Add Image
448              if( value.image != '' ) {
449                console.log(value.image);
450                _marker.icon = value.image; }
451
452              // Add Title
453              if( value.marker_title != '' ) { _marker.title = value.marker_title; }
454
455              // Add Description
456              if( value.description != '' ) {
457                var infoWindow_Object = {
458                  content: '<div><strong>' + value.marker_title + '</strong><br>' + value.marker_description + '</div>'
459                };
460
461                // Add Max Width
462                if( value.maxwidth ) { infoWindow_Object.maxWidth = value.maxwidth; }
463
464                infowindow[index] = new google.maps.InfoWindow(infoWindow_Object);
465              }
466
467              // Add Maker
468              var marker = new google.maps.Marker(_marker);
469
470              // Bind Click
471              if( value.description != '' ) {
472                marker.addListener( 'click', function() {
473                  infowindow[index].open( map, marker );
474                } );
475              }
476            });
477          }
478
479                        // FullScreen Button
480                        e.find('.-fullscreen').on('click', function(){
481                          $el.toggleClass('-fullscreen-mode');
482                          google.maps.event.trigger(map, 'resize');
483                          map.setCenter(mapOptions.center);
484                          return false;
485                        });
486                      };
487
488          jc('.cesis_gmaps').each(function() {
489
490
491
492
493            var e = jc(this);
494              var config = e.data('mapcf' );
495              buildMap(e, config);
496
497              if( e.hasClass('-map-was-initiated') )
498                return;
499
500              if(typeof config == 'undefined')
501                return;
502
503              if(typeof google == 'undefined')
504                return;
505
506              config.center.latitude = config.center.latitude.replace(/[^\d.-]/g, '');
507              config.center.longitude = config.center.longitude.replace(/[^\d.-]/g, '');
508
509              // Start Map
510
511
512
513
514
515
516          });
517      }
518}
519
520//////////////////////////
521//***   Ajax posts  ***//
522////////////////////////
523
524
525
526var aloader = jc('.load_more_btn');
527aloader.on('click', load_ajax_posts);
528
529// navigation function
530
531
532jc('.cesis_navigation_ctn:not(.cesis_classic_navigation)').on('click', 'span', function() {
533  var e = jc(this);
534  var p = parseInt(e.attr('data-page_to_load'));
535  var ctn = e.parents('.cesis_isotope_container')
536  var iso_ctn = ctn.find('.cesis_isotope');
537  if( e.hasClass('cesis_nav_active') || e.hasClass('cesis_nav_off') ){
538    return
539  }
540  else{
541    if(e.hasClass('cesis_nav_number')){
542      ctn.find('.cesis_nav_active').removeClass('cesis_nav_active');
543      e.addClass('cesis_nav_active');
544      if(e.hasClass('cesis_nav_last')){
545        ctn.find('.cesis_nav_next').addClass('cesis_nav_off');
546        ctn.find('.cesis_nav_prev').removeClass('cesis_nav_off').attr('data-page_to_load', (p-1)) ;
547      }else if(e.hasClass('cesis_nav_first')){
548        ctn.find('.cesis_nav_prev').addClass('cesis_nav_off');
549        ctn.find('.cesis_nav_next').removeClass('cesis_nav_off').attr('data-page_to_load', (p+1)) ;
550      }else{
551        ctn.find('.cesis_nav_prev').removeClass('cesis_nav_off').attr('data-page_to_load', (p-1)) ;
552        ctn.find('.cesis_nav_next').removeClass('cesis_nav_off').attr('data-page_to_load', (p+1)) ;
553      }
554    }else{
555      var cp = parseInt(ctn.find('.cesis_nav_active').attr('data-page_to_load'));
556      var lp = parseInt(ctn.find('.cesis_nav_last').attr('data-page_to_load'));
557      if(e.hasClass('cesis_nav_prev')){
558       if(cp == 1){
559         e.addClass('cesis_nav_off');
560         ctn.find('.cesis_nav_active').removeClass('cesis_nav_active');
561         ctn.find('.cesis_nav_first').addClass('cesis_nav_active');
562         ctn.find('.cesis_nav_next').removeClass('cesis_nav_off').attr('data-page_to_load', (cp));
563       }
564       else{
565         ctn.find('.cesis_nav_active').removeClass('cesis_nav_active').prev('.cesis_nav_number').addClass('cesis_nav_active');
566         e.attr('data-page_to_load', (cp-2));
567         ctn.find('.cesis_nav_next').removeClass('cesis_nav_off').attr('data-page_to_load', (cp));
568       }
569     }else if(e.hasClass('cesis_nav_next')){
570      if(cp == (lp-1)){
571        e.addClass('cesis_nav_off');
572        ctn.find('.cesis_nav_active').removeClass('cesis_nav_active');
573        ctn.find('.cesis_nav_last').addClass('cesis_nav_active');
574        ctn.find('.cesis_nav_prev').removeClass('cesis_nav_off').attr('data-page_to_load', (cp));
575      }
576      else{
577        e.attr('data-page_to_load', (cp+2));
578        ctn.find('.cesis_nav_active').removeClass('cesis_nav_active').next('.cesis_nav_number').addClass('cesis_nav_active');
579        ctn.find('.cesis_nav_prev').removeClass('cesis_nav_off').attr('data-page_to_load', (cp));
580      }
581     }
582    }
583
584    iso_ctn.isotope( 'remove',  iso_ctn.isotope('getItemElements'));
585    ctn.find('.load_more_btn').removeClass('post_no_more_posts').attr('data-page_to_load', p ).addClass('nav_load').click().removeClass('nav_load');
586  }
587
588});
589
590// loading function
591
592function load_ajax_posts() {
593
594    var lb_btn = jc(this);
595    var main_ctn = jc(this).parent('.cesis_isotope_container');
596    var acontent = main_ctn.children('.cesis_isotope');
597    var post_type = main_ctn.attr('data-post_type');
598    var style = main_ctn.attr('data-style');
599    var type = main_ctn.attr('data-type');
600    var packery_type = main_ctn.attr('data-packery_type');
601    var to_load = main_ctn.attr('data-load');
602    var cat = main_ctn.attr('data-cat');
603    var tag = main_ctn.attr('data-tag');
604    var order = main_ctn.attr('data-order');
605    var orderby = main_ctn.attr('data-orderby');
606    var target = main_ctn.attr('data-target');
607    var thumbnail = main_ctn.attr('data-thumbnail');
608    var animation = main_ctn.attr('data-animation');
609    if(lb_btn.hasClass('post_reset')){
610    var offset = 0;
611    lb_btn.removeClass('post_reset');
612    }
613    if(lb_btn.hasClass('nav_load')){
614      var page = lb_btn.attr('data-page_to_load');
615      var offset = to_load*page;
616    lb_btn.removeClass('post_reset');
617    }
618    else{
619    var offset = acontent.children('.cesis_iso_item').length;
620    }
621    var heading = main_ctn.attr('data-heading');
622    var i_author = main_ctn.attr('data-i_author');
623    var i_date = main_ctn.attr('data-i_date');
624    var i_location = main_ctn.attr('data-i_location');
625    var i_category = main_ctn.attr('data-i_category');
626    var i_tag = main_ctn.attr('data-i_tag');
627    var i_comment = main_ctn.attr('data-i_comment');
628    var i_rating = main_ctn.attr('data-i_ratingt');
629    var i_price = main_ctn.attr('data-i_price');
630    var i_addtocart = main_ctn.attr('data-i_addtocart');
631    var i_like = main_ctn.attr('data-i_like');
632    var i_text = main_ctn.attr('data-i_text');
633    var i_social = main_ctn.attr('data-i_social');
634    var text_source = main_ctn.attr('data-text_source');
635    var char_length = main_ctn.attr('data-char_length');
636    var read_more = main_ctn.attr('data-read_more');
637    var read_more_lb = main_ctn.attr('data-read_more_lb');
638    var read_more_lbg = main_ctn.attr('data-read_more_lbg');
639    var read_more_lc = main_ctn.attr('data-read_more_lc');
640    var read_more_ebg = main_ctn.attr('data-read_more_ebg');
641    var read_more_eb = main_ctn.attr('data-read_more_eb');
642    var read_more_ec = main_ctn.attr('data-read_more_ec');
643    var read_more_default = main_ctn.attr('data-read_more_default');
644    var read_more_class = main_ctn.attr('data-read_more_class');
645    var padding = main_ctn.attr('data-padding');
646    var inner_padding = main_ctn.attr('data-inner_padding');
647    var hover = main_ctn.attr('data-hover');
648
649
650    if (!(lb_btn.hasClass('post_loading_loader') || lb_btn.hasClass('post_no_more_posts'))) {
651
652        jc.ajax({
653            type: 'POST',
654            dataType: 'html',
655            url: cesis_ajax_val.ajaxurl,
656            data: {
657                'post_type': post_type,
658                'style': style,
659                'type': type,
660                'packery_type': packery_type,
661                'to_load': to_load,
662                'offset': offset,
663                'cat': cat,
664                'tag': tag,
665                'order': order,
666                'orderby': orderby,
667                'target': target,
668                'thumbnail': thumbnail,
669                'heading': heading,
670                'i_author': i_author,
671                'i_date': i_date,
672                'i_location': i_location,
673                'i_category': i_category,
674                'i_tag': i_tag,
675                'i_comment': i_comment,
676                'i_rating': i_rating,
677                'i_price': i_price,
678                'i_addtocart': i_addtocart,
679                'i_like': i_like,
680                'i_text': i_text,
681                'i_social': i_social,
682                'text_source': text_source,
683                'char_length': char_length,
684                'read_more': read_more,
685                'read_more_lb': read_more_lb,
686                'read_more_lbg': read_more_lbg,
687                'read_more_lc': read_more_lc,
688                'read_more_eb': read_more_eb,
689                'read_more_ebg': read_more_ebg,
690                'read_more_ec': read_more_ec,
691                'read_more_default': read_more_default,
692                'read_more_class': read_more_class,
693                'padding': padding,
694                'inner_padding': inner_padding,
695                'animation': animation,
696                'hover': hover,
697                'action': 'cesis_ajax_load'
698            },
699            beforeSend: function() {
700                lb_btn.addClass('post_loading_loader').html(cesis_ajax_val.loading);
701            },
702            success: function(data) {
703                var adata = jc(data);
704
705                current_page = adata.filter('#cp').text();
706                max_pages = adata.filter('#mp').text();
707                if (adata.length) {
708                    var anewElements = adata.css({
709                        opacity: 0
710                    });
711                    jc('.wp-audio-shortcode').addClass('media_adjusted');
712                    jc('.wp-video-shortcode').addClass('media_adjusted');
713                    var iso_ctn = acontent.isotope('insert', anewElements);
714                    var iso = iso_ctn.data('isotope');
715                    imagesLoaded(acontent, function() {
716                        iso.layout();
717                    });
718                    main_ctn.find('.cesis_isotope_filter .cesis_filter li a').each(function() {
719                  	   var filter_class = jc(this).attr('data-filter');
720                  		 if (main_ctn.find(filter_class).length){ // implies *not* zero
721                  		     jc(this).parent('li').show();
722                  				 }else{
723                  				jc(this).parent('li').hide();
724                  				 }
725                  	});
726                    iso_ctn.on('layoutComplete', iso.layout());
727                    iso_ctn.on('layoutComplete', isoLoaded(acontent, to_load));
728                    jc('.cesis_video_ctn').fitVids();
729                    cesis_like();
730                    setTimeout(function() {
731                      jc('.cesis_video_ctn:not(.video_adjusted)').find('.mejs-video .mejs-controls').wrap('<div class="cesis_inner_video_ctn"></div>');
732                    }, 400);
733                    cesis_owl_carousel();
734                    jc('.cesis_blog_m_thumbnail').lightGallery({
735                      selector:'.cesis_gallery_img',
736                    });
737                    jc('.cesis_overlay_ctn').lightGallery({
738                      selector:'.cesis_hover_zoom',
739                    });
740                    if(jc('.wp-audio-shortcode:not(.media_adjusted)').length || jc('.wp-video-shortcode:not(.media_adjusted)').length ){
741	                     mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
742	                     mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
743	                     jc(function () {
744                         var settings = {};
745		                     if ( typeof _wpmejsSettings !== 'undefined' ) {
746			                     settings = _wpmejsSettings;
747		                     }
748                         settings.success = function (mejs) {
749                           var autoplay, loop;
750                           if ( 'flash' === mejs.pluginType ) {
751			                       autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
752	                           loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
753				                     autoplay && mejs.addEventListener( 'canplay', function () {
754					                     mejs.play();
755				                     }, false );
756				                     loop && mejs.addEventListener( 'ended', function () {
757					                   mejs.play();
758				                     }, false );
759			                    }
760		                    };
761                        jc('.wp-audio-shortcode:not(.media_adjusted), .wp-video-shortcode:not(.media_adjusted)').mediaelementplayer( settings );
762	                    });
763                    }
764                    anewElements.animate({
765                        opacity: 1
766                    });
767                    lb_btn.removeClass('post_loading_loader').html(cesis_ajax_val.loadmore);
768                    if (current_page == max_pages) {
769                        lb_btn.removeClass('post_loading_loader').addClass('post_no_more_posts').html(cesis_ajax_val.noposts);
770                    }
771                    // check if navigation
772                    if(main_ctn.find('.cesis_navigation_ctn').length){
773                      // check if new navigation need to be created
774
775                      if(parseInt(max_pages) !== (parseInt(main_ctn.find('.cesis_nav_last').attr('data-page_to_load'))+1)){
776                        var i = 0;
777                        var n = 1;
778                        var nav = '';
779                        while (i < max_pages) {
780                          if(i == 0){
781                            nav = '<span data-page_to_load="'+i+'" class="cesis_nav_number cesis_nav_first cesis_nav_active">'+n+'</span>';
782                          }else if(n == max_pages){
783                            nav = nav+'<span data-page_to_load="'+i+'" class="cesis_nav_number cesis_nav_last">'+n+'</span>';
784                          }else{
785                            nav = nav+'<span data-page_to_load="'+i+'" class="cesis_nav_number">'+n+'</span>';
786                          }
787                          i ++;
788                          n ++;
789
790                        }
791                        main_ctn.find('.cesis_nav_numbers').replaceWith( '<div class="cesis_nav_numbers">'+nav+'</div>' );
792
793
794                      }
795                    }
796                }
797                else{
798                      lb_btn.removeClass('post_loading_loader').addClass('post_no_more_posts').html(cesis_ajax_val.noposts);
799                }
800            },
801            error: function(jqXHR, textStatus, errorThrown) {
802                lb_btn.html(jc.parseJSON(jqXHR.responseText) + ' :: ' + textStatus + ' :: ' + errorThrown);
803                console.log(jqXHR);
804            },
805        });
806    }
807    return false;
808}
809
810
811
812////////////////////////
813//*** Zilla likes ***//
814//////////////////////
815
816
817if ('function' !== typeof(window['cesis_like'])) {
818    window.cesis_like = function() {
819
820
821      jc('.zilla-likes').unbind().on('click', function() {
822        var link = jc(this);
823        if (link.hasClass('active')) return false;
824
825        var id = jc(this).attr('id'),
826            postfix = link.find('.zilla-likes-postfix').text();
827
828        jc.ajax({
829          type: 'POST',
830          url: cesis_ajax_val.ajaxurl,
831          data: {
832            action: 'zilla-likes',
833            likes_id: id,
834            postfix: postfix,
835          },
836          xhrFields: {
837            withCredentials: true,
838          },
839          success: function(data) {
840            link.html(data).addClass('active').attr('title','You already like this');
841          },
842        });
843
844        return false;
845      });
846
847      if (jc('body.ajax-zilla-likes').length) {
848        jc('.zilla-likes').each(function() {
849          var id = jc(this).attr('id');
850          jc(this).load(cesis_ajax_val.ajaxurl, {
851            action: 'zilla-likes',
852            post_id: id,
853          });
854        });
855      }
856
857}
858}
859
860
861//////////////////////////
862//*** Centered Logo ***//
863////////////////////////
864
865
866function set_center_logo() {
867    if (jc('.header_logo.logo_center .site-title').length) {
868        var logo_size = jc('.header_logo.logo_center .site-title').width();
869        if (logo_size > 0) {
870            var logo_size_s = logo_size / 2;
871            var logo_size_m = (logo_size + 60) / 2;
872            jc('.header_logo').css('margin-left', -logo_size_s);
873        }
874    } else {
875        var logo_size = jc('.header_logo.logo_center h1').width();
876        if (logo_size > 0) {
877            var logo_size_s = logo_size / 2;
878            var logo_size_m = (logo_size + 60) / 2;
879            jc('.header_logo').css('margin-left', -logo_size_s);
880        }
881    }
882    var total_menu_items = jc('nav.logo_center .menu-main-ct > ul > li').length;
883    var half_position_even = total_menu_items / 2;
884    var half_position_odd = (total_menu_items + 1) / 2;
885    var ex = /^\d+$/;
886    if (ex.test(total_menu_items / 2)) {
887        //When the total number of the menu items is even
888        jc('nav.logo_center .menu-main-ct > ul > li:nth-child(' + half_position_even + ')').addClass('cl_before_logo');
889        jc('nav.logo_center .menu-main-ct > ul > li:nth-child(' + (half_position_even + 1) + ')').addClass('cl_after_logo');
890    } else {
891        //When the total number of the menu items is odd
892        jc('nav.logo_center .menu-main-ct > ul > li:nth-child(' + half_position_odd + ')').addClass('cl_before_logo');
893        jc('nav.logo_center .menu-main-ct > ul > li:nth-child(' + (half_position_odd + 1) + ')').addClass('cl_after_logo');
894    }
895
896    jc('.cl_before_logo').css('margin-right', logo_size_m);
897    jc('.cl_after_logo').css('margin-left', logo_size_m);
898
899    var li_width = 0;
900    jc('nav.logo_center .menu-main-ct > ul > li').each(function() {
901        current_li_width = jc(this).outerWidth();
902        if (current_li_width > li_width) {
903            li_width = current_li_width;
904            jc('nav.logo_center .menu-main-ct > ul > li').css('min-width', li_width);
905        }
906
907    })
908}
909
910
911//////////////////////////
912//***  Text Resize  ***//
913////////////////////////
914
915
916if ('function' !== typeof(window['cesis_text_resize'])) {
917  window.cesis_text_resize = function() {
918    var ar_text = jc('.cesis_ar_text');
919    jc.each(ar_text, function() {
920      var el = jc(this);
921      var max = jc(this).attr('data-max_size');
922      var min = jc(this).attr('data-min_size');
923      el.fitText(1.2, { minFontSize: min+'px', maxFontSize: max+'px' });
924    })
925  }
926}
927
928
929//////////////////////////
930//*** Section swipe ***//
931////////////////////////
932
933
934if ('function' !== typeof(window['cesis_section_swipe'])) {
935    window.cesis_section_swipe = function() {
936      // init
937
938      if(!jc('.touch').length){
939      if (jc('.cesis_section_swipe').length) {
940        var controller = new ScrollMagic.Controller({
941          globalSceneOptions: {
942            triggerHook: 'onLeave'
943          }
944        }
945      );
946		// get all slides
947		var slides = document.querySelectorAll(".vc_section");
948
949		// create scene for every slide
950		for (var i=0; i<slides.length; i++) {
951			new ScrollMagic.Scene({
952					triggerElement: slides[i]
953				})
954				.setPin(slides[i])
955				.addTo(controller);
956		}
957
958jc(document).ready(function () {
959var sectionR;
960var divs = jc('.scrollmagic-pin-spacer');
961var dir = 'up'; // wheel scroll direction
962var div = 0; // current div
963jc(document.body).on('DOMMouseScroll mousewheel', function (e) {
964  if(sectionR !== "sliding"){
965    sectionR = "sliding";
966    if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
967        dir = 'down';
968    } else {
969        dir = 'up';
970    }
971    // find currently visible div :
972    div = -1;
973    divs.each(function(i){
974        if (div<0 && (jc(this).offset().top >= jc(window).scrollTop())) {
975            div = i;
976        }
977    });
978    if (dir == 'up' && div > 0) {
979        div--;
980        console.log(div);
981    }
982    if (dir == 'down' && div < divs.length-1) {
983        div++;
984        console.log(div);
985    }
986    //console.log(div, dir, divs.length);
987    setTimeout(function() {
988      sectionR = "stopped";
989    }, 700 )
990    jc('html,body').stop().animate({
991        scrollTop: divs.eq(div).offset().top
992
993    }, 700);
994    return false;
995  }
996});
997jc(window).resize(function () {
998    jc('html,body').scrollTop(divs.eq(div).offset().top);
999});
1000});
1001
1002}
1003
1004}
1005
1006}
1007}
1008
1009///////////////////////////////////////
1010//***          To Top            ***//
1011/////////////////////////////////////
1012
1013
1014if ('function' !== typeof(window['cesis_to_top'])) {
1015  window.cesis_to_top = function() {
1016    if (jc('#cesis_to_top').length > 0 ){
1017    var scrollTop = jc(window).scrollTop();
1018
1019    if (jc('#cesis_to_top').length > 0 && jc(window).width() > 420) {
1020
1021        if (scrollTop > 350) {
1022            jc(window).on('scroll', hideToTop);
1023        }
1024        else {
1025            jc(window).on('scroll', showToTop);
1026        }
1027    }
1028
1029function showToTop() {
1030
1031    var scrollTop = jc(window).scrollTop();
1032    if (scrollTop > 350) {
1033
1034        jc('#cesis_to_top').stop(true, true).animate({
1035            'bottom': '30px'
1036        }, 350, 'easeInOutCubic');
1037
1038        jc(window).off('scroll', showToTop);
1039        jc(window).on('scroll', hideToTop);
1040    }
1041
1042}
1043
1044function hideToTop() {
1045
1046    var scrollTop = jc(window).scrollTop();
1047    if (scrollTop < 350) {
1048
1049        jc('#cesis_to_top').stop(true, true).animate({
1050            'bottom': '-30px'
1051        }, 350, 'easeInOutCubic');
1052
1053        jc(window).off('scroll', hideToTop);
1054        jc(window).on('scroll', showToTop);
1055
1056    }
1057}
1058
1059    jc('body').on('click', '#cesis_to_top, a[href="#top"]', function () {
1060        jc('body,html').stop().animate({
1061            scrollTop: 0
1062        }, 800, 'easeOutQuad')
1063        return false;
1064    });
1065
1066}
1067  }
1068}
1069
1070///////////////////////////////////////
1071//*** One page / scroll function ***//
1072/////////////////////////////////////
1073
1074
1075if ('function' !== typeof(window['cesis_scroll_fn'])) {
1076  window.cesis_scroll_fn = function() {
1077    if(!jc('body').hasClass('single-product') ) {
1078     if(jc('.cesis_onepage_page').length) {
1079
1080       if(jc('.cesis_onepage_right_nav').length || jc('.cesis_onepage_left_nav').length) {
1081         if(jc('.cesis_onepage_right_nav').length) {
1082           jc('body').prepend('<div id="cesis_one_page_navigation" style="right:25px;"></div>')
1083         }else{
1084           jc('body').prepend('<div id="cesis_one_page_navigation" style="left:25px;"></div>')
1085         }
1086         jc('.vc_section').each(function() {
1087           var id = jc(this).attr('id');
1088           jc('#cesis_one_page_navigation').append('<a href="#'+id+'"><span></span></a>');
1089         })
1090       }
1091
1092
1093     jc(window).scroll(function() {
1094       if (jc('.cesis_section_swipe').length) {
1095         var section_selector = '.scrollmagic-pin-spacer';
1096       }else{
1097         var section_selector = '.vc_section';
1098       }
1099       var windscroll = jc(window).scrollTop();
1100       if(jc('.cesis_sticky').length) {
1101        if(jc('.cesis_header_hiding').length) {
1102         var h_height = 0;
1103        }
1104        else if(jc('.cesis_transparent_header').length && !jc('.cesis_stuck').length) {
1105          var h_height = 0;
1106        }else{
1107         var h_height = jc(".cesis_sticky").height();
1108        }
1109       }else{
1110         var h_height = 0;
1111       }
1112        jc(section_selector).each(function(i) {
1113          if (jc(this).offset().top <= windscroll + h_height) {
1114            jc('#cesis_one_page_navigation a.current').removeClass('current');
1115            jc('#site-navigation li.current-menu-item').removeClass('current-menu-item');
1116            jc('#cesis_one_page_navigation a').eq(i).addClass('current');
1117            jc('#site-navigation a').eq(i).parent('li').addClass('current-menu-item');
1118          }
1119          if( windscroll === 0) {
1120            jc('#cesis_one_page_navigation a.current').removeClass('current');
1121            jc('#site-navigation li.current-menu-item').removeClass('current-menu-item');
1122            jc('#cesis_one_page_navigation a').eq(0).addClass('current');
1123            jc('#site-navigation a').eq(0).parent('li').addClass('current-menu-item');
1124
1125          }
1126        });
1127    }).scroll();
1128      jc(
1129        '.vertical-main-menu a[href*=\\#]:not([href=\\#]):not([href="#lifestyle_container"]):not([href="#comments_container"]):not(.cesis_open_s_overlay):not([data-toggle="collapse"]):not([data-vc-container=".vc_tta-container"]):not([data-vc-container=".vc_tta"])'
1130      ).on("click", function () {
1131          var oc_ctn = jc(
1132            "body.cesis_offcanvas_header .header_top_bar,body.cesis_offcanvas_header .header_main,body.cesis_offcanvas_header .header_offcanvas,body.cesis_offcanvas_header #main-content,body.cesis_offcanvas_header #cesis_colophon"
1133          );
1134
1135          // Diagnostic: Check if the elements are selected correctly
1136          console.log("oc_ctn length: ", oc_ctn.length);
1137
1138          if (jc(".cesis_offcanvas_switch").length) {
1139            jc(".cesis_offcanvas_switch")
1140              .removeClass("open")
1141              .addClass("closing");
1142
1143            // Diagnostic: Check if the class exists before removal
1144            console.log(
1145              "Before removal, cesis_offcanvas_opened: ",
1146              oc_ctn.hasClass("cesis_offcanvas_opened")
1147            );
1148            oc_ctn.removeClass("cesis_offcanvas_opened");
1149
1150            // Diagnostic: Check if the class is removed
1151            setTimeout(function () {
1152              console.log(
1153                "After removal, cesis_offcanvas_opened: ",
1154                oc_ctn.hasClass("cesis_offcanvas_opened")
1155              );
1156              jc(".closing").removeClass("closing");
1157            }, 400);
1158          }
1159        if (jc(".cesis_menu_overlay").hasClass("open")) {
1160          jc(".cesis_menu_overlay").removeClass("open");
1161          jc(".cesis_menu_overlay_close").removeClass("open");
1162          jc(".header_overlay").removeClass("overlay_on");
1163          jc(this).addClass("closing");
1164          setTimeout(function () {
1165            jc(".closing").removeClass("closing");
1166          }, 400);
1167          setTimeout(function () {
1168            jc("#cesis_header").removeClass("overlay_menu_on");
1169          }, 600);
1170        }
1171      });
1172      jc('.header_mobile a[href*=\\#]:not([href=\\#]):not([href="#lifestyle_container"]):not([href="#comments_container"]):not(.cesis_open_s_overlay):not([data-toggle="collapse"]):not([data-vc-container=".vc_tta-container"]):not([data-vc-container=".vc_tta"])').on('click', function () {
1173        if (jc('.cesis_mobile_menu_switch').hasClass('open')) {
1174          jc('.cesis_mobile_menu_switch').removeClass('open');
1175          jc('.cesis_mobile_menu_switch').addClass('closing');
1176          jc('.header_mobile').slideToggle(400);
1177          setTimeout(function() {
1178            jc('.closing').removeClass('closing');
1179          }, 400);
1180        } else{
1181          jc('.cesis_mobile_menu_switch').addClass('open');
1182          jc('.header_mobile').slideToggle(400);
1183        }
1184      });
1185    }
1186
1187      jc('a[href*=\\#]:not([href=\\#]):not([href="#lifestyle_container"]):not([href="#comments_container"]):not(.cesis_open_s_overlay):not([data-toggle="collapse"]):not([data-vc-container=".vc_tta-container"]):not([data-vc-container=".vc_tta"]):not(.cesis_open_s_overlay):not([href^=\\#el-]):not([href^=\\#vcv-])').on('click', function () {
1188        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
1189          var target = jc(this.hash);
1190          if(jc('.cesis_sticky').length) {
1191           if(jc('.cesis_header_hiding').length) {
1192					  var h_height = 0;
1193           }else{
1194            var h_height = jc(".cesis_sticky").height();
1195           }
1196          }else{
1197            var h_height = 0;
1198          }
1199
1200			    target = target.length ? target : jc('[name=' + this.hash.slice(1) + ']');
1201          if (target.length) {
1202            if (jc('.cesis_section_swipe').length) {
1203            jc('html,body').animate({
1204              scrollTop: target.parent('.scrollmagic-pin-spacer').offset().top-h_height+1
1205            }, 1000);
1206            return false;
1207            }
1208            else{
1209            jc('html,body').animate({
1210              scrollTop: target.offset().top-h_height+1
1211            }, 1000);
1212            return false;
1213            }
1214          }
1215        }
1216      });
1217
1218	   }
1219
1220
1221  }
1222}
1223
1224//////////////////////////////////
1225//*** Row related functions ***//
1226////////////////////////////////
1227
1228
1229if ('function' !== typeof(window['cesis_row'])) {
1230    window.cesis_row = function() {
1231      // init
1232      var $overlays = jc('[data-overlay="true"]');
1233      jc.each($overlays, function() {
1234        var el = jc(this);
1235        var overlay_color = jc(this).attr('data-overlay-color');
1236
1237        var already_set = el.find('.cesis_row_overlay');
1238        if(!already_set.length){
1239
1240        if(el.hasClass('wpb_column')){
1241          setTimeout(function() {
1242              el.children('.vc_column-inner').append('<div class="cesis_row_overlay" style="background:'+overlay_color+';"></div>')
1243          }, 100 )
1244        }else{
1245          setTimeout(function() {
1246              el.append('<div class="cesis_row_overlay" style="background:'+overlay_color+';"></div>')
1247          }, 100 )
1248        }
1249      }else {
1250        el.find('.cesis_row_overlay').remove();
1251        if(el.hasClass('wpb_column')){
1252          setTimeout(function() {
1253              el.children('.vc_column-inner').append('<div class="cesis_row_overlay" style="background:'+overlay_color+';"></div>')
1254          }, 100 )
1255        }else{
1256          setTimeout(function() {
1257              el.append('<div class="cesis_row_overlay" style="background:'+overlay_color+';"></div>')
1258          }, 100 )
1259        }
1260      }
1261
1262      });
1263
1264      var controller = new ScrollMagic.Controller();
1265      jc('.cesis_row_has_parallax').each(function() {
1266      var el = jc(this);
1267      var speed = el.attr('data-parallax_speed');
1268      if(speed.indexOf('.') > -1){
1269        speed = speed.replace('.','');
1270        if(speed.length < 3){
1271          speed = speed+'0';
1272        }
1273      }
1274      else if(speed.length < 2){
1275        speed = speed+'00';
1276      }
1277      var img_url = el.attr('data-vc-parallax-image');
1278      var time = jc(window).height()+el.outerHeight();
1279      var durationValueCache;
1280
1281      function getDuration () {
1282        return durationValueCache;
1283      }
1284      function updateDuration (e) {
1285        durationValueCache = jc(window).height()+el.outerHeight();
1286      }
1287
1288      jc(window).on("resize", updateDuration); // update the duration when the window size changes
1289      jc(window).triggerHandler("resize"); // set to initial value
1290
1291      var parallaxTL = new TimelineMax();
1292      var already_set = el.find('.cesis_row_parallax');
1293      if ( el.parents(".cesis_content_slider_ctn").length == 1 ) {
1294        var t_hook = 0;
1295        if(!already_set.length){
1296          el.prepend('<div class="cesis_parallax_ctn"><div class="cesis_row_parallax"></div></div>');
1297        }
1298        if(img_url !== undefined){
1299          el.find('.cesis_row_parallax').css('background-image','url('+img_url+')');
1300        }
1301        parallaxTL.staggerFromTo(el.find('.cesis_row_parallax'), 1, {
1302          transform:"translate3d(0px, 0px, 0px)"
1303        }, {
1304          transform:"translate3d(0px, "+speed+"px, 0px)"
1305        });
1306
1307      }else{
1308        var t_hook = 1;
1309        if(!already_set.length){
1310          el.prepend('<div class="cesis_parallax_ctn"><div class="cesis_row_parallax"></div></div>');
1311        }
1312        if(img_url !== undefined){
1313          el.find('.cesis_row_parallax').css('background-image','url('+img_url+')');
1314        }
1315        parallaxTL.staggerFromTo(el.find('.cesis_row_parallax'), 1, {
1316          backgroundPosition: "50% "+speed+"px"
1317        }, {
1318          backgroundPosition: "50% -"+speed+"px"
1319        });
1320      }
1321      var slideParallaxScene = new ScrollMagic.Scene({
1322        triggerElement: this,
1323        triggerHook:t_hook,
1324        duration:durationValueCache
1325      })
1326      .setTween(parallaxTL)
1327      .addTo(controller);
1328
1329
1330      slideParallaxScene.duration(getDuration);
1331
1332    });
1333
1334      jc('.cesis_row_content_effect').each(function() {
1335      var el = jc(this);
1336
1337      var effect = el.attr('data-effect');
1338      var effect_depth = el.attr('data-effect_depth');
1339      if(effect_depth.indexOf('.') > -1){
1340        effect_depth = effect_depth.replace('.','');
1341        if(effect_depth.length < 3){
1342          effect_depth = effect_depth+'0';
1343        }
1344      }
1345      else if(effect_depth.length < 2){
1346        effect_depth = effect_depth+'00';
1347      }
1348      var offset_value;
1349      var durationValueCache;
1350      function getDuration () {
1351        return durationValueCache;
1352      }
1353      function updateDuration (e) {
1354        durationValueCache = el.outerHeight();
1355      }
1356      jc(window).on("resize", updateDuration); // update the duration when the window size changes
1357      function getOffset () {
1358        return offset_value;
1359      }
1360      function updateOffset (e) {
1361        offset_value = el.outerHeight();
1362      }
1363      jc(window).on("resize", updateOffset); // update the duration when the window size changes
1364      jc(window).triggerHandler("resize"); // set to initial value
1365      var effectTL = new TimelineMax();
1366      if(effect == 'cesis_row_e_stick' || effect == 'cesis_row_e_fade_stick'){
1367        effectTL.to(el.children('.wpb_column,.cesis_inner_row_ctn'),3,{ y:''+effect_depth+'%' },0.15);
1368      }
1369      if(effect == 'cesis_row_e_fade_out' || effect == 'cesis_row_e_fade_stick'){
1370        effectTL.to(el.children('.wpb_column,.cesis_inner_row_ctn'), 2.5,{ opacity: 0 },0.1);
1371      }
1372      var fadein_scene = new ScrollMagic.Scene({
1373        triggerElement: this,
1374        duration: durationValueCache,
1375        triggerHook:0,
1376        reverse: true
1377      })
1378      .setTween(effectTL)
1379      //.addIndicators()
1380      .addTo(controller);
1381            fadein_scene.duration(getDuration);
1382
1383    });
1384
1385    jc('.cesis_content_slider_ctn').each(function() {
1386
1387if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
1388     var evt = document.createEvent('UIEvents');
1389     evt.initUIEvent('resize', true, false, window, 0);
1390     window.dispatchEvent(evt);
1391    setTimeout(function() {
1392    window.dispatchEvent(evt);
1393    }, 1);
1394    setTimeout(function() {
1395    window.dispatchEvent(evt);
1396    }, 5);
1397    setTimeout(function() {
1398    window.dispatchEvent(evt);
1399    }, 10);
1400    setTimeout(function() {
1401    window.dispatchEvent(evt);
1402    }, 100);
1403    setTimeout(function() {
1404    window.dispatchEvent(evt);
1405    jc('.cesis_content_slider_ctn').addClass('cesis_content_slider_loaded');
1406    }, 500);
1407  } else {
1408    setTimeout(function() {
1409    window.dispatchEvent(new Event('resize'));
1410    }, 1);
1411    setTimeout(function() {
1412    window.dispatchEvent(new Event('resize'));
1413    }, 5);
1414    setTimeout(function() {
1415    window.dispatchEvent(new Event('resize'));
1416    }, 10);
1417    setTimeout(function() {
1418    window.dispatchEvent(new Event('resize'));
1419    }, 100);
1420    setTimeout(function() {
1421    window.dispatchEvent(new Event('resize'));
1422    jc('.cesis_content_slider_ctn').addClass('cesis_content_slider_loaded');
1423    }, 500);
1424
1425    }
1426
1427
1428
1429
1430
1431    });
1432
1433}
1434}
1435
1436/////////////////////////////////
1437//***    Full width row    ***//
1438///////////////////////////////
1439
1440
1441if ('function' !== typeof(window['vc_rowBehaviour'])) {
1442
1443window.vc_rowBehaviour = function() {
1444    function fullWidthRow() {
1445      var $elements = jc('[data-vc-full-width="true"]');
1446      jc.each($elements, function(key, item) {
1447          var $el = jc(this);
1448          $el.addClass('vc_hidden');
1449          var $el_full = $el.next('.vc_row-full-width');
1450          if ($el_full.length || ($el_full = $el.parent().next('.vc_row-full-width')), $el_full.length) {
1451
1452
1453              var el_margin_left = parseInt($el.css('margin-left'), 10),
1454                  el_margin_right = parseInt($el.css('margin-right'), 10);
1455
1456              if (jc('.vc_full_width_row_container').length) {
1457                  var custom_container = jc('.vc_full_width_row_container'), // Set the Custom container
1458                  container_offset = custom_container.offset(); // Set the offset attribute
1459                  var offset = 0 - $el_full.offset().left - el_margin_left + container_offset.left;
1460
1461              } else {
1462                  var custom_container = jc(window);
1463                  var offset = 0 - $el_full.offset().left - el_margin_left;
1464              }
1465
1466              var width = jc(custom_container).width();
1467              if(jc('body').hasClass('rtl')){
1468                if ($el.css({
1469                        position: 'relative',
1470                        right: offset,
1471                        'box-sizing': 'border-box',
1472                        width: width,
1473                    }), !$el.data('vcStretchContent')) {
1474                    var padding = -1 * offset;
1475                    0 > padding && (padding = 0);
1476                    var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
1477                    0 > paddingRight && (paddingRight = 0), $el.css({
1478                        'padding-left': padding + 'px',
1479                        'padding-right': paddingRight + 'px'
1480                    })
1481                }
1482              }else{
1483                if ($el.css({
1484                        position: 'relative',
1485                        left : offset,
1486                        'box-sizing': 'border-box',
1487                        width: width,
1488                    }), !$el.data('vcStretchContent')) {
1489                    var padding = -1 * offset;
1490                    0 > padding && (padding = 0);
1491                    var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
1492                    0 > paddingRight && (paddingRight = 0), $el.css({
1493                        'padding-left': padding + 'px',
1494                        'padding-right': paddingRight + 'px'
1495                    })
1496                }
1497              }
1498              $el.attr('data-vc-full-width-init', 'true'), $el.removeClass('vc_hidden')
1499          }
1500      }), jc(document).trigger('vc-full-width-row', $elements)
1501    }
1502
1503    function parallaxRow() {
1504        var vcSkrollrOptions, callSkrollInit = !1;
1505        return window.vcParallaxSkroll && window.vcParallaxSkroll.destroy(), jc(".vc_parallax-inner").remove(), jc("[data-5p-top-bottom]").removeAttr("data-5p-top-bottom data-30p-top-bottom"), jc("[data-vc-parallax]").each(function() {
1506            var skrollrSpeed, skrollrSize, skrollrStart, skrollrEnd, $parallaxElement, parallaxImage, youtubeId;
1507            callSkrollInit = !0, "on" === jc(this).data("vcParallaxOFade") && jc(this).children().attr("data-5p-top-bottom", "opacity:0;").attr("data-30p-top-bottom", "opacity:1;"), skrollrSize = 100 * jc(this).data("vcParallax"), $parallaxElement = jc("<div />").addClass("vc_parallax-inner").appendTo(jc(this)), $parallaxElement.height(skrollrSize + "%"), parallaxImage = jc(this).data("vcParallaxImage"), youtubeId = vcExtractYoutubeId(parallaxImage), youtubeId ? insertYoutubeVideoAsBackground($parallaxElement, youtubeId) : "undefined" != typeof parallaxImage && $parallaxElement.css("background-image", "url(" + parallaxImage + ")"), skrollrSpeed = skrollrSize - 100, skrollrStart = -skrollrSpeed, skrollrEnd = 0, $parallaxElement.attr("data-bottom-top", "top: " + skrollrStart + "%;").attr("data-top-bottom", "top: " + skrollrEnd + "%;")
1508        }), !(!callSkrollInit || !window.skrollr) && (vcSkrollrOptions = {
1509            forceHeight: !1,
1510            smoothScrolling: !1,
1511            mobileCheck: function() {
1512                return !1
1513            }
1514        }, window.vcParallaxSkroll = skrollr.init(vcSkrollrOptions), window.vcParallaxSkroll)
1515    }
1516    function vc_initVideoBackgrounds() {
1517      jc("[data-vc-video-bg]").each(function() {
1518            var youtubeUrl, youtubeId, $element = jc(this);
1519            $element.data("vcVideoBg") ? (youtubeUrl = $element.data("vcVideoBg"), youtubeId = vcExtractYoutubeId(youtubeUrl), youtubeId && ($element.find(".vc_video-bg").remove(), insertYoutubeVideoAsBackground($element, youtubeId)), jc(window).on("grid:items:added", function(event, $grid) {
1520                $element.has($grid).length && vcResizeVideoBackground($element)
1521            })) : $element.find(".vc_video-bg").remove()
1522        })
1523    }
1524    function fullHeightRow() {
1525        var $element = jc(".vc_row-o-full-height:first");
1526        if ($element.length) {
1527            var $window, windowHeight, offsetTop, fullHeight;
1528            $window = jc(window), windowHeight = $window.height(), offsetTop = $element.offset().top, offsetTop < windowHeight && (fullHeight = 100 - offsetTop / (windowHeight / 100), $element.css("min-height", fullHeight + "vh"))
1529        }
1530        jc(document).trigger("vc-full-height-row", $element)
1531    }
1532
1533    function fixIeFlexbox() {
1534        var ua = window.navigator.userAgent,
1535            msie = ua.indexOf("MSIE ");
1536        (msie > 0 || navigator.userAgent.match(/Trident.*rv\:11\./)) && jc(".vc_row-o-full-height").each(function() {
1537            "flex" === jc(this).css("display") && jc(this).wrap('<div class="vc_ie-flexbox-fixer"></div>')
1538        })
1539    }
1540    function vcExtractYoutubeId(url) {
1541      if ("undefined" == typeof url) return !1;
1542      var id = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
1543      return null !== id && id[1]
1544    }
1545    jc(window).off("resize.vcRowBehaviour").on("resize.vcRowBehaviour", fullWidthRow).on("resize.vcRowBehaviour", fullHeightRow), fullWidthRow(), fullHeightRow(), fixIeFlexbox(), vc_initVideoBackgrounds(), parallaxRow();
1546
1547
1548
1549    }
1550}
1551
1552
1553////////////////////////////
1554//***    Animation    ***//
1555//////////////////////////
1556
1557
1558
1559
1560if ('function' !== typeof(window['cesis_animations'])) {
1561    window.cesis_animations = function() {
1562        jc.each(jc('.animate_when_almost_visible:not(.start_animation)'), function(index, val) {
1563            var run = true;
1564            if (jc(val).closest('.owl-carousel').length > 0) run = false;
1565            if (run) {
1566                new cWaypoint({
1567                    element: val,
1568                    handler: function() {
1569                        var element = jc(this.element),
1570                            delayAttr = element.attr('data-delay');
1571                        if (delayAttr == undefined) delayAttr = 200;
1572                        setTimeout(function() {
1573                            element.addClass('start_animation');
1574                        }, (delayAttr * index));
1575                        this.destroy();
1576                    },
1577                    offset: '90%'
1578                });
1579            }
1580        });
1581    }
1582}
1583
1584
1585
1586////////////////////////////
1587//***      Video      ***//
1588//////////////////////////
1589
1590
1591
1592
1593if ('function' !== typeof(window['cesis_video'])) {
1594    window.cesis_video = function() {
1595      jc('.cesis_video_ctn').fitVids();
1596      setTimeout(function() {
1597        jc('.cesis_video_ctn').find('.mejs-video .mejs-controls').wrap('<div class="cesis_inner_video_ctn"></div>');
1598        jc('.cesis_video_ctn').addClass('video_adjusted');
1599      }, 400);
1600      jc(window).resize(checkResize);
1601      function checkResize(){
1602        if (
1603          document.fullscreenElement ||
1604          document.webkitFullscreenElement ||
1605          document.mozFullScreenElement ||
1606          document.msFullscreenElement
1607        ){
1608        jc('.inside_e').addClass('fullscreen_activated adjusted_inside_e').removeClass('animated');
1609    }else{
1610        jc('.fullscreen_activated').removeClass('fullscreen_activated');
1611        setTimeout(function() {
1612          jc('.adjusted_inside_e').addClass('animated');
1613        }, 1000);
1614    }
1615}
1616
1617    }
1618}
1619
1620
1621
1622////////////////////////////
1623//***     Isotope     ***//
1624//////////////////////////
1625
1626
1627if ('function' !== typeof(window['cesis_isotope'])) {
1628    window.cesis_isotope = function() {
1629    if(jc('.cesis_isotope').length){
1630      // filter function
1631
1632      jc('.cesis_filter').on('click', 'a', function() {
1633        var e = jc(this);
1634        var f = e.attr('data-filter');
1635        var type = e.attr('data-type');
1636        var ctn = e.parents('.cesis_isotope_container')
1637        var iso_ctn = ctn.find('.cesis_isotope');
1638        var filter_ctn = ctn.find('.cesis_filter_ctn');
1639				filterItems = [];
1640        if(e.parents('li').hasClass('selected')){
1641            return
1642        }
1643        else{
1644          iso_ctn.find('.inside_e').addClass('iso_fading').removeClass('wpb_start_animation');
1645
1646          e.parents('.cesis_isotope_container').find('.selected').removeClass('selected');
1647          e.parents('li').addClass('selected');
1648          if(filter_ctn.hasClass("cesis_isotope_filter")){
1649
1650            setTimeout(function() {
1651              iso_ctn.isotope({
1652                filter: f
1653            	});
1654      				filterItems.push(e);
1655              jc('.inside_e.iso_fading', iso_ctn).removeClass('iso_fading');
1656            }, 400);
1657
1658						iso_ctn.isotope('once', 'arrangeComplete', function() {
1659							setTimeout(function() {
1660								isoAnimation(jc('.cesis_iso_item:not([style*="display: none"])', iso_ctn), 0, false, iso_ctn);
1661							}, 50);
1662						});
1663
1664          }else{
1665            iso_ctn.find('.inside_e').addClass('iso_fading').removeClass('wpb_start_animation');
1666            var new_val = f.replace(/^.f_+/i, '');
1667            if(type == 'post_tag' || type == 'portfolio_tag' || type == 'staff_tag' || type == 'product_tag' ){
1668              ctn.attr("data-tag", new_val);
1669              ctn.attr("data-cat", 'all');
1670            }
1671            if(type == 'category'  || type == 'portfolio_category' || type == 'staff_group' || type == 'product_cat' ){
1672              ctn.attr("data-cat", new_val);
1673              ctn.attr("data-tag", 'all');
1674            }
1675            if(type == 'all'){
1676              ctn.attr("data-cat", 'all');
1677              ctn.attr("data-tag", 'all');
1678            }
1679            setTimeout(function() {
1680              iso_ctn.isotope( 'remove',  iso_ctn.isotope('getItemElements'));
1681              ctn.find('.load_more_btn').removeClass('post_no_more_posts').addClass('post_reset').click();
1682              jc('.inside_e.iso_fading', iso_ctn).removeClass('iso_fading');
1683            }, 100);
1684          }
1685          filter_linemove();
1686        }
1687      })
1688
1689      // filter Line moving effect
1690
1691      jc('.cesis_filter_ctn').each(function() {
1692        var current_width = jc(this).find('li.selected a');
1693        jc('<span class="filter_moving_line"></span>').insertAfter(jc(this).find('.cesis_filter > li:first-child'));
1694        var Line = jc(this).find('.filter_moving_line');
1695        Line.width(current_width.width())
1696        Line.css('left', jc(this).find('li.selected').position().left);
1697        Line.css('opacity', '1');
1698      });
1699
1700      function filter_linemove() {
1701        var filter = jc('.cesis_filter_ctn');
1702        filter.each(function() {
1703          var el, leftPos, newWidth;
1704          var Line = jc(this).find('.filter_moving_line');
1705          Line.width(jc(this).find('li.selected a').width())
1706          .css('left', jc(this).find('li.selected a').position().left)
1707          .data('origLeft', Line.position().left)
1708          .data('origWidth', Line.width());
1709
1710          jc('.cesis_filter li a').on('click', function() {
1711            el = jc(this);
1712            leftPos = el.position().left;
1713            newWidth = el.parent().width();
1714            });
1715        });
1716      }
1717
1718
1719
1720
1721      // sorter function
1722
1723      jc('.cesis_sorter').on('click','li', function(e) {
1724        var ctn = jc(this).parents('.cesis_isotope_container').find('.cesis_isotope')
1725        var s = jc(this).attr('data-sort');
1726        var o = jc(this).attr('data-order');
1727        jc(this).parents('.cesis_sorter').find('.sort_selected').removeClass('sort_selected');
1728        jc(this).addClass('sort_selected');
1729
1730        if(o !== undefined){
1731          ctn.isotope({
1732            sortAscending: (o == 'true') ? true : false,
1733          })
1734        }
1735        if(s !== undefined){
1736          ctn.isotope({
1737            sortBy: s
1738          })
1739        }
1740      })
1741
1742
1743
1744
1745        isoLoaded = function(isotopeCtn, startIndex) {
1746                isotopeCtn.css('opacity', 1);
1747                setTimeout(function() {
1748                    isoAnimation(jc('.cesis_iso_item', isotopeCtn), startIndex, true, isotopeCtn);
1749                }, 100);
1750            },
1751            isoAnimation = function(items, startIndex, sequential, container) {
1752                var allItems = items.length - startIndex,
1753                    showed = 0,
1754                    index = 0;
1755                if (container.closest('.owl-item').length == 1) return false;
1756                jc.each(items, function(index, val) {
1757                    var elInner = jc('> .inside_e', val); // maybe need to add not animated
1758                    if (val[0]) val = val[0];
1759                    if (elInner.hasClass('wpb_animate_when_almost_visible')) {
1760
1761                        new cWaypoint({
1762                            element: val,
1763                            handler: function() {
1764                                var element = jc('> .inside_e', this.element),
1765                                    parent = jc(this.element),
1766                                    currentIndex = parent.index();
1767                                var delay = (!sequential) ? index : ((startIndex !== 0) ? currentIndex - allItems : currentIndex),
1768                                    delayAttr = parseInt(element.attr('data-delay'));
1769                                if (isNaN(delayAttr)) delayAttr = 100;
1770                                delay -= showed;
1771                                var objTimeout = setTimeout(function() {
1772                                    element.removeClass('iso_fading').addClass('wpb_start_animation  animated');
1773                                    showed = parent.index();
1774                                }, delay * delayAttr)
1775                                parent.data('objTimeout', objTimeout);
1776                                this.destroy();
1777                            },
1778                            offset: '90%'
1779                        })
1780                    } else {
1781                        if (elInner.hasClass('force-anim')) {
1782                            elInner.addClass('start_animation');
1783                        } else {
1784                            elInner.css('opacity', 1);
1785                        }
1786                    }
1787                    index++;
1788                });
1789            };
1790
1791
1792
1793        var iso_ctn = jc('.cesis_isotope');
1794        if (iso_ctn.length) {
1795            jc(iso_ctn).each(function() {
1796
1797
1798                var container = jc(this);
1799                var m_container = jc(this).parents('.cesis_isotope_container').attr('id');
1800                var layout = container.attr('data-layout');
1801                if (layout == null) {
1802                    var layout = 'packery';
1803                }
1804                var iso_ctn = container.isotope({
1805                    itemSelector: '.cesis_iso_item',
1806                    layoutMode: layout,
1807                    percentPosition: true,
1808                    stagger: 40,
1809                    originLeft: jc('body').hasClass('rtl') ? false : true,
1810                    hiddenStyle: {  opacity: 0 },
1811                    visibleStyle: { opacity: 1 },
1812                    transitionDuration: 0,
1813                    transformsEnabled : false,
1814                    getSortData: {
1815                      title: '.isotope_filter_name',
1816                      date: '.isotope_filter_date parseInt',
1817                      price: '.isotope_filter_price parseInt',
1818                    },
1819                    sortBy : 'original-order'
1820                });
1821                var iso = iso_ctn.data('isotope');
1822
1823                imagesLoaded(container, function() {
1824                    iso.layout();
1825                });
1826
1827                iso_ctn.on('layoutComplete', iso.layout());
1828                jc('#'+m_container+' .cesis_isotope_filter .cesis_filter li a').each(function() {
1829              	   var filter_class = jc(this).attr('data-filter');
1830              		 if (jc('#'+m_container).find(filter_class).length){ // implies *not* zero
1831              		     jc(this).parent('li').show();
1832              				 }else{
1833              				jc(this).parent('li').hide();
1834              				 }
1835              	});
1836              	jc('#'+m_container).find('.cesis_filter').css('opacity','1');
1837
1838                setTimeout(function() {
1839                    iso_ctn.on('layoutComplete', isoLoaded(container, 0));
1840                }, 200);
1841
1842            });
1843        }
1844    }
1845  }
1846};
1847
1848
1849
1850
1851////////////////////////////
1852//***   OwlCarousel   ***//
1853//////////////////////////
1854
1855function owl_adjustment(){
1856  jc('.cesis_content_slider_ctn').trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
1857  jc('.cesis_content_slider_ctn').find('.cloned').remove();
1858  jc('.cesis_content_slider_ctn').find('.owl-prev').remove();
1859  jc('.cesis_content_slider_ctn').find('.owl-next').remove();
1860  jc('.cesis_content_slider_ctn').find('.owl-controls').remove();
1861  jc('.cesis_content_slider_ctn').find('.owl-stage').unwrap();
1862  jc('.cesis_content_slider_ctn').find('.owl-item').unwrap();
1863  jc('.cesis_content_slider_ctn').find('.owl-item > .vc_element').unwrap();
1864  jc('.cesis_content_slider_ctn').find('.owl-stage-outer > .vc_element').unwrap();
1865}
1866
1867if ('function' !== typeof(window['cesis_owl_carousel'])) {
1868    window.cesis_owl_carousel = function() {
1869
1870
1871
1872        jc('.cesis_owl_carousel').on('initialized.owl.carousel change.owl.carousel changed.owl.carousel', function(e) {
1873
1874            if (!e.namespace || e.type != 'initialized' && e.property.name != 'position') return;
1875            var current = e.relatedTarget.current()
1876            var items = jc(this).find('.owl-stage').children()
1877            var a_items = jc(this).find('.owl-stage').children('.active').length;
1878            var add = e.type == 'changed' || e.type == 'initialized'
1879            items.eq(e.relatedTarget.normalize(current)).toggleClass('current', add)
1880            items.eq(e.relatedTarget.normalize(current)).find('.wpb_animate_when_almost_visible').addClass('wpb_start_animation animated');
1881
1882
1883            function items_animation(i) {
1884                if (a_items > 5) {
1885                    var speed = 150;
1886                } else if (a_items < 3) {
1887                    var speed = 300;
1888                } else {
1889                    var speed = 200;
1890                }
1891                if (i == 1) {
1892                    var delay = 0
1893                } else {
1894                    var delay = (i - 1) * speed;
1895                }
1896                setTimeout(function() {
1897                    items.eq(e.relatedTarget.normalize(current + i)).find('.wpb_animate_when_almost_visible').addClass('wpb_start_animation animated');
1898                }, delay);
1899            }
1900            for (var i = 1; i < a_items; i++) {
1901                items_animation(i);
1902            }
1903
1904
1905
1906        });
1907
1908        jc('.cesis_content_slider_ctn').on('initialized.owl.carousel change.owl.carousel changed.owl.carousel', function(e) {
1909          if (!e.namespace || e.type != 'initialized' && e.property.name != 'position') return;
1910          var current = e.relatedTarget.current()
1911          var items = jc(this).find('.owl-stage').children()
1912          var a_items = jc(this).find('.owl-stage').children('.active').length;
1913          var add = e.type == 'changed' || e.type == 'initialized'
1914          items.eq(e.relatedTarget.normalize(current)).find('.wpb_animate_when_almost_visible').removeClass('wpb_start_animation animated');
1915          setTimeout(function() {
1916            items.eq(e.relatedTarget.normalize(current)).find('.wpb_animate_when_almost_visible').each(function () {
1917              var element = jc(this),
1918              delayAttr = element.attr('data-delay');
1919              if (delayAttr == undefined) delayAttr = 0;
1920              setTimeout(function() {
1921                element.addClass('wpb_start_animation animated');
1922              }, (delayAttr));
1923            });
1924          }, 200);
1925        });
1926
1927        jc('.cesis_owl_carousel').on('resize.owl.carousel change.owl.carousel changed.owl.carousel', function() {
1928            var iso_check = jc(this).closest('.cesis_isotope')
1929            var owl_stage = jc(this).find('.owl-stage-outer');
1930            var owl_height = jc(this);
1931
1932            setTimeout(function() {
1933                iso_check.isotope('layout');
1934            }, 10);
1935
1936            setTimeout(function() {
1937                var caca = owl_height.find('.owl-height');
1938                var test = caca.find('.active');
1939                var prout = test.outerHeight();
1940                owl_stage.height(prout);
1941                iso_check.isotope('layout');
1942            }, 200);
1943
1944            setTimeout(function() {
1945                iso_check.isotope('layout');
1946            }, 400);
1947        });
1948
1949
1950        jc('.cesis_owl_carousel').each(function() {
1951
1952
1953
1954
1955            var id = jc(this).attr('id');
1956            var cesis_col = jc(this).data('col');
1957            var cesis_col_big = jc(this).data('col_big');
1958            var cesis_col_tablet = jc(this).data('col_tablet');
1959            var cesis_col_mobile = jc(this).data('col_mobile');
1960            var cesis_scroll = jc(this).data('scroll');
1961            var cesis_speed = jc(this).data('speed');
1962            var cesis_pag = jc(this).data('pag');
1963            var cesis_pag_tablet = jc(this).data('pag_tablet');
1964            var cesis_pag_mobile = jc(this).data('pag_mobile');
1965            var cesis_nav = jc(this).data('nav');
1966            var cesis_nav_tablet = jc(this).data('nav_tablet');
1967            var cesis_nav_mobile = jc(this).data('nav_mobile');
1968            var cesis_loop = jc(this).data('loop');
1969            var cesis_center = jc(this).data('center');
1970            var cesis_margin = jc(this).data('margin');
1971            var cesis_autoheight = jc(this).data('autoheight');
1972
1973
1974            if (cesis_col_big == null || cesis_col_big == "inherit"){
1975              cesis_col_big = cesis_col;
1976            }
1977
1978            jc(this).owlCarousel({
1979                rtl: jc('body').hasClass('rtl') ? true : false,
1980                responsiveClass: true,
1981                responsive: {
1982                    0: {
1983                        items: cesis_col_mobile,
1984                        dots: (cesis_pag_mobile == 'yes') ? true : false,
1985                        nav: (cesis_nav_mobile == 'yes') ? true : false,
1986                    },
1987                    780: {
1988                        items: cesis_col_tablet,
1989                        dots: (cesis_pag_tablet == 'yes') ? true : false,
1990                        nav: (cesis_nav_tablet == 'yes') ? true : false,
1991                    },
1992                    1000: {
1993                        items: cesis_col,
1994                        dots: (cesis_pag == 'yes') ? true : false,
1995                        nav: (cesis_nav == 'yes') ? true : false,
1996                    },
1997                    1600: {
1998                        items: cesis_col_big,
1999                        dots: (cesis_pag == 'yes') ? true : false,
2000                        nav: (cesis_nav == 'yes') ? true : false,
2001                    },
2002                },
2003
2004                navContainer: jc(this),
2005                navText: ['<div class="owl-nav-container"><i class="fa fa-fw fa-angle-left"></i></div>', '<div class="owl-nav-container"><i class="fa fa-fw fa-angle-right"></i></div>'],
2006
2007                autoplayTimeout: cesis_speed,
2008                autoplaySpeed: 800,
2009                autoplay: (cesis_scroll == 'yes') ? true : false,
2010                center: (cesis_center == 'yes') ? true : false,
2011                loop: (cesis_loop == 'yes') ? true : false,
2012                autoHeight: (cesis_autoheight == 'yes') ? true : false,
2013                margin: (cesis_margin !== '0' && cesis_col !== '1') ? cesis_margin : 0,
2014
2015            });
2016
2017
2018
2019        });
2020
2021
2022
2023    }
2024};
2025
2026
2027
2028
2029////////////////////////////
2030//*** Animated Number ***//
2031//////////////////////////
2032
2033
2034if ('function' !== typeof(window['cesis_animated_number'])) {
2035    window.cesis_animated_number = function() {
2036
2037        jc('.cesis_count_to').each(function() {
2038
2039
2040            var id = jc(this).attr('id');
2041            var cesis_number = jc(this).data('number');
2042            var cesis_separator = jc(this).data('separator');
2043            var cesis_decimal = jc(this).data('decimal');
2044            var cesis_d_separator = jc(this).data('d_separator');
2045            var cesis_prefix = jc(this).data('prefix');
2046            var cesis_suffix = jc(this).data('suffix');
2047            var cesis_speed = jc(this).data('speed');
2048
2049
2050            jc(this).cwaypoint(function() {
2051                var easingFn = function(t, b, c, d) {
2052                    var ts = (t /= d) * t;
2053                    var tc = ts * t;
2054                    return b + c * (tc * ts + -5 * ts * ts + 10 * tc + -10 * ts + 5 * t);
2055                }
2056                var options = {  
2057                    useEasing: true,
2058                      easingFn: easingFn,
2059                      useGrouping: true,
2060                      separator: cesis_separator,
2061                      decimal: cesis_d_separator,
2062                      prefix: cesis_prefix,
2063                      suffix: cesis_suffix,
2064                };
2065                var count_to = new CountUp(id, 0, cesis_number, cesis_decimal, cesis_speed, options);
2066                count_to.start();
2067                this.destroy();
2068            }, {
2069                offset: '85%'
2070            });
2071
2072
2073        })
2074    }
2075};
2076
2077
2078//////////////////////////////////
2079//*** Circular Progress Bar ***//
2080////////////////////////////////
2081
2082
2083if ('function' !== typeof(window['cesis_circular_progress_bar'])) {
2084    window.cesis_circular_progress_bar = function() {
2085
2086        jc('.cesis_circular_pb_ctn').each(function() {
2087
2088
2089            var SET_PERCENTAGE = jc(this).children('.cesis_circular_pb_canvas').data('percentage-value');
2090            var status = jc(this).find('.cesis_cbp_percentage');
2091            console.log("cestlestatus"+status);
2092            var speed = jc(this).children('.cesis_circular_pb_canvas').data('speed');
2093            var linecap_style = jc(this).children('.cesis_circular_pb_canvas').data('linecap');
2094            var bar_color = jc(this).children('.cesis_circular_pb_canvas').data('bar-color');
2095            var alt_color = jc(this).children('.cesis_circular_pb_canvas').data('bar-alt-color');
2096            var track_color = jc(this).children('.cesis_circular_pb_canvas').data('track-color');
2097            var bar_size = jc(this).children('.cesis_circular_pb_canvas').data('bar-size');
2098            var track_size = jc(this).children('.cesis_circular_pb_canvas').data('track-size');
2099            var canvas_size = jc(this).children('.cesis_circular_pb_canvas').data('canvas-size');
2100            var radius = jc(this).children('.cesis_circular_pb_canvas').data('radius');
2101            var canvasid = jc(this).children('.cesis_circular_pb_canvas').attr('id');
2102
2103
2104            jc(this).cwaypoint(function() {
2105
2106
2107                        var requestAnimationFrame =
2108                                window.requestAnimationFrame ||       // According to the standard
2109                                window.mozRequestAnimationFrame ||    // For mozilla
2110                                window.webkitRequestAnimationFrame || // For webkit
2111                                window.msRequestAnimationFrame ||     // For ie
2112                                function (f) { window.setTimeout(function () { f(Date.now()); }, 1000/300); }; // If everthing else fails
2113
2114                        var cancelAnimationFrame =
2115                                window.cancelAnimationFrame ||
2116                                window.mozCancelAnimationFrame ||
2117                                window.webkitCancelAnimationFrame ||
2118                                window.msCancelAnimationFrame;
2119                        var x = canvas_size;//set the x - center here
2120                        var y = canvas_size;//set the y - center here
2121                        var r = radius;//set the radius here
2122                        var linewidth = bar_size;//set the line width here
2123
2124                //========
2125
2126                        var c =  document.getElementById(canvasid);
2127                        var loaded = false;
2128
2129                        window.onload = function () {
2130
2131                            loaded = true;
2132                        }
2133
2134
2135                        var ROTATION = 0;
2136
2137                        function setcanvas() {
2138                            var ctx = c.getContext("2d");
2139
2140                            ctx.translate(x, y);
2141                            ctx.rotate((Math.PI / 180) * (-ROTATION));
2142                            ctx.translate(-x, -y);
2143                            ctx.clearRect(0, 0, c.width, c.height);
2144
2145                            ctx.beginPath();
2146                            ctx.lineWidth = track_size;
2147                            ctx.strokeStyle = track_color;
2148                            ctx.arc(x, y, r, 0, 2 * Math.PI);
2149                            ctx.stroke();
2150
2151
2152                        }
2153
2154                        function getPoint(c1, c2, radius, angle) {
2155                            return [c1 + Math.cos(angle) * radius, c2 + Math.sin(angle) * radius];
2156                        }
2157
2158                        function setPercent(uplimit) {
2159                            var ctx = c.getContext("2d");
2160                            ctx.beginPath();
2161                            ctx.translate(x, y);
2162                            ROTATION = 270;
2163                            ctx.rotate((Math.PI / 180) * ROTATION);
2164                            ctx.translate(-x, -y);
2165                            ctx.lineWidth = linewidth;//40
2166                            ctx.lineCap = linecap_style;
2167                            var my_gradient = ctx.createLinearGradient(-0, 0, 0, 520);
2168                            my_gradient.addColorStop(0, bar_color);
2169                            my_gradient.addColorStop(1, alt_color);
2170
2171                            ctx.strokeStyle = my_gradient;
2172                            ctx.arc(x, y, r, 0, (Math.PI / 180) * (-uplimit), false);
2173                            ctx.globalAlpha = 1;
2174                            ctx.stroke();
2175
2176
2177                        }
2178                        function callcanvas(degree) {
2179                            setcanvas();
2180                            setPercent(360 - degree);
2181                        }
2182
2183                        var degree = parseInt((SET_PERCENTAGE * 360) / 100);
2184                        var start = 0;
2185
2186
2187                        function animatebar() {
2188
2189                              start = start + speed;
2190                              if (start > degree) {
2191
2192                                if(degree == 360 || degree == -360){
2193                                  status.html('100%');
2194                                  degree = -360;
2195                                }else{
2196                                  status.html(Math.round((degree * 100) / 360) + '%');
2197                                }
2198                                callcanvas(degree);
2199                                var BarAnimation = requestAnimationFrame(animatebar);
2200                              }else if(start == degree) {
2201                                start = degree;
2202                                if(degree == 360 || degree == -360){
2203                                    status.html('100%');
2204                                    degree = -360;
2205                                }else{
2206                                  status.html(Math.round((degree * 100) / 360) + '%');
2207                                }
2208                                callcanvas(degree);
2209                                var BarAnimation = requestAnimationFrame(animatebar);
2210                              }else {
2211                                callcanvas(start);
2212                                status.html(parseInt((start * 100) / 360) + '%');
2213                                var BarAnimation = requestAnimationFrame(animatebar);
2214                              }
2215                        }
2216                        animatebar();
2217
2218
2219
2220                this.destroy();
2221            }, {
2222                offset: '85%'
2223            });
2224
2225
2226        })
2227    }
2228};
2229
2230
2231////////////////////////////
2232//***  Progress Bar   ***//
2233//////////////////////////
2234
2235if ('function' !== typeof(window['vc_progress_bar'])) {
2236    window.vc_progress_bar = function() {
2237
2238        if ('undefined' !== typeof(jQuery.fn.cwaypoint)) {
2239            jc('.vc_progress_bar').cwaypoint(function() {
2240                var pb_this = jc(this.element);
2241                jc(pb_this).find('.vc_single_bar').each(function(index) {
2242                    var $this = jc(this),
2243                        bar = $this.find('.vc_bar'),
2244                        stripe = $this.find('.cesis_progress_bar_effect'),
2245                        val = bar.data('percentage-value');
2246
2247
2248
2249                    setTimeout(function() {
2250                        bar.css({
2251                            'width': val + '%'
2252                        });
2253                        stripe.css({
2254                            'width': val + '%'
2255                        });
2256                    }, index * 200);
2257                });
2258                this.destroy();
2259            }, {
2260                offset: '85%'
2261            });
2262
2263        }
2264    }
2265}
2266
2267//////////////////////////////////////////
2268//***  Visual Composer animations   ***//
2269////////////////////////////////////////
2270
2271if ('function' !== typeof(window['vc_waypoints'])) {
2272    window.vc_waypoints = function() {
2273      if ('undefined' !== typeof(jc.fn.cwaypoint)) {
2274        jc('.wpb_animate_when_almost_visible:not(.wpb_start_animation):not(.inside_e)').cwaypoint(function() {
2275          var element = jc(this.element),
2276          delayAttr = element.attr('data-delay');
2277          if (delayAttr == undefined) delayAttr = 0;
2278          setTimeout(function() {
2279            element.addClass('wpb_start_animation animated');
2280          }, (delayAttr));
2281            this.destroy();
2282          }, {
2283            offset: '90%'
2284          });
2285        }
2286    }
2287}
2288
2289
2290
2291//////////////////////////////////////////
2292//***          Accordion            ***//
2293////////////////////////////////////////
2294
2295function cesis_accordion() {
2296
2297    jc(document).on('click', '[data-toggle="tab"]', function(e) {
2298        e.preventDefault()
2299        jc(this).tab('show');
2300    });
2301    jc(document).on('click', '[data-toggle="collapse"]', function(e) {
2302        var $this = jc(this),
2303            href
2304        var target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')
2305        var $target = jc(target)
2306        var data = $target.data('bs.collapse')
2307        var option = data ? 'toggle' : $this.data()
2308        var parent = $this.attr('data-parent')
2309        var $parent = parent && jc(parent)
2310        var owl = jc($target).find('.owl-carousel');
2311        if (owl.data('owlCarousel')) {
2312            owl.data('owlCarousel').onThrottledResize();
2313        }
2314        var $title = jc(this).parent()
2315        if ($parent) {
2316            $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
2317            if ($title.hasClass('active')) {
2318                $title.removeClass('active');
2319            } else {
2320                $parent.find('.panel-title').removeClass('active')
2321                $title[!$target.hasClass('in') ? 'addClass' : 'removeClass']('active')
2322            }
2323        }
2324        $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
2325    });
2326
2327
2328}
2329
2330
2331
2332//////////////////////////////////////////
2333//***          Tabs / Tour          ***//
2334////////////////////////////////////////
2335
2336if ('function' !== typeof(window['cesis_tabs'])) {
2337    window.cesis_tabs = function() {
2338        var strHash = document.location.hash;
2339
2340        jc('.tabs-wrapper').each(function() {
2341            var t = 1;
2342
2343            jc(this).find('.tabli').each(function() {
2344                jc(this).parents('.tabs-wrapper').find('.tabs').append(this);
2345                t++;
2346            });
2347            /* GET ALL BODY */
2348            var t = 1;
2349            jc(this).find('.tab_content').each(function() {
2350
2351                jc(this).parents('.tabs-wrapper').find('.tabs-container').append(this);
2352                t++;
2353            });
2354            jc(this).find('.tab_content').hide(); //Hide all content
2355
2356            jc(this).find('ul.tabs li:first').addClass('active').show(); //Activate first tab
2357
2358            jc(this).find('.tab_content:first').show(); //Show first tab content
2359
2360        });
2361
2362        var Tabs = jc('.cesis_tab_4');
2363        Tabs.each(function() {
2364
2365            var current_width = jc(this).find('li.active a');
2366            jc('<span class="tab_moving_line"></span>').insertAfter(jc(this).find('.tabs li:first-child'));
2367            var Line = jc(this).find('.tab_moving_line');
2368
2369            Line.width(current_width.width())
2370            Line.css('left', jc(this).find('li.active').position().left)
2371        });
2372
2373
2374        // Line moving effect
2375        function linemove() {
2376            var Tabs = jc('.cesis_tab_4');
2377            Tabs.each(function() {
2378                var el, leftPos, newWidth;
2379
2380                var Line = jc(this).find('.tab_moving_line');
2381
2382                Line.width(jc(this).find('li.active a').width())
2383                    .css('left', jc(this).find('li.active').position().left)
2384                    .data('origLeft', Line.position().left)
2385                    .data('origWidth', Line.width());
2386
2387                jc('.cesis_tab_4 ul.tabs li a').on('click', function() {
2388                    el = jc(this);
2389                    leftPos = el.position().left;
2390                    newWidth = el.parent().width();
2391                });
2392            });
2393        }
2394        //On Click Event
2395
2396        jc('.tabs-wrapper ul.tabs li').on('click', function(e) {
2397
2398            jc(this).parents('.tabs-wrapper').find('ul.tabs li').removeClass('active'); //Remove any 'active' class
2399            jc(this).addClass('active'); //Add 'active' class to selected tab
2400            jc(this).parents('.tabs-wrapper').find('.tab_content').hide(); //Hide all tab content
2401            var activeTab = jc(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
2402            jc(this).parents('.tabs-wrapper').find(activeTab).fadeIn(); //Fade in the active ID content
2403            jc('ul').trigger('updateSizes');
2404            linemove();
2405            var owl = jc(activeTab).find('.owl-carousel');
2406            if (owl.data('owlCarousel')) {
2407                owl.data('owlCarousel').onThrottledResize();
2408            }
2409            var iso_check = jc('.cesis_isotope')
2410            iso_check.isotope('layout');
2411            e.preventDefault();
2412
2413        });
2414
2415        jc('ul.wc-tabs li').on('click', function(e) {
2416          setTimeout(function() {
2417              linemove()
2418          }, 20);
2419        });
2420
2421        jc('.tabs-wrapper ul.tabs > li > a').on('click', function(e) {
2422            e.preventDefault();
2423
2424
2425        });
2426
2427
2428
2429        if (strHash) jc('.tabli a[href$="' + strHash + '"]').parent().trigger('click');
2430
2431
2432    }
2433}
2434
2435//////////////////////////////////////////
2436//***            Lightbox           ***//
2437////////////////////////////////////////
2438
2439if ('function' !== typeof(window['cesis_lightbox'])) {
2440    window.cesis_lightbox = function() {
2441        jc('.cesis_lightbox_si').lightGallery();
2442        jc('.cesis_lightbox_lg').lightGallery({
2443          selector:'.cesis_lightbox_el',
2444        });
2445        jc('.cesis_blog_m_thumbnail').lightGallery({
2446          selector:'.cesis_gallery_img',
2447        });
2448        jc('.cesis_portfolio_m_thumbnail').lightGallery({
2449          selector:'.cesis_gallery_img',
2450        });
2451        jc('.cesis_overlay_ctn').lightGallery({
2452          selector:'.cesis_hover_zoom',
2453        });
2454        jc('.cesis_gallery_ctn').lightGallery({
2455          selector:'.cesis_gallery_lightbox',
2456        });
2457        jc('.woocommerce-product-gallery__wrapper').lightGallery({
2458          selector:'.woocommerce-product-gallery__image',
2459        });
2460
2461        // 1) ASSIGN EACH 'DOT' A NUMBER
2462        dotcount = 1;
2463
2464        jQuery('.woocommerce-product-gallery__wrapper .owl-dot').each(function() {
2465          jQuery( this ).addClass( 'dotnumber' + dotcount);
2466          jQuery( this ).attr('data-info', dotcount);
2467          dotcount=dotcount+1;
2468        });
2469
2470        // 2) ASSIGN EACH 'SLIDE' A NUMBER
2471        slidecount = 1;
2472
2473        jQuery('.woocommerce-product-gallery__wrapper .owl-item').not('.cloned').each(function() {
2474          jQuery( this ).addClass( 'slidenumber' + slidecount);
2475          slidecount=slidecount+1;
2476        });
2477
2478        // SYNC THE SLIDE NUMBER IMG TO ITS DOT COUNTERPART (E.G SLIDE 1 IMG TO DOT 1 BACKGROUND-IMAGE)
2479        jQuery('.woocommerce-product-gallery__wrapper .owl-dot').each(function() {
2480
2481          grab = jQuery(this).data('info');
2482
2483          slidegrab = jQuery('.slidenumber'+ grab +' img').attr('src');
2484
2485          jQuery(this).css("background-image", "url("+slidegrab+")");
2486
2487        });
2488
2489        // THIS FINAL BIT CAN BE REMOVED AND OVERRIDEN WITH YOUR OWN CSS OR FUNCTION, I JUST HAVE IT
2490        // TO MAKE IT ALL NEAT
2491        amount = jQuery('.woocommerce-product-gallery__wrapper .owl-dot').length;
2492        gotowidth = 100/amount;
2493
2494        jQuery('.woocommerce-product-gallery__wrapper .owl-dot').css("width", gotowidth+"%");
2495        newwidth = jQuery('.woocommerce-product-gallery__wrapper .owl-dot').width();
2496        jQuery('.woocommerce-product-gallery__wrapper .owl-dot').css("height", newwidth+"px");
2497        jQuery('body').on('change', '.variations select', function() {
2498        var mysrcset = jQuery('.slidenumber1 .woocommerce-product-gallery__image a img').attr('srcset');
2499        if (typeof mysrcset !== 'undefined'){ //checking if the srcset attribute is defined
2500        lastsrcset = mysrcset.split(',');
2501        lastsrc = lastsrcset[(lastsrcset.length - 1)];
2502        lastpuresrc = lastsrc.split(' ');
2503        mysrc = lastpuresrc[1];
2504        }
2505        // display or use src of biggest image src
2506        jQuery('.slidenumber1 .woocommerce-product-gallery__image').attr('data-src', mysrc);
2507        jQuery('.dotnumber1').css('background-image', 'url('+mysrc+')');
2508
2509        // Action goes here.
2510        });
2511
2512
2513    }
2514}

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.