Advertisement
Twansparant

Shaken Grid theme & Infinite Scroll

Nov 6th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.37 KB | None | 0 0
  1. // Change setIsotope function in script.js
  2. function setIsotope(){
  3.     if( jQuery(window).width() >= mobile_width && !isotope_set ){        
  4.             isotope_set = true;    
  5.         /* Works with Infinite Scroll version 2.0b2.120519 */
  6.         jQuery('.sort, #sort').isotope( {
  7.             itemSelector : '.box:not(.invis)',
  8.             //transformsEnabled: true, // must be default to avoid Opera conflict (should be false for Opera and true for other browsers)
  9.             masonry: { columnWidth : 175 }
  10.         });
  11.     }
  12. }
  13.  
  14. // Infinite Scroll Setup
  15. (function($) {
  16.     $(function(){
  17.         // Initialize Infinite Scroll
  18.         var $container = $('.sort');
  19.         $container.isotope({itemSelector : '.all'});
  20.         $container.infinitescroll({
  21.                 navSelector     : '.navigation',    // selector for the paged navigation
  22.                 nextSelector    : '.nav-previous a',  // selector for the NEXT link (to page 2)
  23.                 itemSelector    : '.all',     // selector for all items you'll retrieve
  24.                 loading                 : {
  25.                         img                     : '<?php echo get_stylesheet_directory_uri(); ?>/images/inf-loading-icon.gif',
  26.                         msgText                 : "Loading..",
  27.                         finishedMsg             : "Ill see you at the crossroads so you wont be lonely"
  28.                 },
  29.                 behaviour       : 'twitter',
  30.                 errorCallback: function() {
  31.                         // fade out the error message after 2 seconds
  32.                         $('#infscr-loading').animate({opacity: 0.8},2000).fadeOut('normal');
  33.                 }
  34.         },
  35.         // call Isotope as a callback
  36.         function( newElements, data ) {                  
  37.                 var $newElems = $(newElements).css({ opacity: 0 }); // hide new items while they are loading
  38.                 $newElems.imagesLoaded(function(){ // ensure that images load before adding to masonry layout
  39.                         $newElems.animate({ opacity: 1 }); // show elems now they're ready
  40.                         $container.isotope( 'insert', $newElems); // resort new isotope content ('insert' preserves current filter, 'appended' does not)
  41.                         $newElems.each(function(){
  42.                                 // Fancybox init      
  43.                                 $(this).find("a[rel='gallery'], a[rel='lightbox'], .gallery-icon a, .colorbox").fancybox({
  44.                                         padding: 0,
  45.                                         overlayColor: "#000",
  46.                                         overlayOpacity: 0.85,
  47.                                         titleShow: false
  48.                                 });
  49.                                 // Slides init
  50.                                 $(this).find('.slider').slides({
  51.                                         play: 9500,
  52.                                         pause: 2500,
  53.                                         hoverPause: true,
  54.                                         effect: 'fade',
  55.                                         generatePagination: false
  56.                                 });
  57.                                 // Share icons
  58.                                 $(this).find('.share-window').on('click', function(){
  59.                                         var width  = 650;
  60.                                         var height = 500;
  61.                                         var left   = (screen.width  - width)/2;
  62.                                         var top    = (screen.height - height)/2;
  63.                                         var params = 'width='+width+', height='+height;
  64.                                         params += ', top='+top+', left='+left;
  65.                                         params += ', directories=no';
  66.                                         params += ', location=no';
  67.                                         params += ', menubar=no';
  68.                                         params += ', resizable=no';
  69.                                         params += ', scrollbars=no';
  70.                                         params += ', status=no';
  71.                                         params += ', toolbar=no';
  72.                                         newwin=window.open($(this).attr('href'),'Share', params);
  73.                                         if (window.focus) {newwin.focus();}
  74.                                         return false;
  75.                                 });
  76.                                 // FitVids init
  77.                                 $(this).find('.vid-container').fitVids();
  78.                         });
  79.                 });
  80.         });
  81.         $(document).ajaxError(function(e,xhr,opt){
  82.               // remove 404 error 'page 2 not found'
  83.               if (xhr.status == 404) jQuery('.navigation .nav-previous a').remove();
  84.         });
  85.     });
  86. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement