PageSourceSearch

https://www.mindko.com/static/js/global/utils/main.js

js mindko.com collected 2026-09-24 10:55:00 UTC 2,881 bytes, 93 lines download raw bytes

1// Menu toggle functionality + misc used by all
2
3// Additional functionality specific to newest landing page
4document.addEventListener("DOMContentLoaded", function() {
5 // Menu toggler functionality
6 const menuToggler = document.querySelector('.menu-toggler');
7 const menu = document.querySelector('.menu');
8 
9 if (menuToggler && menu) {
10   menuToggler.addEventListener('click', function() {
11     menuToggler.classList.toggle('active');
12     menu.classList.toggle('active');
13     document.querySelector('.mobile-btn-group').classList.toggle('active');
14   });
15 }
16
17 // Close menu when clicking outside
18 document.addEventListener('click', function(event) {
19   if (!menu.contains(event.target) && !menuToggler.contains(event.target)) {
20     menu.classList.remove('active');
21     menuToggler.classList.remove('active');
22     document.querySelector('.mobile-btn-group').classList.remove('active');
23   }
24 });
25
26 // Smooth scroll for anchor links
27 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
28   anchor.addEventListener('click', function (e) {
29     e.preventDefault();
30     const target = document.querySelector(this.getAttribute('href'));
31     if (target) {
32       target.scrollIntoView({
33         behavior: 'smooth'
34       });
35       // Close mobile menu if open
36       menu.classList.remove('active');
37       menuToggler.classList.remove('active');
38     }
39   });
40 });
41
42
43 // Select all elements with the class 'offer-date' and set their text content
44 document.querySelectorAll('.offer-date').forEach(element => {
45   element.textContent = addDaysToDate(3);
46 });
47}); 
48
49
50function getDayWithSuffix(day) {
51 if (day > 3 && day < 21) return day + 'th'; // for days 4th to 20th
52 switch (day % 10) {
53   case 1: return day + 'st';
54   case 2: return day + 'nd';
55   case 3: return day + 'rd';
56   default: return day + 'th';
57 }
58}
59
60function addDaysToDate(days) {
61 const currentDate = new Date();
62 currentDate.setDate(currentDate.getDate() + days);
63 const day = currentDate.getDate();
64 const month = currentDate.toLocaleDateString('en-US', { month: 'long' });
65
66 // Get the day with the suffix
67 const dayWithSuffix = getDayWithSuffix(day);
68
69 return `${month} ${dayWithSuffix}`;
70}
71
72// Handle clicks on menu items with submenus (mobile)
73$('.menu li > a').on('click', function(e) {
74  if ($(window).width() <= 991) {
75    var submenu = $(this).siblings('.submenu');
76    
77    // Only prevent default and toggle if this link has a submenu
78    if (submenu.length > 0) {
79      e.preventDefault();
80      var chevron = $(this).find('img');
81      
82      if (submenu.is(':visible')) {
83        chevron.css('transform', 'rotate(0deg)');
84        submenu.slideUp(180);
85      } else {
86        $('.submenu').slideUp(180);
87        $('.menu li a img').css('transform', 'rotate(0deg)'); // reset others
88        submenu.slideDown(180);
89        chevron.css('transform', 'rotate(-180deg)');
90      }
91    }
92  }
93});

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.