Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0181532686cf4a31163be0bf3e6bb6732bf/1c6d174d8fe0b5c2ecc9452e10df5db8 to your computer and use it in GitHub Desktop.
Save 0181532686cf4a31163be0bf3e6bb6732bf/1c6d174d8fe0b5c2ecc9452e10df5db8 to your computer and use it in GitHub Desktop.
Make WordPress FooGallery scroll across the pages
(function($){
$(document).ready(function()
{
$.fn.isLink = function() {
return this.prop("tagName").toLowerCase() == 'a';
};
window.setTimeout(function()
{
var curr = $('.pagination .current');
function stat(){
var regx = new RegExp(/item (\d{1,3}) of (\d{1,3})/);
var x = regx.exec($('.fbx-count').html());
if( x != null)
return new Array(parseInt(x[1]), parseInt(x[2]));
else return new Array(100, 500);
}
$('.fbx-prev').click(function(){
var v = stat();
if( v[0] == v[1] )
{
var p = $(curr).prev();
if($(p).length && $(p[0]).isLink()){
window.location = $(p[0]).attr('href');
}
}
});
$('.fbx-next').click(function(){
var v = stat();
if( v[0] == 1 )
{
var n = $(curr).next();
if($(n).length && $(n[0]).isLink()){
window.location = $(n[0]).attr('href');
}
}
});
}, 300);
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment