Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/infinite...
File: infinity.js
/* globals infiniteScroll, _wpmejsSettings, ga, _gaq, WPCOM_sharing_counts, MediaElementPlayer */
[0] Fix | Delete
( function () {
[1] Fix | Delete
// Open closure.
[2] Fix | Delete
// Local vars.
[3] Fix | Delete
var Scroller, stats, type, text, totop, loading_text;
[4] Fix | Delete
[5] Fix | Delete
// IE requires special handling
[6] Fix | Delete
var isIE = -1 !== navigator.userAgent.search( 'MSIE' );
[7] Fix | Delete
if ( isIE ) {
[8] Fix | Delete
var IEVersion = navigator.userAgent.match( /MSIE\s?(\d+)\.?\d*;/ );
[9] Fix | Delete
IEVersion = parseInt( IEVersion[ 1 ] );
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
// HTTP ajaxurl when site is HTTPS causes Access-Control-Allow-Origin failure in Desktop and iOS Safari
[13] Fix | Delete
if ( 'https:' === document.location.protocol ) {
[14] Fix | Delete
infiniteScroll.settings.ajaxurl = infiniteScroll.settings.ajaxurl.replace(
[15] Fix | Delete
'http://',
[16] Fix | Delete
'https://'
[17] Fix | Delete
);
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Loads new posts when users scroll near the bottom of the page.
[22] Fix | Delete
*/
[23] Fix | Delete
Scroller = function ( settings ) {
[24] Fix | Delete
var self = this;
[25] Fix | Delete
[26] Fix | Delete
// Initialize our variables
[27] Fix | Delete
this.id = settings.id;
[28] Fix | Delete
this.body = document.body;
[29] Fix | Delete
this.window = window;
[30] Fix | Delete
this.element = document.getElementById( settings.id );
[31] Fix | Delete
this.wrapperClass = settings.wrapper_class;
[32] Fix | Delete
this.ready = true;
[33] Fix | Delete
this.disabled = false;
[34] Fix | Delete
this.page = 1;
[35] Fix | Delete
this.offset = settings.offset;
[36] Fix | Delete
this.currentday = settings.currentday;
[37] Fix | Delete
this.order = settings.order;
[38] Fix | Delete
this.throttle = false;
[39] Fix | Delete
this.click_handle = settings.click_handle;
[40] Fix | Delete
this.google_analytics = settings.google_analytics;
[41] Fix | Delete
this.history = settings.history;
[42] Fix | Delete
this.origURL = window.location.href;
[43] Fix | Delete
[44] Fix | Delete
// Handle element
[45] Fix | Delete
this.handle = document.createElement( 'div' );
[46] Fix | Delete
this.handle.setAttribute( 'id', 'infinite-handle' );
[47] Fix | Delete
this.handle.innerHTML = '<span><button>' + text.replace( '\\', '' ) + '</button></span>';
[48] Fix | Delete
[49] Fix | Delete
// Footer settings
[50] Fix | Delete
this.footer = {
[51] Fix | Delete
el: document.getElementById( 'infinite-footer' ),
[52] Fix | Delete
wrap: settings.footer,
[53] Fix | Delete
};
[54] Fix | Delete
[55] Fix | Delete
// Bind methods used as callbacks
[56] Fix | Delete
this.checkViewportOnLoadBound = self.checkViewportOnLoad.bind( this );
[57] Fix | Delete
[58] Fix | Delete
// Core's native MediaElement.js implementation needs special handling
[59] Fix | Delete
this.wpMediaelement = null;
[60] Fix | Delete
[61] Fix | Delete
// We have two type of infinite scroll
[62] Fix | Delete
// cases 'scroll' and 'click'
[63] Fix | Delete
[64] Fix | Delete
if ( type === 'scroll' ) {
[65] Fix | Delete
// Bind refresh to the scroll event
[66] Fix | Delete
// Throttle to check for such case every 300ms
[67] Fix | Delete
[68] Fix | Delete
// On event the case becomes a fact
[69] Fix | Delete
this.window.addEventListener( 'scroll', function () {
[70] Fix | Delete
self.throttle = true;
[71] Fix | Delete
} );
[72] Fix | Delete
[73] Fix | Delete
// Go back top method
[74] Fix | Delete
self.gotop();
[75] Fix | Delete
[76] Fix | Delete
setInterval( function () {
[77] Fix | Delete
if ( self.throttle ) {
[78] Fix | Delete
// Once the case is the case, the action occurs and the fact is no more
[79] Fix | Delete
self.throttle = false;
[80] Fix | Delete
// Reveal or hide footer
[81] Fix | Delete
self.thefooter();
[82] Fix | Delete
// Fire the refresh
[83] Fix | Delete
self.refresh();
[84] Fix | Delete
self.determineURL(); // determine the url
[85] Fix | Delete
}
[86] Fix | Delete
}, 250 );
[87] Fix | Delete
[88] Fix | Delete
// Ensure that enough posts are loaded to fill the initial viewport, to compensate for short posts and large displays.
[89] Fix | Delete
self.ensureFilledViewport();
[90] Fix | Delete
this.body.addEventListener( 'is.post-load', self.checkViewportOnLoadBound );
[91] Fix | Delete
} else if ( type === 'click' ) {
[92] Fix | Delete
if ( this.click_handle ) {
[93] Fix | Delete
this.element.appendChild( this.handle );
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
this.handle.addEventListener( 'click', function () {
[97] Fix | Delete
// Handle the handle
[98] Fix | Delete
if ( self.click_handle ) {
[99] Fix | Delete
self.handle.parentNode.removeChild( self.handle );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
// Fire the refresh
[103] Fix | Delete
self.refresh();
[104] Fix | Delete
} );
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
// Initialize any Core audio or video players loaded via IS
[108] Fix | Delete
this.body.addEventListener( 'is.post-load', self.initializeMejs );
[109] Fix | Delete
};
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Normalize the access to the document scrollTop value.
[113] Fix | Delete
*/
[114] Fix | Delete
Scroller.prototype.getScrollTop = function () {
[115] Fix | Delete
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
[116] Fix | Delete
};
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Polyfill jQuery.extend.
[120] Fix | Delete
*/
[121] Fix | Delete
Scroller.prototype.extend = function ( out ) {
[122] Fix | Delete
out = out || {};
[123] Fix | Delete
[124] Fix | Delete
for ( var i = 1; i < arguments.length; i++ ) {
[125] Fix | Delete
if ( ! arguments[ i ] ) {
[126] Fix | Delete
continue;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
for ( var key in arguments[ i ] ) {
[130] Fix | Delete
if ( Object.hasOwn( arguments[ i ], key ) ) {
[131] Fix | Delete
out[ key ] = arguments[ i ][ key ];
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
return out;
[136] Fix | Delete
};
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Check whether we should fetch any additional posts.
[140] Fix | Delete
*/
[141] Fix | Delete
Scroller.prototype.check = function () {
[142] Fix | Delete
var wrapperMeasurements = this.measure( this.element, [ this.wrapperClass ] );
[143] Fix | Delete
[144] Fix | Delete
// Fetch more posts when we're less than 2 screens away from the bottom.
[145] Fix | Delete
return wrapperMeasurements.bottom < 2 * this.window.innerHeight;
[146] Fix | Delete
};
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Renders the results from a successful response.
[150] Fix | Delete
*/
[151] Fix | Delete
Scroller.prototype.render = function ( response ) {
[152] Fix | Delete
var childrenToAppend = Array.prototype.slice.call( response.fragment.childNodes );
[153] Fix | Delete
this.body.classList.add( 'infinity-success' );
[154] Fix | Delete
[155] Fix | Delete
// Render the retrieved nodes.
[156] Fix | Delete
while ( childrenToAppend.length > 0 ) {
[157] Fix | Delete
var currentNode = childrenToAppend.shift();
[158] Fix | Delete
this.element.appendChild( currentNode );
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
this.trigger( this.body, 'is.post-load', {
[162] Fix | Delete
jqueryEventName: 'post-load',
[163] Fix | Delete
data: response,
[164] Fix | Delete
} );
[165] Fix | Delete
[166] Fix | Delete
this.ready = true;
[167] Fix | Delete
};
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Returns the object used to query for new posts.
[171] Fix | Delete
*/
[172] Fix | Delete
Scroller.prototype.query = function () {
[173] Fix | Delete
return {
[174] Fix | Delete
page: this.page + this.offset, // Load the next page.
[175] Fix | Delete
currentday: this.currentday,
[176] Fix | Delete
order: this.order,
[177] Fix | Delete
scripts: window.infiniteScroll.settings.scripts,
[178] Fix | Delete
styles: window.infiniteScroll.settings.styles,
[179] Fix | Delete
query_args: window.infiniteScroll.settings.query_args,
[180] Fix | Delete
query_before: window.infiniteScroll.settings.query_before,
[181] Fix | Delete
last_post_date: window.infiniteScroll.settings.last_post_date,
[182] Fix | Delete
};
[183] Fix | Delete
};
[184] Fix | Delete
[185] Fix | Delete
Scroller.prototype.animate = function ( cb, duration ) {
[186] Fix | Delete
var start = performance.now();
[187] Fix | Delete
[188] Fix | Delete
requestAnimationFrame( function animate( time ) {
[189] Fix | Delete
var timeFraction = Math.min( 1, ( time - start ) / duration );
[190] Fix | Delete
cb( timeFraction );
[191] Fix | Delete
[192] Fix | Delete
if ( timeFraction < 1 ) {
[193] Fix | Delete
requestAnimationFrame( animate );
[194] Fix | Delete
}
[195] Fix | Delete
} );
[196] Fix | Delete
};
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Scroll back to top.
[200] Fix | Delete
*/
[201] Fix | Delete
Scroller.prototype.gotop = function () {
[202] Fix | Delete
var blog = document.getElementById( 'infinity-blog-title' );
[203] Fix | Delete
var self = this;
[204] Fix | Delete
[205] Fix | Delete
if ( ! blog ) {
[206] Fix | Delete
return;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
blog.setAttribute( 'title', totop );
[210] Fix | Delete
blog.addEventListener( 'click', function ( e ) {
[211] Fix | Delete
var sourceScroll = self.window.pageYOffset;
[212] Fix | Delete
e.preventDefault();
[213] Fix | Delete
[214] Fix | Delete
self.animate( function ( progress ) {
[215] Fix | Delete
var currentScroll = sourceScroll - sourceScroll * progress;
[216] Fix | Delete
document.documentElement.scrollTop = document.body.scrollTop = currentScroll;
[217] Fix | Delete
}, 200 );
[218] Fix | Delete
} );
[219] Fix | Delete
};
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* The infinite footer.
[223] Fix | Delete
*/
[224] Fix | Delete
Scroller.prototype.thefooter = function () {
[225] Fix | Delete
var self = this,
[226] Fix | Delete
pageWrapper,
[227] Fix | Delete
footerContainer,
[228] Fix | Delete
width,
[229] Fix | Delete
sourceBottom,
[230] Fix | Delete
targetBottom,
[231] Fix | Delete
footerEnabled = this.footer && this.footer.el;
[232] Fix | Delete
[233] Fix | Delete
if ( ! footerEnabled ) {
[234] Fix | Delete
return;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
// Check if we have an id for the page wrapper
[238] Fix | Delete
if ( 'string' === typeof this.footer.wrap ) {
[239] Fix | Delete
try {
[240] Fix | Delete
pageWrapper = document.getElementById( this.footer.wrap );
[241] Fix | Delete
width = pageWrapper.getBoundingClientRect();
[242] Fix | Delete
width = width.width;
[243] Fix | Delete
} catch {
[244] Fix | Delete
width = 0;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
// Make the footer match the width of the page
[248] Fix | Delete
if ( width > 479 ) {
[249] Fix | Delete
footerContainer = this.footer.el.querySelector( '.container' );
[250] Fix | Delete
if ( footerContainer ) {
[251] Fix | Delete
footerContainer.style.width = width + 'px';
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
// Reveal footer
[257] Fix | Delete
sourceBottom = parseInt( self.footer.el.style.bottom || -50, 10 );
[258] Fix | Delete
targetBottom = this.window.pageYOffset >= 350 ? 0 : -50;
[259] Fix | Delete
[260] Fix | Delete
if ( sourceBottom !== targetBottom ) {
[261] Fix | Delete
self.animate( function ( progress ) {
[262] Fix | Delete
var currentBottom = sourceBottom + ( targetBottom - sourceBottom ) * progress;
[263] Fix | Delete
self.footer.el.style.bottom = currentBottom + 'px';
[264] Fix | Delete
[265] Fix | Delete
if ( 1 === progress ) {
[266] Fix | Delete
sourceBottom = targetBottom;
[267] Fix | Delete
}
[268] Fix | Delete
}, 200 );
[269] Fix | Delete
}
[270] Fix | Delete
};
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Recursively convert a JS object into URL encoded data.
[274] Fix | Delete
*/
[275] Fix | Delete
Scroller.prototype.urlEncodeJSON = function ( obj, prefix ) {
[276] Fix | Delete
var params = [],
[277] Fix | Delete
encodedKey,
[278] Fix | Delete
newPrefix;
[279] Fix | Delete
[280] Fix | Delete
for ( var key in obj ) {
[281] Fix | Delete
encodedKey = encodeURIComponent( key );
[282] Fix | Delete
newPrefix = prefix ? prefix + '[' + encodedKey + ']' : encodedKey;
[283] Fix | Delete
[284] Fix | Delete
if ( 'object' === typeof obj[ key ] ) {
[285] Fix | Delete
if ( ! Array.isArray( obj[ key ] ) || obj[ key ].length > 0 ) {
[286] Fix | Delete
params.push( this.urlEncodeJSON( obj[ key ], newPrefix ) );
[287] Fix | Delete
} else {
[288] Fix | Delete
// Explicitly expose empty arrays with no values
[289] Fix | Delete
params.push( newPrefix + '[]=' );
[290] Fix | Delete
}
[291] Fix | Delete
} else {
[292] Fix | Delete
params.push( newPrefix + '=' + encodeURIComponent( obj[ key ] ) );
[293] Fix | Delete
}
[294] Fix | Delete
}
[295] Fix | Delete
return params.join( '&' );
[296] Fix | Delete
};
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Controls the flow of the refresh. Don't mess.
[300] Fix | Delete
*/
[301] Fix | Delete
Scroller.prototype.refresh = function () {
[302] Fix | Delete
var self = this,
[303] Fix | Delete
query,
[304] Fix | Delete
xhr,
[305] Fix | Delete
loader,
[306] Fix | Delete
customized;
[307] Fix | Delete
[308] Fix | Delete
// If we're disabled, ready, or don't pass the check, bail.
[309] Fix | Delete
if ( this.disabled || ! this.ready || ! this.check() ) {
[310] Fix | Delete
return;
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
// Let's get going -- set ready to false to prevent
[314] Fix | Delete
// multiple refreshes from occurring at once.
[315] Fix | Delete
this.ready = false;
[316] Fix | Delete
[317] Fix | Delete
// Create a loader element to show it's working.
[318] Fix | Delete
if ( this.click_handle ) {
[319] Fix | Delete
if ( ! loader ) {
[320] Fix | Delete
document.getElementById( 'infinite-aria' ).textContent = loading_text;
[321] Fix | Delete
loader = document.createElement( 'div' );
[322] Fix | Delete
loader.classList.add( 'infinite-loader' );
[323] Fix | Delete
loader.setAttribute( 'role', 'progress' );
[324] Fix | Delete
loader.innerHTML =
[325] Fix | Delete
'<div class="spinner"><div class="spinner-inner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>';
[326] Fix | Delete
}
[327] Fix | Delete
this.element.appendChild( loader );
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
// Generate our query vars.
[331] Fix | Delete
query = self.extend(
[332] Fix | Delete
{
[333] Fix | Delete
action: 'infinite_scroll',
[334] Fix | Delete
},
[335] Fix | Delete
this.query()
[336] Fix | Delete
);
[337] Fix | Delete
[338] Fix | Delete
// Inject Customizer state.
[339] Fix | Delete
if ( 'undefined' !== typeof wp && wp.customize && wp.customize.settings.theme ) {
[340] Fix | Delete
customized = {};
[341] Fix | Delete
query.wp_customize = 'on';
[342] Fix | Delete
query.theme = wp.customize.settings.theme.stylesheet;
[343] Fix | Delete
wp.customize.each( function ( setting ) {
[344] Fix | Delete
if ( setting._dirty ) {
[345] Fix | Delete
customized[ setting.id ] = setting();
[346] Fix | Delete
}
[347] Fix | Delete
} );
[348] Fix | Delete
query.customized = JSON.stringify( customized );
[349] Fix | Delete
query.nonce = wp.customize.settings.nonce.preview;
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
// Fire the ajax request.
[353] Fix | Delete
xhr = new XMLHttpRequest();
[354] Fix | Delete
xhr.open( 'POST', infiniteScroll.settings.ajaxurl, true );
[355] Fix | Delete
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
[356] Fix | Delete
xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' );
[357] Fix | Delete
xhr.send( self.urlEncodeJSON( query ) );
[358] Fix | Delete
[359] Fix | Delete
// Allow refreshes to occur again if an error is triggered.
[360] Fix | Delete
xhr.onerror = function () {
[361] Fix | Delete
if ( self.click_handle && loader.parentNode ) {
[362] Fix | Delete
loader.parentNode.removeChild( loader );
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
self.ready = true;
[366] Fix | Delete
};
[367] Fix | Delete
[368] Fix | Delete
// Success handler
[369] Fix | Delete
xhr.onload = function () {
[370] Fix | Delete
var response = JSON.parse( xhr.responseText ),
[371] Fix | Delete
httpCheck = xhr.status >= 200 && xhr.status < 300,
[372] Fix | Delete
responseCheck = 'undefined' !== typeof response.html;
[373] Fix | Delete
[374] Fix | Delete
if ( ! response || ! httpCheck || ! responseCheck ) {
[375] Fix | Delete
if ( self.click_handle && loader.parentNode ) {
[376] Fix | Delete
loader.parentNode.removeChild( loader );
[377] Fix | Delete
}
[378] Fix | Delete
return;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
// On success, let's hide the loader circle.
[382] Fix | Delete
if ( self.click_handle && loader.parentNode ) {
[383] Fix | Delete
loader.parentNode.removeChild( loader );
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
// If additional scripts are required by the incoming set of posts, parse them
[387] Fix | Delete
if ( response.scripts && Array.isArray( response.scripts ) ) {
[388] Fix | Delete
response.scripts.forEach( function ( item ) {
[389] Fix | Delete
var elementToAppendTo = item.footer ? 'body' : 'head';
[390] Fix | Delete
[391] Fix | Delete
// Add script handle to list of those already parsed
[392] Fix | Delete
window.infiniteScroll.settings.scripts.push( item.handle );
[393] Fix | Delete
[394] Fix | Delete
// Output extra data, if present
[395] Fix | Delete
if ( item.extra_data ) {
[396] Fix | Delete
self.appendInlineScript( item.extra_data, elementToAppendTo );
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
if ( item.before_handle ) {
[400] Fix | Delete
self.appendInlineScript( item.before_handle, elementToAppendTo );
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
// Build script tag and append to DOM in requested location
[404] Fix | Delete
var script = document.createElement( 'script' );
[405] Fix | Delete
script.type = 'text/javascript';
[406] Fix | Delete
script.src = item.src;
[407] Fix | Delete
script.id = item.handle;
[408] Fix | Delete
[409] Fix | Delete
// Dynamically loaded scripts are async by default.
[410] Fix | Delete
// We don't want that, it breaks stuff, e.g. wp-mediaelement init.
[411] Fix | Delete
script.async = false;
[412] Fix | Delete
[413] Fix | Delete
if ( item.after_handle ) {
[414] Fix | Delete
script.onload = function () {
[415] Fix | Delete
self.appendInlineScript( item.after_handle, elementToAppendTo );
[416] Fix | Delete
};
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
// If MediaElement.js is loaded in by item set of posts, don't initialize the players a second time as it breaks them all
[420] Fix | Delete
if ( 'wp-mediaelement' === item.handle ) {
[421] Fix | Delete
self.body.removeEventListener( 'is.post-load', self.initializeMejs );
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
if ( 'wp-mediaelement' === item.handle && 'undefined' === typeof mejs ) {
[425] Fix | Delete
self.wpMediaelement = {};
[426] Fix | Delete
self.wpMediaelement.tag = script;
[427] Fix | Delete
self.wpMediaelement.element = elementToAppendTo;
[428] Fix | Delete
setTimeout( self.maybeLoadMejs.bind( self ), 250 );
[429] Fix | Delete
} else {
[430] Fix | Delete
document.getElementsByTagName( elementToAppendTo )[ 0 ].appendChild( script );
[431] Fix | Delete
}
[432] Fix | Delete
} );
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
// If additional stylesheets are required by the incoming set of posts, parse them
[436] Fix | Delete
if ( response.styles && Array.isArray( response.styles ) ) {
[437] Fix | Delete
response.styles.forEach( function ( item ) {
[438] Fix | Delete
// Add stylesheet handle to list of those already parsed
[439] Fix | Delete
window.infiniteScroll.settings.styles.push( item.handle );
[440] Fix | Delete
[441] Fix | Delete
// Build link tag
[442] Fix | Delete
var style = document.createElement( 'link' );
[443] Fix | Delete
style.rel = 'stylesheet';
[444] Fix | Delete
style.href = item.src;
[445] Fix | Delete
style.id = item.handle + '-css';
[446] Fix | Delete
[447] Fix | Delete
// Destroy link tag if a conditional statement is present and either the browser isn't IE, or the conditional doesn't evaluate true
[448] Fix | Delete
if (
[449] Fix | Delete
item.conditional &&
[450] Fix | Delete
( ! isIE || ! eval( item.conditional.replace( /%ver/g, IEVersion ) ) )
[451] Fix | Delete
) {
[452] Fix | Delete
style = false;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
// Append link tag if necessary
[456] Fix | Delete
if ( style ) {
[457] Fix | Delete
document.getElementsByTagName( 'head' )[ 0 ].appendChild( style );
[458] Fix | Delete
}
[459] Fix | Delete
} );
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
// Convert the response.html to a fragment element.
[463] Fix | Delete
// Using a div instead of DocumentFragment, because the latter doesn't support innerHTML.
[464] Fix | Delete
response.fragment = document.createElement( 'div' );
[465] Fix | Delete
response.fragment.innerHTML = response.html;
[466] Fix | Delete
[467] Fix | Delete
// Increment the page number
[468] Fix | Delete
self.page++;
[469] Fix | Delete
[470] Fix | Delete
// Record pageview in WP Stats, if available.
[471] Fix | Delete
if ( stats ) {
[472] Fix | Delete
new Image().src =
[473] Fix | Delete
document.location.protocol +
[474] Fix | Delete
'//pixel.wp.com/g.gif?' +
[475] Fix | Delete
stats +
[476] Fix | Delete
'&post=0&baba=' +
[477] Fix | Delete
Math.random();
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
// Add new posts to the postflair object
[481] Fix | Delete
if ( 'object' === typeof response.postflair && 'object' === typeof WPCOM_sharing_counts ) {
[482] Fix | Delete
WPCOM_sharing_counts = self.extend( WPCOM_sharing_counts, response.postflair ); // eslint-disable-line no-global-assign
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
// Render the results
[486] Fix | Delete
self.render.call( self, response );
[487] Fix | Delete
[488] Fix | Delete
// If 'click' type and there are still posts to fetch, add back the handle
[489] Fix | Delete
if ( type === 'click' ) {
[490] Fix | Delete
// add focus to new posts, only in button mode as we know where page focus currently is and only if we have a wrapper
[491] Fix | Delete
if ( infiniteScroll.settings.wrapper ) {
[492] Fix | Delete
document
[493] Fix | Delete
.querySelector(
[494] Fix | Delete
'#infinite-view-' + ( self.page + self.offset - 1 ) + ' a:first-of-type'
[495] Fix | Delete
)
[496] Fix | Delete
.focus( {
[497] Fix | Delete
preventScroll: true,
[498] Fix | Delete
} );
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function