Skip to content

Instantly share code, notes, and snippets.

@tautologistics
Last active August 29, 2015 14:02
Show Gist options
  • Save tautologistics/af3316697156d04c9011 to your computer and use it in GitHub Desktop.
Save tautologistics/af3316697156d04c9011 to your computer and use it in GitHub Desktop.
var pInfScrLoading = false;
var pInfScrDelay = 250;
function pInfScrExecute() {
pInfScrNode = $('.more').last();
pInfScrURL = $('.more a').last().attr("href");
if(pInfScrNode.length > 0 && pInfScrNode.css('display') != 'none') {
$.ajax({
type: 'GET',
url: pInfScrURL,
beforeSend: function() {
pInfScrLoading = true;
pInfScrNode.clone().empty().insertAfter(pInfScrNode).append('<img src=\"http://cdn.shopify.com/s/files/1/0068/2162/assets/loading.gif?105791\" />');
pInfScrNode.hide();
},
success: function(data) {
// remove loading feedback
pInfScrNode.next().remove();
pInfScrNode.remove();
var filteredData = $(data).find(".collection-matrix");
// Saves reference to footer element
var footer = $("#product-list-foot");
// Removes any existing named anchor
$('#last_content_page').remove();
// Set hash part of window URL to 'last_content_page'
// This is done here, while there is no matching named
// anchor, so that the scroll position of the page does
// not actually change
window.location.hash = 'last_content_page';
// Adds a new named anchor before new content
$('<a name="last_content_page" id="last_content_page">').insertBefore( footer );
filteredData.insertBefore( footer );
pInfScrLoading = false;
var link = $('li.singleproduct');
link.setAllToMaxHeight();
attachClickEvent(link);
},
dataType: "html"
});
}
}
function attachClickEvent(){
(link || $('li.more a')).click(function(event){
pInfScrExecute();
event.stopPropagation();
return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment