PageSourceSearch

https://viatran.com/static/js/050-viatran/000-viatran.js

js viatran.com collected 2026-10-08 07:14:14 UTC 12,004 bytes, 390 lines download raw bytes

1//Viatran "main" file is here.
2
3//Function to toggle visibilty of objects on click
4function toggle_visibility(id) {
5    var e = document.getElementById(id);
6    e.style.display = ((e.style.display!='none') ? 'none' : 'block');
7}
8
9// Function that controls the slide up animation on homepage Matrix squares
10function slideInHome() {
11    $('.category').each(function() {
12        $overlayWrapper = $(this).find('.overlay-wrapper');
13        $overlay = $(this).find('.overlay');
14        $categoryTitle = $(this).find('.category-title');
15        $category = $(this).find('.category-thumbnail');
16        $overlayContain = $(this).find('.overlay-contain');
17        $height = $category.height();
18
19        $overlay.css({
20            height: $height
21        });
22        var t1 = new TimelineLite();
23        t1.stop();
24        t1.to($overlayWrapper, 0.3, {top: -($height), ease: Power2.easeOut}, 0);
25        t1.from($overlayContain, 0.3, {scale: 0.1}, 0);
26
27        var t2 = new TimelineLite();
28        t2.stop();
29        t2.to($overlayWrapper, 0.4, {top: "0", ease: Power2.easeOut}, 0);
30        t2.to($overlayContain, 0.3, {scale: 0.1}, 0.1);
31
32        $($overlayWrapper).hover(function() {
33            /*Play timline of events on hover*/
34            t1.stop();
35            t2.stop();
36            t1.restart();
37            $(this).addClass("active");
38        }, function() {
39            /* Reverse Timeline on exit */
40            t1.stop();
41            t2.stop();
42            t2.restart();
43            $(this).removeClass("active");
44        });
45    });
46    $('.industry-grid').addClass('hide');
47}
48
49function homeTabs() {
50
51    $('.matrix-tab').on("click", function(){
52        var matrix = $(this).data('matrix');
53        if(!(matrix)) {
54            return true;
55        }
56        $('.matrix-tab').removeClass('active').addClass('not-active');
57        $(this).removeClass('not-active').addClass('active');
58
59        $('.matrix-grid').hide();
60        $('.'+matrix+'-grid').show();
61    });
62
63    if(window.location.toString().match(/industries/)){
64        $('#tab-industries').trigger('click');
65    }
66    else if(window.location.toString().match(/services/)){
67        $('#tab-services').trigger('click');
68    }
69    else {
70        $('#tab-products').trigger('click');
71    }
72
73}
74
75
76$(function() {
77    //We activate our theme.
78    $('li.toplevel.menu-item-'+section_theme).addClass('activated-section');
79
80    $('.viatran-slider').slick({
81        'slickFilter': '.slide',
82        autoplay: true,
83        autoplaySpeed: 10000,
84        fade: true,
85        pauseOnHover: true,
86        dots: true,
87        arrows:false,
88        adaptiveHeight: true,
89        responsive: [{
90          breakpoint: 640,
91          settings: {
92              adaptiveHeight: true
93          }
94        }]
95    });
96
97    slideInHome();
98    homeTabs();
99
100    $('li.nav-icon a').on('mouseenter', function(){
101        $(this).parent().find('.hoverbox').addClass('hovered');
102        $(this).addClass('active');
103        $('.top-bar .is-active').removeClass('is-active');
104        $('.top-bar .js-dropdown-active').removeClass('js-dropdown-active');
105    });
106
107    $('li.nav-icon').on('mouseleave', function(){
108        //console.log('unhovered');
109        var that = this;
110        /*setTimeout(function(){
111            $(that).find('.hoverbox').removeClass('hovered');
112            $(that).find('.active').removeClass('active');
113        }, 300);*/
114        $(that).find('.hoverbox').removeClass('hovered');
115        $(that).find('.active').removeClass('active');
116    });
117
118    $('.logout-link').click(function(){
119
120        $.get('/logout/', function(){
121            if(window.location.toString().match(/view_cart|order_history|parts_entry/)){
122                location = '/';
123            }
124            else {
125                location.reload();
126            }
127        });
128
129        return false;
130    });
131
132    $('.resources-tabs a, .resources-container a').each(function(){
133
134        var $elem = $(this);
135
136        if($elem.data('rewritten') || $elem.hasClass('no-rewrite')){
137            return false;
138        }
139
140        if($elem.attr('href') && !($elem.attr('href') == '#')) {
141            var href = $elem.attr('href');
142            href = '/get_file_form/?file_to_download='+ encodeURIComponent(href);
143            $elem.attr('href', href);
144            $elem.data('rewritten', '1');
145        }
146
147    });
148
149    $('.mobile-nav-link').click(function(){
150        var $elem = $(this);
151        var $box = $('#dropdown-'+$elem.data('box'));
152        
153        if($(".mobile-nav-dropdowns").is(':visible')){
154            $(".mobile-nav-dropdowns").removeClass("isactive");
155            $("#dropdown-bar").hide();
156        }
157
158        if($box.is(':visible')){
159            closeMobileNavs();
160        }
161        else {
162            $('.mobile-dropdown-box').hide();
163            $box.show();
164            $(".mobile-nav-contain").addClass("navopen");
165        }
166    });
167
168    $('.mobile-drop-bar a').click(function(){
169        var $elem = $(this);
170
171        if($("#dropdown-bar").is(':visible')){
172            closeMobileNavs();
173        } else if ($("#dropdown-bar").not(':visible')){
174            if($(".mobile-dropdown-box").is(':visible')){
175                closeMobileNavs();
176            }
177            openMobileNavs();
178            $("#dropdown-bar").show();
179        }
180        
181    });
182
183    $('.mobile-dropdown-box a.closebtn').click(function(){
184        closeMobileNavs();
185    });
186
187    function openMobileNavs() {
188        $(".mobile-nav-dropdowns").addClass("isactive");
189        $(".mobile-nav-contain").addClass("navopen");
190    }
191    
192    function closeMobileNavs() {
193        $(".mobile-dropdown-box").hide();
194        $("#dropdown-bar").hide();
195        $(".mobile-nav-dropdowns").removeClass("isactive");
196        $(".mobile-nav-contain").removeClass("navopen");
197    }
198    
199    //Activate Sticky Nav
200    $(window).scroll(function() {
201        if ($(this).scrollTop() >= 5) {
202            $(".top-header").addClass('sticky-nav');
203            $("#page-contents").addClass('sticky-nav');
204        } 
205
206        else if ($(this).scrollTop() <= 4) {
207            $(".top-header").removeClass('sticky-nav');
208            $("#page-contents").removeClass('sticky-nav');
209        }
210    });
211
212
213    $('iframe').on('load', function(){
214        setInterval(function(){
215
216            //To resize the iframes, couldn't find a way to make them go full height with just CSS.
217            if($('iframe').length) {
218                try {
219                    var newHeight = 0;
220
221                    $(frames[0].document).find('table, tr').each(function(){
222                        $(this).css('height', 'auto');
223                    });
224                    $(frames[0].document).find('body').css('height', '98%');
225
226                    if($(frames[0].document).find('body > form').length && $(frames[0].document).find('body > form').height() > 0) {
227                        newHeight = $(frames[0].document).find('body > form').height();
228                    }
229                    else {
230                        newHeight = $(frames[0].document).find('body').height();
231                    }
232
233                    //Adding on some padding as per Advanceware.
234                    if(newHeight > 0 && $('iframe').data('height') != newHeight){
235                        $('iframe').data('height', newHeight);
236                        newHeight += 40;
237                        //console.log('Resizing iframe: '+newHeight);
238                        $('iframe').css('height', newHeight);
239                    }
240
241                }
242                catch(e) {
243
244                }
245            }
246
247        }, 1000);
248    });
249
250
251    $('[data-scrollfrom]').on('click', function(){
252        var $this = $(this),
253            scrollfrom = $this.data('scrollfrom');
254
255        $('[data-scrollto').each(function(){
256            var $that = $(this);
257                scrollto = $that.data('scrollto');
258                scrollDistance = $that.offset().top - 120
259            if (scrollto === scrollfrom) {
260                $('html, body').animate({
261                    scrollTop: scrollDistance
262                }, 500);
263                return false; //break out of each
264            }
265        });
266    });
267
268    // Breaks rep titles after a hyphen (if there is one)
269    $('.rep-title').each(function() {
270        var $this = $(this),
271            $text = $this.html(),
272            $dash = $text.indexOf('-');
273        if ($dash !== -1) {
274            var newText = $text.slice(0, ($dash + 1)) + '<br>' + $text.slice($dash + 1);
275            $this.html(newText);
276        }
277    });
278   
279});
280
281$(window).load(function(){
282    var hash = window.location.hash;
283    hash = hash.replace("#", "");
284    $('[data-scrollto').each(function () {
285        var $this = $(this);
286        scrollto = $this.data('scrollto');
287        console.log(hash, scrollto);
288        scrollDistance = $this.offset().top - 120
289        if (scrollto === hash) {
290            $('html, body').animate({
291                scrollTop: scrollDistance
292            }, 500);
293            return false; //break out of each
294        }
295    });
296});
297
298$(document).ready(function() {
299
300    var $regionBox = $('.download-form-fields select'),
301        $regionCheckboxes = $('.gdpr-confirm input'),
302        $submitBtn = $('.tr-download-form-submit input');
303
304    // Hoister no hoisting
305    var disableSubmit = function() {
306        $submitBtn.attr('disabled', 'true');
307        $submitBtn.attr('title', 'Please select a checkbox above to continue');
308    }
309
310    var enableSubmit = function() {
311        $submitBtn.removeAttr('disabled');
312        $submitBtn.attr('title', 'Download now!');
313    }
314
315    // Download Registration form --
316    // Show GDPR checkboxes if 'Europe' is selected as region
317    $regionBox.change(function() {
318
319        if ($(this).val() === 'EU') {
320
321            $('.gdpr-confirm').removeClass('tr-hidden');
322
323            disableSubmit();
324            
325
326        } else {
327
328            $('.gdpr-confirm').addClass('tr-hidden');
329            
330            enableSubmit();
331        }
332
333    });
334
335    // User can't submit unless they check a GDPR box (Europe only)
336    $regionCheckboxes.click(function() {
337
338        if ($('.gdpr-confirm input:checked').length > 0) {
339
340            enableSubmit();
341
342        } else {
343
344            disableSubmit();
345
346        }
347
348    });
349
350    // Show privacy banner, set cookie on accept
351    // (set the 'devMode' flag to show banner for dev)
352    var devMode = false,
353        cookieDuration = 14,
354        cookieName = 'complianceCookie',
355        cookieValue = 'on',
356        $privacyBanner = $('.tr-privacy-banner'),
357        $acceptButton = $('.tr-privacy-button button');
358
359    var setCookie = function(cName, value, exdays) {
360        var exdate = new Date();
361        exdate.setDate(exdate.getDate() + exdays);
362        var cValue = escape(value) + ((exdays === null) ? '' : '; expires=' + exdate.toUTCString());
363        document.cookie = cName + '=' + cValue;
364    }
365    
366    var getCookie = function(cName) {
367        var i, x, y, ARRcookies = document.cookie.split(';');
368        for (i = 0; i < ARRcookies.length; i++) {
369            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf('='));
370            y = ARRcookies[i].substr(ARRcookies[i].indexOf('=') + 1);
371            x = x.replace(/^\s+|\s+$/g, '');
372            if (x === cName) {
373                return unescape(y);
374            }
375        }
376    };
377
378    $acceptButton.click(function() {
379        setCookie(cookieName, cookieValue, cookieDuration);
380        $privacyBanner.remove();
381    });
382   
383    if (getCookie(cookieName) === cookieValue && !devMode) {
384        $privacyBanner.remove();
385    } else {
386        // Removes cookie for banner dev
387        setCookie(cookieName, cookieValue, 0);
388    }
389});
390

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.