updated plugin GP Premium
version 2.0.3
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
jQuery( document ).ready( function($) {
|
||||
jQuery( function( $ ) {
|
||||
// Featured image controls
|
||||
var featured_image_archive_controls = [
|
||||
var featuredImageArchiveControls = [
|
||||
'generate_blog_settings-post_image',
|
||||
'generate_blog_settings-post_image_padding',
|
||||
'generate_blog_settings-post_image_position',
|
||||
@ -11,11 +11,11 @@ jQuery( document ).ready( function($) {
|
||||
'generate_regenerate_images_notice',
|
||||
];
|
||||
|
||||
$.each( featured_image_archive_controls, function( index, value ) {
|
||||
$.each( featuredImageArchiveControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-archives' );
|
||||
} );
|
||||
|
||||
var featured_image_single_controls = [
|
||||
var featuredImageSingleControls = [
|
||||
'generate_blog_settings-single_post_image',
|
||||
'generate_blog_settings-single_post_image_padding',
|
||||
'generate_blog_settings-single_post_image_position',
|
||||
@ -26,17 +26,17 @@ jQuery( document ).ready( function($) {
|
||||
'generate_regenerate_single_post_images_notice',
|
||||
];
|
||||
|
||||
$.each( featured_image_single_controls, function( index, value ) {
|
||||
$.each( featuredImageSingleControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-single' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden'
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
|
||||
var featured_image_page_controls = [
|
||||
var featuredImagePageControls = [
|
||||
'generate_blog_settings-page_post_image',
|
||||
'generate_blog_settings-page_post_image_padding',
|
||||
'generate_blog_settings-page_post_image_position',
|
||||
@ -47,18 +47,18 @@ jQuery( document ).ready( function($) {
|
||||
'generate_regenerate_page_images_notice',
|
||||
];
|
||||
|
||||
$.each( featured_image_page_controls, function( index, value ) {
|
||||
$.each( featuredImagePageControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-page' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden'
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
|
||||
// Post meta controls
|
||||
var post_meta_archive_controls = [
|
||||
var postMetaArchiveControls = [
|
||||
'generate_settings-post_content',
|
||||
'generate_blog_settings-excerpt_length',
|
||||
'generate_blog_settings-read_more',
|
||||
@ -74,11 +74,11 @@ jQuery( document ).ready( function($) {
|
||||
'blog_masonry_loading_control',
|
||||
];
|
||||
|
||||
$.each( post_meta_archive_controls, function( index, value ) {
|
||||
$.each( postMetaArchiveControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-archives' );
|
||||
} );
|
||||
|
||||
var post_meta_single_controls = [
|
||||
var postMetaSingleControls = [
|
||||
'generate_blog_settings-single_date',
|
||||
'generate_blog_settings-single_author',
|
||||
'generate_blog_settings-single_categories',
|
||||
@ -86,13 +86,13 @@ jQuery( document ).ready( function($) {
|
||||
'generate_blog_settings-single_post_navigation',
|
||||
];
|
||||
|
||||
$.each( post_meta_single_controls, function( index, value ) {
|
||||
$.each( postMetaSingleControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-single' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden'
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
});
|
||||
} );
|
||||
|
@ -5,39 +5,38 @@
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
|
||||
// Container width
|
||||
wp.customize( 'generate_settings[container_width]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( $( '.masonry-container' )[0] ) {
|
||||
var $initiate = jQuery('.masonry-container').imagesLoaded( function() {
|
||||
$container = jQuery('.masonry-container');
|
||||
if (jQuery($container).length) {
|
||||
$container.masonry({
|
||||
value.bind( function() {
|
||||
if ( $( '.masonry-container' )[ 0 ] ) {
|
||||
jQuery( '.masonry-container' ).imagesLoaded( function() {
|
||||
$container = jQuery( '.masonry-container' );
|
||||
if ( jQuery( $container ).length ) {
|
||||
$container.masonry( {
|
||||
columnWidth: '.grid-sizer',
|
||||
itemSelector: '.masonry-post',
|
||||
stamp: '.page-header'
|
||||
});
|
||||
stamp: '.page-header',
|
||||
} );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
$( 'body' ).on( 'generate_spacing_updated', function() {
|
||||
if ( $( '.masonry-container' )[0] ) {
|
||||
var $initiate = jQuery('.masonry-container').imagesLoaded( function() {
|
||||
$container = jQuery('.masonry-container');
|
||||
if (jQuery($container).length) {
|
||||
$container.masonry({
|
||||
if ( $( '.masonry-container' )[ 0 ] ) {
|
||||
jQuery( '.masonry-container' ).imagesLoaded( function() {
|
||||
$container = jQuery( '.masonry-container' );
|
||||
if ( jQuery( $container ).length ) {
|
||||
$container.masonry( {
|
||||
columnWidth: '.grid-sizer',
|
||||
itemSelector: '.masonry-post',
|
||||
stamp: '.page-header'
|
||||
});
|
||||
stamp: '.page-header',
|
||||
} );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
/**
|
||||
* The first infinite scroll load in the Customizer misses article classes if they've been
|
||||
@ -45,34 +44,33 @@
|
||||
*
|
||||
* This is totally hacky, but I'm just happy I finally got it working!
|
||||
*/
|
||||
var $container = $( 'article' ).first().parent();
|
||||
$container.on( 'load.infiniteScroll', function( event, response, path ) {
|
||||
$posts = $( response ).find( 'article' );
|
||||
if ( wp.customize.value('generate_blog_settings[column_layout]')() ) {
|
||||
var $container = $( '.infinite-scroll-item' ).first().parent();
|
||||
$container.on( 'load.infiniteScroll', function( event, response ) {
|
||||
var $posts = $( response ).find( 'article' );
|
||||
if ( wp.customize.value( 'generate_blog_settings[column_layout]' )() ) {
|
||||
$posts.addClass( 'generate-columns' );
|
||||
$posts.addClass( 'grid-parent' );
|
||||
$posts.addClass( 'grid-' + wp.customize.value('generate_blog_settings[columns]')() );
|
||||
$posts.addClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
|
||||
$posts.addClass( 'tablet-grid-50' );
|
||||
$posts.addClass( 'mobile-grid-100' );
|
||||
} else {
|
||||
$posts.removeClass( 'generate-columns' );
|
||||
$posts.removeClass( 'grid-parent' );
|
||||
$posts.removeClass( 'grid-' + wp.customize.value('generate_blog_settings[columns]')() );
|
||||
$posts.removeClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
|
||||
$posts.removeClass( 'tablet-grid-50' );
|
||||
$posts.removeClass( 'mobile-grid-100' );
|
||||
}
|
||||
|
||||
if ( wp.customize.value('generate_blog_settings[masonry]')() ) {
|
||||
if ( wp.customize.value( 'generate_blog_settings[masonry]' )() ) {
|
||||
$posts.addClass( 'masonry-post' );
|
||||
} else {
|
||||
$posts.removeClass( 'masonry-post' );
|
||||
}
|
||||
|
||||
if ( ! wp.customize.value('generate_blog_settings[post_image_padding]')() ) {
|
||||
if ( ! wp.customize.value( 'generate_blog_settings[post_image_padding]' )() ) {
|
||||
$posts.addClass( 'no-featured-image-padding' );
|
||||
} else {
|
||||
$posts.removeClass( 'no-featured-image-padding' );
|
||||
}
|
||||
});
|
||||
|
||||
} )( jQuery );
|
||||
} );
|
||||
}( jQuery ) );
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,33 +1,41 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var $masonry_container = $( '.masonry-container' );
|
||||
var msnry = false;
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
var msnryContainer = document.querySelector( '.masonry-container' );
|
||||
|
||||
if ( $masonry_container.length ) {
|
||||
var $grid = $masonry_container.masonry( generateBlog.masonryInit );
|
||||
if ( msnryContainer ) {
|
||||
// eslint-disable-next-line no-undef -- Masonry is a dependency.
|
||||
var msnry = new Masonry( msnryContainer, generateBlog.masonryInit ),
|
||||
navBelow = document.querySelector( '#nav-below' ),
|
||||
loadMore = document.querySelector( '.load-more' );
|
||||
|
||||
msnry = $grid.data( 'masonry' );
|
||||
// eslint-disable-next-line no-undef -- imagesLoaded is a dependency.
|
||||
imagesLoaded( msnryContainer, function() {
|
||||
msnry.layout();
|
||||
msnryContainer.classList.remove( 'are-images-unloaded' );
|
||||
|
||||
$grid.imagesLoaded( function() {
|
||||
$grid.masonry( 'layout' );
|
||||
$grid.removeClass( 'are-images-unloaded' );
|
||||
$( '.load-more' ).removeClass( 'are-images-unloaded' );
|
||||
$( '#nav-below' ).css( 'opacity', '1' );
|
||||
$grid.masonry( 'option', { itemSelector: '.masonry-post' });
|
||||
var $items = $grid.find( '.masonry-post' );
|
||||
$grid.masonry( 'appended', $items );
|
||||
if ( loadMore ) {
|
||||
loadMore.classList.remove( 'are-images-unloaded' );
|
||||
}
|
||||
|
||||
if ( navBelow ) {
|
||||
navBelow.style.opacity = 1;
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#nav-below' ).insertAfter( '.masonry-container' );
|
||||
msnryContainer.parentNode.insertBefore( navBelow, msnryContainer.nextSibling );
|
||||
|
||||
$( window ).on( "orientationchange", function( event ) {
|
||||
$grid.masonry( 'layout' );
|
||||
window.addEventListener( 'orientationchange', function() {
|
||||
msnry.layout();
|
||||
} );
|
||||
}
|
||||
|
||||
if ( $( '.infinite-scroll' ).length && $( '.nav-links .next' ).length ) {
|
||||
var $container = $( '#main article' ).first().parent();
|
||||
var $button = $( '.load-more a' );
|
||||
var svgIcon = '';
|
||||
var hasInfiniteScroll = document.querySelector( '.infinite-scroll' ),
|
||||
nextLink = document.querySelector( '.infinite-scroll-path a' );
|
||||
|
||||
if ( hasInfiniteScroll && nextLink ) {
|
||||
var infiniteItems = document.querySelectorAll( '.infinite-scroll-item' ),
|
||||
container = infiniteItems[ 0 ].parentNode,
|
||||
button = document.querySelector( '.load-more a' ),
|
||||
svgIcon = '';
|
||||
|
||||
if ( generateBlog.icon ) {
|
||||
svgIcon = generateBlog.icon;
|
||||
@ -37,37 +45,54 @@ jQuery( document ).ready( function( $ ) {
|
||||
|
||||
infiniteScrollInit.outlayer = msnry;
|
||||
|
||||
$container.infiniteScroll( infiniteScrollInit );
|
||||
// eslint-disable-next-line no-undef -- InfiniteScroll is a dependency.
|
||||
var infiniteScroll = new InfiniteScroll( container, infiniteScrollInit );
|
||||
|
||||
$button.on( 'click', function( e ) {
|
||||
document.activeElement.blur();
|
||||
$( this ).html( svgIcon + generateBlog.loading ).addClass( 'loading' );
|
||||
} );
|
||||
if ( button ) {
|
||||
button.addEventListener( 'click', function( e ) {
|
||||
document.activeElement.blur();
|
||||
e.target.innerHTML = svgIcon + generateBlog.loading;
|
||||
e.target.classList.add( 'loading' );
|
||||
} );
|
||||
}
|
||||
|
||||
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
|
||||
if ( ! $( '.generate-columns-container' ).length ) {
|
||||
$container.append( $button.parent() );
|
||||
infiniteScroll.on( 'append', function( response, path, items ) {
|
||||
if ( button && ! document.querySelector( '.generate-columns-container' ) ) {
|
||||
container.appendChild( button.parentNode );
|
||||
}
|
||||
|
||||
// Fix srcset images not loading in Safari.
|
||||
// img.outerHTML = img.outerHTML isn't minified properly, so we need the extra var.
|
||||
$( items ).find( 'img' ).each( function( index, img ) {
|
||||
var imgOuterHTML = img.outerHTML;
|
||||
img.outerHTML = imgOuterHTML;
|
||||
items.forEach( function( element ) {
|
||||
var images = element.querySelectorAll( 'img' );
|
||||
|
||||
if ( images ) {
|
||||
images.forEach( function( image ) {
|
||||
var imgOuterHTML = image.outerHTML;
|
||||
image.outerHTML = imgOuterHTML;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( $grid ) {
|
||||
$grid.imagesLoaded( function() {
|
||||
$grid.masonry( 'layout' );
|
||||
if ( msnryContainer && msnry ) {
|
||||
// eslint-disable-next-line no-undef -- ImagesLoaded is a dependency.
|
||||
imagesLoaded( msnryContainer, function() {
|
||||
msnry.layout();
|
||||
} );
|
||||
}
|
||||
|
||||
$button.html( svgIcon + generateBlog.more ).removeClass( 'loading' );
|
||||
$( document.body ).trigger( 'post-load' );
|
||||
if ( button ) {
|
||||
button.innerHTML = svgIcon + generateBlog.more;
|
||||
button.classList.remove( 'loading' );
|
||||
}
|
||||
|
||||
document.body.dispatchEvent( new Event( 'post-load' ) );
|
||||
} );
|
||||
|
||||
$container.on( 'last.infiniteScroll', function() {
|
||||
$( '.load-more' ).hide();
|
||||
infiniteScroll.on( 'last', function() {
|
||||
var loadMoreElement = document.querySelector( '.load-more' );
|
||||
|
||||
if ( loadMoreElement ) {
|
||||
loadMoreElement.style.display = 'none';
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
@ -1 +1 @@
|
||||
jQuery(document).ready(function(t){var i,r,l,s,n,e=t(".masonry-container"),o=!1;e.length&&(o=(i=e.masonry(generateBlog.masonryInit)).data("masonry"),i.imagesLoaded(function(){i.masonry("layout"),i.removeClass("are-images-unloaded"),t(".load-more").removeClass("are-images-unloaded"),t("#nav-below").css("opacity","1"),i.masonry("option",{itemSelector:".masonry-post"});var n=i.find(".masonry-post");i.masonry("appended",n)}),t("#nav-below").insertAfter(".masonry-container"),t(window).on("orientationchange",function(n){i.masonry("layout")})),t(".infinite-scroll").length&&t(".nav-links .next").length&&(r=t("#main article").first().parent(),l=t(".load-more a"),s="",generateBlog.icon&&(s=generateBlog.icon),(n=generateBlog.infiniteScrollInit).outlayer=o,r.infiniteScroll(n),l.on("click",function(n){document.activeElement.blur(),t(this).html(s+generateBlog.loading).addClass("loading")}),r.on("append.infiniteScroll",function(n,e,o,a){t(".generate-columns-container").length||r.append(l.parent()),t(a).find("img").each(function(n,e){var o=e.outerHTML;e.outerHTML=o}),i&&i.imagesLoaded(function(){i.masonry("layout")}),l.html(s+generateBlog.more).removeClass("loading"),t(document.body).trigger("post-load")}),r.on("last.infiniteScroll",function(){t(".load-more").hide()}))});
|
||||
document.addEventListener("DOMContentLoaded",function(){var t,e,n,r=document.querySelector(".masonry-container");r&&(t=new Masonry(r,generateBlog.masonryInit),e=document.querySelector("#nav-below"),n=document.querySelector(".load-more"),imagesLoaded(r,function(){t.layout(),r.classList.remove("are-images-unloaded"),n&&n.classList.remove("are-images-unloaded"),e&&(e.style.opacity=1)}),r.parentNode.insertBefore(e,r.nextSibling),window.addEventListener("orientationchange",function(){t.layout()}));var a,i,l,o,c,d=document.querySelector(".infinite-scroll"),u=document.querySelector(".infinite-scroll-path a");d&&u&&(a=document.querySelectorAll(".infinite-scroll-item")[0].parentNode,i=document.querySelector(".load-more a"),l="",generateBlog.icon&&(l=generateBlog.icon),(o=generateBlog.infiniteScrollInit).outlayer=t,c=new InfiniteScroll(a,o),i&&i.addEventListener("click",function(e){document.activeElement.blur(),e.target.innerHTML=l+generateBlog.loading,e.target.classList.add("loading")}),c.on("append",function(e,n,o){i&&!document.querySelector(".generate-columns-container")&&a.appendChild(i.parentNode),o.forEach(function(e){var n=e.querySelectorAll("img");n&&n.forEach(function(e){var n=e.outerHTML;e.outerHTML=n})}),r&&t&&imagesLoaded(r,function(){t.layout()}),i&&(i.innerHTML=l+generateBlog.more,i.classList.remove("loading")),document.body.dispatchEvent(new Event("post-load"))}),c.on("last",function(){var e=document.querySelector(".load-more");e&&(e.style.display="none")}))});
|
Reference in New Issue
Block a user