Advertisement
beetrootman

Untitled

Aug 26th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | None | 0 0
  1. <?php
  2. // Template Name: Older Issues
  3. get_header(); ?>
  4.  
  5. <div id="content" role="main"><!-- Start content -->
  6.     <h3><?php the_title(); ?></h3>
  7.    
  8.     <?php get_template_part( 'loop', 'older' ); ?>
  9.  
  10. </div><!-- End content -->
  11. <div id="pagination" class="margin4"><?php paginate(); ?></div>
  12. <div id="inifiniteLoader" class="margin4">Loading more covers...</div>
  13. </div><!-- End container -->
  14. <script src="<?php bloginfo('template_directory'); ?>/js/lazy.js"></script>
  15. <script type="text/javascript">
  16. jQuery(document).ready(function($) {
  17.  
  18.     $("img.lazy").show().lazyload();
  19.        
  20.     $("img.lazy").lazyload({
  21.         threshold : 50,
  22.         effect : "fadeIn"
  23.     }).removeClass("lazy");
  24.    
  25.     $(document).ajaxStop(function(){
  26.    
  27.         $("img.lazy").show().lazyload();
  28.  
  29.         $("img.lazy").lazyload({
  30.             threshold : 50,
  31.             effect : "fadeIn"
  32.         }).removeClass("lazy");
  33.     });
  34.    
  35.     $('div#pagination').hide();
  36.     var inProgress = false;    
  37.     var count = 2;
  38.     var total = <?php echo $wp_query->max_num_pages; ?>;
  39.    
  40.     $(window).scroll(function(){
  41.             if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
  42.               if (!inProgress) {
  43.                 inProgress = true;
  44.                if (count > total){
  45.                     return false;
  46.                }else{
  47.                     loadArticle(count);
  48.                }
  49.                count++;
  50.             }
  51.     }}
  52.    
  53.     );
  54.  
  55.     function loadArticle(pageNumber){    
  56.             $('div#inifiniteLoader').show();
  57.             $.ajax({
  58.                 url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
  59.                 type:'POST',
  60.                 data: "action=infinite_scroll&page_no="+ count +"&loop_file=loop-older", // Change this for different loops
  61.                 success: function(html){
  62.                     $(html).hide().appendTo("#content").fadeIn(200);
  63.                     $('div#inifiniteLoader').hide();
  64.                     inProgress = false;
  65.                     return;
  66.                 }
  67.             });
  68.         return false;
  69.     }
  70.  
  71. });
  72. </script>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement