-
-
Save amitabhaghosh197/11217515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kickOffAjax(){ | |
// we dont want to fire the ajax multiple times | |
opts.isDuringAjax = true; | |
// show the loading message quickly | |
// then hide the previous/next links after we're | |
// sure the loading message was visible | |
props.loadingMsg.appendTo( opts.loadMsgSelector ).show(opts.loadingMsgRevealSpeed, function(){ | |
$( opts.navSelector ).hide(); | |
// increment the URL bit. e.g. /page/3/ | |
opts.currPage++; | |
debug('heading into ajax',path); | |
if ($.isFunction(opts.pathParse)){ | |
// if we got a custom path parsing function, pass in our path guess and page iteration | |
desturl = opts.pathParse(path.join('2'), opts.currPage); | |
} else { | |
desturl = path.join( opts.currPage ); | |
} | |
$.ajax({ | |
url: desturl, | |
type: 'GET', | |
dataType: 'html', | |
success: function (data) { | |
if (data.trim().length == 0) { | |
showDoneMsg(); | |
return false; | |
} else { | |
// append the ajax data to the end | |
$(opts.contentSelector).append(data); | |
// fadeout currently makes the <em>'d text ugly in IE6 | |
props.loadingMsg.fadeOut('normal' ); | |
// smooth scroll to ease in the new content | |
if (opts.animate){ | |
var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px'; | |
$('html,body').animate({scrollTop: scrollTo}, 800,function(){ opts.isDuringAjax = false; }); | |
} | |
callback.call( $(opts.contentSelector) ); | |
if (!opts.animate) opts.isDuringAjax = false; // once the call is done, we can allow it again. | |
} | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment