1(function($) { 2 'use strict'; 3 4 $(document).ready(function() { 5 $(document).on('click', '.load-more-btn', function() { 6 const btn = $(this); 7 const widget = btn.closest('.news-list-widget'); 8 const initialGrid = widget.find('.news-list-grid').first(); 9 10 if (btn.hasClass('loading')) return; 11 12 const page = parseInt(btn.data('page')) + 1; // still tracked for UI 13 const postType = btn.data('post-type'); 14 const perPage = parseInt(btn.data('per-page')); 15 const total = parseInt(btn.data('total')); 16 const loaded = parseInt(btn.data('loaded')); 17 18 btn.addClass('loading').prop('disabled', true); 19 20 $.ajax({ 21 url: ajax_object.ajax_url, 22 type: 'POST', 23 data: { 24 action: 'load_more_news', 25 page: page, 26 post_type: postType, 27 posts_per_page: perPage, 28 offset: loaded // critical: continue right after already loaded items 29 }, 30 success: function(response) { 31 if (response && response.success && response.data && response.data.html) { 32 let ajaxContainer = widget.find('.news-list-grid-ajax'); 33 if (!ajaxContainer.length) {
34 ajaxContainer = $('<div class="news-list-grid news-list-grid-ajax"></div>'); 35 initialGrid.after(ajaxContainer); 36 } 37 38 ajaxContainer.append(response.data.html); 39 40 const newLoaded = loaded + (response.data.count || 0); 41 btn.data('loaded', newLoaded); 42 btn.data('page', page); 43 44 if (newLoaded >= total || (response.data.count || 0) === 0) { 45 btn.closest('.load-more-container').fadeOut(); 46 } 47 } 48 }, 49 error: function() { 50 alert('Erreur lors du chargement des articles.'); 51 }, 52 complete: function() { 53 btn.removeClass('loading').prop('disabled', false); 54 } 55 }); 56 }); 57 }); 58 59 $('.detail_toggle').click(function(e){ 60 e.preventDefault() 61 var $detail = $(this).prev() 62 $detail.toggleClass('displayed') 63 if($detail.hasClass('displayed')){ 64 $(this).text("Moins d'informations") 65 }else { 66 $(this).text("Plus d'informations") 67 } 68 }) 69 70})(jQuery); 71 72
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.