PageSourceSearch

https://lumi.vn/wp-content/themes/flatsome-child/assets/js/trendy.js?ver=7.1.2

js lumi.vn collected 2026-10-02 14:53:18 UTC 10,048 bytes, 265 lines download raw bytes

1(function($){
2    // --- Cookie helpers ---
3    function setCookieAllDomain(name, value, days) {
4        var expires = "";
5        if (days) {
6            var date = new Date();
7            date.setTime(date.getTime() + (days*24*60*60*1000));
8            expires = "; expires=" + date.toUTCString();
9        }
10        var hostname = window.location.hostname.replace(/^www\./, '');
11
12        // cookie thường (root)
13        document.cookie = name + "=" + (value || "") + expires + "; path=/";
14
15        // cookie kèm domain (Google Translate yêu cầu)
16        document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=" + hostname;
17    }
18    function getCookie(name) {
19        var matches = document.cookie.match(new RegExp(
20            "(?:^|; )" + name.replace(/([$?*|{}\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
21        ));
22        return matches ? decodeURIComponent(matches[1]) : undefined;
23    }
24
25    // --- Update current flag ---
26    function updateCurrentFlag(lang) {
27        var $item = $('.language-box__item[data-lang="' + lang + '"] img');
28        if ($item.length) {
29            $('.current-flag').attr('src', $item.attr('src'));
30        }
31    }
32
33    // --- Toggle dropdown ---
34    $(document).on('click','.language-box__button', function(event){
35        event.stopPropagation();
36        var $list = $(this).closest('.language-box').find('.language-box__list');
37        $list.toggle();
38    });
39
40    // --- Click outside to close ---
41    $(document).on('click touchstart', function(e) {
42        if (!$(e.target).closest('.language-box').length) {
43            $('.language-box__list').hide();
44        }
45    });
46
47    // --- Handle language change ---
48    $(document).on('click','.language-box__item', function(){
49        var $select = $('.goog-te-combo'),
50            lang = $(this).attr('data-lang'),
51            $item = $(this).find('img');
52
53        if ($select.length) {
54            $select.val(lang);
55
56            // ép trigger event cho chắc (2 lần)
57            var event = document.createEvent("HTMLEvents");
58            event.initEvent("change", true, true);
59            $select[0].dispatchEvent(event);
60            $select[0].dispatchEvent(event);
61
62            // set cookie cho cả root + domain
63            setCookieAllDomain('googtrans', '/vi/' + lang, 365);
64        }
65
66        if ($item.length) {
67            $('.current-flag').attr('src', $item.attr('src'));
68        }
69
70        $('.language-box__list').hide();
71    });
72    $(document).on('click','.solutions__ctn a.button', function(e){
73        e.preventDefault();
74        var $col = $(this).closest('.solutions__ctn').find('.solutions__content.hidden');
75        $col.removeClass('hidden').css('margin-top','-32px');
76        $(this).addClass('hidden');
77    });
78    $(document).ready(function ($) {
79        var cookie = getCookie('googtrans');
80        var currentLang = 'vi';
81        if (cookie && cookie !== '/auto/auto') {
82            var parts = cookie.split('/');
83            if (parts.length === 3) {
84                currentLang = parts[2];
85            }
86        }
87        updateCurrentFlag(currentLang);
88        if ( $().slick ) {
89            var slick = jQuery(".slick-carousel");
90            slick.each(function(){
91                var item        = $(this).data('item'),
92                    item_lg     = $(this).data('item_lg'),
93                    item_md     = $(this).data('item_md'),
94                    item_sm     = $(this).data('item_sm'),
95                    item_mb     = $(this).data('item_mb'),
96                    row         = $(this).data('row'),
97                    arrows      = $(this).data('arrows'),
98                    dots        = $(this).data('dots'),
99                    vertical    = $(this).data('vertical');
100                $(this).slick({
101                    autoplay: true,
102                    dots: dots,
103                    arrows: arrows,
104                    infinite: true,
105                    autoplaySpeed: 2000,
106                    vertical: vertical,
107                    slidesToShow: item,
108                    slidesToScroll: 1,
109                    lazyLoad: 'ondemand',
110                    // verticalSwiping: true,
111                    rows: row,
112                    responsive: [
113                        {
114                            breakpoint: 1200,
115                            settings: {
116                                slidesToShow: item_lg,
117                                slidesToScroll: 1,
118                            }
119                        },
120                        {
121                            breakpoint: 992,
122                            settings: {
123                                slidesToShow: item_md,
124                                slidesToScroll: 1,
125                            }
126                        },
127                        {
128                            breakpoint: 768,
129                            settings: {
130                                slidesToShow: item_sm,
131                                slidesToScroll: 1,
132                            }
133                        },
134                        {
135                            breakpoint: 576,
136                            settings: {
137                                slidesToShow: item_mb,
138                                slidesToScroll: 1,
139                            }
140                        }
141                    ]
142                });
143            });
144        }
145
146        function initInfiniteCarousel(selector, itemWidth) {
147            var $track = $(selector);
148            var $items = $track.children();
149
150            // Nếu chưa có item hoặc ít hơn 2 thì bỏ qua
151            if ($items.length < 2) return;
152
153            // Clone toàn bộ items gốc và append vào cuối
154            $items.each(function() {
155                $(this).clone().appendTo($track);
156            });
157
158            // Nếu không truyền itemWidth thì tự tính theo item đầu tiên
159            var width = itemWidth || $items.first().outerWidth(true);
160            $track.css("width", (width * $items.length * 2) + "px");
161        }
162        initInfiniteCarousel(".reviews__carousel-track", 456);
163        initInfiniteCarousel(".partners__carousel-track", 250);
164
165        const fallbackSrc = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
166        const lazyImages = $('img[lazy]');
167        const observer = new IntersectionObserver(function (entries, observer) {
168            entries.forEach(function (entry) {
169                if (entry.isIntersecting) {
170                    const img = entry.target;
171
172                    img.onerror = function () {
173                        img.src = fallbackSrc;
174                    };
175
176                    img.src = img.getAttribute('data-src');
177                    img.removeAttribute('lazy');
178                    img.removeAttribute('data-src');
179                    observer.unobserve(img);
180                }
181            });
182        }, {
183            threshold: 0.01
184        });
185        lazyImages.each(function () {
186            observer.observe(this);
187        });
188
189        $('.accordion.multi-toggle .accordion-title').on('click', function(e) {
190            // Ngăn Flatsome xử lý mặc định
191            e.preventDefault();
192            e.stopImmediatePropagation();
193            const $title = $(this);
194            const $item = $title.closest('.accordion-item');
195            const $inner = $item.children('.accordion-inner');
196            const isActive = $item.hasClass('active');
197            if (isActive) {
198                $item.removeClass('active');
199                $title.attr('aria-expanded', 'false');
200                $inner.stop(true, true).slideUp(300);
201            } else {
202                $item.addClass('active');
203                $title.attr('aria-expanded', 'true');
204                $inner.stop(true, true).slideDown(300);
205            }
206        });
207        // Khởi tạo trạng thái ban đầu cho các tab
208        $('.accordion.multi-toggle .accordion-item').each(function () {
209            const $item = $(this);
210            const $title = $item.children('.accordion-title');
211            const $inner = $item.children('.accordion-inner');
212            if ($item.hasClass('active')) {
213                $inner.show();
214                $title.attr('aria-expanded', 'true');
215            } else {
216                $inner.hide();
217                $title.attr('aria-expanded', 'false');
218            }
219        });
220
221        function initLichSuDragScroll() {
222            const $courseWrap = $(".lich_su_wrap");
223
224            let isDown = false;
225            let startX;
226            let scrollLeft;
227
228            $courseWrap.on("mousedown", function(e) {
229                isDown = true;
230                startX = e.pageX - $courseWrap.offset().left;
231                scrollLeft = $courseWrap.scrollLeft();
232                $courseWrap.css("user-select", "none");
233            });
234
235            $courseWrap.on("mouseleave mouseup", function() {
236                isDown = false;
237                $courseWrap.css("user-select", "");
238            });
239
240            $courseWrap.on("mousemove", function(e) {
241                if (!isDown) return;
242                e.preventDefault();
243                const x = e.pageX - $courseWrap.offset().left;
244                const walk = (x - startX) * 0.7;
245                $courseWrap.scrollLeft(scrollLeft - walk);
246            });
247        }
248        initLichSuDragScroll();
249        $('.tab-link').on('click', function () {
250            var tabId = $(this).data('tab');
251            $('.tab-link').removeClass('active');
252            $(this).addClass('active');
253            $('.tab-content').removeClass('active');
254            $('#' + tabId).addClass('active');
255        });
256        $('.header-nav.nav-left >li.has-dropdown>ul.nav-dropdown-default>li.nav-dropdown-col>ul.sub-menu').hover(
257            function () {
258                $(this).closest('li.nav-dropdown-col').addClass('hover');
259            },
260            function () {
261                $(this).closest('li.nav-dropdown-col').removeClass('hover');
262            }
263        );
264    });
265})(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.