PageSourceSearch

https://www.indas.com/static/version1790829743/frontend/Attindas/attindas/default/Magento_Theme/js/layout.js

js indas.com collected 2026-10-04 13:33:37 UTC 10,716 bytes, 281 lines download raw bytes

1/**
2 * Copyright © 2023 ITG Commerce. All rights reserved.
3 * See COPYING.txt for license details.
4 * @author: Niraj Bhoot <[email protected]>
5 */
6
7require(["jquery", "slick"], function ($) {
8    $(".password .show-text").click(function () {
9        if ($(this).find('img').length) {
10            $("img", this).toggle();
11            if ($("img.hide", this).css("display") === "none") {
12                $(this).siblings("input").attr("type", "text");
13            } else {
14                $(this).siblings("input").attr("type", "password");
15            }
16        }
17    });
18
19    $(document).on("click", ".search-icon", function (e) {
20        e.preventDefault();
21        $(".amsearch-wrapper-block").show();
22        $(".amsearch-wrapper-block").find('[name="q"]').focus();
23    });
24
25    $(document).on("click", "#close_search", function (event) {
26        $(".amsearch-wrapper-block").hide();
27        $(".amsearch-overlay-block").hide();
28        var input_value = $("input.amsearch-input").val("");
29        if (input_value) {
30            $("button.amsearch-button.-close.-clear.-icon").trigger("click");
31        }
32    });
33
34    /* Menu Height Adjustment for Mobile and desktop */
35    $(window).on("load", function (event) {
36        let checkExist = setInterval(function () {
37            if ($(".ammenu-nav-sections.-sidebar").length) {
38                clearInterval(checkExist);
39                let headerHeight = $(".page-wrapper .page-header").height();
40                $("body").css("padding-top", headerHeight + "px");
41                $(".ammenu-nav-sections.-sidebar").css("top", headerHeight + "px");
42            }
43        }, 100);
44    });
45
46    $(window).on("resize", function (event) {
47        let headerHeight = $(".page-wrapper .page-header").height();
48        $("body").css("padding-top", headerHeight + "px");
49        $(".ammenu-nav-sections.-sidebar").css("top", headerHeight + "px");
50    });
51
52    $("body").on("DOMSubtreeModified", function () {
53        let headerHeight = $(".page-wrapper .page-header").height();
54        $("body").css("padding-top", headerHeight + "px");
55        $(".ammenu-nav-sections.-sidebar").css("top", headerHeight + "px");
56    });
57
58    $(document).on("click", ".show-text", function () {
59        if ($(this).find('span').length) {
60            $("span", this).toggleClass("hidden");
61            if ($("span.hide", this).css("display") == "none") {
62                $(this).siblings("input").attr("type", "text");
63            } else {
64                $(this).siblings("input").attr("type", "password");
65            }
66        }
67    });
68
69    /* Qty + - update function */
70
71    function pad(i)
72    {
73        return i < 10 ? "0" + i.toString() : i.toString();
74    }
75
76    function triggerCartUpdateButton()
77    {
78        $("body").trigger("processStart");
79        $('#update_cart_button').trigger("click");
80        setTimeout(() => {
81            $("body").trigger("processStop");
82        }, 1000);
83    }
84
85    function triggerMiniCartUpdateButton(element)
86    {
87        $("body").trigger("processStart");
88        element.trigger("click");
89        setTimeout(() => {
90            $("body").trigger("processStop");
91        }, 1000);
92    }
93
94    $(document).on("click", ".more, .less", function (){
95        var $this = $(this);
96        var currentQty = $this.parent().find(".item-qty").val();
97        var updateBtnMiniCart = $this.parent().find('.update-cart-item');
98
99        if ($this.hasClass("more")) {
100            var addQty = parseInt(currentQty) + parseInt(1);
101            $this.parent().find(".item-qty").val(addQty);
102            if (updateBtnMiniCart.length) {
103                triggerMiniCartUpdateButton(updateBtnMiniCart);
104            } else {
105                triggerCartUpdateButton();
106            }
107        } else {
108            if (parseInt(currentQty) > 1) {
109                var addQty = parseInt(currentQty) - parseInt(1);
110                $this.parent().find(".item-qty").val(addQty);
111                if (updateBtnMiniCart.length) {
112                    triggerMiniCartUpdateButton(updateBtnMiniCart);
113                } else {
114                    triggerCartUpdateButton();
115                }
116            }
117        }
118    });
119
120    $(document).on("click", '[data-toggle="collapse"]', function (e) {
121        e.preventDefault();
122        $(this).next().toggleClass("show");
123    });
124
125    // glossary
126    $(document).on('click', '.glossary-section .all', function () {
127        $('.alphabet').removeClass('active');
128        var filter = '';
129        let count = 0;
130        $(this).addClass('active');
131        // Loop through the comment list
132        $('.alphabet-content').each(function () {
133            // If the list item does not contain the text phrase fade it out
134            // Else Show the list item if the phrase matches and increase the count by 1
135            if ($(this).text().search(new RegExp(filter, "i")) < 0) {
136                $(this).hide();
137            } else {
138                $(this).show();
139                count++;
140            }
141        });
142    });
143
144    $(document).on('click', '.glossary-section .alphabet', function () {
145        $('.all').removeClass('active');
146        $('.alphabet').removeClass('active');
147        var filter = $(this).text();
148        let count = 0;
149        $(this).addClass('active');
150        // Loop through the comment list
151        $('.alphabet-content').each(function () {
152            // If the list item does not contain the text phrase fade it out
153            // Else Show the list item if the phrase matches and increase the count by 1
154            if ($(this).find('h3').text().charAt(0).search(new RegExp(filter, "i")) < 0) {
155                $(this).hide();
156            } else {
157                $(this).show();
158                count++;
159            }
160        });
161    });
162
163    // Product finder add to cart
164    $(document).on('ajaxAddToCartTrigger', function () {
165        $(".product-items")
166            .find('[data-role=tocart-form], .form.map.checkout')
167            .attr('data-mage-init', JSON.stringify({ 'catalogAddToCart': {} }))
168            .trigger('contentUpdated');
169    });
170
171    $('body').on('click', '.ammenu-menu-wrapper a, .footer-aside a', function (e) {
172        if ($(this).attr('href') == '#' || $(this).attr('href') == 'javascript:void(0)' || $(this).attr('href') == 'javascript:void(0);') {
173            e.preventDefault();
174        }
175
176        let linkHref = $(this).attr('href');
177        let baselinkHref = linkHref.replace(/[^a-zA-Z#0-9-]/g, "");
178        let toSlide = baselinkHref.split('-');
179        let startWith = linkHref.startsWith('#');
180        linkHref = linkHref.replace(/[^a-zA-Z#]/g, "");
181        if (linkHref == '#') {
182            e.preventDefault();
183        }
184
185        if (linkHref.includes('#') && $(linkHref).length) {
186            e.preventDefault();
187            $('html, body').animate({
188                scrollTop: $(linkHref).offset().top - $('#ammenu-header-container').height()
189            }, 500);
190            $('#ammenu-sidebar').hide();
191            $('body').css('overflow', '');
192        }
193
194        if (toSlide.length == 2) {
195            let slideNo = parseInt(toSlide[1]) - 1;
196            $('.slick-slider').slick('slickGoTo', slideNo);
197        }
198
199        if ($(this).closest('.ammenu-submenu-wrapper').length) {
200            $('.ammenu-submenu-wrapper').hide();
201        }
202    });
203    let openSampleCheckoutPage = function () {
204        if (location.href.includes('customer/index/choosesamples')) {
205            if (document.location.href.indexOf('#choose-sample-proceed-to-cart') > -1) {
206                setTimeout(() => {
207                    $("#ship-samples-cart").trigger('click');
208                    $("html, body").animate({scrollTop: 0}, "slow");
209                }, 300);
210            }
211            if (document.location.href.indexOf('#proceed-to-cart') > -1) {
212                setTimeout(() => {
213                    if (!$("#prof-login-cart-list").is(":visible")) {
214                        $("#choose-sample-proceed-to-cart").trigger('click');
215                    }
216                }, 300);
217            }
218        }
219    };
220    $(window).on('load', function (e) {
221        let linkHref = window.location.hash;
222        let baselinkHref = linkHref.replace(/[^a-zA-Z#0-9-]/g, "");
223        let toSlide = baselinkHref.split('-');
224        linkHref = linkHref.replace(/[^a-zA-Z#]/g, "");
225
226        if (linkHref.includes('#') && $(linkHref).length) {
227            let scrollMargin = parseFloat($(linkHref).css('scroll-margin-top')) || 0;
228
229            $('html, body').animate({
230                scrollTop: $(linkHref).offset().top - (scrollMargin || $('#ammenu-header-container').height())
231            }, 500);
232            $('#ammenu-sidebar').hide();
233            $('body').css('overflow', '');
234        }
235
236        if (toSlide.length == 2) {
237            let slideNo = parseInt(toSlide[1]) - 1;
238            $('.slick-slider').slick('slickGoTo', slideNo);
239        }
240        openSampleCheckoutPage();
241    });
242
243    var currentUrl = location.href;
244    var customerUrl = BASE_URL + 'customer/account/index';
245    var customerWithoutIndexUrl = BASE_URL + 'customer/account';
246
247    $(document).on('click', '#top-cart-btn-cart, .modal-cart-link a', function (e) {
248        e.preventDefault();
249        $('#prof-login-product-list').hide();
250        if (window.isProfessionalLoginEnabled == 1 && window.isProfessional == 1) {
251            if ($(".modal-cart-link").length) {
252                $("#cart-message-popup-modal").modal("closeModal");
253            }
254
255            window.location.href =  BASE_URL + 'customer/index/choosesamples#proceed-to-cart';
256            openSampleCheckoutPage();
257        } else {
258            var url = BASE_URL + 'checkout/cart/';
259            window.location.href = url;
260        }
261    });
262
263    $(document).on('click', '#proflogin_top-cart-btn-checkout', function (e) {
264        e.preventDefault();
265        $('#prof-login-product-list').hide();
266        if (window.isProfessionalLoginEnabled == 1 && window.isProfessional == 1) {
267            window.location.href =  BASE_URL + 'customer/index/choosesamples#choose-sample-proceed-to-cart';
268            openSampleCheckoutPage();
269        } else {
270            var url = BASE_URL + 'checkout/';
271            window.location.href = url;
272            //location.reload();
273        }
274    });
275
276    $('#view-all-posts').on('click', function (e) {
277        e.preventDefault();
278        $(this).parent().find('.post-item').removeClass('hide');
279        $(this).hide();
280    });
281});

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.