PageSourceSearch

https://swicos.com.my/wp-content/themes/rayo/js/theme-loadmore.js?ver=1791292513

js swicos.com.my collected 2026-10-06 13:15:56 UTC 6,039 bytes, 176 lines download raw bytes

1(function($) {
2	"use strict";
3
4	$(document).ready(function() {
5        rayoAjaxLoad();
6    });
7
8    function rayoAjaxLoad() {
9
10        var i, section;
11        var sections = document.getElementsByClassName('mxd-projects');
12        for (i = 0; i < sections.length; i++) {
13            section = sections[i];
14            var load_more = section.getElementsByClassName('rayo-btn-loadmore');
15            if (load_more.length) {
16                rayoAjaxInit(section);
17            }
18        }
19    }
20    
21    var	offset_items = 0;
22
23    function rayoAjaxQuery(grid, section, request_data) {
24
25    	offset_items = grid.getElementsByClassName('mxd-project-item').length;
26		request_data['offset_items'] = offset_items ? offset_items : 0;
27
28		
29        $.ajax({
30			url : rayo_loadmore_params.ajaxurl, /*AJAX handler*/
31			data : request_data,
32			type : 'POST',
33			beforeSend : function ( xhr ) { 
34				/* $(section).find('.loadmore_wrapper .rayo-btn-loadmore').append('<i class=" uil-sync" aria-hidden="true"></i>'); some type of preloader */
35			},
36			success : function( response ){
37				var resp, new_items, load_more_hidden;
38				resp = document.createElement('div');
39                resp.innerHTML = response;
40                new_items = $('.mxd-project-item', resp);
41                load_more_hidden = $('.hidden_load_more', resp);
42				/*console.log(new_items);*/
43				if(load_more_hidden.length){
44                    $(section)
45                        .find('.loadmore_wrapper')
46                        .fadeOut(1200, function() {
47                            $(this).remove();
48                        });
49                }else{
50                    $(section)
51                        .find('.loadmore_wrapper .rayo-btn-loadmore')
52                        .removeClass('loading');
53                }
54				if( new_items.length ) {
55					var items = $(new_items);
56					$(grid).imagesLoaded().always(function() {
57						$(grid).find('.row').append(items); /*insert new posts*/
58                        initAnimateInUp($(items).get(0).parentNode);
59                        initUkiyo($(items).get(0).parentNode);
60					});
61				}
62			}
63		});
64    }
65
66    function rayoAjaxInit(section) {
67
68        var grid, btn_loadmore, form_data, field_data, data, request_data;
69        if (section == undefined) {
70            return;
71        }
72
73        /* Get projects masonry */
74        grid = section.getElementsByClassName('mxd-projects-inner');
75        if (!grid.length) { return; }
76        grid = grid[0];
77
78        /*Get form data*/
79        form_data = section.getElementsByClassName('posts_data_ajax');
80        if (!form_data.length) { return; }
81        form_data = form_data[0];
82
83        /*Get field data*/
84        field_data = form_data.getElementsByClassName('data_ajax');
85        if (!field_data.length) { return; }
86        field_data = field_data[0];
87
88        /* Get param loadmore */
89        data = field_data.value;
90        request_data = JSON.parse(data);
91        request_data['action'] = 'loadmore';
92
93        /* Get btn loadmore */
94        btn_loadmore = section.getElementsByClassName('rayo-btn-loadmore');
95        if (!btn_loadmore.length) { return; }
96        btn_loadmore = btn_loadmore[0];
97
98        btn_loadmore.addEventListener( 'click',
99            function(e) {
100                e.preventDefault();
101                $(this).addClass('loading');
102                rayoAjaxQuery(grid, section, request_data);
103            },
104            false
105        );
106    }
107    function initAnimateInUp(context = document) {
108        const elements = context.querySelectorAll('.anim-uni-in-up:not([data-animated])');
109        const tl = gsap.timeline();
110
111        if (elements.length === 0) return; // Không có ảnh mới thì thôi
112        elements.forEach((el, i) => {
113            const rect = el.getBoundingClientRect();
114            const inView = rect.top < window.innerHeight && rect.bottom > 0;
115
116            if (inView) {
117                tl.fromTo(el,
118                    { opacity: 0, y: 20 },
119                    { opacity: 1, y: 0, duration: 0.5, ease: 'sine.out' },
120                    i * 0.1 // 👈 tạo hiệu ứng xuất hiện nối tiếp nhau
121                );
122            } else {
123                gsap.fromTo(el,
124                    { opacity: 0, y: 50 },
125                    {
126                        opacity: 1,
127                        y: 0,
128                        duration: 0.8,
129                        ease: 'sine.out',
130                        scrollTrigger: {
131                            trigger: el,
132                            start: 'top 90%',
133                            toggleActions: 'play none none reverse',
134                        }
135                    }
136                );
137            }
138
139            el.dataset.animated = 'true';
140        });
141    }
142    function initUkiyo(context = document) {
143        // Lấy ra tất cả các ảnh .parallax-img-small chưa được khởi tạo
144        const newImages = context.querySelectorAll('.parallax-img-small:not([data-ukiyo-initialized])');
145      
146        if (newImages.length === 0) return; // Không có ảnh mới thì thôi
147
148        newImages.forEach(img => {
149        // Khởi tạo hiệu ứng Ukiyo
150            new Ukiyo(img, {
151                scale: 1.2,
152                speed: 1.5,
153                externalRAF: false
154            });
155
156            // Đánh dấu đã khởi tạo, để lần sau không re-init
157            img.dataset.ukiyoInitialized = 'true';
158        });
159    }
160
161	/**
162     * Elementor JS Hooks
163     */
164    $(window).on("elementor/frontend/init", function () {
165    	if ( window.elementorFrontend.isEditMode() ) {
166    		/* Portfolio filter isotop */
167            window.elementorFrontend.hooks.addAction(
168                "frontend/element_ready/ray-portfolio-list.default",
169                function () {
170                    rayoAjaxLoad();
171                }
172            );
173    	}
174  	});
175
176})(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.