1/*! ajax.min.js */ 2jQuery(function($){ 3 4 // Related 5 if ( typeof ajax_js_related_params !== 'undefined' && ajax_js_related_params.page_type == 'single' ) { 6 var per_page = ajax_js_related_params.per_page; 7 var current_page = ajax_js_related_params.current_page; 8 9 $(".ajax-related-loadmore").on("click",function(){ 10 var button = $(this); 11 current_page++; 12 var str = '¤t_page=' + current_page + '&per_page=' + per_page + '&action=related_loadmore'; 13 $.ajax({ 14 type: "POST", 15 dataType: "html", 16 url: ajax_js_related_params.ajaxurl, 17 data: str, 18 beforeSend : function ( xhr ) { 19 button.hide(); 20 button.next().show(); // change the button text, you can also add a preloader image 21 }, 22 success: function(data){ 23 var $data = $(data); 24 if( $data.length ) { 25 button.show().before($data); // insert new posts 26 button.next().hide(); 27 if ( current_page == ajax_js_related_params.max_page ) 28 button.remove(); // if last page, remove the button 29 } else { 30 button.remove(); // if no data, remove the button as well 31 } 32 if (typeof getDataRefresh == 'function') { 33 getDataRefresh(); 34 } 35 }, 36 error : function(jqXHR, textStatus, errorThrown) { 37 $loader.html(jqXHR + " :: " + textStatus + " :: " + errorThrown); 38 } 39 40 }); 41 return false; 42 }); 43 44 } 45 46 // Archive 47 if ( typeof ajax_js_params !== 'undefined' && ajax_js_params.page_type == 'archive' ) { 48 $('.ajax-loadmore').click(function(){ 49 50 var button = $(this), 51 data = { 52 'action': 'loadmore', 53 'query': ajax_js_params.posts, // that's how we get params from wp_localize_script() function 54 'page' : ajax_js_params.current_page, 55 56 }; 57 58 $.ajax({ // you can also use $.post here 59 url : ajax_js_params.ajaxurl, // AJAX handler 60 data : data, 61 type : 'POST', 62 beforeSend : function ( xhr ) { 63 button.hide(); 64 button.next().show(); // change the button text, you can also add a preloader image 65 }, 66 success : function( data ){ 67 if( data ) { 68 button.show().before(data); // insert new posts 69 ajax_js_params.current_page++; 70 button.next().hide(); 71 if ( ajax_js_params.current_page == ajax_js_params.max_page ) 72 button.remove(); // if last page, remove the button 73 74 // you can also fire the "post-load" event here if you use a plugin that requires it 75 // $( document.body ).trigger( 'post-load' ); 76 } else { 77 button.remove(); // if no data, remove the button as well 78 } 79 if (typeof getDataRefresh == 'function') { 80 getDataRefresh(); 81 } 82 }, 83 error : function(jqXHR, textStatus, errorThrown) { 84 $loader.html(jqXHR + " :: " + textStatus + " :: " + errorThrown); 85 } 86 }); 87 }); 88 89 // Integrate: Loading 90 $('.ajax-loading').hide(); 91 92 // Integrate: SEO / Ajax 93 $(function () { 94 var currentHash = "" 95 $(document).scroll(function () { 96 $('.change-url').each(function () { 97 var top = window.pageYOffset; 98 var distance = top - $(this).offset().top; 99 var base = $('.ajax-list').attr('data-base'); 100 var hash = $(this).attr('data-page'); 101 var hashbase = base+hash; 102 103 if (distance < 100 && distance > -100 && currentHash != hash) { 104 105 // Change URL 106 window.history.replaceState( '', '', hashbase ); 107 currentHash = hash; 108 109 // Refresh data 110 if (typeof getAnalyticsDataRefreshArchive == 'function') { 111 getAnalyticsDataRefreshArchive(); 112 } 113 } 114 }); 115 }); 116 }); 117 } 118 119});
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.