PageSourceSearch

https://www.farmacianeusmartinez.cat/assets/common/js/mobileShopMenu.js?v=2026092902

js farmacianeusmartinez.cat collected 2026-10-04 22:15:08 UTC 3,092 bytes, 81 lines download raw bytes

1(function ($) {
2    $(document).ready(function () {
3  
4        const $openSearchBtn = $("#open-search-mobile");
5        const $searchContainer = $("#scroll-hide");
6        $openSearchBtn.show();
7        $('#fixed-header-on').css({"position": "fixed"})
8        $searchContainer.hide();
9    // Scroll-based header hide/show on mobile
10    var lastScrollTop = 0;
11    var scrollTicking = false;
12    var headerScrollHidden = false;
13    var $stickyBanner = $('.container-fluid.sticky-app-banner');
14    var initialBodyPadding = parseInt($('body').css('padding-top')) || 0;
15
16    function updateMobileHeaderOnScroll() {
17        var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
18
19        if (scrollTop > lastScrollTop && scrollTop > 10 && !headerScrollHidden) {
20            var $header = $('#fixed-header-on');
21            var rect = $header[0].getBoundingClientRect();
22            $header.addClass('mobile-scroll-hiding');
23            $header.css('transform', 'translateY(-' + (rect.top + rect.height) + 'px)');
24            $stickyBanner.addClass('mobile-scroll-hidden');
25            $('body').css('padding-top', '0');
26            headerScrollHidden = true;
27        } else if (scrollTop < lastScrollTop && headerScrollHidden) {
28            $('#fixed-header-on').removeClass('mobile-scroll-hiding').css('transform', '');
29            $stickyBanner.removeClass('mobile-scroll-hidden');
30            $('body').css('padding-top', initialBodyPadding + 'px');
31            headerScrollHidden = false;
32        }
33
34        lastScrollTop = Math.max(scrollTop, 0);
35        scrollTicking = false;
36    }
37
38    $(window).on('scroll', function () {
39        if (!scrollTicking) {
40            window.requestAnimationFrame(updateMobileHeaderOnScroll);
41            scrollTicking = true;
42        }
43    });
44
45    //shop categories menu
46    const $menu = $('#shop-categories-menu');
47    $('body').on('click', '#open-categories-mobile', function (event) {
48        event.preventDefault();
49        if ($menu.width() === 0){
50            $menu.css('width', '300px');
51            $menu.css('margin-left', '10px');
52        }else{
53            $menu.css('width', '0');
54            $menu.css('margin-left', '0');
55        }
56    });
57    $('body').on('click', '#close-categories-menu', function (event) {
58        event.preventDefault();
59        $menu.css('width', '0');
60        $menu.css('margin-left', '0');
61    });
62    $(document).mouseup(e => {
63        if (!$menu.is(e.target) // if the target of the click isn't the container...
64            && $menu.has(e.target).length === 0) // ... nor a descendant of the container
65        {
66            $menu.css('width', '0');
67            $menu.css('margin-left', '0');
68        }
69    });
70    $('body').on('click', '.btn-show-submenu-mobile', function (event) {
71        event.preventDefault();
72        var target = $(this).parent().children(".show-mobile-submenu");
73        $(target).slideToggle();
74        if($(this).html() == '-') {
75            $(this).html('+');
76        }else{
77            $(this).html('-');
78        }
79    });
80    }); // End document ready
81})(this.jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.