Gists

6 months ago
<?php
/** re-triggers masonry from generate press pro plugin after facet loads **/
add_action( 'wp_head', function() { ?>
<script>
document.addEventListener('facetwp-loaded', function() {
	var msnry = new Masonry( ".facetwp-template", generateBlog.masonryInit );	
	msnry.layout();
});
</script>
<?php }, 100 );
3 years ago
(function($) {
    $(document).on('facetwp-loaded', function() {
        $(".init-masonry-intrinsic").each(function() {
            var t = $(this)
              , e = $(this).data("masonry-selector")
              , i = !0;
            $("body.rtl").length && (i = !1),
            t.masonry({
                itemSelector: e,
                isOriginLeft: i
            }),
            t.find(".kt_item_fade_in").each(function(t) {
                $(this).delay(75 * t).animate({
                    opacity: 1
                }, 175)
            })
        })
    });
})(jQuery);
4 years ago
function resizeGridItem(item){
  grid = document.getElementsByClassName("fwpl-layout")[0];
  rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
  rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
  rowSpan = Math.ceil((item.querySelector('.fwpl-row').getBoundingClientRect().height+rowGap)/(rowHeight+rowGap));
    item.style.gridRowEnd = "span "+rowSpan;
}

function resizeAllGridItems(){
  allItems = document.getElementsByClassName("fwpl-result");
  for(x=0;x<allItems.length;x++){
    resizeGridItem(allItems[x]);
  }
}

function resizeInstance(instance){
	item = instance.elements[0];
  resizeGridItem(item);
}

window.onload = resizeAllGridItems();
window.addEventListener("resize", resizeAllGridItems);

allItems = document.getElementsByClassName("fwpl-result");
for(x=0;x<allItems.length;x++){
  imagesLoaded( allItems[x], resizeInstance);
}
4 years ago
<?php
/**
 ** re-run masonry layout for beaver builder masonry post module after refreshing facets
 **/
add_action( 'wp_head', function() { ?>

    <script>
        (function($) {
            $(document).on('facetwp-loaded', function() {
                var $element 		= 'undefined' == typeof element ? $( 'body' ) : $( element ),
                    msnryContent	= $element.find('.masonry');
                if ( msnryContent.length )	{
                    msnryContent.masonry('layout');
                }
            });
        })(jQuery);
    </script>

<?php } );
4 years ago
<?php

// Add the following into functions.php

add_action( 'wp_footer', function() {
?>
<script>
(function($) {
    $(document).on('facetwp-loaded', function() {
        if (FWP.loaded) {
            $grid = $('.fusion-blog-layout-grid');
            $grid.isotope('appended', $grid.find('article'));
            $grid.imagesLoaded(function() {
                $grid.isotope('layout');
            });
        }
    });
})(jQuery);
</script>
<?php
}, 100 );
1 year ago
<script>

(function($) {
    $(document).on('facetwp-loaded', function() {
        var $grid = $('.columns-3').imagesLoaded(function() {
            $grid.isotope({
                layoutMode: 'masonry',
                itemSelector : '.product',
                masonry: {
                    columnWidth: '.product',
                }
            });
        });
    });
})(jQuery);

</script>
3 years ago
(function($) {
    $(document).on('facetwp-loaded', function() {
        if (FWP.loaded) { // trigger only after the initial refresh
            $blogGrid = $( '.fusion-blog-layout-grid' ); // this to the class or id to apply isotope to
	        $blogGrid.isotope( {
                // options - change these options to match the isotope options in use - https://isotope.metafizzy.co/options.html
                itemSelector: 'article',
                layoutMode: 'masonry'
            });
            $blogGrid.imagesLoaded(function() {
                $blogGrid.isotope('layout');
            });
        }
     });
})(jQuery);
4 years ago
<?php
/** add additional classes / id to the facetwp-template div generated by a facetwp 
 ** layout template
 **/
add_filter( 'facetwp_shortcode_html', function( $output, $atts) {
	if ( $atts['template'] = 'example' ) { // replace 'example' with name of your template
    /** modify replacement as needed, make sure you keep the facetwp-template class **/
		$output = str_replace( 'class="facetwp-template"', 'id="masonry-container" class="facetwp-template small-up-1 medium-up-2 large-up-3"', $output );
	}
	return $output; 
}, 10, 2 );
5 years ago
(function($) {
    $(document).on('facetwp-loaded', function() {
    if ( $().isotope ) {

      var $container = $( '#tribe-events-photo-events' )

      $container.isotope({
        itemSelector: '.tribe-events-photo-event',
        percentPosition: true,
        masonry: {
          columnWidth: '.tribe-events-photo-grid-sizer',
          gutter: '.tribe-events-photo-gutter-sizer'
        }
      });

      $container.imagesLoaded().progress( function() {
        $container.isotope( 'layout' );
      });

    } else {
      $( '#tribe-events-photo-events' ).removeClass( "photo-hidden" ).css( "opacity", "1" );
    }
      
     });
})(jQuery);