PageSourceSearch

https://yntraacloud.ai/wp-content/themes/yottasafe/assets/js/megamenu.js?ver=1.1

js yntraacloud.ai collected 2026-10-05 13:26:03 UTC 6,808 bytes, 209 lines download raw bytes

1if ($(window).outerWidth() < 1200) {
2  this.MobileNav = function () {
3    this.curItem,
4      (this.curLevel = 0),
5      (this.transitionEnd = _getTransitionEndEventName());
6
7    var defaults = {
8      initElem: ".main-menu",
9      menuTitle: "Menu",
10    };
11
12    // Check if MobileNav was initialized with some options and assign them to the "defaults"
13    if (arguments[0] && typeof arguments[0] === "object") {
14      this.options = extendDefaults(defaults, arguments[0]);
15    }
16
17    // Add to the "defaults" ONLY if the key is already in the "defaults"
18    function extendDefaults(source, extender) {
19      for (option in extender) {
20        if (source.hasOwnProperty(option)) {
21          source[option] = extender[option];
22        }
23      }
24    }
25
26    MobileNav.prototype.getCurrentItem = function () {
27      return this.curItem;
28    };
29
30    MobileNav.prototype.setMenuTitle = function (title) {
31      defaults.menuTitle = title;
32      _updateMenuTitle(this);
33      return title;
34    };
35
36    // Init is an anonymous IIFE
37    (function (MobileNav) {
38      var initElem = $(defaults.initElem).length ? $(defaults.initElem) : false;
39
40      if (initElem) {
41        defaults.initElem = initElem;
42        _clickHandlers(MobileNav);
43        _updateMenuTitle(MobileNav);
44      } else {
45        console.log(
46          defaults.initElem + " element doesn't exist, menu not initialized."
47        );
48      }
49    })(this);
50
51    function _getTransitionEndEventName() {
52      var i,
53        undefined,
54        el = document.createElement("div"),
55        transitions = {
56          transition: "transitionend",
57          OTransition: "otransitionend", // oTransitionEnd in very old Opera
58          MozTransition: "transitionend",
59          WebkitTransition: "webkitTransitionEnd",
60        };
61
62      for (i in transitions) {
63        if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {
64          return transitions[i];
65        }
66      }
67    }
68
69    function _clickHandlers(menu) {
70      defaults.initElem.on("click", ".has-dropdown > a", function (e) {
71        e.preventDefault();
72        menu.curItem = $(this).parent();
73        _updateActiveMenu(menu);
74      });
75
76      defaults.initElem.on("click", ".nav-toggle", function () {
77        _updateActiveMenu(menu, "back");
78      });
79    }
80
81    // TODO: Make this DRY (deal with waiting for transitionend event)
82    function _updateActiveMenu(menu, direction) {
83      _slideMenu(menu, direction);
84      if (direction === "back") {
85        menu.curItem.removeClass("nav-dropdown-open nav-dropdown-active");
86        menu.curItem = menu.curItem.parent().closest("li");
87        menu.curItem.addClass("nav-dropdown-open nav-dropdown-active");
88        _updateMenuTitle(menu);
89      } else {
90        menu.curItem.addClass("nav-dropdown-open nav-dropdown-active");
91        _updateMenuTitle(menu);
92      }
93    }
94
95    // Update main menu title to be the text of the clicked menu item
96    function _updateMenuTitle(menu) {
97      var title = defaults.menuTitle;
98      if (menu.curLevel > 0) {
99        // title = menu.curItem.children("a").children(".mob-title").text();
100        title = menu.curItem.find(".mob-title").first().text();
101
102        defaults.initElem.find(".nav-toggle").addClass("back-visible");
103      } else {
104        defaults.initElem.find(".nav-toggle").removeClass("back-visible");
105      }
106      $(".nav-title").text(title);
107    }
108
109    // Slide the main menu based on current menu depth
110    function _slideMenu(menu, direction) {
111      if (direction === "back") {
112        menu.curLevel = menu.curLevel > 0 ? menu.curLevel - 1 : 0;
113      } else {
114        menu.curLevel += 1;
115      }
116      defaults.initElem.children("ul").css({
117        transform: "translateX(-" + menu.curLevel * 100 + "%)",
118      });
119    }
120  };
121}
122
123$(document).on("click", ".js-nav-toggle", function (e) {
124  e.preventDefault();
125  $(".menu").toggleClass("show-menu");
126  $(".nav-wrapper").toggleClass("show-menu");
127  let rt = window.innerWidth;
128  let menuBtnX = $(".js-nav-toggle").offset().left;
129  console.log(rt, menuBtnX);
130  $(".js-nav-toggle").css("right", 0);
131  $(".show-menu .js-nav-toggle").css("right", -(rt - menuBtnX - 50));
132});
133
134$(document).ready(function () {
135  $("#h-search").on("click", function () {
136    var searchFieldContainer = $(".search-field-container");
137
138    if (searchFieldContainer.css("display") === "none") {
139      searchFieldContainer.css("display", "flex");
140    } else {
141      searchFieldContainer.css("display", "none");
142    }
143  });
144  $("#h-close").on("click", function () {
145    $(".search-field-container").css("display", "none");
146  });
147});
148
149$(document).ready(function () {
150  // Initially show only the first tab content
151  $(".feat-tab-content-wrap").hide();
152  $(".feat-tab-content-wrap:first").show();
153
154  $(".feat-product-tab").click(function () {
155    const targetId = $(this).attr("tabid");
156
157    // Hide all tab contents and show the selected one
158    $(".feat-tab-content-wrap").hide();
159    $("#" + targetId).fadeIn();
160
161    // Remove active class from all tabs and add to the clicked one
162    $(".feat-product-tab").removeClass("active");
163    $(this).addClass("active");
164  });
165});
166
167// // multiple accordion
168// $(".acc-item").find(".panel").slideUp();
169// $(".acc-item").eq(0).find(".panel").slideDown();
170// $(".acc-container").each((i, e) => $(e).find(".panel:first").slideDown());
171// $(document).on("click", ".acc-item", function () {
172//   var accContainer = $(this).closest(".acc-container");
173//   accContainer
174//     .find(".acc-item")
175//     .not(this)
176//     .removeClass("active")
177//     .find(".panel")
178//     .slideUp();
179//   $(this).toggleClass("active").find(".panel").slideToggle();
180// });
181
182// // prevent multiple click on accordion
183// $(document).on("click", ".acc-item.active", function () {
184//   $(this).css("pointer-events", "none");
185//   setTimeout(function () {
186//     $(".acc-item").css("pointer-events", "all");
187//   }, 1000);
188// });
189
190$(document).on("click", ".sub-acc-item", function (event) {
191  event.stopPropagation(); // Prevent triggering parent accordion click
192  var accContainer = $(this).closest(".sub-acc-container");
193  accContainer
194    .find(".sub-acc-item")
195    .not(this)
196    .removeClass("active")
197    .find(".sub-panel")
198    .slideUp();
199  $(this).toggleClass("active").find(".sub-panel").slideToggle();
200});
201
202// prevent multiple clicks on sub accordion
203$(document).on("click", ".sub-acc-item.active", function (event) {
204  event.stopPropagation(); // Prevent parent accordion interference
205  $(this).css("pointer-events", "none");
206  setTimeout(function () {
207    $(".sub-acc-item").css("pointer-events", "all");
208  }, 1000);
209});

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.