PageSourceSearch

https://fpt.vn/frontend_layout_2025_vibecode/assets/js/script.js?v=v1.50.17

js fpt.vn collected 2026-10-01 11:55:29 UTC 11,068 bytes, 310 lines download raw bytes

1jQuery(document).ready(function($) {
2
3    // Test click
4    $('.vat-icon').each(function(index) {
5        console.log('VAT icon #' + index + ':', this);
6    });
7
8    // Location mobile click handler
9    $('.location-mobile').on('click', function(e) {
10        e.preventDefault();
11        const locationModalOverlay = document.getElementById('locationModalOverlay');
12        
13        if (locationModalOverlay) {
14            locationModalOverlay.style.display = 'flex';
15            document.body.style.overflow = 'hidden';
16            //document.documentElement.style.overflow = 'hidden'; // remove hidden ở thẻ html: do ko hoạt động đc khi đóng modal
17        }
18
19    });
20
21    $(window).scroll(function() {
22        var targetElement = $('body');
23        var targetOffset = targetElement.offset().top;
24        var distanceToTop = targetOffset - $(this).scrollTop();
25        // console.log('Distance to top of element:', distanceToTop);
26
27        // Truong hop co smartbanner
28        if (targetElement.hasClass('smr-banner-added')) {
29            //
30            if (distanceToTop <= 84 && distanceToTop > -1) {
31                $('.header_area').css('top', distanceToTop + 'px');
32            } else {
33                $('.header_area').css('top', '0px');
34            }
35        }
36
37    });
38    
39    // custom button allways on top 
40    if (window.innerWidth <= 540) {
41        // console.log(" <= 540px.");
42        $(window).scroll(function() {
43            var scrollPosition = $(window).scrollTop() + $(window).height();
44            var documentHeight = $(document).height();
45
46            if (documentHeight - scrollPosition <= 180) {
47                $('.always-on').addClass('js_always_on_bottom');
48                $('.back-to-top').addClass('_js_back_top');
49            } else {
50                $('.always-on').removeClass('js_always_on_bottom');
51                $('.back-to-top').removeClass('_js_back_top');
52            }
53        });
54
55    }
56
57    // OLD VAT Info Tooltip Handler - DISABLED
58    // This old system appended tooltip to body with fixed positioning
59    // New system uses .vat-icon-wrapper with relative positioning (see vat-tooltip.js)
60    // Keeping code commented for reference
61
62    /*
63    let vatTooltipActive = null;
64
65    function createVatTooltip() {
66        const tooltip = document.createElement('div');
67        tooltip.className = 'vat-info-tooltip';
68        tooltip.innerHTML = `
69            <div class="tooltip-content">
70                <p class="tooltip-text">
71                    Mức giá bao gồm VAT và có thể được thay đổi theo khu vực và thời điểm. Giá chưa bao gồm phí thuê thiết bị đầu cuối, phí thu tiền tận nhà và các dịch vụ gia tăng khác.
72                </p>
73                <div class="tooltip-arrow">
74                    <svg width="10" height="5" viewBox="0 0 10 5" fill="none">
75                        <path d="M5 5L0 0H10L5 5Z" fill="#3D3D3D"/>
76                    </svg>
77                </div>
78            </div>
79        `;
80        return tooltip;
81    }
82
83    function positionVatTooltip(tooltip, icon) {
84        const iconRect = icon.getBoundingClientRect();
85        tooltip.style.visibility = 'hidden';
86        tooltip.style.display = 'block';
87        const tooltipRect = tooltip.getBoundingClientRect();
88        const left = iconRect.left + (iconRect.width / 2) - (tooltipRect.width / 2);
89        const top = iconRect.top - tooltipRect.height - 8;
90        tooltip.style.left = left + 'px';
91        tooltip.style.top = top + 'px';
92        tooltip.style.visibility = '';
93        tooltip.style.display = '';
94    }
95
96    function showVatTooltip(icon) {
97        if (vatTooltipActive) {
98            hideVatTooltip();
99        }
100        vatTooltipActive = createVatTooltip();
101        document.body.appendChild(vatTooltipActive);
102        positionVatTooltip(vatTooltipActive, icon);
103        vatTooltipActive.offsetHeight;
104        setTimeout(() => {
105            if (vatTooltipActive) {
106                vatTooltipActive.classList.add('show');
107            }
108        }, 10);
109    }
110
111    function hideVatTooltip() {
112        if (vatTooltipActive) {
113            vatTooltipActive.classList.remove('show');
114            const tooltipToRemove = vatTooltipActive;
115            vatTooltipActive = null;
116            setTimeout(() => {
117                if (tooltipToRemove && tooltipToRemove.parentNode) {
118                    tooltipToRemove.parentNode.removeChild(tooltipToRemove);
119                }
120            }, 200);
121        }
122    }
123
124    document.addEventListener('click', function(e) {
125        const target = e.target;
126        if (target.classList.contains('vat-icon') || target.closest('.vat-icon')) {
127            e.preventDefault();
128            e.stopPropagation();
129            const icon = target.classList.contains('vat-icon') ? target : target.closest('.vat-icon');
130            showVatTooltip(icon);
131        } else if (!target.closest('.vat-info-tooltip')) {
132            hideVatTooltip();
133        }
134    });
135
136    document.addEventListener('keydown', function(e) {
137        if (e.key === 'Escape' && vatTooltipActive) {
138            hideVatTooltip();
139        }
140    });
141    */
142
143    // BCT Certificate link handler - ensure URL is preserved
144    document.addEventListener('click', function(e) {
145        const bctLink = e.target.closest('.bct-certificate-link');
146        if (bctLink) {
147            // Let the link work normally, don't interfere
148            return true;
149        }
150    }, true); // Use capture phase to run before other handlers
151
152    // OLD tooltip scroll/resize handlers - DISABLED (old system disabled above)
153    /*
154    window.addEventListener('scroll', function() {
155        if (vatTooltipActive) {
156            hideVatTooltip();
157        }
158    });
159
160    window.addEventListener('resize', function() {
161        if (vatTooltipActive) {
162            hideVatTooltip();
163        }
164    });
165    */
166
167    // Close dropdown menu on scroll
168    let scrollTimeout;
169    window.addEventListener('scroll', function() {
170        const dropdowns = document.querySelectorAll('.nav-item.dropdown');
171        dropdowns.forEach(function(dropdown) {
172            dropdown.classList.remove('force-hide-dropdown');
173            dropdown.classList.add('force-hide-dropdown');
174        });
175
176        clearTimeout(scrollTimeout);
177        scrollTimeout = setTimeout(function() {
178            dropdowns.forEach(function(dropdown) {
179                dropdown.classList.remove('force-hide-dropdown');
180            });
181        }, 150);
182    });
183
184    // Mobile Drawer Menu
185    const menuToggle = document.querySelector('.menu-toggle');
186    const drawer = document.querySelector('.mobile-drawer');
187    const drawerOverlay = document.querySelector('.mobile-drawer-overlay');
188    const drawerNavToggles = document.querySelectorAll('.drawer-nav-toggle');
189
190    // Close drawer function
191    function closeDrawer() {
192        drawer.classList.remove('active');
193        drawer.setAttribute('data-drawer-state', 'closed');
194        drawerOverlay.classList.remove('active');
195        document.body.style.overflow = '';
196        document.documentElement.style.overflow = '';
197    }
198
199    // Open drawer function
200    function openDrawer() {
201        drawer.classList.add('active');
202        drawer.setAttribute('data-drawer-state', 'open');
203        drawerOverlay.classList.add('active');
204        document.body.style.overflow = 'hidden';
205        document.documentElement.style.overflow = 'hidden';
206    }
207
208    // Toggle drawer with menu button
209    if (menuToggle && drawer) {
210        menuToggle.addEventListener('click', function() {
211            const drawerState = drawer.getAttribute('data-drawer-state');
212            const isOpen = drawerState === 'open' || drawer.classList.contains('active');
213
214            if (isOpen) {
215                closeDrawer();
216            } else {
217                openDrawer();
218            }
219        });
220    }
221
222    // Close drawer when clicking overlay
223    if (drawerOverlay) {
224        drawerOverlay.addEventListener('click', closeDrawer);
225    }
226
227    // Accordion toggle for expandable menu items
228    drawerNavToggles.forEach(function(toggle) {
229        toggle.addEventListener("click", function(e) {
230            e.preventDefault();
231            const submenu = this.nextElementSibling;
232            const isExpanded = this.getAttribute("aria-expanded") === "true";
233
234            // Đóng các submenu khác
235            drawerNavToggles.forEach(function(otherToggle) {
236                const otherSubmenu = otherToggle.nextElementSibling;
237                if (otherToggle !== toggle && otherSubmenu) {
238                    otherToggle.classList.remove("active");
239                    otherToggle.setAttribute("aria-expanded", "false");
240                    otherSubmenu.style.maxHeight = "0";
241                    otherSubmenu.classList.remove("active");
242                    otherSubmenu.setAttribute("hidden", "");
243                }
244            });
245
246            if (isExpanded) {
247                this.classList.remove("active");
248                this.setAttribute("aria-expanded", "false");
249                submenu.style.maxHeight = submenu.scrollHeight + "px"; // set chiều cao hiện tại
250                requestAnimationFrame(() => {
251                    submenu.style.maxHeight = "0"; // animate đóng
252                });
253                submenu.addEventListener("transitionend", function hide() {
254                    submenu.classList.remove("active");
255                    submenu.setAttribute("hidden", "");
256                    submenu.removeEventListener("transitionend", hide);
257                }, { once: true });
258            } else {
259                this.classList.add("active");
260                this.setAttribute("aria-expanded", "true");
261                submenu.hidden = false;
262                submenu.classList.add("active");
263                submenu.style.maxHeight = submenu.scrollHeight + "px"; // animate mở
264            }
265        });
266    });
267
268    // Close drawer on escape key
269    document.addEventListener('keydown', function(e) {
270        if (e.key === 'Escape' && drawer && drawer.classList.contains('active')) {
271            closeDrawer();
272        }
273    });
274
275
276    /* ẩn popup lần sau mở lại
277    // ---------------------------- popups
278    // Đóng popup khi bấm vào nút close (×)
279    $('._js_close_x').on('click', function () {
280        closeAllPopups();
281    });
282    // Đóng popup khi bấm vào button chính
283    $('._js_btn_close_pop').on('click', function () {
284        closeAllPopups();
285    });
286
287    // Đóng popup khi click ra ngoài nội dung popup (vùng overlay)
288    $('.popup-overlay').on('click', function (e) {
289        if ($(e.target).is('.popup-overlay')) {
290            closeAllPopups();
291        }
292    });
293    // ---------------------------- end popups
294    */
295
296});
297
298
299/*ẩn popup lần sau mở lại
300// ---------------------------- funtions popup
301// Đóng tất cả popup
302function closeAllPopups() {
303    $('.popup-overlay').fadeOut();
304}
305// ----------------- call all popup
306function registrationSuccess() {
307    closeAllPopups();
308    $('#show_registration_success').fadeIn();
309}
310*/

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.