PageSourceSearch

https://www.be-terna.com/sites/5ebfc39e232fb906a3dfc34b/theme/javascripts/frontend2.js?1790247815

js be-terna.com collected 2026-09-25 14:33:55 UTC 77,198 bytes, 2,261 lines download raw bytes

1if (window.MsCrmMkt)
2console.log(window.MsCrmMkt);
3
4var loc = "en";
5
6// Disable non-essential Dynamics 365 Marketing cookies 
7function d365mktConfigureTracking() {
8  return {Anonymize: true};
9}
10
11document.addEventListener("d365mkt-beforeformload", function() { console.log("d365mkt-beforeformload") });
12document.addEventListener("d365mkt-afterformload", function() { 
13  
14  var hiddenField,
15        jsonObject;
16        
17  console.log("d365mkt-afterformload") 
18  
19  console.log("form loaded");
20  hiddenField = $("label:contains('Homepage JSON')").next("textarea");
21  console.log(hiddenField);
22  
23  // jsonObject = {
24  //   page_url: "https://www.be-terna.com",
25  //   initial_referrer: "https://google.com",
26  //   referrer: "https://google.com",
27  //   UTM_source: "utm"
28  // }
29  
30  //console.log(jsonObject, JSON.stringify(jsonObject));
31  
32  //hiddenField.val(JSON.stringify(jsonObject));
33  
34  const encodedDetails = sessionStorage.getItem('visitorDetails');
35  let visitorDetails = JSON.parse(decodeURIComponent(escape(atob(encodedDetails))));
36  
37  // console.log(visitorDetails);
38  
39  if (visitorDetails) {
40    visitorDetails.lang = loc;
41    // Update visitor details with current page information
42    visitorDetails.page = window.location.href;
43    visitorDetails.page_title = document.title;
44    visitorDetails.previous_page = document.referrer;
45  
46    
47    console.log(visitorDetails);
48    
49    // Re-encode the updated details before storing them again
50    sessionStorage.setItem('visitorDetails', btoa(unescape(encodeURIComponent(JSON.stringify(visitorDetails)))));
51  
52    // Load the details into a form field
53    //document.querySelector('input[name="visitorInfo"]').value = JSON.stringify(visitorDetails, null, 2); // Pretty print JSON
54    
55    hiddenField.val(JSON.stringify(visitorDetails, null, 2));
56  }
57  
58  //console.log(hiddenField.val());
59      
60});
61
62document.addEventListener("d365mkt-formrender", function() { console.log("d365mkt-formrender") });
63document.addEventListener("d365mkt-formsubmit", function(event) {
64  
65  window.dataLayer = window.dataLayer || [];
66  window.dataLayer.push({
67   'event': 'form_submitted'
68  });
69  
70  // example of validation using form submit event - cancelling form submission unless first name is John 
71  // if (document.forms[0]["firstname"].value !== "John") { 
72  //   event.preventDefault(); 
73  //   console.log("blocked mkt-formsubmit"); 
74  //   return;
75  // }
76  console.log("mkt-formsubmit" + JSON.stringify(event.detail.payload)); 
77});
78
79document.addEventListener("d365mkt-afterformsubmit", function(event) {
80    console.log(event);
81    console.log(this);
82    
83    window.dataLayer = window.dataLayer || [];
84    window.dataLayer.push({
85        'event': 'formSubmitted',
86        'formName': 'MVW Contact'
87    });
88    window.dataLayer = window.dataLayer || [];
89    window.dataLayer.push({
90       'event': 'form_submitted_after'
91    });
92   
93});
94
95document.addEventListener("d365mkt-afterformsubmit", function(event) {
96  console.log("success - " + event.detail.successful);
97  console.log("payload - " + JSON.stringify(event.detail.payload));
98});
99
100
101document.addEventListener('DOMContentLoaded', function() {
102  console.log("DOMContentLoaded");
103// Check if visitor details have already been stored in this session
104  if (!sessionStorage.getItem('visitorDetails')) {
105      
106      const urlParams = new URLSearchParams(window.location.search);
107    
108      function extractDomain(url) {
109        let hostname;
110        if (url.indexOf("://") > -1) {
111          hostname = url.split('/')[2];
112        } else {
113          hostname = url.split('/')[0];
114        }
115        hostname = hostname.split(':')[0];
116        hostname = hostname.split('?')[0];
117        return hostname;
118      }
119    
120      // Initialize visitorDetails with all keys, ensuring consistent order
121      const visitorDetails = {
122        initial_referrer: '',
123        initial_referring_domain: '',
124        landing_page: '',
125        utm_source: '',
126        utm_medium: '',
127        utm_campaign: '',
128        utm_term: '',
129        utm_content: '',
130        page: '',
131        page_title: '',
132        previous_page: ''
133      };
134    
135      // Populate visitorDetails with actual values
136      visitorDetails.initial_referrer = document.referrer;
137      visitorDetails.initial_referring_domain = document.referrer ? extractDomain(document.referrer) : '';
138      visitorDetails.landing_page = window.location.href;
139      visitorDetails.utm_source = urlParams.get('utm_source') || '';
140      visitorDetails.utm_medium = urlParams.get('utm_medium') || '';
141      visitorDetails.utm_campaign = urlParams.get('utm_campaign') || '';
142      visitorDetails.utm_term = urlParams.get('utm_term') || '';
143      visitorDetails.utm_content = urlParams.get('utm_content') || '';
144    
145      // Base64 encode the visitor details
146      const encodedDetails = btoa(unescape(encodeURIComponent(JSON.stringify(visitorDetails))));
147    
148      // Store the encoded details in session storage
149      sessionStorage.setItem('visitorDetails', encodedDetails);
150      
151      
152  }
153});
154
155
156// retrieve and update visitor information
157document.addEventListener('DOMContentLoaded', function() {
158  console.log("DOMContentLoaded");
159  // Retrieve and Base64 decode the visitor details from session storage
160  const encodedDetails = sessionStorage.getItem('visitorDetails');
161  let visitorDetails = JSON.parse(decodeURIComponent(escape(atob(encodedDetails))));
162
163  if (visitorDetails) {
164    // Update visitor details with current page information
165    visitorDetails.page = window.location.href;
166    visitorDetails.page_title = document.title;
167    visitorDetails.previous_page = document.referrer;
168
169    // Re-encode the updated details before storing them again
170    sessionStorage.setItem('visitorDetails', btoa(unescape(encodeURIComponent(JSON.stringify(visitorDetails)))));
171  
172    console.log(visitorDetails);
173    // Load the details into a form field
174    //document.querySelector('input[name="visitorInfo"]').value = JSON.stringify(visitorDetails, null, 2); // Pretty print JSON
175  }
176});
177
178
179// REINIT COOKIE SCRIPT WITH IFRAMES FROM WEBFLOW'S VIDEO LIGHTBOX
180var Webflow = Webflow || [];
181Webflow.push(function() {
182  
183  // 1. Listen for clicks on the Webflow Lightbox triggers
184  $(document).on('click', '.w-inline-block.w-lightbox', function() {
185    
186    // 2. Observe the DOM for the appearance of the Lightbox
187    var observer = new MutationObserver(function(mutations, obs) {
188      const lightbox = document.querySelector('.w-lightbox-view');
189      
190      if (lightbox) {
191        
192        initYoutubeEmbeds();
193        
194        // 3. Wait for the cookie script to be fully loaded
195        setTimeout(function() {
196          
197          
198          
199          if (window.CookieScript && window.CookieScript.instance) {
200            const cs = window.CookieScript.instance;
201            
202            // Try the most common Cookie-Script re-scan methods
203            if (typeof cs.init === 'function') {
204                //console.log("init");
205                cs.init(); 
206            } else if (typeof cs.run === 'function') {
207                //console.log("run");
208                cs.run();
209            } else if (typeof cs.check === 'function') {
210                //console.log("check");
211                cs.check();
212            } else {
213                //console.log("fallback");
214                // Fallback: Manually swap data-src to src if consent was already given
215                // Cookie-Script stores categories in currentState().categories
216                const state = cs.currentState();
217                if (state && state.categories && state.categories.includes('targeting')) {
218                    const iframe = lightbox.querySelector('iframe[data-src]');
219                    if (iframe) {
220                        iframe.src = iframe.getAttribute('data-src');
221                        console.log('Cookie-Script: Manual fallback trigger used.');
222                    }
223                }
224            }
225            console.log('Webflow Lightbox: Cookie-Script re-triggered.');
226          }
227        }, 200); // Small delay to ensure Webflow finished rendering the iframe
228        
229        obs.disconnect();
230      }
231    });
232
233    observer.observe(document.body, { childList: true, subtree: true });
234  });
235});
236
237
238//document.addEventListener("DOMContentLoaded", initYoutubeEmbeds);
239
240//setTimeout(initYoutubeEmbeds, 1000);
241
242document.addEventListener("DOMContentLoaded", waitForCookieScript);
243
244function waitForCookieScript() {
245
246    const interval = setInterval(() => {
247
248        if (window.CookieScript && CookieScript.instance) {
249            clearInterval(interval);
250            initYoutubeEmbeds();
251        }
252
253    }, 100);
254
255}
256
257function initYoutubeEmbeds() {
258
259    const consent = CookieScript.instance.currentState();
260    //console.log(consent);
261    const cookiesAccepted = consent.action === "accept" && consent.categories.includes("targeting");
262
263    const embeds = document.querySelectorAll(".yt-embed[data-src]");
264
265    embeds.forEach(container => {
266        
267        //console.log(container);
268        
269        const src = container.dataset.src;
270        // const videoId = extractYoutubeId(src);
271
272        if (cookiesAccepted) {
273            loadYoutubePlayer(container, src);
274        } 
275        // else {
276        //     showPlaceholder(container, videoId);
277        // }
278
279    });
280
281}
282
283function extractYoutubeId(url) {
284    const match = url.match(/embed\/([^?]+)/);
285    return match ? match[1] : null;
286}
287
288function loadYoutubePlayer(container, src) {
289
290    const iframe = document.createElement("iframe");
291
292    iframe.src = src;
293    iframe.width = "100%";
294    iframe.height = "100%";
295    iframe.frameBorder = "0";
296    iframe.allow =
297        "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
298    iframe.allowFullscreen = true;
299
300    container.innerHTML = "";
301    container.appendChild(iframe);
302
303}
304
305
306jQuery(function($){
307  // JS READY 
308    $("html").addClass("js-ready");
309  
310  // GET LANG
311  
312  loc = $("html").attr("lang");
313  
314  // MAIN NAV / MAKE PARENT DROPDOWN OF CURRENT PAGE ALSO CURRENT
315  $(".menu-pad a.w--current").parents(".w-dropdown").find(".nav-link").addClass("w--current");
316  //// STICKY HEADER
317  let header = $(".header-section");
318  let hero = $(".hero, .article-hero");
319  let stickyForm = $(".hero-form-section");
320  let stickyFormTop = 0;
321  if (stickyForm.length > 0)
322    stickyFormTop = stickyForm.offset().top; //stickyForm.offset().top - 100; //.scrollTop(); //.offset().top;
323  // if (stickyForm.length > 0)
324  //   console.log(stickyForm.offset().top);
325  let headerHeight = header.outerHeight();
326  let heroHeight = hero.outerHeight() || headerHeight;
327  let stickyFormHeight = stickyForm.outerHeight() || 0;
328  //console.log(stickyForm);
329  //console.log(headerHeight, heroHeight, stickyFormHeight);
330  let sensitivity = 0;
331  let scrollTop = 0;
332  let scrollPos = 0;
333  let lastScrollPosUp = 0;
334  let lastScrollPosDown = 0;
335  let navbar = header.find(".w-nav");
336  let mainMenu = navbar.find(".w-nav-menu");
337  
338  
339  
340  
341  if (typeof MsCrmMkt != "undefined"){
342  
343    console.log("page ready");
344    var hiddenField,
345        jsonObject;
346        
347    MsCrmMkt.MsCrmFormLoader.on("afterFormLoad", function() {
348      console.log("form loaded");
349      hiddenField = $("label:contains('Homepage JSON')").next("textarea");
350      console.log(hiddenField);
351      
352      // jsonObject = {
353      //   page_url: "https://www.be-terna.com",
354      //   initial_referrer: "https://google.com",
355      //   referrer: "https://google.com",
356      //   UTM_source: "utm"
357      // }
358      
359      //console.log(jsonObject, JSON.stringify(jsonObject));
360      
361      //hiddenField.val(JSON.stringify(jsonObject));
362      
363      const encodedDetails = sessionStorage.getItem('visitorDetails');
364      let visitorDetails = JSON.parse(decodeURIComponent(escape(atob(encodedDetails))));
365      
366      // console.log(visitorDetails);
367      
368      if (visitorDetails) {
369        visitorDetails.lang = loc;
370        // Update visitor details with current page information
371        visitorDetails.page = window.location.href;
372        visitorDetails.page_title = document.title;
373        visitorDetails.previous_page = document.referrer;
374      
375        
376        console.log(visitorDetails);
377        
378        // Re-encode the updated details before storing them again
379        sessionStorage.setItem('visitorDetails', btoa(unescape(encodeURIComponent(JSON.stringify(visitorDetails)))));
380    
381        // Load the details into a form field
382        //document.querySelector('input[name="visitorInfo"]').value = JSON.stringify(visitorDetails, null, 2); // Pretty print JSON
383        
384        hiddenField.val(JSON.stringify(visitorDetails, null, 2));
385      }
386   
387      //console.log(hiddenField.val());
388      
389    });
390    
391    MsCrmMkt.MsCrmFormLoader.on("formSubmit", function() {
392      window.dataLayer = window.dataLayer || [];
393      window.dataLayer.push({
394       'event': 'form_submitted'
395       });
396    });
397    
398    MsCrmMkt.MsCrmFormLoader.on("afterFormSubmit", function() {
399      window.dataLayer = window.dataLayer || [];
400      window.dataLayer.push({
401       'event': 'form_submitted_after'
402       });
403    });
404  
405  }
406  
407  
408  
409  //console.log(headerHeight, heroHeight);
410  /*
411  navbar.find(".dropdown-toggle").click(function(){
412    //if (!$(this).hasClass("w--open"))
413      header.toggleClass("open");
414  });
415  */
416  $('body').on("tap", function(evt){
417    //console.log("body tap");
418    header.removeClass("open");
419  });
420  navbar.on("tap", ".dropdown-toggle, .w-nav-button", function(evt){ //:not(.w--nav-dropdown-toggle-open)
421    evt.stopPropagation();
422    //if (!$(this).hasClass("w--open"))
423    //console.log($(evt.currentTarget), $(evt.currentTarget).hasClass("dropdown-toggle"));
424    if (($(evt.currentTarget).hasClass("dropdown-toggle") && !mainMenu.parent().hasClass("w-nav-overlay")) || $(evt.currentTarget).hasClass("w-nav-button")) {
425      //console.log("main dropdown tap");
426      //console.log("st. odprtih dropdownov v headerju: ", navbar.find(".nav-link.w--open").length);
427      if (navbar.find(".w--open").length){
428          header.removeClass("open");
429          // $("html, body").removeClass("noscroll-on-mobile-menu");
430      }
431      else {
432          header.addClass("open");
433          // $("html, body").addClass("noscroll-on-mobile-menu");
434      }
435    }
436  });
437  //$(window).resize(function(e) {
438    ////mainMenu = navbar.find(".w-nav-menu");
439    ///heroHeight = hero.outerHeight() || 0;
440    ///headerHeight = header.outerHeight();
441    ////console.log(headerHeight, heroHeight);
442    //stickyFormHeight = stickyForm.outerHeight() || 0; // ne rabim, ker je sticky samo na desktopu, kjer je pa v eni vrstici in se z resizom ne spreminja visina
443  //});
444  $(window).scroll(function(e) {
445    //console.log(e);
446    // if (mainMenu.find(".w--open").length == 0 && !mainMenu.hasClass("w--nav-menu-open")) {
447      scrollTop = $(window).scrollTop();
448      let scrollPosCur = (document.body.getBoundingClientRect()).top;
449      const $toTop = $('.to-top');
450      
451      // --- 1. BACK TO TOP BUTTON ---
452      // Show button as soon as we leave the top of the page
453      if (scrollTop > heroHeight) {
454        //$toTop.addClass("active");
455        //$toTop.show();
456        $toTop.addClass("show");
457      } else {
458        $toTop.removeClass("show");
459        //$toTop.hide();
460      }
461      
462      //console.log(scrollPosCur, scrollTop);
463      if (scrollTop > heroHeight)
464        header.addClass("hide");
465      if (scrollPosCur > scrollPos) { // if scroll dir up //scrollPos + sensitivity
466        if (scrollTop > heroHeight) {// + headerHeight 
467          header.addClass("hide");
468          if (scrollTop > heroHeight - 80 - stickyFormHeight){
469          	stickyForm.addClass("bg-dark");
470          }
471          if (!header.data("animating")) { // && !header.hasClass("sticky")) {
472            //console.log(!header.hasClass("sticky"));
473            if (!header.hasClass("sticky")){  
474            	header.addClass("sticky sticky-style");
475              	//console.log("header.hasClass sticky: ", header.hasClass("sticky"));
476            }
477            //hero.css("height", heroHeight - headerHeight);
478            //header.css('color');
479            header.removeClass("hide");
480          }
481          lastScrollPosUp = scrollPosCur; //(document.body.getBoundingClientRect()).top;
482        }
483        else {
484          if (scrollTop < heroHeight - 80 - stickyFormHeight){
485            //console.log("umikam ozadje..", scrollTop, heroHeight, stickyFormHeight, heroHeight - 80 - stickyFormHeight);
486          	stickyForm.removeClass("bg-dark");
487          }
488          if (navbar.find(".w--open").length == 0 && !mainMenu.hasClass("w--nav-menu-open") && $(".nav-center-col[data-nav-menu-open]").length == 0) //mainMenu.data("nav-menu-open") == undefined) 
489            header.removeClass("sticky sticky-style");  // hide
490          	//hero.css("height", "auto");
491          else
492            header.removeClass("sticky-style");  // if open just make it sticky not with bg
493        }
494      }
495      else {
496        if (heroHeight)
497          if (scrollTop > heroHeight - 80 - stickyFormHeight){ // -80px zato, ker je seznam rezultatov .move-up -> margin-top: -80px, -103 pa zaradi visine .hero-forma
498            stickyForm.addClass("bg-dark");
499          }
500       	else // ce ni herota, itak se ni stajlov za hero-form, da ni margin-top 
500-500px  !!! dodaj !!!
501          if (scrollTop > heroHeight + headerHeight){
502            stickyForm.addClass("bg-dark");
503          }
504        if (scrollTop <= heroHeight && !header.hasClass("open")) {
505          header.removeClass("sticky");
506        }
507        if (scrollTop > heroHeight && header.hasClass("open")) {
508          header.addClass("sticky-style");
509        }
510        //if (navbar.find(".w--open").length == 0 && mainMenu.find(".w--open").length == 0 ) { //&& !mainMenu.hasClass("w--nav-menu-open") && $(".nav-center-col[data-nav-menu-open]").length == 0) { //mainMenu.data("nav-menu-open") == undefined){
511          //console.log(navbar.find(".w--open").length, mainMenu.find(".w--open").length);
512          //if (!header.data("animating") && header.hasClass("sticky") && navbar.find(".w--open").length == 0) {
513        if (header.hasClass("sticky") && !header.data("animating") && !header.hasClass("open") && scrollTop > heroHeight) { //!navbar.find(".w--open").length){
514          //console.log(navbar.find(".w--open").length, mainMenu.find(".w--open").length);
515          //console.log(header.hasClass("open"));
516          header.data("animating", true);
517          header.addClass("hide");
518          setTimeout(function(){ 
519            header.removeClass("sticky"); //  hide
520            //hero.css("height", "auto");
521            header.data("animating", false);
522          }, 300);
523        }
524          //}
525        //}
526      }
527    scrollPos = scrollPosCur; //(document.body.getBoundingClientRect()).top;
528    //console.log(scrollPos);
529  });  
530  $(window).scroll();
531  ///// SCROLL ANIMATIONS
532  // uporaba:
533  // data-fx="fade" -> ko je element viden doda class .fade
534  // data-fx-repeat -> doda class, ko je element viden in ga umakne, ko ni (drugace se doda samo 1x in se ne umakne)
535  // data-fx-group  -> ko postane viden en notranji element, doda classe vsem notranjim elementom, tudi ce ostali se niso vidni
536  // data-fx-hide-on-load -> skrije element on load (ni treba dodati, ce se class zacne s fadeIn(..) ali zoomIn(..))
537  // ali
538  // data-fx-initially-hidden -> skrije element on load
539  function isScrolledIntoView(elem) { // Scroll function 'isScrolledIntoView' courtesy of Scott Dowding; http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling
540    var docViewTop = $(window).scrollTop();
541    var docViewBottom = docViewTop + $(window).height();
542    var elemTop = $(elem).offset().top;
543    var elemBottom = elemTop + $(elem).height();
544	if (elemBottom <= docViewBottom && elemTop >= docViewTop)
545    	$(elem).data("scrolledIntoView", true); // shrani, da je elem. viden //bil elem enkrat ze pokazan
546    return elemBottom <= docViewBottom && elemTop >= docViewTop;
547    //return (elemTop >= docViewTop && elemTop < docViewBottom) || (elemBottom > docViewTop && elemTop < docViewBottom)  //&& (elemBottom >= docViewBottom && )) || (elemBottom <= docViewBottom && elemTop <= docViewTop); 
548  }
549  function isScrolledOutOfView(elem) {
550    var docViewTop = $(window).scrollTop();
551    var docViewBottom = docViewTop + $(window).height();
552    var elemTop = $(elem).offset().top;
553    var elemBottom = elemTop + $(elem).height();
554	//if ((elemTop < docViewTop && elemBottom < docViewTop) || (elemTop > docViewBottom && elemBottom > docViewBottom))
555    //	$(elem).data("scrolledIntoView", true); // shrani, da je bil elem enkrat ze pokazan
556    if ((elemTop < docViewTop && elemBottom < docViewTop) || (elemTop > docViewBottom && elemBottom > docViewBottom))
557    	$(elem).data("scrolledIntoView", false); // shrani, da elem ni viden 
558    return (elemTop < docViewTop && elemBottom < docViewTop) || (elemTop > docViewBottom && elemBottom > docViewBottom);
559  }
560  $(window).scroll(function() {
561    $("[data-fx], [data-fx-group]").each(function() {
562      let $this = $(this);
563      //console.log($this);
564      //if (this.hasAttribute("data-fx-group")){ // if group
565      	//console.log("data-fx-group: ", $this);
566      //}
567      if (this.hasAttribute("data-fx-group")){ // if group
568      	//console.log("data-fx-group: ", $this, $this.find("[data-fx]").length);
569        let children = $this.find("[data-fx]");
570        let hiddenChildren = 0;  
571        children.each(function(){
572          //console.log($(this));
573          if (isScrolledIntoView(this) === true && !$this.data("scrolledIntoView")) {
574            $this.data("scrolledIntoView", true);
575          	$this.addClass("inView");
576            children.each(function(){
577              	if ($(this).data("fxDelay")) {
578                  setTimeout(function() {
579                    $(this).addClass("inView "+ $(this).data("fx"));
580                  }, $(this).data("fxDelay")*1000);
581                }
582              	else
583                  $(this).addClass("inView "+ $(this).data("fx"));
584            });
585            //return false;
586          }
587          if (isScrolledOutOfView(this) === true){
588            hiddenChildren++;
589            //$(this).data("scrolledIntoView", false);
590          }
591        });
592        //console.log(hiddenChildren, children.length);
593        if ($this.data("fxRepeat") && children.length == hiddenChildren){
594          //if ($this.data("fxRepeat") && isScrolledOutOfView(this) === true) {
595		  $this.data("scrolledIntoView", false);
596          $this.removeClass("inView");
597          children.each(function(){
598            $(this).removeClass("inView "+ $(this).data("fx"));  
599          });
600          //}
601        }
602        //}
603      }
604      else if ($this.parents("[data-fx-group]").length == 0) {
605        if (isScrolledIntoView(this) === true) {
606          //console.log($(this).data("fx"));
607            if ($this.data("fxDelay")) {
608              setTimeout(function() {$this.addClass("inView");$this.addClass($this.data("fx"));}, $this.data("fxDelay")*1000);
609            }
610            else {
611              $this.addClass("inView");
612              $this.addClass($this.data("fx"));
613            }
614        }
615        if ($this.data("fxRepeat") && isScrolledOutOfView(this) === true) {
616          /*
617          if (this.hasAttribute("data-fx-group")){ // if group
618            $this.removeClass("inView");
619            $this.find("[data-fx]").each(function(){
620              $(this).removeClass("inView "+ $(this).data("fx"));  
621            });
622          }
623          else {
624          */
625            $this.removeClass($this.data("fx"));
626            $this.removeClass("inView");
627          //}
628        }
629      }
630    });
631  });
632  $(window).scroll();
633  
634  
635  /// SIDEBARS
636  $('[href^="#"]').click(function(){
637    if ($(this).attr("href").length > 1) {
638      $(".sidebar").hide();
639      $($(this).attr("href")).show();
640    }
641  });
642  
643  $(".sidebar .close").click(function(){
644    $(this).parents(".sidebar").hide();
645  });
646  
647  
648  /* POSTS-FILTER FORM ON CHANGE SUBMIT  */
649  // var t,
650  // change = false;
651  
652  // $('.hero-form .form-field').change(function() {
653  //   change = true;
654  //   // console.log("change");
655  //   clearTimeout(t);
656  //   // console.log("timeout 3s");
657  //   formSub(this);
658  // });
659  
660  // // $( "#department, #location" ).focus(function() {
661  // //   clearTimeout(t);
662    
663    
664  // // });
665  // $( ".hero-form .form-field" ).focusin(function() {
666  //   // console.log("focusin");
667  //     // clearTimeout(t);
668  //     if (change)
669  //       clearTimeout(t);
670  //   });
671  
672  // $( ".hero-form .form-field" ).focusout(function() {
673  //   // console.log("focusout");
674  //     // clearTimeout(t);
675  //     if (change){
676  //       clearTimeout(t);
677  //       formSub(this);
678  //     }
679  //   });
680  
681  // function formSub(ctx){
682  //   t = setTimeout(function(){ctx.form.submit();}, 100);
683  // }
684  
685  /////////
686  
687  
688  /* POSTS-FILTER FORM ON CHANGE AJAX FETCH  */
689  if (stickyForm.length) {
690    
691    console.log(stickyFormTop, stickyFormHeight);
692    var filterForm = stickyForm.find("form");
693    // if (filterForm.length > 0)
694    //   history.pushState({ search: "" }, document.title, "");
695    
696    $('.hero-form .form-field').on("change", onFilterChange);
697    
698    function onFilterChange() {
699      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
700      var form = $(this).parents("form");
701      var formData = form.serialize();
702      form.find(".form-field").attr("disabled", true);
703      //window.location.search = "?" + formData;
704      var dataUrl = currentUrl + "?" + formData;
705      //console.log(dataUrl);
706      //console.log(formData, formData.split("&"));
707      
708      // let formDataArr = formData.split("&");
709      // let formDataArrLen = formDataArr.length;
710      let formDataSanitized = sanitizeFormData(formData);
711      
712      // for (let i=0; i < formDataArrLen; i++) {
713      //   if (formDataArr[i] != "i=" && formDataArr[i] != "s=" && formDataArr[i] != "t=" && formDataArr[i] != "c="){
714      //     if (formDataSanitized != "")
715      //       formDataSanitized += "&"
716      //     formDataSanitized += formDataArr[i];
717      //   }
718      // }
719      
720      let formParams = location.pathname;
721      
722      if (formDataSanitized != "")
723       formParams = "?" + formDataSanitized;
724      
725      //console.log(formDataSanitized, formParams);
726      
727      history.pushState({ search: formDataSanitized }, document.title, formParams);
728      
729      //console.log(dataUrl);
730      loadDoc(dataUrl);
731    }
732    
733    function loadDoc(postURL) {
734      // show loader
735      //$(".w-lightbox-spinner").removeClass("w-lightbox-hide");
736      $.ajax({
737        url: postURL
738        // cache: false
739      })
740      .done(function( html ) {
741        var params;
742        //console.log($(html));
743        //console.log($(html).filter(".locomotive-sections").length, $(html).find(".locomotive-sections").length); //html, 
744        $(".locomotive-section.posts-list-section").first().html( $(html).find(".locomotive-section.posts-list-section").html() );
745        $(".locomotive-section.events-list-section").first().html( $(html).find(".locomotive-section.events-list-section").html() );
746        
747        // if (postURL.split("?").length > 1){
748        //   params = postURL.split("?")[1];
749        //   history.pushState({ search: params }, document.title, "?" + params);
750        // }
751        // else // pomoje ne pride nikoli sem... sprobaj in umakni?..
752        //   history.pushState({ search: "" }, document.title, "");
753          
754        //hero = $(".hero, .article-hero");
755        stickyForm = $(".hero-form-section");
756        //heroHeight = hero.outerHeight() || headerHeight;
757        stickyFormHeight = stickyForm.outerHeight() || 0;
758        stickyForm.find(".form-field").attr("disabled", false).on("change", onFilterChange);
759        //var top = stickyForm.offset().top; //.scrollTop();
760        
761        //console.log(stickyFormTop, scrollTop);
762        
763        //$(window).animate({ scrollTop: top }, 1000);
764        //$(window).scrollTop(top);
765        //window.scrollTo(0, top - stickyFormHeight);
766        window.scrollTo({
767            top: stickyFormTop, // - stickyFormHeight, // ne smem vec odsteti, ker je zdaj po novem fixed, ne pa sticky!!!
768            left: 0,
769            behavior: 'smooth'
770        });
771  
772        //$(window).scroll();
773        // hide loader
774        //$(".w-lightbox-spinner").addClass("w-lightbox-hide");
775      });
776      
777    }
778  
779    window.onpopstate = function(event){
780      console.log(document.location, JSON.stringify(event.state));
781      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
782      // var form = $(this).parents("form");
783      // var formData = form.serialize();
784      // najbrz moram rocno nastavit izbrane opcije v selectih..
785      var paramsArr = event.state.search.split("&");
786      var paramArr;
787      
788      var filterSelects = $(".hero-form").find(".form-field");
789      filterSelects.find(":selected").removeAttr("selected");
790      
791      for (var i = 0; i < paramsArr.length; i++) {
792        paramArr = paramsArr[i].split("=");
793        if (paramArr.length > 1) {
794          // filterSelects.find(":selected").removeAttr("selected");
795          filterSelects.filter("[name="+ paramArr[0] +"]").attr("selected", true);
796        }
797      }
798      filterSelects.attr("disabled", true);
799      //window.location.search = "?" + formData;
800      var dataUrl = currentUrl + "?" + event.state.search;
801      //console.log(dataUrl);
802      loadDoc(dataUrl);
803    };
804    
805  }
806  
807  ////////////////////
808  
809  
810  /* CUSTOMERS (FORM FILTER ON CHANGE AJAX FETCH  */
811  
812  let customersSection = $(".customers-section, .partners-section");
813  let customersForm = customersSection.find(".customer-form");
814  var loadMore = customersSection.find(".loadMore");
815  
816  loadMore.show();
817  
818  if (customersForm.length) {
819    
820    customersSection.find(".pagination").find(".side-pad").first().hide();
821  
822    function onLoadMoreClick(evt){ 
823      evt.preventDefault();
824      let $this = $(this);
825      if (!$this.attr("disabled")){
826        // console.log("loadMore href", loadMore.attr("href"));
827        // console.log("evt target href", $(evt.target).attr("href"));
828        //console.log("$this href", $this.attr("href")); // $(this).attr("href")
829        loadNewCustomers($this.attr("href"), true);  //loadNewCustomers($(evt.target).attr("href"), true); 
830      }
831      $this.find(".loading").show();
832      $this.attr("disabled", true);
833    }
834    
835    loadMore.on("click", onLoadMoreClick);
836    
837    var filterForm = customersForm.find("form");
838    // if (filterForm.length > 0)
839    //   history.pushState({ search: "" }, document.title, "");
840    
841    $('.customer-form .form-field').on("change", onCustomerFilterChange);
842    
843    function onCustomerFilterChange() {
844      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
845      var form = $(this).parents("form");
846      var formData = form.serialize();
847      form.find(".form-field").attr("disabled", true);
848      //window.location.search = "?" + formData;
849      var dataUrl = currentUrl + "?" + formData;
850      //console.log(dataUrl);
851      
852      let formDataSanitized = sanitizeFormData(formData);
853
854      let formParams = location.pathname;
855      
856      if (formDataSanitized != "")
857       formParams = "?" + formDataSanitized;
858      
859      //console.log(formDataSanitized, formParams);
860      
861      history.pushState({ search: formDataSanitized }, document.title, formParams);
862      
863      //history.pushState({ search: formData }, document.title, "?" + formData);
864  
865      loadNewCustomers(dataUrl);
866    }
867    
868    function loadNewCustomers(postURL, appendResults=false) {
869      //console.log(postURL);
870      // show loader
871      //$(".w-lightbox-spinner").removeClass("w-lightbox-hide");
872      $.ajax({
873        url: postURL
874        // cache: false
875      })
876      .done(function( html ) {
877        var params;
878        // console.log($(html));
879        //console.log($(html).filter(".locomotive-sections").length, $(html).find(".locomotive-sections").length); //html, 
880        var loadedSection = $(html).find(".locomotive-section.customers-section, .locomotive-section.partners-section");
881        //console.log(loadedSection);
882        
883        loadMore = customersSection.find(".loadMore");
884        //console.log(loadMore);
885        
886        //loadMore = loadedSection.find(".loadMore"); //customersSection.find(".loadMore");
887        //console.log(loadMore);
888        
889        
890        if (appendResults) { // on load more button
891          
892          loadMore.find(".loading").hide();
893          loadMore.removeAttr("disabled");
894          
895          customersSection.find(".customers").append(loadedSection.find(".customers").html());
896          if (loadedSection.find(".loadMore").length == 0)
897            loadMore.hide();
898          else {
899            let oldHref = loadMore.attr("href");
900            let hrefArr= oldHref.split("?page=");
901            let newHref;
902            if (hrefArr.length > 1 )
903              newHref = hrefArr[0] + "?page=" + (parseInt(hrefArr[1], 10) + 1);
904            else {
905              hrefArr= oldHref.split("&page=");
906              if (hrefArr.length > 1 )
907                newHref = hrefArr[0] + "&page=" + (parseInt(hrefArr[1], 10) + 1);
908            }
909            console.log(oldHref, newHref);
910            loadMore.attr("href", newHref);
911          }
912        }
913        else { // on change filter
914          loadedSection.find(".pagination").find(".side-pad").first().hide();
915          var loadMoreBtn = loadedSection.find(".loadMore").show();
916          
917          //loadedSection.find(".loadMore").show();
918        
919          customersSection.html(loadedSection.html());
920          
921          customersForm = $(".customer-form");
922          customersForm.find(".form-field").attr("disabled", false).on("change", onCustomerFilterChange);
923          //loadMoreBtn ?
924          customersSection.find(".loadMore").on("click", onLoadMoreClick);
925        
926        }
927        
928        //heroHeight = hero.outerHeight() || headerHeight;
929        // stickyFormHeight = stickyForm.outerHeight() || 0;
930        
931        
932        // var top = customersForm.offset().top; //.scrollTop();
933        // //console.log(stickyFormTop, scrollTop);
934        // //$(window).animate({ scrollTop: top }, 1000);
935        // //$(window).scrollTop(top);
936        // //window.scrollTo(0, top - stickyFormHeight);
937        // window.scrollTo({
938        //     top: top, // - stickyFormHeight, // ne smem vec odsteti, ker je zdaj po novem fixed, ne pa sticky!!!
939        //     left: 0,
940        //     behavior: 'smooth'
941        // });
942  
943        //$(window).scroll();
944        // hide loader
945        //$(".w-lightbox-spinner").addClass("w-lightbox-hide");
946      });
947      
948    }
949  
950    window.onpopstate = function(event){
951      console.log(document.location, JSON.stringify(event.state));
952      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
953      // var form = $(this).parents("form");
954      // var formData = form.serialize();
955      // najbrz moram rocno nastavit izbrane opcije v selectih..
956      var paramsArr = event.state.search.split("&");
957      var paramArr;
958      
959      var filterSelects = $(".customer-form").find(".form-field");
960      filterSelects.find(":selected").removeAttr("selected");
961      
962      for (var i = 0; i < paramsArr.length; i++) {
963        paramArr = paramsArr[i].split("=");
964        if (paramArr.length > 1) {
965          // filterSelects.find(":selected").removeAttr("selected");
966          filterSelects.filter("[name="+ paramArr[0] +"]").attr("selected", true);
967        }
968      }
969      filterSelects.attr("disabled", true);
970      //window.location.search = "?" + formData;
971      var dataUrl = currentUrl + "?" + event.state.search;
972      //console.log(dataUrl);
973      loadNewCustomers(dataUrl);
974    };
975    
976  }
977  
978  
979  /* JOBS (FORM FILTER ON CHANGE AJAX FETCH  */
980  
981  let jobsSection = $(".jobs-section");
982  let jobsForm = jobsSection.find(".jobs-form");
983  
984  
985  if (jobsForm.length) {
986    
987    //jobsSection.find(".pagination").find(".side-pad").first().hide();
988
989    var filterForm = jobsForm.find("form");
990    // if (filterForm.length > 0)
991    //   history.pushState({ search: "" }, document.title, "");
992    
993    $('.jobs-form .form-field').on("change", onJobsFilterChange);
994    
995    var country;
996    
997    let squery = getQueryParams(document.location.search);
998    if (squery.c)
999      switchCardsTab(squery.c);
1000    
1001    function onJobsFilterChange() {
1002      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
1003      var form = $(this).parents("form");
1004      var formData = form.serialize();
1005      form.find(".form-field").attr("disabled", true);
1006      //window.location.search = "?" + formData;
1007      var dataUrl = currentUrl + "?" + formData;
1008      //console.log(dataUrl);
1009      
1010      let formDataSanitized = sanitizeFormData(formData);
1011
1012      let formParams = location.pathname;
1013      
1014      if (formDataSanitized != "")
1015       formParams = "?" + formDataSanitized;
1016      
1017      //console.log(formDataSanitized, formParams);
1018      
1019      history.pushState({ search: formDataSanitized }, document.title, formParams);
1020      
1021      //history.pushState({ search: formData }, document.title, "?" + formData);
1022  
1023      loadNewJobs(dataUrl);
1024      
1025      
1026      //console.log(squery.c);
1027      
1028      country = form.find("#Country").find(":selected").val();
1029      //console.log(country);
1030
1031      // var cityTest = country.split('~');
1032      // if (cityTest.length > 1) {
1033      //   country = cityTest[0];
1034      // }
1035      
1036      //console.log(country);
1037      
1038      switchCardsTab(country);
1039      
1040    }
1041    
1042    function switchCardsTab(countryCode){
1043      var country;
1044      var cityTest = countryCode.split('~');
1045      
1046      if (cityTest.length > 1) {
1047        countryCode = cityTest[0];
1048      }
1049      
1050      // if (countryCode == "DEU")
1051      //   country = "Germany";
1052      
1053      // if (countryCode == "AUT")
1054      //   country = "Austria";
1055        
1056      // if (countryCode == "CHE")
1057      //   country = "Switzerland";
1058      
1059      // if (countryCode == "SVN" || countryCode == "HRV" || countryCode == "SRB")
1060      //   country = "Adriatic";
1061      
1062      // if (countryCode == "SWE" || countryCode == "DNK" || countryCode == "NLD")
1063      //   country = "Nordic";
1064      
1065      
1066      if (countryCode) {
1067        $(".cards-section").find(".tab-pill").each(function(){
1068          //console.log($(this).data("cntry"));
1069          let cntry = $(this).data("cntry").split(",");
1070          //console.log(cntry);
1071          if (cntry == countryCode || cntry.includes(countryCode))
1072            $(this).click();
1073          // if ($(this).data("text") == country)
1074          //   $(this).click();
1075        });
1076      }
1077    } 
1078    
1079    function loadNewJobs(postURL, appendResults=false) {
1080      // show loader
1081      //$(".w-lightbox-spinner").removeClass("w-lightbox-hide");
1082      $.ajax({
1083        url: postURL
1084        // cache: false
1085      })
1086      .done(function( html ) {
1087        var params;
1088        // console.log($(html));
1089        //console.log($(html).filter(".locomotive-sections").length, $(html).find(".locomotive-sections").length); //html, 
1090        var loadedSection = $(html).find(".jobs-section");
1091        //console.log(loadedSection);
1092        
1093        // loadMore = jobsSection.find(".loadMore");
1094        //console.log(loadMore);
1095        
1096        //loadMore = loadedSection.find(".loadMore"); //customersSection.find(".loadMore");
1097        //console.log(loadMore);
1098        
1099        
1100        // if (appendResults) { // on load more button
1101          
1102        //   loadMore.find(".loading").hide();
1103        //   loadMore.removeAttr("disabled");
1104          
1105        //   customersSection.find(".customers").append(loadedSection.find(".customers").html());
1106        //   if (loadedSection.find(".loadMore").length == 0)
1107        //     loadMore.hide();
1108        //   else {
1109        //     let oldHref = loadMore.attr("href");
1110        //     let hrefArr= oldHref.split("?page=");
1111        //     let newHref;
1112        //     if (hrefArr.length > 1 )
1113        //       newHref = hrefArr[0] + "?page=" + (parseInt(hrefArr[1], 10) + 1);
1114        //     else {
1115        //       hrefArr= oldHref.split("&page=");
1116        //       if (hrefArr.length > 1 )
1117        //         newHref = hrefArr[0] + "&page=" + (parseInt(hrefArr[1], 10) + 1);
1118        //     }
1119        //     console.log(oldHref, newHref);
1120        //     loadMore.attr("href", newHref);
1121        //   }
1122        // }
1123        // else { // on change filter
1124        
1125        //loadedSection.find(".pagination").find(".side-pad").first().hide();
1126        //var loadMoreBtn = loadedSection.find(".loadMore").show();
1127        
1128        //loadedSection.find(".loadMore").show();
1129        
1130        jobsSection.html(loadedSection.html());
1131        
1132        jobsForm = $(".jobs-form");
1133        jobsForm.find(".form-field").attr("disabled", false).on("change", onJobsFilterChange);
1134        //loadMoreBtn ?
1135        // jobsSection.find(".loadMore").on("click", onLoadMoreClick);
1136        
1137        // }
1138        
1139        
1140      });
1141      
1142    }
1143  
1144    window.onpopstate = function(event){
1145      console.log(document.location, JSON.stringify(event.state));
1146      var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
1147      // var form = $(this).parents("form");
1148      // var formData = form.serialize();
1149      // najbrz moram rocno nastavit izbrane opcije v selectih..
1150      var paramsArr = event.state.search.split("&");
1151      var paramArr;
1152      
1153      var filterSelects = $(".jobs-form").find(".form-field");
1154      filterSelects.find(":selected").removeAttr("selected");
1155      
1156      for (var i = 0; i < paramsArr.length; i++) {
1157        paramArr = paramsArr[i].split("=");
1158        if (paramArr.length > 1) {
1159          // filterSelects.find(":selected").removeAttr("selected");
1160          filterSelects.filter("[name="+ paramArr[0] +"]").attr("selected", true);
1161        }
1162      }
1163      filterSelects.attr("disabled", true);
1164      //window.location.search = "?" + formData;
1165      var dataUrl = currentUrl + "?" + event.state.search;
1166      //console.log(dataUrl);
1167      loadNewJobs(dataUrl);
1168    };
1169    
1170  }
1171  
1172  
1173  ////////////////////
1174  
1175  /// SEARCH AND FACETS ////
1176  
1177  console.log(document.location.search, window.location.pathname);
1178  var hash = document.location.hash;
1179  hash = hash.replace("#", "");
1180  var query = getQueryParams(hash);
1181  //console.log(query);
1182  var squery = getQueryParams(document.location.search);
1183  console.log(squery);
1184  
1185  //console.log(query.stq);
1186  
1187  //console.log(document.location.hash);
1188  
1189
1190  
1191  // if (squery.q) {
1192  //   $("#st-search-input").val(squery.q);
1193  //   //document.location.search = document.location.search.replace('q=[^&]*/i, '');
1194  //   //document.location.search = removeParam(document.location.search, "q1=234");
1195    
1196    
1197  //   document.location.hash = "#stq=" + squery.q;
1198    
1199  //   Swiftype.reloadResults();
1200  // }
1201  
1202  if (squery.q){
1203    $("#st-search-input").val(squery.q);
1204    //$("#st-search-input").trigger("change");
1205  }
1206  
1207  if (query.stq)
1208    $("#st-search-input").val(query.stq);
1209  
1210  //console.log(sanitizeFormData(document.location.hash));
1211  
1212  //var hash = getUrlHash(window.location.hash);
1213  //console.log(hash);
1214  
1215  $("#search-drop-wrap").find(".w-dropdown-toggle").on("click", function(){
1216    console.log("focus");
1217    setTimeout(function() {$("#search-input-head").focus();}, 10);
1218  });
1219  
1220  
1221  // var loc = "en";
1222  // loc = $("html").attr("lang");
1223  
1224  var firstLoad = true;
1225  
1226  var searchConfig = {
1227    sort: {
1228      field: undefined,
1229      direction: undefined
1230    },
1231    facets: {},
1232  };
1233  
1234  var reloadResults = function() {
1235    window.location.hash = window.location.hash.replace(/stp=[^&]*/i, 'stp=1'); // Reset to page 1
1236    //$(window).hashchange();
1237    Swiftype.reloadResults();
1238    
1239    
1240  };
1241  
1242  var readFilters = function() {
1243    return {
1244      page: {
1245        locale: loc,
1246        category: searchConfig.facets['category'],
1247        type: searchConfig.facets['type'],
1248        // tags: searchConfig.facets['tags'],
1249        // price: {
1250        //   type: 'range',
1251        //   from: searchConfig.price.from,
1252        //   to: searchConfig.price.to
1253        // }
1254      }
1255    };
1256  }
1257  
1258  //console.log("search", loc);
1259  
1260  var translateFromKey = function(key) {
1261    key = key.replace("_post",""); // remove _post
1262    key = key.replace("_"," "); // change _ to space
1263    if (key == "post" || key == "Blog")
1264      key = "Blog";
1265    else if (key == "news")
1266      key = "News";
1267    // else if (key == "case_study")
1268    //   key = "Case studies";
1269    else {
1270      key = key.charAt(0).toUpperCase() + key.slice(1); // capitalize
1271      if (key.slice(-1) == "y") {
1272        key = key.slice(0,-1) + "ie" ;
1273      }
1274      if (key.slice(-1) != "s")
1275        key = key + "s";
1276    }
1277    return key;
1278  };
1279  
1280  var customRenderFunction = function(document_type, item) {
1281    
1282    var tip = item['type'];
1283    
1284    // "translate" from keys
1285    tip = translateFromKey(tip);
1286    
1287    // translate from existing sidebar facets
1288    var label = $facetContainer.find("input[value='"+ item['type'] +"']").next("label").find("span").first();
1289    // var justText = label.clone().find("span").remove();
1290    console.log(label.text());
1291    
1292    tip = label.text();
1293    
1294    
1295    if (item['category'])
1296      tip = item['category']; // dont translate category field, only type!
1297    
1298    //console.log(document_type);
1299    //console.log(item);
1300    
1301    
1302    
1303    var out = '<a href="' + item['fullpath'] + '" class="card flex reverse db hover-shadow side-pad pt10 pb10 tdn c-body mb0 bg-trans rounded" data-l="' + item['locale'] + '" data-t="'+ item['type'] +'">';
1304    if (item['type'] == "Blog" || item['type'] == "news_post" || item['type'] == "career_post" || item['type'] == "event" || item['type'] == "Case Study" || item['type'] == "Recorded Webinar")
1305      out = out.concat('<div class="w-col w-col-3 p0"><div class="pr blue-mask h100p1"><img src="' + item['image'] + '" class="bg-image"></div></div>');
1306    if (item['type'] == "Blog" || item['type'] == "news_post" || item['type'] == "career_post" || item['type'] == "event" || item['type'] == "Case Study" || item['type'] == "Recorded Webinar")  
1307      out = out.concat('<div class="w-col w-col-9 pl0">');
1308    else
1309      out = out.concat('<div class="w-col w-col-12 p0">');
1310    out = out.concat('<div class="pre-title c-primary fs12 fw500 mb0" data-c="' + item['category'] + '">' + tip + '</div><h5 class="st-search-result-link mb5">' + item['title'] + '</h5>');
1311    if (item.highlight['body']){
1312      var abstract = item.highlight['body'];
1313      if (abstract.length > 300)
1314        abstract = abstract.substring(0, 300) + '...';
1315      out = out.concat('<p class="fs14 mb5 search-result">' + abstract + '</p>');
1316    }
1317    out = out.concat('<p class="dib c-light fs12 mt0 mb5">' + item['fullpath'] + '</p>');
1318    out = out.concat('<div class="arrow-link dib ml10"><img src="/sites/5ebfc39e232fb906a3dfc34b/theme/images/arrow-right-icon.svg?1609163216" width="22" alt=""></div>');
1319    out = out.concat('</div></a>');
1320    return out; //.concat('<p class="genre">' + item['genre'] + '</p>');
1321  };
1322  
1323  var $facetContainer = $('.st-facets'); //$('.st-dynamic-facets');
1324
1325  var bindControls = function(data) {
1326    var resultInfo = data['info'],
1327    facets = '';
1328    var lastQuery;
1329    
1330    console.log(resultInfo, searchConfig);
1331    
1332    console.log(loc);
1333    
1334    if (loc == "sl"){
1335      var resultsContainer = $("#st-results-container");
1336      resultsContainer.find(".st-prev").html("« nazaj");
1337      resultsContainer.find(".st-next").html("naprej »");
1338    }
1339    
1340    var desetice = 10*(resultInfo.page.current_page-1);
1341    var lowerLimitCurrResults = 1 + desetice;
1342    var upperLimitCurrResults = 10 + desetice;
1343    
1344    if (upperLimitCurrResults > resultInfo.page.total_result_count)
1345      upperLimitCurrResults = resultInfo.page.total_result_count;
1346    
1347    $("#st-status").html("Showing "+ lowerLimitCurrResults + " - " + upperLimitCurrResults + " out of " + resultInfo.page.total_result_count);
1348    
1349    $facetContainer.find("label").hide();
1350  
1351    $.each(resultInfo, function(documentType, typeInfo){
1352      $.each(typeInfo.facets, function(field, facetCounts) {
1353        //facets += ['<div class="facet"><div class="pre-title fs12 fw600">', field, '</div></div>'].join('');
1354        console.log(field, facetCounts);
1355        
1356        //$facetContainer.find("label").hide();
1357        
1358        //$('.st-facets input[type="checkbox"]').prop("checked", false);
1359        
1360        if ((field == "category" && searchConfig.facets["type"] && searchConfig.facets["type"].length > 0 && searchConfig.facets["category"] && searchConfig.facets["category"].length == 0) ||
1361           (field == "type" && searchConfig.facets["category"] && searchConfig.facets["category"].length > 0 && searchConfig.facets["type"] && searchConfig.facets["type"].length == 0))
1362          $facetContainer.find("[data-prop="+ field +"]").find("label").find("span").html(""); //
1363        
1364        $.each(facetCounts, function(label, count) {
1365          //console.log(label, count);
1366          var status = "",
1367          id = label.toLowerCase().replace(" ","_"); //encodeURIComponent(label).toLowerCase();
1368          
1369          //console.log(id);
1370          
1371          //console.log(field, searchConfig.facets["type"]);
1372          
1373          if (firstLoad || resultInfo.page.query != lastQuery || 
1374             (field == "category" && searchConfig.facets["type"] && searchConfig.facets["type"].length > 0) ||
1375             (field == "type" && searchConfig.facets["category"] && searchConfig.facets["category"].length > 0)) {
1376              console.log("first load or diff query or ...");
1377              $('label[for="' + id +'"]').show().find("span").last().html(count);
1378              
1379          }
1380        
1381          
1382          console.log(searchConfig.facets, searchConfig.facets[field], label, id);
1383          
1384          if (searchConfig.facets[field] && searchConfig.facets[field].indexOf(label) > -1) {
1385            $("#" + id).prop("checked", true);
1386            status = ' checked="checked"';
1387          }
1388          
1389          // var lab = label;
1390          // if (field == "type")
1391          //   lab = translateFromKey(label);
1392          // facets += '<input class="ha" type="checkbox"' + status + ' name="' + field + '" value="' + label + '" id="' + id + '"> <label class="dib fw400" for="' + id + '">' + lab + ' (' + count + ')</label><br/>';
1393        });
1394        //facets += '<a href="#" class="clear-selection dib mb20" data-name="' + field + '">Clear all</a>'
1395      });
1396
1397      //$facetContainer.html(facets);
1398    });
1399    
1400    lastQuery = resultInfo.page.query;
1401    console.log(lastQuery);
1402    
1403    if (resultInfo.page.total_result_count > 0 && firstLoad) {
1404      $facetContainer.show();
1405      firstLoad = false;
1406    }
1407    //else
1408    //  $facetContainer.hide();
1409    
1410  };
1411  
1412  $facetContainer.on('click', 'input', function(e) {
1413    //if ($(e.target).find("span").html() != "(0)") {
1414      searchConfig.facets = {}; // Set the hash to empty
1415      //console.log($(e.target));
1416      $(e.target).parents(".st-facets-group").find('input[type="checkbox"]').not(e.target).prop("checked", false);
1417      $('.st-facets input[type="checkbox"]').each(function(idx, obj) {
1418        var $checkbox = $(obj),
1419        facet = $checkbox.attr('name');
1420        if(!searchConfig.facets[facet]) { // if facets are null or undefined, put empty array for the category
1421          searchConfig.facets[facet] = [];
1422        }
1423        if(obj.checked) { // add ids to array for the category
1424          searchConfig.facets[facet].push($checkbox.attr('value'));
1425        }
1426      });
1427    
1428      reloadResults();
1429    //}
1430  });
1431  
1432  $facetContainer.on('click', 'a.clear-selection', function(e) {
1433    e.preventDefault();
1434    var name = $(this).data('name');
1435    $('input[name=' + name + ']').prop('checked', false);
1436    searchConfig.facets[name] = [];
1437  
1438    reloadResults();
1439  });
1440  
1441  // $('#st-search-input').swiftype({
1442  //   fetchFields: {'page': ['title', 'fullpath', 'locale' ]},
1443  //   filters: {'page': {'locale': 'en' }},
1444  //   renderFunction: customRenderFunction,
1445  //   resultContainingElement: '#st-results-container',
1446  //   engineKey: 'J6y2U_5APppW-NKD-hts'
1447  // });
1448  
1449  $('#st-search-input').swiftypeSearch({
1450    fetchFields: {'page': ['title', 'fullpath', 'locale', 'type', 'category', 'abstract', 'image']},
1451    highlightFields: {
1452        'page': {'body': {'size': 300, 'fallback': true}}
1453      },
1454    // filters: {'page': {'locale': 'en' }},
1455    filters: readFilters,
1456    facets: {'page': ['category', 'type']}, //'type',
1457    renderFunction: customRenderFunction,
1458    postRenderFunction: bindControls,
1459    resultContainingElement: '#st-results-container',
1460    engineKey: 'J6y2U_5APppW-NKD-hts'
1461  });
1462  
1463  // $('#st-search-input-head').swiftypeSearch({
1464  //   fetchFields: {'page': ['title', 'fullpath', 'locale', 'type', 'category', 'abstract', 'image']},
1465  //   highlightFields: {
1466  //       'page': {'body': {'size': 300, 'fallback': true}}
1467  //     },
1468  //   // filters: {'page': {'locale': 'en' }},
1469  //   filters: readFilters,
1470  //   facets: {'page': ['category', 'type']}, //'type',
1471  //   renderFunction: customRenderFunction,
1472  //   postRenderFunction: bindControls,
1473  //   resultContainingElement: '#st-results-container-head',
1474  //   engineKey: 'J6y2U_5APppW-NKD-hts'
1475  // });
1476  
1477  $('#search-form-head').submit(function( evt ) {
1478    evt.preventDefault();
1479    //console.log(window.location.protocol + window.location.hostname + "/search#stq=" + $("#search-input-head").val());
1480    
1481    var searchUrl = window.location.protocol + "//" + window.location.hostname;
1482    searchUrl = searchUrl + $(this).data("url");
1483    var searchQuery = $("#search-input-head").val();
1484    
1485    // if (loc == "en")
1486    //   searchUrl = searchUrl + "/search#stq=" + searchQuery;
1487    // else
1488    //   searchUrl = searchUrl + "/" + loc + "/search#stq=" + searchQuery;
1489    
1490    searchUrl = searchUrl + "#stq=" + searchQuery;
1491      
1492    window.location.href = searchUrl;
1493  });
1494
1495  
1496  
1497  //// PUSH FACETS PARAMS TO HISTORY 
1498
1499
1500 /*
1501  $('.facets-form input').on("change", onFacetChange);
1502    
1503    function onFacetChange() {
1504      //var currentUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; //window.location.href; //
1505      var form = $(this).parents("form");
1506      var formData = form.serialize();
1507      // form.find("input").attr("disabled", true);
1508      // //window.location.search = "?" + formData;
1509      // var dataUrl = currentUrl + "?" + formData;
1510      //console.log(dataUrl);
1511      //console.log(formData, formData.split("&"));
1512      
1513      // let formDataArr = formData.split("&");
1514      // let formDataArrLen = formDataArr.length;
1515      let formDataSanitized = sanitizeFormData(formData);
1516      
1517      // for (let i=0; i < formDataArrLen; i++) {
1518      //   if (formDataArr[i] != "i=" && formDataArr[i] != "s=" && formDataArr[i] != "t=" && formDataArr[i] != "c="){
1519      //     if (formDataSanitized != "")
1520      //       formDataSanitized += "&"
1521      //     formDataSanitized += formDataArr[i];
1522      //   }
1523      // }
1524      
1525      let formParams = location.pathname;
1526      
1527      if (formDataSanitized != "")
1528       formParams = "?" + formDataSanitized;
1529      
1530      console.log(formDataSanitized, formParams);
1531      
1532      history.pushState({ search: formDataSanitized }, document.title, formParams);
1533      
1534      //console.log(dataUrl);
1535      //loadDoc(dataUrl);
1536    }
1537  
1538 */ 
1539  
1540  
1541  
1542  ///////////////////
1543  
1544  
1545  
1546  function sanitizeFormData(formData){
1547    let formDataArr = formData.split("&");
1548    let formDataArrLen = formDataArr.length;
1549    let formDataSanitized = "";
1550    
1551    for (let i=0; i < formDataArrLen; i++) {
1552      if (formDataArr[i] != "i=" && formDataArr[i] != "s=" && formDataArr[i] != "t=" && formDataArr[i] != "c=" && formDataArr[i] != "cat=" && formDataArr[i] != "l="){
1553        if (formDataSanitized != "")
1554          formDataSanitized += "&"
1555        formDataSanitized += formDataArr[i];
1556      }
1557    }
1558    
1559    return formDataSanitized;
1560  }
1561  
1562  
1563  
1564  // FAQS
1565
1566  if ($(".faq").length > 0) {
1567    
1568  
1569    $(".faq").each(function(){
1570      let h = $(this).find(".accordion-item").outerHeight();
1571      $(this).animate({
1572        height: h
1573      }, 0, function() { $(this).addClass("collapsed") });
1574    });
1575    
1576    $(".faq").click(function(){
1577      
1578      if ($(this).hasClass("collapsed")){
1579        let h = $(this).outerHeight();
1580        $(this).data("collapsedHeight", h);
1581        let hc = $(this).find(".accordion-item-content").outerHeight();
1582        //console.log(h, hc);
1583        
1584        $(this).animate({
1585          height: h + hc
1586        }, 250, function() { $(this).css('height', 'auto'); $(this).removeClass("collapsed") });
1587      }
1588      else
1589        $(this).animate({
1590          height: $(this).data("collapsedHeight")
1591        }, 250, function() { $(this).addClass("collapsed") });
1592    });
1593    
1594    $(window).resize(function(e) {
1595      $(".faq").each(function(){
1596        let h = $(this).find(".accordion-item").outerHeight();
1597        if ($(this).hasClass("collapsed"))
1598          $(this).height(h);
1599        else
1600          $(this).data("collapsedHeight", h);
1601      });
1602    });
1603  
1604  }
1605  
1606  
1607  
1608  // OTHER FUNCTIONS //
1609    
1610  function getUrlHash(){
1611      if (location.hash != ""){
1612      	var hash = location.hash;
1613      	hash = hash.substring(1, hash.length);
1614      	return hash;
1615      }
1616      else 
1617  	    return false;
1618  }
1619    
1620  
1621  function getQueryParams(qs) {
1622    qs = qs.split('+').join(' ');
1623  
1624    var params = {},
1625        tokens,
1626        re = /[?&]?([^=]+)=([^&]*)/g;
1627  
1628    while (tokens = re.exec(qs)) {
1629        params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
1630    }
1631  
1632    return params;
1633  }
1634  
1635  ////////////////////
1636  
1637  
1638  // FIX ZA SAFARI BROWSERJE - POSKRBI, DA SE PAGE FADER FADEOUTA
1639  
1640  function unloadingWebsite() {
1641    // Do something just before the user leaves:
1642    // Eg: Hide/close your menu/reset settings/clear cookies etc, whatever you need to do.
1643    document.body.classList.add("unloaded");
1644    console.log("fade in");
1645    if (!window.AnimationEvent) { return; }
1646    console.log("add class for fade in...");
1647    var fader = document.getElementById('fader');
1648    //fader.classList.add('fade-out');
1649    fader.setAttribute('class', 'fade-out');
1650  }
1651  
1652  window.addEventListener("pagehide", function() {
1653      unloadingWebsite();
1654  });
1655  
1656  window.addEventListener("pageshow", function() {
1657      // You can use the pageshow function if required to double ensure that everything is reset on the page load.
1658      // Most of the time the "pagehide" event will provide the solution.
1659      unloadingWebsite();
1660  });
1661  
1662  
1663  
1664  /// CUSTOMERS LOGO SLIDER
1665  
1666  $(".customers-slider").carouFredSel({
1667    responsive: true,
1668    width   : 260, //"100%",
1669    height  : 240,
1670    scroll  : 1,
1671    height  : "auto",
1672    items   : {
1673        visible   : { //"variable",
1674          min: 1,
1675          max: 4
1676        }
1677        // height    : "variable"
1678    },
1679    align       : "center",
1680    auto: {
1681      // play: false,
1682      pauseOnHover: true
1683    }
1684    
1685  });
1686  
1687  $(".customers-compact-slider .slides").carouFredSel({
1688    responsive: true,
1689    width   : 100, //"100%",
1690    height  : 100,
1691    scroll  : 1,
1692    height  : "auto",
1693    nav: true,
1694    items   : {
1695        visible   : { //"variable",
1696          min: 1,
1697          max: 7
1698        }
1699        // height    : "variable"
1700    },
1701    align       : "center",
1702    auto: {
1703      // play: false,
1704      pauseOnHover: true
1705    }
1706    
1707  });
1708  
1709  
1710  $('.customers-compact-slider .prevButton').click(function() {
1711        $('.customers-compact-slider .slides').trigger('prev');
1712    });
1713
1714  $('.customers-compact-slider .nextButton').click(function() {
1715      $('.customers-compact-slider .slides').trigger('next');
1716  });
1717  
1718  
1719  // MODALS (OPEN JOB APPLICATION FORM IFRAME)
1720  
1721  $("body").on("click", ".open-modal", function(evt) {
1722    evt.preventDefault();
1723    //var postURL = $(this).data("href");
1724    //console.log(postURL);
1725    
1726    //$(".modal-content div").html("");
1727    $(".modal").show();
1728    //$('body').css('overflow', 'hidden');
1729    
1730    //loadDoc(postURL);
1731    
1732    return false;
1733  });
1734  
1735  $('.w-lightbox-control.w-lightbox-close').click(function() { /* , .modal.w-lightbox-backdrop */
1736      //$('body').css('overflow', 'auto');
1737      if ($(this).hasClass("modal"))
1738        $(this).hide();
1739      else
1740        $(this).parents(".modal").hide();
1741  });
1742  
1743  
1744  //*** WEBFLOW TABS TO MOBILE ACCORDION  ***//
1745
1746  let mobileAccordions = $(".accordion-on-mobile");
1747  
1748  if (mobileAccordions.length > 0) {
1749    
1750    let tabPanes = mobileAccordions.find(".w-tab-pane");
1751  
1752    const mediaQuery = '(max-width: 767px)';
1753    const mediaQueryList = window.matchMedia(mediaQuery);
1754    
1755    mediaQueryList.addEventListener('change', event => {
1756      //console.log(window.innerWidth);
1757      if (event.matches) {
1758        tabPanes.show();
1759        // console.log('The window is now 7670px or under');
1760      } else {
1761        tabPanes.not(".w--tab-active").hide();
1762        // console.log('The window is now over 768px');
1763      }
1764    });
1765    
1766    $(".accordion-on-mobile").on("click", ".w-tab-link", function(evt){
1767      if (window.innerWidth >= 768) {
1768        let $this = $(this); //.w-tab-link
1769        let accordion = $this.parents(".accordion-on-mobile");
1770        let tabPanes = accordion.find(".w-tab-pane");
1771        let activePane = accordion.find(".w-tab-pane[data-w-tab='" + $(this).data("w-tab") + "']"); //accordion.find(".w-tab-pane.w--tab-active");
1772        tabPanes.not(activePane).hide();
1773      }
1774    });
1775    
1776    $(".accordion-on-mobile").on("click", ".tab-link-mobile", function(evt){
1777      if (window.innerWidth < 768) {
1778        //console.log($(evt.currentTarget).parents(".w-tab-pane").data("w-tab"));
1779        //console.log($(this), $(this).find(".w-tab-menu"));
1780        let $this = $(this); //.tab-link-mobile
1781        
1782        let tabPane = $this.parents(".w-tab-pane");
1783        let accordion = $this.parents(".accordion-on-mobile");
1784        
1785        let activePane = accordion.find(".w-tab-pane.w--tab-active");
1786        let activeTabIndex = accordion.find(".w-tab-pane").index(activePane);
1787        let clickedTabIndex = accordion.find(".w-tab-pane").index(tabPane);
1788        
1789        
1790        //
1791        //console.log();
1792        //console.log(accordion.find(".w-tab-menu").find('[data-w-tab="' + $this.parents(".w-tab-pane").data("w-tab") + '"]'));
1793        accordion.find(".w-tab-menu").find('[data-w-tab="' + tabPane.data("w-tab") + '"]').click();
1794        //let prevPane = tabPane.prev();
1795        let nextTop;
1796        
1797        //if (tabPane.length > 0){
1798          //console.log(activeTabIndex, clickedTabIndex, prevPane, prevPane.offset().top);
1799          //console.log(activePane.find(".tab-pane-mobile").outerHeight());
1800          //if (header.hasClass("sticky"))
1801          if (clickedTabIndex > activeTabIndex) {
1802            nextTop = 0; //80; //headerHeight;
1803            let endPos = tabPane.offset().top - activePane.find(".tab-pane-mobile").outerHeight();
1804            let currScroll = $(window).scrollTop();
1805            if (endPos < currScroll)
1806              nextTop = headerHeight * -1;
1807            // console.log(tabPane.offset().top, activePane.find(".tab-pane-mobile").outerHeight());
1808            nextTop +=  endPos; // + prevPane.find(".tab-link-mobile").outerHeight();
1809          }
1810          //else
1811          //  nextTop = 0;
1812          
1813        //}
1814        
1815        if (nextTop) {
1816          // console.log(nextTop);
1817          
1818          window.scrollTo({
1819              top: nextTop, // - stickyFormHeight, // ne smem vec odsteti, ker je zdaj po novem fixed, ne pa sticky!!!
1820              behavior: 'smooth',
1821              left: 0
1822          });
1823        }
1824      }
1825      
1826    });
1827  
1828  }
1829  
1830  ///////// TABS FIX !!! 
1831  
1832  $(".w-tabs:not(.accordion-on-mobile)").on("click", ".w-tab-link", function(evt){ 
1833        let $this = $(this); //.w-tab-link
1834        let tabs = $this.parents(".w-tabs");
1835        let tabPanes = tabs.find(".w-tab-pane");
1836        let activePane = tabs.find(".w-tab-pane[data-w-tab='" + $(this).data("w-tab") + "']"); //tabs.find(".w-tab-pane.w--tab-active");
1837        console.log(activePane);
1838        tabPanes.not(activePane).hide();
1839    });
1840
1841
1842  //// HORIZONTAL VERTICAL SCROLL ////
1843  
1844  const calcDynamicHeight = ref => {
1845    const objectWidth = ref.width();
1846    const vw = window.innerWidth;
1847    const vh = window.innerHeight;
1848    console.log(vw, vh);
1849    
1850    let margin = parseInt(ref.find(".scroller-item").first().css("margin-left"), 10);
1851    console.log(margin);
1852    
1853  //   if (vw > 767)
1854    return objectWidth - vw + vh + (margin - 20);
1855  //   else 
1856  //    return "auto";
1857  };
1858  
1859  const handleDynamicHeight = (ref, target) => { //, setDynamicHeight
1860    //ref.trigger("resize");
1861    //const objectWidth = ref.width(); //ref.current.scrollWidth;
1862    //console.log(objectWidth);
1863    const dynamicHeight = calcDynamicHeight(ref);
1864    //setDynamicHeight(dynamicHeight);
1865    console.log(dynamicHeight);
1866    target.height(dynamicHeight);
1867    return dynamicHeight;
1868  };
1869  
1870  function initHorizScrollers(){
1871    $("[data-horizontal-vertical-scroll]").each(function() { //$("[data-fx], [data-fx-group]")
1872      
1873      let $this = $(this);
1874
1875      let $section = $this;
1876
1877      
1878
1879      let $outer = $section.find(".tall-outer-container");
1880      $section.data("outerDiv", $outer);
1881      let $inner = $section.find(".sticky-inner-container");
1882      $section.data("innerDiv", $inner);
1883      let $translate = $section.find(".horizontal-translate-container");
1884      $section.data("translateDiv", $translate);
1885
1886      let minWH = parseInt($inner.css('padding-top'), 10) + parseInt($inner.css('padding-bottom'), 10);
1887
1888      console.log(minWH);
1889
1890      $inner.find("> *").each(function(){
1891          minWH += $(this).outerHeight();
1892      });
1893
1894      console.log(minWH);
1895
1896      if (window.innerHeight >= minWH) //window.innerWidth > 767 && 
1897          $section.addClass("scroll-active");
1898
1899      let dynamicHeight = handleDynamicHeight($translate, $outer);
1900      $section.data("dynamicHeight", dynamicHeight);
1901      let objectWidth = $translate.width();
1902      //console.log(calcDynamicHeight(objectWidth));
1903
1904
1905      //console.log($inner.offset().top);
1906
1907      
1908
1909    });
1910        
1911  }
1912    
1913  initHorizScrollers();
1914  
1915
1916  window.addEventListener("scroll", () => {
1917    $("[data-horizontal-vertical-scroll]").each(function() {
1918      let $section = $(this);
1919      let $outer = $section.data("outerDiv");   //$section.find(".tall-outer-container");
1920      let $inner = $section.data("innerDiv"); //$section.find(".sticky-inner-container");
1921      
1922      let startOffsetTop = $outer.offset().top; //$section.offset().top;
1923      let offsetTop = $inner.offset().top - startOffsetTop;
1924      let dynamicHeight = $section.data("dynamicHeight");
1925      //console.log(offsetTop);
1926      if (offsetTop >= 0 && offsetTop <= dynamicHeight){
1927          let $translate = $section.data("translateDiv");
1928          $translate.css("transform", "translateX(-"+ offsetTop +"px)"); //`translateX(${translateX}px)`
1929      }
1930      //else 
1931    });
1932  });
1933
1934  $(window).resize(function(e) {
1935    $("[data-horizontal-vertical-scroll]").each(function() {
1936      let $section = $(this);
1937      let $outer = $section.data("outerDiv");
1938      let $translate = $section.data("translateDiv");
1939      let dynamicHeight = handleDynamicHeight($translate, $outer);
1940      $section.data("dynamicHeight", dynamicHeight);
1941
1942      let $inner = $section.data("innerDiv");
1943      let minWH = parseInt($inner.css('padding-top'), 10) + parseInt($inner.css('padding-bottom'), 10);
1944
1945      console.log(minWH);
1946
1947      $inner.find("> *").each(function(){
1948          minWH += $(this).outerHeight();
1949      });
1950      
1951      console.log(minWH);
1952
1953      if (window.innerHeight >= minWH ) //window.innerWidth > 767 && 
1954          $section.addClass("scroll-active");
1955      else
1956          $section.removeClass("scroll-active");
1957    });
1958  });
1959
1960
1961
1962
1963  //// IMAGE MAP PRO
1964  
1965  let imageMap = $("#image-map-pro-container");
1966  
1967  if (imageMap.length > 0) {
1968    let parentTab = imageMap.parents(".w-tab-pane");
1969    // console.log(parentTab);
1970    if (parentTab.length > 0 && !parentTab.hasClass("w--tab-active")){
1971      parentTab.parent(".w-tab-content").find(".w-tab-pane.w--tab-active").removeClass("w--tab-active");
1972      parentTab.addClass("w--tab-active");
1973    }
1974    imageMap.imageMapPro(imageMapConfig);
1975    
1976    $.imageMapProInitialized = function(imageMapName) {
1977      if (parentTab.length > 0 && parentTab.hasClass("w--tab-active")){
1978        parentTab.removeClass("w--tab-active");
1979        parentTab.siblings(".w-tab-pane").first().addClass("w--tab-active");
1980      }
1981    }
1982    
1983  }
1984  
1985  
1986  /// ADD POPUP FUNCTIONALITY // PRICING TABLE SECTION
1987  
1988  $('.open-modal').click(function() {
1989    //console.log($(this));
1990    
1991    var $this = $(this);
1992    var modal = $("#modal");
1993    
1994    //modal.css({"display": "block", "transition": "opacity 300ms ease", "opacity": "1"});
1995    
1996    modal.css({"opacity": "1"}).fadeIn();
1997    
1998    console.log($this.data("cta-link"));
1999    
2000    if ($this.data("cta-link")) {
2001      var btn = '<a class="button primary" href="'+ $this.data("cta-link") +'" '+$this.data("cta-nwa")+'>'+ $this.data("cta") +'</a>';
2002      
2003      modal.find(".modal-content").html($this.find(".popup-content").html() + btn);
2004    }
2005    else {
2006      modal.find(".modal-content").html($this.find(".popup-content").html());
2007    }
2008    
2009    modal.find(".w-lightbox-spinner").addClass("w-lightbox-hide");
2010    
2011  });
2012  
2013  $('.close-modal').click(function() {
2014    
2015    $("#modal").fadeOut(250);
2016    //$('#modal').css({"opacity": "0", "display": "none"});
2017    
2018  });
2019  
2020  
2021  //// ADD GENERAL POPUP FUNCTIONALITY
2022  
2023  // $('.pop-up-master').click(function() {
2024  //   $(this).addClass("pop-up");
2025  // });
2026  
2027  $('.page').on("click", ".pop-up-master", function(evt) {
2028    
2029    evt.preventDefault();
2030    let $this = $(this);
2031    //console.log("on screenshot", $(this));
2032    if (!$this.hasClass("pop-up")){
2033      //if ($(".screenshot.pop-up").length > 0)
2034      $(".pop-up-master.pop-up").removeClass("pop-up");
2035      $(this).addClass("pop-up"); //.toggleClass("pop-up");
2036    }
2037    else {
2038      $(this).removeClass("pop-up"); //$(this).toggleClass("pop-up");
2039    }
2040  });
2041  
2042  $('.page').on("click", ".pop-up-master a", function(evt) {
2043    
2044    evt.stopPropagation();
2045  
2046  });
2047
2048  
2049  // ARTICLE (BLOG POST)
2050  // REMOVE SHADOW FROM IMAGES WITHOUT CAPTION (h6) // NE RABIM VEC, SEM NAREDIL Z LIQUIDOM IN PREMAKNIL V ARTCILE_BODY SNIPPET
2051  // $(".article-content-col").find(".rich-text").find("p>img").each(function(){
2052  //   console.log("each", $(this));
2053  //   if ($(this).parent().next("h6").length == 0) //.find(">h6:first-child")
2054  //     $(this).addClass("bsn");
2055  // });
2056  
2057  
2058  //// SECTION_TABS ()
2059  
2060  var pageHasSectionTabs = false;
2061  
2062  $(".section-tabs").each(function(obj){
2063    var $this = $(this);
2064    
2065    pageHasSectionTabs = true;
2066    
2067    //console.log($(obj), $this);
2068    
2069    var sectionTabLinks = $this.find(".section-tab-link");
2070    
2071    sectionTabLinks.each(function(){
2072    
2073      var hrefSplit = $(this).attr("href").split("#");
2074      //console.log(hrefSplit);
2075      if (hrefSplit.length == 2) {
2076        //console.log(hrefSplit[1]);
2077        var section = $("#"+ hrefSplit[1]).next(".section");
2078        section.parent().addClass("tab-section");
2079        if (!$(this).hasClass("w--current")){
2080          section.hide();
2081        }
2082      }
2083    });
2084    
2085    $this.on("click", ".section-tab-link", function(evt) {
2086      evt.preventDefault();
2087      
2088      // $('html, body').stop();
2089      
2090      // console.log($(this));
2091      if ($(this).hasClass("w--current"))
2092        return;
2093        
2094      // hide prev selected section
2095      var currTab = $this.find(".w--current");
2096      var hrefSplit = currTab.attr("href").split("#");
2097      //console.log(hrefSplit);
2098      if (hrefSplit.length == 2) {
2099        //console.log(hrefSplit[1]);
2100        $("#"+ hrefSplit[1]).next(".section").hide();
2101      }
2102      // remove prev selected class
2103      currTab.removeClass("w--current");
2104      
2105      // show current selected section
2106      var hrefSplit = $(this).attr("href").split("#");
2107      //console.log(hrefSplit);
2108      if (hrefSplit.length == 2) {
2109        //console.log(hrefSplit[1]);
2110        // $("#"+ hrefSplit[1]).next(".section").show();
2111        
2112        var $target =  $("#"+ hrefSplit[1]).next(".section");
2113        $target.show();
2114        $(window).scroll();
2115        //$target.addClass("inView");
2116  
2117      }
2118      // add current selected class
2119      $(this).addClass("w--current");
2120    });
2121  
2122  });
2123  
2124  if (pageHasSectionTabs){
2125    $('a[href*="#"]:not(.section-tab-link)').click(function(e) { // trigger correct section tab with an outside (from other section) link to section in section tabs
2126      
2127      let hash = $(this).attr("href");
2128      let tablink = $(".section-tabs").find(".section-tab-link[href$='"+hash+"']:not(.w--current)");
2129      
2130      if (tablink.length > 0) {
2131        e.preventDefault();
2132        console.log("found tablink");
2133        console.log(tablink);
2134        tablink.click();
2135      }
2136    });
2137  }
2138  
2139  
2140  
2141  ///////////////  COLLAPSIBLE LIST OPTION IN PRICING TABLE
2142  
2143  $(".collapsible").hide();
2144  
2145  $(".collapse-ul").click(function(){
2146    $(this).next(".collapsible").toggle();
2147  });
2148  
2149  /////// or ///// NEW DESIGN
2150  
2151  $(".collapse-next-features").click(function(){
2152    let order = $(this).css("order");
2153    console.log(order);
2154    $(this).parent().find(".collapse-next-features[style*='order: "+ order +"']").find(".collapsible").toggle();
2155  });
2156  
2157  //////// TOGGLE TEXT CONTENT WITH BUTTON IN CTA SECTION
2158  
2159  $(".toggleContentBtn").click(function(){
2160    $(this).removeClass("blinking").toggleClass("on");
2161    $(this).parent().prev(".content2").toggle().prev(".content").toggle();
2162    $(this).parents(".w-col").prev(".w-col").find("img").toggle();
2163    $(window).scroll();
2164    
2165  });
2166  
2167  
2168  //////
2169  
2170  //FORM TABS SECTION - MULTI FORM SELECT
2171  
2172  $('#formPicker').on('change', function (e) {
2173    var optionSelected = $("option:selected", this);
2174    var valueSelected = this.value;
2175    //console.log(valueSelected, formsArr[valueSelected].replaceAll("<scri","<script").replaceAll("</scri>","</script>"));
2176    //$("#formWidget").html(formsArr[valueSelected].replaceAll("<scri","<script").replaceAll("</scri>","</script>")).change();
2177    $("#formWidget").show();
2178    $("#formWidget > div").hide();
2179    $("#formWidget > div").eq(valueSelected).show();
2180  });
2181  
2182  /////////
2183  
2184  
2185  
2186  ///// CAROUSEL - GALLERY SECTION - SLICK CAROUSEL
2187  
2188  $(".carousel-main-thumbnails").each(function () { 
2189    var main = $(this).find(".carousel-images"), 
2190    pager = $(this).find(".pager-slider");
2191    
2192    console.log(pager.data("slidestoshow"));
2193    
2194    main.slick({
2195      slidesToShow: 1,
2196      slidesToScroll: 1,
2197      arrows: false,
2198      fade: true,
2199      asNavFor: pager
2200    });
2201    pager.slick({
2202      slidesToShow: pager.data("slidestoshow") || 5,
2203      slidesToScroll: 1,
2204      asNavFor: main,
2205      //variableWidth: true,
2206      //dots: true,
2207      //centerMode: true,
2208      prevArrow: pager.prev(".slick-prev"), 
2209      nextArrow: pager.next(".slick-next"),
2210      focusOnSelect: true
2211    });
2212    
2213    //main.slick({ slidesToShow: 1, slidesToScroll: 1, prevArrow: main.prev(".slick-prev"), nextArrow: main.next(".slick-next"), fade: !0, asNavFor: pager, centerMode: !0 }), 
2214    //pager.slick({ slidesToShow: 3, slidesToScroll: 1, asNavFor: main, dots: !1, centerMode: !1, focusOnSelect: !0, vertical: 0, prevArrow: pager.prev(".prev"), nextArrow: pager.next(".next") }) 
2215  });
2216  
2217  $(".carousel-thumbnails").each(function () { 
2218    var pager = $(this).find(".pager-slider");
2219
2220    pager.slick({
2221      slidesToShow: pager.data("slidestoshow") || 5,
2222      slidesToScroll: 1,
2223      infinite: false,
2224      //dots: true,
2225      //centerMode: true,
2226      prevArrow: pager.prev(".slick-prev"), 
2227      nextArrow: pager.next(".slick-next"),
2228      focusOnSelect: true
2229    });
2230    
2231  });
2232  
2233  $(".carousel-main").each(function () { 
2234    var main = $(this).find(".carousel-images");
2235    
2236    main.slick({
2237      slidesToShow: 1,
2238      slidesToScroll: 1,
2239      //arrows: true,
2240      prevArrow: main.prev(".slick-prev"), 
2241      nextArrow: main.next(".slick-next"),
2242      fade: true
2243    });
2244    
2245  });
2246  
2247  
2248  // /**** CAROUSEL GALLERY LIGHTBOX ****/
2249  
2250  var lightboximages = $('.chocolat-parent .chocolat-image');
2251  
2252  Chocolat(document.querySelectorAll('.chocolat-parent .chocolat-image'), {
2253    description: function () { 
2254        const currentImage = this.images[this.settings.currentImageIndex];
2255        console.log(lightboximages.eq(this.settings.currentImageIndex).parent());
2256        return currentImage.title
2257    }
2258  });
2259  
2260  
2261});

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.