Gists

by djrmom - 5 months 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);
by mgibbs189 - 11 months 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);
}
by djrmom - 1 year 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 } );
by mgibbs189 - 1 year ago

<?php

// Add the following into functions.php

add_action( 'wp_footer', function() {
?>
<script>
(function($) {
    $(document).on('facetwp-loaded', function() {
        if (FWP.loaded) { // trigger only after the initial refresh
            $blogGrid = $( '.fusion-blog-layout-grid' );
			$blogGrid.imagesLoaded(function() {
				$items = $blogGrid.find( 'article' );
				$blogGrid.isotope( 'appended', $items ).isotope('layout');
			});
        }
     });
})(jQuery);
</script>
<?php
}, 100 );

by mgibbs189 - 5 years ago

<script>
(function($) {
  $(document).on('facetwp-loaded', function() {
    $('.blog-grid').packery({
      itemSelector: '.blog-item'
    });
  });
})(jQuery);
</script>
by djrmom - 8 months 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 );
by djrmom - 2 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);
by mgibbs189 - 5 years ago

<?php

$args = array(
    'posts_per_page' => -1,
    'post_type' => 'bookshelf',
    'post_status' => 'publish',
    'tax_query' => array( // Query on the "Co-Authors Plus" custom taxonomy
        array(
            'taxonomy' => 'author',
            'terms' => $author // the author ID
        )
    )
);

// The Query
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
    echo '<div class="masonry-item"><h2>Bookshelf</h2>';
    echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>';
        echo '<a href="'.get_permalink().'">'.get_the_title().'</a>';
        echo '</li>';
    }
    echo '</ul></div>';
}

wp_reset_postdata();