1(function($) { 2 "use strict"; 3 4 $(document).ready(function() { 5 otAjaxLoad(); 6 }); 7 8 function otAjaxLoad() { 9 10 /* Handle glightbox before */ 11 const pGlightbox = GLightbox({ 12 selector: '.project-glightbox', 13 }); 14 15 var i, section; 16 var sections = document.getElementsByClassName('projects-filter-wrapper'); 17 for (i = 0; i < sections.length; i++) { 18 section = sections[i]; 19 var load_more = section.getElementsByClassName('btn-loadmore'); 20 if (load_more.length) { 21 otAjaxInit(section, pGlightbox); 22 } 23 } 24 } 25 26 var offset_items = 0; 27 28 function otAjaxQuery(grid, section, request_data, pGlightbox) { 29 30 offset_items = grid.getElementsByClassName('project-item').length; 31 request_data['offset_items'] = offset_items ? offset_items : 0; 32 33 34 $.ajax({ 35 url : sandbox_loadmore_params.ajaxurl, /*AJAX handler*/ 36 data : request_data, 37 type : 'POST', 38 beforeSend : function ( xhr ) { 39 /* $(section).find('.loadmore_wrapper .btn-loadmore').append('<i class=" uil-sync" aria-hidden="true"></i>'); some type of preloader */ 40 }, 41 success : function( response ){ 42 var resp, new_items, load_more_hidden; 43 resp = document.createElement('div'); 44 resp.innerHTML = response; 45 new_items = $('.project-item', resp); 46 load_more_hidden = $('.hidden_load_more', resp); 47 /*console.log(new_items);*/ 48 if(load_more_hidden.length){ 49 $(section) 50 .find('.loadmore_wrapper') 51 .fadeOut(1200, function() { 52 $(this).remove(); 53 }); 54 }else{ 55 $(section) 56 .find('.loadmore_wrapper .btn-loadmore') 57 .removeClass('loading'); 58 } 59 if( new_items.length ) { 60 var items = $(new_items); 61 $(grid).imagesLoaded().always(function() { 62 $(grid).append(items).isotope('appended', items).isotope('reloadItems'); /*insert new posts*/ 63 setTimeout(function() { 64 $(grid).isotope('layout'); 65 $(grid).isotope({ sortBy : 'original-order' }); 66 }, 700); 67 pGlightbox.reload(); 68 }); 69 } 70 } 71 }); 72 } 73 74 function otAjaxInit(section, pGlightbox) { 75 76 var grid, btn_loadmore, form_data, field_data, data, request_data; 77 if (section == undefined) { 78 return; 79 } 80 81 /* Get projects masonry */ 82 grid = section.getElementsByClassName('projects-masonry'); 83 if (!grid.length) { return; } 84 grid = grid[0]; 85 86 /*Get form data*/ 87 form_data = section.getElementsByClassName('posts_data_ajax'); 88 if (!form_data.length) { return; } 89 form_data = form_data[0]; 90 91 /*Get field data*/ 92 field_data = form_data.getElementsByClassName('data_ajax'); 93 if (!field_data.length) { return; } 94 field_data = field_data[0]; 95 96 /* Get param loadmore */ 97 data = field_data.value; 98 request_data = JSON.parse(data); 99 request_data['action'] = 'loadmore'; 100 101 /* Get btn loadmore */ 102 btn_loadmore = section.getElementsByClassName('btn-loadmore'); 103 if (!btn_loadmore.length) { return; } 104 btn_loadmore = btn_loadmore[0]; 105 106 btn_loadmore.addEventListener( 'click', 107 function(e) { 108 e.preventDefault(); 109 $(this).addClass('loading'); 110 otAjaxQuery(grid, section, request_data, pGlightbox); 111 }, 112 false 113 ); 114 115 } 116 117 /** 118 * Elementor JS Hooks 119 */ 120 $(window).on("elementor/frontend/init", function () { 121 if ( window.elementorFrontend.isEditMode() ) { 122 /* Portfolio filter isotop */ 123 window.elementorFrontend.hooks.addAction( 124 "frontend/element_ready/ot-portfolio-filter.default", 125 function () { 126 otAjaxLoad(); 127 } 128 ); 129 window.elementorFrontend.hooks.addAction( 130 "frontend/element_ready/ot-portfolio-filter_2.default", 131 function () { 132 otAjaxLoad(); 133 } 134 ); 135 } 136 }); 137 138})(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.