summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
committerAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
commit10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch)
treeb4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/modules/infinite-scroll
parentUpdating script for Update (diff)
downloadblogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/infinite-scroll')
-rw-r--r--plugins/jetpack/modules/infinite-scroll/infinity.js84
-rw-r--r--plugins/jetpack/modules/infinite-scroll/infinity.php13
2 files changed, 64 insertions, 33 deletions
diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.js b/plugins/jetpack/modules/infinite-scroll/infinity.js
index 67eed745..24dd413e 100644
--- a/plugins/jetpack/modules/infinite-scroll/infinity.js
+++ b/plugins/jetpack/modules/infinite-scroll/infinity.js
@@ -1,3 +1,4 @@
+/* globals infiniteScroll, _wpmejsSettings, ga, _gaq, WPCOM_sharing_counts */
( function( $ ) {
// Open closure
// Local vars
@@ -7,7 +8,7 @@
var isIE = -1 != navigator.userAgent.search( 'MSIE' );
if ( isIE ) {
var IEVersion = navigator.userAgent.match( /MSIE\s?(\d+)\.?\d*;/ );
- var IEVersion = parseInt( IEVersion[ 1 ] );
+ IEVersion = parseInt( IEVersion[ 1 ] );
}
// HTTP ajaxurl when site is HTTPS causes Access-Control-Allow-Origin failure in Desktop and iOS Safari
@@ -176,12 +177,17 @@
width = $( 'body #' + this.footer.wrap ).outerWidth( false );
// Make the footer match the width of the page
- if ( width > 479 ) this.footer.find( '.container' ).css( 'width', width );
+ if ( width > 479 ) {
+ this.footer.find( '.container' ).css( 'width', width );
+ }
}
// Reveal footer
- if ( this.window.scrollTop() >= 350 ) self.footer.animate( { bottom: 0 }, 'fast' );
- else if ( this.window.scrollTop() < 350 ) self.footer.animate( { bottom: '-50px' }, 'fast' );
+ if ( this.window.scrollTop() >= 350 ) {
+ self.footer.animate( { bottom: 0 }, 'fast' );
+ } else if ( this.window.scrollTop() < 350 ) {
+ self.footer.animate( { bottom: '-50px' }, 'fast' );
+ }
};
/**
@@ -197,7 +203,9 @@
customized;
// If we're disabled, ready, or don't pass the check, bail.
- if ( this.disabled || ! this.ready || ! this.check() ) return;
+ if ( this.disabled || ! this.ready || ! this.check() ) {
+ return;
+ }
// Let's get going -- set ready to false to prevent
// multiple refreshes from occurring at once.
@@ -323,11 +331,14 @@
if (
this.conditional &&
( ! isIE || ! eval( this.conditional.replace( /%ver/g, IEVersion ) ) )
- )
- var style = false;
+ ) {
+ style = false;
+ }
// Append link tag if necessary
- if ( style ) document.getElementsByTagName( 'head' )[ 0 ].appendChild( style );
+ if ( style ) {
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( style );
+ }
} );
}
@@ -338,17 +349,19 @@
self.page++;
// Record pageview in WP Stats, if available.
- if ( stats )
+ if ( stats ) {
new Image().src =
document.location.protocol +
'//pixel.wp.com/g.gif?' +
stats +
'&post=0&baba=' +
Math.random();
+ }
// Add new posts to the postflair object
- if ( 'object' == typeof response.postflair && 'object' == typeof WPCOM_sharing_counts )
- WPCOM_sharing_counts = $.extend( WPCOM_sharing_counts, response.postflair );
+ if ( 'object' === typeof response.postflair && 'object' === typeof WPCOM_sharing_counts ) {
+ WPCOM_sharing_counts = $.extend( WPCOM_sharing_counts, response.postflair ); // eslint-disable-line no-global-assign
+ }
// Render the results
self.render.apply( self, arguments );
@@ -493,8 +506,11 @@
wrapperQty++;
} );
- if ( wrapperQty > 0 ) aveSetHeight = aveSetHeight / wrapperQty;
- else aveSetHeight = 0;
+ if ( wrapperQty > 0 ) {
+ aveSetHeight = aveSetHeight / wrapperQty;
+ } else {
+ aveSetHeight = 0;
+ }
// Load more posts if space permits, otherwise stop checking for a full viewport
if ( postsHeight < windowHeight && postsHeight + aveSetHeight < windowHeight ) {
@@ -615,8 +631,11 @@
var setData = setsInView.pop();
// If the first set of IS posts is in the same view as the posts loaded in the template by WordPress, determine how much of the view is comprised of IS-loaded posts
- if ( ( windowBottom - setData.top ) / windowSize < 0.5 ) pageNum = -1;
- else pageNum = setData.pageNum;
+ if ( ( windowBottom - setData.top ) / windowSize < 0.5 ) {
+ pageNum = -1;
+ } else {
+ pageNum = setData.pageNum;
+ }
} else {
var majorityPercentageInView = 0;
@@ -627,15 +646,20 @@
percentOfView = 0;
// Figure percentage of view the current set represents
- if ( setData.top > windowTop && setData.top < windowBottom )
+ if ( setData.top > windowTop && setData.top < windowBottom ) {
topInView = ( windowBottom - setData.top ) / windowSize;
+ }
- if ( setData.bottom > windowTop && setData.bottom < windowBottom )
+ if ( setData.bottom > windowTop && setData.bottom < windowBottom ) {
bottomInView = ( setData.bottom - windowTop ) / windowSize;
+ }
// Figure out largest percentage of view for current set
- if ( topInView >= bottomInView ) percentOfView = topInView;
- else if ( bottomInView >= topInView ) percentOfView = bottomInView;
+ if ( topInView >= bottomInView ) {
+ percentOfView = topInView;
+ } else if ( bottomInView >= topInView ) {
+ percentOfView = bottomInView;
+ }
// Does current set's percentage of view supplant the largest previously-found set?
if ( percentOfView > majorityPercentageInView ) {
@@ -647,7 +671,7 @@
// If a page number could be determined, update the URL
// -1 indicates that the original requested URL should be used.
- if ( 'number' == typeof pageNum ) {
+ if ( 'number' === typeof pageNum ) {
self.updateURL( pageNum );
}
};
@@ -662,14 +686,16 @@
return;
}
var self = this,
+ pageSlug = self.origURL;
+
+ if ( -1 !== page ) {
pageSlug =
- -1 == page
- ? self.origURL
- : window.location.protocol +
- '//' +
- self.history.host +
- self.history.path.replace( /%d/, page ) +
- self.history.parameters;
+ window.location.protocol +
+ '//' +
+ self.history.host +
+ self.history.path.replace( /%d/, page ) +
+ self.history.parameters;
+ }
if ( window.location.href != pageSlug ) {
history.pushState( null, null, pageSlug );
@@ -695,7 +721,9 @@
*/
$( document ).ready( function() {
// Check for our variables
- if ( 'object' != typeof infiniteScroll ) return;
+ if ( 'object' !== typeof infiniteScroll ) {
+ return;
+ }
$( document.body ).addClass( infiniteScroll.settings.body_class );
diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.php b/plugins/jetpack/modules/infinite-scroll/infinity.php
index 35193cfc..6b8d3775 100644
--- a/plugins/jetpack/modules/infinite-scroll/infinity.php
+++ b/plugins/jetpack/modules/infinite-scroll/infinity.php
@@ -1,14 +1,16 @@
<?php
+use Automattic\Jetpack\Assets;
+
/*
Plugin Name: The Neverending Home Page.
-Plugin URI: http://automattic.com/
+Plugin URI: https://automattic.com/
Description: Adds infinite scrolling support to the front-end blog post view for themes, pulling the next set of posts automatically into view when the reader approaches the bottom of the page.
Version: 1.1
Author: Automattic
-Author URI: http://automattic.com/
+Author URI: https://automattic.com/
License: GNU General Public License v2 or later
-License URI: http://www.gnu.org/licenses/gpl-2.0.html
+License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/**
@@ -16,6 +18,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
* styling from each theme; including fixed footer.
*/
class The_Neverending_Home_Page {
+
/**
* Register actions and filters, plus parse IS settings
*
@@ -432,7 +435,7 @@ class The_Neverending_Home_Page {
// Add our scripts.
wp_register_script(
'the-neverending-homepage',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/infinite-scroll/infinity.min.js',
'modules/infinite-scroll/infinity.js'
),
@@ -1608,7 +1611,7 @@ function the_neverending_home_page_init() {
if ( ! current_theme_supports( 'infinite-scroll' ) )
return;
- new The_Neverending_Home_Page;
+ new The_Neverending_Home_Page();
}
add_action( 'init', 'the_neverending_home_page_init', 20 );