Gists

by djrmom - 8 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 - 1 year 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 - 2 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 );

by mgibbs189 - 5 years ago

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

var FWPBB = FWPBB || {};

(function($) {

    // Prevent BB scroll
    FLBuilderLayout._scrollToElement = function(el, callback) {
        var config  = FLBuilderLayoutConfig.anchorLinkAnimations;

        if (el.length > 0) {

            // See _initAnchorLink() within bb-plugin/js/fl-builder-layout.js
            if ( el.hasClass( 'fl-scroll-link' ) || el.hasClass( 'fl-row' ) || el.hasClass( 'fl-col' ) || el.hasClass( 'fl-module' ) ) {
                var ot = el.offset().top,
                    dh = $(document).height(),
                    wh = $(window).height();

                var dest = (ot > dh - wh) ? (dh - wh) : (ot - config.offset);

                $('html, body').animate({ scrollTop: dest }, config.duration, config.easing, function() {
                    if ('undefined' != typeof callback) {
                        callback();
                    }
                });
            }
        }
    }

    // Grids
    FWPBB.init_grids = function() {
        $.each(FWPBB.modules, function(id, obj) {
            if ('grid' === obj.layout) {
                if ('post-grid' === obj.type) {
                    new FLBuilderPostGrid(obj);
                    $('.fl-node-' + id + ' .fl-post-grid').masonry('reloadItems');
                }
                else if ('pp-content-grid' === obj.type) {
                    new PPContentGrid(obj);
                }
                else if ('blog-posts' === obj.type) {
                    new UABBBlogPosts(obj);
                }
            }
            else if ('gallery' == obj.layout) {
                new FLBuilderPostGrid(obj);

                $('.fl-post-gallery-img').each(function() {
                    $(this)[0].style.setProperty('max-width', '100%', 'important');
                });
            }
        });
        clean_pager();
    }

    function clean_pager() {
        $('a.page-numbers').attr('href', '').each(function() {
            $(this).trigger('init');
        });
    }

    // Pagination
    $(document).on('click init', 'a.page-numbers', function(e) {
        e.preventDefault();
        var clicked = $(this);
        var page = clicked.text();

        if (clicked.hasClass('prev')) { // previous
            page = FWP.settings.pager.page - 1;
        }

        if (clicked.hasClass('next')) { // next
            page = FWP.settings.pager.page + 1;
        }

        $('.page-numbers').removeClass('current');
        clicked.addClass('current');

        if (e.type === 'click') {
            FWP.paged = page;
            FWP.soft_refresh = true;
            FWP.refresh();
        }
        else {
            FWP.facets['paged'] = page;
            clicked.attr('href', '?' + FWP.build_query_string());
        }
    });

    // Set Trigger
    $(document).on('facetwp-loaded', function() {
        if (FWP.loaded || FWP.is_bfcache) {
            FWPBB.init_grids();
        }
    });
    $(document).on('facetwp-refresh', function() {
        if ($('.facetwp-template:first').hasClass('facetwp-bb-module')) {
            FWP.template = 'wp';
        }
    });

})(jQuery);
by djrmom - 4 days 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();