PageSourceSearch

https://www.cg-marine.dk/template/js/main.js

js cg-marine.dk collected 2026-09-27 08:45:30 UTC 45,287 bytes, 1,382 lines download raw bytes

1"use strict";
2/* document.addEventListener('DOMContentLoaded', function () {
3    ToxProgress.create();
4    ToxProgress.animate();
5});
6$(window).load(function () {
7     $('.uni-popular-cars-item').isotope({
8        itemSelector: '.item',
9        layoutMode: 'fitRows'
10    });
11});
12$(window).resize(function () {
13     $('.uni-popular-cars-item').isotope({
14        itemSelector: '.item',
15        layoutMode: 'fitRows'
16    });
17});*/
18(function ($) {
19    $.fn.menumaker = function (options) {
20        var cssmenu = $(this), settings = $.extend({
21            title: "Menu",
22            format: "dropdown",
23            sticky: false
24        }, options);
25        return this.each(function () {
26            cssmenu.find('li ul').parent().addClass('has-sub');
27            var multiTg = function () {
28                cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
29                cssmenu.find('.submenu-button').on('click', function () {
30                    $(this).toggleClass('submenu-opened');
31                    $(this).toggleClass('active');
32                    if ($(this).siblings('ul').hasClass('open')) {
33                        $(this).siblings('ul').removeClass('open').slideToggle();
34                    } else {
35                        $(this).siblings('ul').addClass('open').slideToggle();
36                    }
37                });
38            };
39
40            if (settings.format === 'multitoggle') multiTg();
41            else cssmenu.addClass('dropdown');
42
43            if (settings.sticky === true) cssmenu.css('position', 'fixed');
44
45            var resizeFix = function () {
46                if ($(window).width() > 768) {
47                    cssmenu.find('ul').show();
48                }
49
50                if ($(window).width() <= 768) {
51                    cssmenu.find('ul').hide().removeClass('open');
52                }
53            };
54            resizeFix();
55            return $(window).on('resize', resizeFix);
56
57        });
58    };
59})(jQuery);
60
61$(document).ready(function () {
62    "use strict";
63
64    $("#cssmenu").menumaker({
65        title: "",
66        format: "multitoggle"
67    });
68    $("#cssmenu").prepend("<div id='menu-line'></div>");
69
70    var foundActive = false, activeElement, linePosition = 0, menuLine = $("#cssmenu #menu-line"), lineWidth,
71        defaultPosition, defaultWidth;
72
73    $("#cssmenu > ul > li").each(function () {
74        if ($(this).hasClass('active')) {
75            activeElement = $(this);
76            foundActive = true;
77        }
78    });
79
80    if (foundActive === false) {
81        activeElement = $("#cssmenu > ul > li").first();
82    }
83
84    defaultWidth = lineWidth = activeElement.width();
85    menuLine.css("width", lineWidth);
86    menuLine.css("left", linePosition);
87    $("#cssmenu > ul > li").on('mouseenter', function () {
88            activeElement = $(this);
89            lineWidth = activeElement.width();
90            linePosition = activeElement.position().left;
91            menuLine.css("width", lineWidth);
92            menuLine.css("left", linePosition);
93        },
94        function () {
95            menuLine.css("left", defaultPosition);
96            menuLine.css("width", defaultWidth);
97        });
98    //==================load page===============
99    setTimeout(function () {
100        jQuery('.load-page').hide();
101    }, 500);
102
103    //-----------------Sticky memu-----------------
104    $(".sticky-menu").sticky({topSpacing: 0});
105    $('.ui.selection.dropdown').dropdown();
106    $('.ui.menu .ui.dropdown').dropdown({
107        on: 'hover'
108    });
109
110    $('#search-click').on('click', function (e) {
111        if ($(e.target).is('#search-click, i')) {
112            $('.close-search').fadeIn();
113            $('.search').css('visibility', 'visible');
114            $('.search-field').removeClass('none-search');
115            $('.search-field').addClass('block-search');
116            return false;f
117        }
118    });
119    $('.search-frm').on('click', function (e) {
120        if ($(e.target).is('.close-search, .close-search i')) {
121            $('.close-search').hide();
122            $('.search').css('visibility', 'hidden');
123            $('.search-field').removeClass('block-search');
124            $('.search-field').addClass('none-search');
125            return false;
126        }
127    });
128
129    $('.uni-processbar-thick .progress .progress-bar').css("width",
130        function () {
131            return $(this).attr("aria-valuenow") + "%";
132        }
133    );
134
135    $('[data-toggle="tooltip"]').tooltip({trigger: 'manual'}).tooltip('show');
136
137    //-----------------------------ACORDION---------------------------
138    $('.accordion-default .accordion .accordion-toggle').on('click', function (e) {
139        if ($(e.target).is('h4.accordion-toggle')) {
140            $(this).next().slideToggle('600');
141            $(".accordion-content").not($(this).next()).slideUp('600');
142            $(this).toggleClass('active').siblings().removeClass('active');
143        }
144    });
145
146    //-------------------------COUNT ABOUT----------------------------
147    jQuery('.counter').each(function(){
148        statsCounterAnimation(this);
149    });
150
151    function statsCounterAnimation(element) {
152        var inView = false;
153
154        if (isScrolledIntoView(element)) {
155            if (inView) {
156                return;
157            }
158            inView = true;
159            jQuery(element).each(function() {
160                jQuery(this).animateNumber({ number: jQuery(this).data('value'), easing: 'easeOutExpo'}, 1500);
161            });
162        }
163
164        jQuery(window).scroll(function() {
165            if (isScrolledIntoView(element)) {
166                if (inView) {
167                    return;
168                }
169                inView = true;
170                jQuery(element).each(function() {
171                    jQuery(this).animateNumber({ number: jQuery(this).data('value'), easing: 'easeOutExpo'}, 1500);
172                });
173            }
174        });
175    }
176    function isScrolledIntoView(elem) {
177        var docViewTop = jQuery(window).scrollTop();
178        var docViewBottom = docViewTop + jQuery(window).height();
179
180        var elemTop = jQuery(elem).offset().top;
181        var elemBottom = elemTop + jQuery(elem).height();
182
183        return ((elemTop <= docViewBottom) && (elemBottom >= docViewTop));
184    }
185
186
187    //------------------------checkout-----------------------------
188    $('.woocommerce-info').on('click', function (e) {
189        if ($(e.target).is('.click-here-to-login')) {
190            $('.vk-form-woo-login').slideToggle();
191            return false;
192        }
193        if ($(e.target).is('.click-here-entry-code')) {
194            $('.vk-check-coupon').slideToggle();
195            return false;
196        }
197    });
198    $('.vk-checkout-billing-left').on('click', function (e) {
199        if ($(e.target).is('.checkbox-create-account')) {
200            $('.checkbox-create-account-form').slideToggle();
201        }
202    });
203
204    //----------------------FILTER PRICE-----------------------
205    $("#slider-range").each(function () {
206        $(this).slider({
207            range: true,
208            min: 139000,
209            max: 958000,
210            values: [0, 958000],
211            slide: function (event, ui) {
212                $("#amount").val("kr. " + formatNumber(ui.values[0]) + " - kr. " + formatNumber(ui.values[1]));
213            }
214        });
215        $("#amount").val("kr. " + $("#slider-range").slider("values", 0) +
216            " - kr. " + $("#slider-range").slider("values", 1));
217
218    });
219
220    $("#slider-range").on("slidestop", function() {
221        updateParams();
222    });
223
224
225    //---------------------SLIDE GALLERY IMAGE--------------------
226    $('.slider-for').slick({
227        slidesToShow: 1,
228        slidesToScroll: 1,
229        speed: 500,
230        arrows: true,
231        fade: true,
232        asNavFor: '.slider-nav'
233    });
234    $('.slider-nav').slick({
235        slidesToShow: 5,
236        slidesToScroll: 1,
237        speed: 500,
238        asNavFor: '.slider-for',
239        dots: true,
240        focusOnSelect: true,
241        slide: 'div'
242    });
243
244    //------------------------------OWL CAROUSE----------------------
245    /*
246    if (!$.isFunction('owlCarousel')) {
247
248        $('.owl-four-item-dotted').owlCarousel({
249            loop: true,
250            margin: 30,
251            responsiveClass: true,
252            nav: true,
253            navText: [],
254            dots: true,
255            responsive: {
256                0: {
257                    items: 1
258                },
259                600: {
260                    items: 3
261                },
262                1000: {
263                    items: 4
264                }
265            }
266        });
267        $('.owl-one-nav-dotted').owlCarousel({
268            loop: true,
269            responsiveClass: true,
270            nav: true,
271            navText: [],
272            margin: 30,
273            responsive: {
274                0: {
275                    items: 1
276                }
277            }
278        });
279        $('.owl-two-nav').owlCarousel({
280            loop: true,
281            responsiveClass: true,
282            nav: true,
283            navText: [],
284            margin: 30,
285            dots: true,
286            responsive: {
287                0: {
288                    items: 1
289                },
290                992: {
291                    items: 2
292                }
293            }
294        });
295        $('.uni-feature-cars-slide').owlCarousel({
296            center: true,
297            loop: true,
298            margin: 90,
299            nav: true,
300            navText: [],
301            dotted: true,
302            responsive: {
303                0: {
304                    items: 1,
305                    margin: 30
306                },
307                991: {
308                    items: 2
309                },
310                1920: {
311                    items: 3,
312                },
313                2800: {
314                    items: 4,
315                    margin: 10
316                }
317            }
318        });
319        $('.owl-three-item-dotted').owlCarousel({
320            items: 3,
321            loop: true,
322            margin: 30,
323            nav: false,
324            dots: true
325        });
326        $('.owl-partner').owlCarousel({
327            items: 6,
328            loop: true,
329            margin: 30,
330            nav: false,
331            dots: false,
332            autoplay: true
333        });
334        $('.owl-partner-nav').owlCarousel({
335            loop: true,
336            margin: 30,
337            nav: true,
338            navText: [],
339            dots: false,
340            autoplay: true,
341            responsive: {
342                0: {
343                    items: 2
344                },
345                768: {
346                    items: 4
347                },
348                992: {
349                    items: 5
350                },
351                1200: {
352                    items: 6
353                }
354            }
355        });
356    }
357
358    */
359
360    //---------------Show Notification----------------------------
361    $('.uni-sell-a-car-1-right').on('click', function (e) {
362        if ($(e.target).is('.uni-shortcode-tab-2 .nav-tabs li:nth-child(2) a')) {
363            $('.uni-show-notification').show();
364        }
365        if ($(e.target).is('.uni-shortcode-tab-2 .nav-tabs li:nth-child(1) a')) {
366            $('.uni-show-notification').hide();
367        }
368    });
369
370    //--------------------------SLIDER HOME PAGE------------------------------
371    var Slider = function () {
372        var singleProjectSlider = function () {
373            $('.vk-slider-project .slider-for').slick({
374                slidesToShow: 1,
375                slidesToScroll: 1,
376                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
377                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
378                fade: true,
379                asNavFor: '.slider-nav',
380                focusOnSelect: true
381            });
382            $('.vk-slider-project .slider-nav').slick({
383                slidesToShow: 6,
384                slidesToScroll: 1,
385                asNavFor: '.slider-for',
386                focusOnSelect: true,
387                arrows: false,
388                responsive: [{
389
390                    breakpoint: 992,
391                    settings: {
392                        slidesToShow: 3
393                    }
394
395                }]
396            });
397        };
398
399        var singleProductSlider = function () {
400            $('.vk-slider-shop .slider-for').slick({
401                slidesToShow: 1,
402                slidesToScroll: 1,
403                fade: true,
404                arrows: false,
405                asNavFor: '.slider-nav',
406                adaptiveHeight: true
407            });
408            $('.vk-slider-shop .slider-nav').slick({
409                slidesToShow: 5,
410                slidesToScroll: 1,
411                asNavFor: '.slider-for',
412                focusOnSelect: true,
413                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
414                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
415            });
416        };
417
418        var imageSlider = function () {
419            $('.vk-slick-slider').slick({
420                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
421                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
422                centerPadding: 0,
423                responsive: [
424                    {
425                        breakpoint: 992,
426                        settings: {
427                            arrows: true,
428                        }
429
430                    }, {
431                        breakpoint: 768,
432                        settings: {
433                            slidesToShow: 1,
434                            arrows: false,
435                            centerMode: true,
436                            centerPadding: '50px'
437                        }
438
439                    }]
440            });
441        };
442
443        var homepageSlider = function () {
444            $('.recent-blog-slider').slick({
445                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
446                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
447                slidesToShow: 2,
448                dots: true,
449                dotsClass: 'vk-arrow-dots',
450                responsive: [{
451
452                    breakpoint: 992,
453                    settings: {
454                        slidesToShow: 1,
455                        arrows: false
456                    }
457
458                }]
459            })
460                .on('setPosition', function (event, slick) {
461                    arrowDotNav();
462                });
463
464        };
465
466        var aboutPageSlider = function () {
467            $('.customer-slider').slick({
468                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
469                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
470                adaptiveHeight: true,
471                responsive: [{
472                    breakpoint: 992,
473                    settings: {
474                        arrows: false
475                    }
476                }]
477            });
478        };
479
480        var homeShopSlider = function () {
481            $('.vk-list-client-shop > .vk-list').slick({
482                slidesToShow: 6,
483                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-angle-right"></i></button>',
484                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-angle-left"></i></button>',
485                responsive: [{
486                    breakpoint: 992,
487                    settings: {
488                        slidesToShow: 3,
489                    }
490                },
491                    {
492                        breakpoint: 768,
493                        settings: {
494                            slidesToShow: 1
495                        }
496                    }]
497            });
498        };
499
500        var arrowDotNav = function () {
501            var arrowDots = $('.vk-arrow-dots');
502            if (arrowDots.length > 0) {
503                var dots = arrowDots.find('>li');
504                var numDots = dots.length;
505                dots.css('width', 'calc(100% / ' + numDots + ')')
506            }
507        };
508
509        var homeOnePage = function () {
510            var currentWidth = $(window).outerWidth();
511            if (currentWidth >= 768) {
512                $('.slick-slider-one-page').addClass('_pc');
513                if ($('.slick-slider-one-page.slick-slider').length == 1 && $('.slick-slider-one-page._mobile').length == 1) {
514                    $('.slick-slider-one-page').slick('destroy');
515                    $('.slick-slider-one-page').removeClass('_mobile');
516                }
517                if ($('.slick-slider-one-page._pc').length == 1 && $('.slick-slider-one-page.slick-slider').length == 0) {
518
519                    $('.slick-slider-one-page').slick({
520                        nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
521                        prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
522                        slidesToShow: 3,
523                        rows: 2,
524                        responsive: [
525                            {
526                                breakpoint: 991,
527                                settings: {
528                                    slidesToShow: 2
529                                }
530                            }]
531                    });
532                }
533            }
534
535            if (currentWidth < 768) {
536
537                $('.slick-slider-one-page').addClass('_mobile');
538
539                if ($('.slick-slider-one-page.slick-slider').length == 1 && $('.slick-slider-one-page._pc').length == 1) {
540                    $('.slick-slider-one-page').slick('destroy');
541                    $('.slick-slider-one-page').removeClass('_pc');
542                }
543                if ($('.slick-slider-one-page._mobile').length == 1 && $('.slick-slider-one-page.slick-slider').length == 0) {
544
545                    $('.slick-slider-one-page').slick({
546                        nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
547                        prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
548                        slidesToShow: 1,
549                        rows: 1
550                    });
551                }
552            }
553
554            if (currentWidth >= 1068) {
555                $('.slick-slider-left-menu').addClass('_pc');
556                if ($('.slick-slider-left-menu.slick-slider').length == 1 && $('.slick-slider-left-menu._mobile').length == 1) {
557                    $('.slick-slider-left-menu').slick('destroy');
558                    $('.slick-slider-left-menu').removeClass('_mobile');
559                }
560                if ($('.slick-slider-left-menu._pc').length == 1 && $('.slick-slider-left-menu.slick-slider').length == 0) {
561
562                    $('.slick-slider-left-menu').slick({
563                        nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
564                        prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
565                        slidesToShow: 3,
566                        rows: 2,
567                        responsive: [
568                            {
569                                breakpoint: 1291,
570                                settings: {
571                                    slidesToShow: 2
572                                }
573                            }]
574                    });
575                }
576            }
577        };
578
579        var homeOnePageExtra = function () {
580            $('.vk-slider-testimonial').slick({
581                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="ti-angle-right"></i></button>',
582                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="ti-angle-left"></i></button>',
583                adaptiveHeight: true
584            });
585
586            $('.vk-pricing-table-slider').slick({
587                arrows: false,
588                adaptiveHeight: true,
589                slidesToShow: 4,
590                responsive: [
591                    {
592                        breakpoint: 991,
593                        settings: {
594                            slidesToShow: 2
595                        }
596                    },
597                    {
598                        breakpoint: 768,
599                        settings: {
600                            slidesToShow: 1
601                        }
602                    }
603                ]
604            });
605        };
606
607        var homeSlider = function () {
608            var slider = $('.vk-baner-slider');
609
610            // slick initial
611            slider.on('init', function (event, slick) {
612
613                var imageNext = $('.slick-slide.slick-current').next().css('background-image');
614                var imagePrev = $('.slick-slide.slick-current').prev().css('background-image');
615
616                $(this).find('.vk-arrow.next .image-preview-thumbnail').css('background-image', imageNext);
617                $(this).find('.vk-arrow.prev .image-preview-thumbnail').css('background-image', imagePrev);
618
619                var $firstAnimatingElements = $('.slick-slide').find('[data-animation]');
620                doAnimations($firstAnimatingElements);
621            });
622
623            slider.on('beforeChange', function (e, slick, currentSlide, nextSlide) {
624                var $animatingElements = $('.slick-slide[data-slick-index="' + nextSlide + '"]').find('[data-animation]');
625                doAnimations($animatingElements);
626
627            });
628            slider.slick({
629                nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-angle-right" aria-hidden="true"></i><span class="image-preview-thumbnail"></span></button>',
630                prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-angle-left" aria-hidden="true"></i><span class="image-preview-thumbnail"></span></button>',
631                dotsClass: 'vk-list vk-dots-nav',
632                dots: true,
633                fade: false,
634                responsive: [
635                    {
636                        breakpoint: 992,
637                        settings: {
638                            slidesToShow: 1,
639                            arrows: false
640                        }
641                    }
642                ]
643            });
644
645            slider.on('afterChange', function (event, slick, currentSlide) {
646                var imageNext = $('.slick-slide.slick-current').next().css('background-image');
647                var imagePrev = $('.slick-slide.slick-current').prev().css('background-image');
648                $(this).find('.vk-arrow.next .image-preview-thumbnail').css('background-image', imageNext);
649                $(this).find('.vk-arrow.prev .image-preview-thumbnail').css('background-image', imagePrev);
650            });
651
652            function doAnimations(elements) {
653                var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
654                elements.each(function () {
655                    var $this = $(this);
656                    var $animationDelay = $this.data('delay');
657                    var $animationType = 'animated ' + $this.data('animation');
658                    $this.css({
659                        'animation-delay': $animationDelay,
660                        '-webkit-animation-delay': $animationDelay,
661                        'display': 'inline-block',
662                    });
663                    $this.addClass($animationType).one(animationEndEvents, function () {
664                        $this.removeClass($animationType);
665                    });
666                });
667            }
668        };
669
670        var _initInstances = function () {
671            imageSlider();
672            homepageSlider();
673            singleProjectSlider();
674            aboutPageSlider();
675            homeShopSlider();
676            singleProductSlider();
677            homeOnePage();
678            homeOnePageExtra();
679            homeSlider();
680        };
681
682        return {
683            init: function () {
684                _initInstances();
685            },
686            responsive: function () {
687                homeOnePage();
688            }
689        };
690    }();
691
692    Slider.init();
693
694    //======================short code hover==================
695    $('.hover-element').on({
696        mouseenter: function () {
697            $('.show-hover-shortcodes').fadeIn();
698        },
699        mouseleave: function () {
700            $('.show-hover-shortcodes').hide();
701        }
702    });
703    $('.show-hover-shortcodes').on({
704        mouseenter: function () {
705            $(this).show();
706        },
707        mouseleave: function () {
708            $(this).fadeOut();
709        }
710    });
711    //-------------------mega menu----------
712    $('.home-mega-hover').on({
713        mouseenter: function () {
714            $('.uni-mega-menu').clearQueue();
715            $('.uni-mega-menu').fadeIn();
716
717            $('.uni-mega-menu .uni-mega-menu-left a').each( function (i) {
718                let title = $(this).data('title').replace(',', '\\,').replace('.', '\\.');
719                if ($('#uni-mega-menu-tab-' + title + ' .item').size() == 0) {
720                    let uri = $(this).data('uri').replace(',', '-').replace('.', '-');
721                    jQuery.get(uri + '?limit=3&view=menu3', function (response) {
722                        console.log('#uni-mega-menu-tab-' + title);
723                        $('#uni-mega-menu-tab-' + title).html(response);
724                    })
725                }
726            });
727        },
728        mouseleave: function () {
729            $('.uni-mega-menu').delay(300).fadeOut();
730        }
731    });
732    $('.uni-mega-menu').on({
733        mouseenter: function () {
734            $(this).clearQueue();
735            $(this).show();
736        },
737        mouseleave: function () {
738            $(this).delay(300).fadeOut();
739        }
740    });
741/*
742    if (!$.isFunction('owlCarousel')) {
743        $('.uni-mega-menu-1-default').owlCarousel({
744            loop: true,
745            margin: 20,
746            nav: true,
747            dots: false,
748            autoplay: true,
749            navText: [],
750            items: 3
751        });
752    }
753
754 */
755    //-----------------menu mobile---------------------
756    $('.mobile-menu-container .menu-mobile-nav').on('click', function (e) {
757        $('body').css('overflow', 'hidden');
758        $('#cssmenu').slideToggle();
759        $('#cssmenu ul ul').hide();
760    });
761    $('.uni-icons-close').on('click', function (e) {
762        $('#cssmenu .submenu-opened').removeClass('submenu-opened');
763        $('#cssmenu .active').removeClass('active');
764        $('body').css('overflow', 'auto');
765        $('#cssmenu').hide();
766    });
767
768    $('.uni-popular-cars-menu ul li').on('click', function () {
769        $('.uni-popular-cars-menu ul li').removeClass('active');
770        $(this).addClass('active');
771
772        var selector = $(this).attr('data-filter');
773        $('.uni-popular-cars-item').isotope({
774            filter: selector
775        });
776        return false;
777    });
778
779    //-----------------replace image single product----------------
780    jQuery('.flexslider .product-slide .img-small img').on('click', function (e) {
781        if ($(e.target).is('img')) {
782            var value2 = jQuery(this).attr("data-filter2");
783            jQuery('.flexslider .product-slide .img-small img').addClass('none');
784            jQuery('.filter2').not("." + value2).removeClass('active');
785            jQuery('.filter2').filter("." + value2).addClass('active');
786        }
787    });
788
789    $('.flexslider .product-slide .img-small').on('click', function (e) {
790        if ($(e.target).is('img')) {
791            $('.img-small').removeClass('active');
792            $(this).addClass('active');
793        }
794    });
795
796    //----------------BACK TOP TOP-----------------------------
797    $('footer .copyright-area').append('<div id="toTop"><div class="btn btn-totop"><i class="fa fa-angle-double-up" aria-hidden="true"></i></div></div>');
798    $(window).on('scroll', function () {
799        if ($(this).scrollTop() != 0) {
800            $('#toTop').fadeIn();
801        } else {
802            $('#toTop').fadeOut();
803        }
804
805        $(".progress-bar").each(function () {
806            var each_bar_width = $(this).attr('aria-valuenow');
807            $(this).width(each_bar_width + '%');
808        });
809    });
810
811    $('#toTop').on('click', function (e) {
812        if ($(e.target).is('.btn-totop')) {
813            $("html, body").animate({scrollTop: 0}, 600);
814            return false;
815        }
816        if ($(e.target).is('.btn-totop i')) {
817            $("html, body").animate({scrollTop: 0}, 600);
818            return false;
819        }
820    });
821});
822
823
824//--- PRODUCT PAGE ---//
825function updatePage(pageNo) {
826    setPage(pageNo);
827
828    updateParams();
829    productSearch();
830
831    $([document.documentElement, document.body]).animate({
832        scrollTop: $(".uni-iventory-grid-right").offset().top - 60
833    }, 200);
834}
835
836function updateOrderBy(select) {
837    var asc = $('a.order-direction-asc i');
838    var desc = $('a.order-direction-desc i');
839    switch($(select).val()) {
840        case 'alpha':
841            asc.attr('class', 'fa fa-sort-alpha-asc');
842            desc.attr('class', 'fa fa-sort-alpha-desc');
843            break;
844        case 'date':
845            asc.attr('class', 'fa fa-sort-numeric-asc');
846            desc.attr('class', 'fa fa-sort-numeric-desc');
847            break;
848        case 'price':
849            asc.attr('class', 'fa fa-sort-amount-asc');
850            desc.attr('class', 'fa fa-sort-amount-desc');
851            break;
852    };
853
854    setDirection('asc');
855    updatePage(1);
856
857    updateParams();
858    productSearch();
859}
860
861function updateOrderDirection(direction) {
862    if (direction == 'desc') {
863        setDirection('desc');
864    } else {
865        setDirection('asc');
866    }
867
868    updateParams();
869    productSearch();
870}
871
872function updateView(view) {
873    if (view == 'list') {
874        setView('list');
875    } else {
876        setView('grid');
877    }
878
879    updateParams();
880    productSearch();
881}
882
883function updateFilter(filter, value) {
884    var regExp = /\[(.*?)\]/;
885
886    var filterString = decodeURI(filter.slice(6));
887
888    var matches = regExp.exec(filterString);
889    var filterAttribute = matches[1];
890
891    filterString = filterString.slice(matches[0].length);
892
893    matches = regExp.exec(filterString);
894    var filterVar = matches[1];
895
896    $('#search-form li').each(function (a) {
897        var input = $(this).find('input');
898        
899	    if ($(input).data('productattribute') == filterAttribute && $(input).data('var') == filterVar) {
900
901		if ($(input).attr('type') == 'radio') {
902
903			$(this).find('input[type="radio"]').each(function (a) {
904		        	if ($(this).attr('value').toLowerCase() == decodeURI(value).toLowerCase()) {
905					$(this).prop('checked', true);
906				}
907			});
908
909			//if ($(input).attr('value') == decodeURI(value)) {
910			//	$(input).prop('checked', true);
911			//}
912		} else {
913			$(input).attr('value', decodeURI(value));
914		}
915
916		
917
918            console.log($(this).find('div.text').html(decodeURI(value)));
919        }
920
921        /*
922        if ($(this).attr('value') != undefined && $(this).attr('value') != '-' && $(this).attr('value') != 'ingen min.' && $(this).attr('value') != 'ingen maks.') {
923            params['filter[' + $(this).data('productattribute') + '][' + $(this).data('var') + ']'] = $(this).attr('value');
924            params['filter[' + $(this).data('productattribute') + '][type]'] = $(this).data('type');
925        }*/
926    });
927
928    updateParams();
929}
930
931function initParams() {
932    var url = window.location.search.substring(1);
933    var queryString = url.split('&');
934
935    $.each(queryString, function(key, param) {
936        var paramSet = param.split('=');
937
938        switch (paramSet[0]) {
939            case 'direction' :
940                setDirection(paramSet[1])
941                break;
942            case 'order' :
943                setOrderBy(paramSet[1]);
944                break;
945            case 'view' :
946                setView(paramSet[1]);
947                break;
948            case 'min_price' :
949                setSelectedMinPrice(paramSet[1]);
950                break;
951            case 'max_price' :
952                setSelectedMaxPrice(paramSet[1]);
953                break;
954            case 'campaign':
955		setCampaign(paramSet[1]);
956		console.log("camp");
957		break;
958            default :
959                if (paramSet[0].startsWith("filter")) {
960                    updateFilter(paramSet[0], paramSet[1]);
961                }
962                break;
963        }
964    });
965}
966
967function updateParams() {
968    var params = {};
969    $('#search-form li input').each(function (a) {
970        //params['filter[' + $(this).data('productattribute') + '][value]'] = $(this).attr('value');
971
972        if ($(this).attr('value') != undefined && $(this).attr('value') != '-' && $(this).attr('value') != 'ingen min.' && $(this).attr('value') != 'ingen maks.') {
973	if ($(this).attr('type') === 'radio' && !$(this).is(':checked')) {
974    		return true; 
975	} 
976
977		params['filter[' + $(this).data('productattribute') + '][' + $(this).data('var') + ']'] = encodeURI($(this).attr('value').replace(/\s+/g, ''));
978            params['filter[' + $(this).data('productattribute') + '][type]'] = $(this).data('type');
979        }
980    });
981
982    $('#search-form li select').each(function (a) {
983        //params['filter[' + $(this).data('productattribute') + '][value]'] = $(this).attr('value');
984
985        if ($(this).val() != undefined && $(this).val() != '-' && $(this).val() != 'Ingen min.' && $(this).val() != 'Ingen maks.') {
986            params['filter[' + $(this).data('productattribute') + '][' + $(this).data('var') + ']'] = encodeURI($(this).val().replace(/\s+/g, ''));
987            params['filter[' + $(this).data('productattribute') + '][type]'] = $(this).data('type');
988
989        }
990    });
991
992    params['direction'] = getDirection();
993    params['order'] = getOrderBy();
994    params['page'] = getPage();
995    params['view'] = getView();
996    params['campaign'] = getCampaign();
997
998    var category = getCategory();
999    if (category !== undefined) {
1000        params['category'] = category;
1001    }
1002    var text = getText();
1003    if (text !== undefined) {
1004        params['text'] = text;
1005    }
1006
1007
1008    params['min_price'] = getSelectedMinPrice();
1009    params['max_price'] = getSelectedMaxPrice();
1010
1011    window.history.replaceState(null, null, "?" + $.param(params));
1012}
1013
1014function getCategory() {
1015    var category = $("#list-categories li a.selected").data('category')
1016    if (category == undefined) {
1017        return null;
1018    } else {
1019        return category;
1020    }
1021}
1022
1023function getText() {
1024    var text = $("#text-search").val();
1025    if (text == undefined) {
1026        return null;
1027    } else {
1028        return text;
1029    }
1030}
1031
1032function setMinPrice(price) {
1033    if (getSelectedMinPrice() == getMinPrice() && getSelectedMinPrice() >= price) {
1034        setSelectedMinPrice(price);
1035    }
1036
1037    $('#slider-range').slider("option", 'min', price);
1038
1039    refreshSlider();
1040    updateParams();
1041}
1042
1043function getMinPrice() {
1044    return $('#slider-range').slider("option", 'min');
1045}
1046
1047function setMaxPrice(price) {
1048    if (getSelectedMaxPrice() == getMaxPrice() && getSelectedMaxPrice() <= price) {
1049        setSelectedMaxPrice(price);
1050    }
1051
1052    $('#slider-range').slider("option", 'max', price);
1053
1054    refreshSlider();
1055    updateParams();
1056}
1057
1058function getMaxPrice() {
1059    return $('#slider-range').slider("option", 'max');
1060}
1061
1062function setSelectedMinPrice(price) {
1063    $('#slider-range').slider("option", 'values', [price, $("#slider-range").slider("values", 1)]);
1064    refreshSlider();
1065}
1066
1067function getSelectedMinPrice() {
1068    return $("#slider-range").slider("values", 0);
1069}
1070
1071function setSelectedMaxPrice(price) {
1072    $('#slider-range').slider("option", 'values', [$("#slider-range").slider("values", 0), price]);
1073    refreshSlider();
1074}
1075
1076function getSelectedMaxPrice() {
1077    return $("#slider-range").slider("values", 1);
1078}
1079
1080function refreshSlider() {
1081    $("#slider-range").slider("value", $("#slider-range").slider("value"));
1082
1083    $("#amount").val("kr. " + formatNumber($("#slider-range").slider("values", 0)) +
1084        " - kr. " + formatNumber($("#slider-range").slider("values", 1)));
1085}
1086
1087function formatNumber(num) {
1088    num = num.toFixed(2).replace('.', ',');
1089    return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
1090}
1091
1092
1093function getCampaign() {
1094    return $('#campaign-toggle').prop('checked');
1095}
1096
1097function setCampaign(campaign) {
1098    if (campaign == "true" || campaign === true) {
1099        $('#campaign-toggle').prop('checked', true);
1100    } else {
1101        $('#campaign-toggle').prop('checked', false);
1102    }
1103}
1104
1105function getDirection() {
1106    return $('.order-direction-desc.active')[0] !== undefined ? 'desc' : 'asc';
1107}
1108
1109function setDirection(direction) {
1110    $('.order-direction-asc').removeClass('active');
1111    $('.order-direction-desc').removeClass('active');
1112
1113    $('.order-direction-' + direction).addClass('active');
1114}
1115
1116function getOrderBy() {
1117    return $('#orderby').val();
1118}
1119
1120function setOrderBy(orderBy) {
1121    console.log($('#orderby').val(orderBy));
1122    $('#orderby').val(orderBy);
1123}
1124
1125function getView() {
1126    return $('.filter-view-list.active')[0] !== undefined ? 'list' : 'grid';
1127}
1128
1129function setView(view) {
1130    $('.filter-view-list').removeClass('active');
1131    $('.filter-view-grid').removeClass('active');
1132
1133    $('.filter-view-' + view).addClass('active');
1134}
1135
1136function getPage() {
1137    return $('a.page-numbers.current').html();
1138}
1139
1140function setPage(pageNo) {
1141    $('a.page-numbers.current').removeClass('current');
1142    $('a.page-numbers.page' + pageNo).addClass('current');
1143}
1144
1145function setFilter(filter) {
1146    console.log(filter);
1147}
1148
1149function productSearch() {
1150    var url = window.location.search.substring(1);
1151    var queryString = url.split('&');
1152
1153    var params = {};
1154
1155    $.each(queryString, function(key, param) {
1156        var paramSet = param.split('=');
1157        params[paramSet[0]] = paramSet[1];
1158    })
1159
1160    params['search'] = true;
1161
1162    $.ajax({
1163        url: location.protocol + '//' + location.host + location.pathname + '?' + $.param(params),
1164        type: 'get',
1165        data: '', // <-- Add this!
1166        cache: false,
1167        success: function(response){
1168            $('#search-results').fadeTo(50, 0.3).html(response).fadeTo(50, 1);
1169            setMinPrice(0);
1170            $('#search-count-display').html($('#search-count').html());
1171        },
1172        error: function(response){
1173        }
1174    });
1175
1176    /*jQuery.get(location.protocol + '//' + location.host + location.pathname + '?' + $.param(params), function (response) {
1177        $('#search-results').fadeTo(100, 0.3).html(response).fadeTo(100, 1);
1178    });
1179    */
1180
1181    // Reupdate for slower connections
1182    setTimeout( function () {
1183        $('#search-count-display').html($('#search-count').html());
1184    }, 2000);
1185
1186    return false;
1187}
1188
1189function scrollToDescription() {
1190    $('#description_tab_button').tab('show');
1191
1192    $([document.documentElement, document.body]).animate({
1193        scrollTop: $("#description_tab_button").offset().top - 100
1194    }, 200);
1195}
1196
1197function scrollToSpecifications() {
1198    $('#specifications_tab_button').tab('show');
1199
1200    $([document.documentElement, document.body]).animate({
1201        scrollTop: $("#specifications_tab_button").offset().top - 100
1202    }, 200);
1203}
1204
1205function scrollToContact() {
1206    $('#contact_tab_button').tab('show');
1207
1208    updateMap();
1209
1210    $([document.documentElement, document.body]).animate({
1211        scrollTop: $("#contact_tab_button").offset().top - 100
1212    }, 200);
1213}
1214
1215function scrollToPreview() {
1216    $('#preview_tab_button').tab('show');
1217
1218    $([document.documentElement, document.body]).animate({
1219        scrollTop: $("#preview_tab_button").offset().top - 100
1220    }, 200);
1221}
1222
1223function scrollToMaterials() {
1224    $('#materials_tab_button').tab('show');
1225
1226    $([document.documentElement, document.body]).animate({
1227        scrollTop: $("#materials_tab_button").offset().top - 100
1228    }, 200);
1229}
1230
1231function addToCompare(productId, redirect) {
1232    $.ajax({
1233        url: location.protocol + '//' + location.host + '/product/compare/add/' + productId,
1234        type: 'get',
1235        data: '', // <-- Add this!
1236        cache: false,
1237        success: function(response){
1238            $('.btn-compare-disabled').hide();
1239            $('.btn-compare-enabled').show();
1240
1241            $('.btn-compare-disabled-' + productId).hide();
1242            $('.btn-compare-enabled-' + productId).show();
1243            if (redirect) {
1244                window.location = '/product/compare';
1245            }
1246        },
1247        error: function(response){
1248          /*  $("<div>Dette produkt kan ikke sammenlignes med de øvrige produkter, som er valgt til sammenligning.</div>").dialog({
1249                modal: true,
1250                resizable: false,
1251                draggable: false,
1252                title: 'Sammenligni',
1253                autowidth: true,
1254                closeOnEscape: false,
1255                buttons : [
1256                    {
1257                        text: 'Start forfra',
1258                        class: 'btn',
1259                        click: function () {
1260                            alert("test");
1261                        }
1262                    },
1263                    {
1264                        text: 'Annullér',
1265                        class: 'btn',
1266                        click: function () {
1267                            $(this).remove();
1268                        }
1269                    }
1270                ],
1271                open: function(event, ui) {
1272                    $(".ui-dialog-titlebar").hide();
1273                },
1274                close: function(event, ui) {
1275                    $('body').append("<h1>Test</h1>");
1276                    $(this).remove();
1277                }
1278            });*/
1279        }
1280    });
1281}
1282
1283function removeFromCompare(productId) {
1284    $.ajax({
1285        url: location.protocol + '//' + location.host + '/product/compare/remove/' + productId,
1286        type: 'get',
1287        data: '', // <-- Add this!
1288        cache: false,
1289        success: function(response){
1290            $('.btn-compare-disabled').show();
1291            $('.btn-compare-enabled').hide();
1292
1293            $('.btn-compare-disabled-' + productId).show();
1294            $('.btn-compare-enabled-' + productId).hide();
1295        },
1296        error: function(response){
1297        }
1298    });
1299}
1300
1301//-- GENERAL PAGES (Collection: Pages entries) --//
1302$(window).load (function() {
1303    $.each($('img'), function() {
1304        if ( $(this).attr('data-src') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1305            var source = $(this).data('src');
1306            $(this).hide();
1307            $(this).attr('src', source);
1308            $(this).removeAttr('data-src');
1309            $(this).fadeIn(1000);
1310        }
1311    });
1312
1313    $.each($('picture source'), function() {
1314        if ( $(this).attr('data-srcset') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1315            var source = $(this).data('srcset');
1316            $(this).hide();
1317            $(this).attr('srcset', source);
1318            $(this).removeAttr('data-srcset');
1319            $(this).fadeIn(1000);
1320        }
1321    });
1322
1323    $.each($('.lazy-img'), function() {
1324        if ( $(this).attr('data-style') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1325            var source = $(this).data('src');
1326            var style = $(this).data('style');
1327            $(this).attr('style', style);
1328            $(this).removeAttr('data-style');
1329            $(this).fadeIn(1000);
1330        }
1331    });
1332
1333    setTimeout(function () {
1334        $.each($('.lazy-caption'), function() {
1335           var left = $(this).css('left');
1336           $(this).css('left', '0%');
1337           $(this).css('left', left);
1338        });
1339    }, 550);
1340});
1341
1342$(window).scroll(function() {
1343    $.each($('img'), function() {
1344        if ( $(this).attr('data-src') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1345            var source = $(this).data('src');
1346            $(this).hide();
1347            $(this).attr('src', source);
1348            $(this).removeAttr('data-src');
1349            $(this).fadeIn(1000);
1350        }
1351    });
1352
1353    $.each($('picture source'), function() {
1354        if ( $(this).attr('data-srcset') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1355            var source = $(this).data('srcset');
1356            $(this).hide();
1357            $(this).attr('srcset', source);
1358            $(this).removeAttr('data-srcset');
1359            $(this).fadeIn(1000);
1360        }
1361    });
1362});
1363
1364$(window).scroll(function() {
1365    $.each($('.lazy-img'), function() {
1366        if ( $(this).attr('data-style') && $(this).offset().top < ($(window).scrollTop() + $(window).height() + 100) ) {
1367            var source = $(this).data('src');
1368            var style = $(this).data('style');
1369            $(this).attr('style', style);
1370            $(this).removeAttr('data-style');
1371            $(this).fadeIn(1000);
1372        }
1373    })
1374});
1375
1376$(window).scroll(function() {
1377    $.each($('.lazy-caption'), function() {
1378       var left = $(this).css('left');
1379       $(this).css('left', '0%');
1380       $(this).css('left', left);
1381    })
1382});

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.