!function(h){"use strict";h.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",loadingFunction:!1,padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1}};function l(r,t){function e(t){i.pagingSelector?t.closest(i.pagingSelector).hide():t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide().length||t.wrap('
').parent().hide()}function l(){if(r.is(":visible")){f();var t=r.find("div.jscroll-inner").first(),n=r.data("jscroll"),e=parseInt(r.css("borderTopWidth"),10),e=isNaN(e)?0:e,e=parseInt(r.css("paddingTop"),10)+e,l=c?d.scrollTop():r.offset().top,o=t.length?t.offset().top:0,l=Math.ceil(l-o+d.height()+e);if(!n.waiting&&l+i.padding>=t.outerHeight())return j("info","jScroll:",t.outerHeight()-l,"from bottom. Loading next request..."),p()}}function n(){var t,n=r.find(i.nextSelector).first();n.length&&(i.autoTrigger&&(!1===i.autoTriggerUntil||0')},g=function(){return d.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()},u=function(t){return(t=t||r.data("jscroll"))&&t.nextHref?(n(),!0):(j("warn","jScroll: nextSelector not found - destroying"),g(),!1)},p=function(){var t=r.find("div.jscroll-inner").first(),e=r.data("jscroll");return e.waiting=!0,t.append('').children(".jscroll-added").last().html(''+i.loadingHtml+"
").promise().done(function(){i.loadingFunction&&i.loadingFunction()}),r.animate({scrollTop:t.outerHeight()},0,function(){t.find("div.jscroll-added").last().load(e.nextHref,function(t,n){if("error"===n)return g();n=h(this).find(i.nextSelector).first();e.waiting=!1,e.nextHref=!!n.attr("href")&&h.trim(n.attr("href")+" "+i.contentSelector),h(".jscroll-next-parent",r).remove(),u(),i.callback&&i.callback.call(this),j("dir",e)})})},j=function(t){if(i.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var n,e=[];for(n in t)("function"==typeof console[n]?(e=t[n].length?t[n]:[t[n]],console[n]):console.log).apply(console,e)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))};return r.data("jscroll",h.extend({},o,{initialized:!0,waiting:!1,nextHref:t})),f(),(o=h(i.loadingHtml).filter("img").attr("src"))&&((new Image).src=o),n(),h.extend(r.jscroll,{destroy:g}),r}h.fn.jscroll=function(e){return this.each(function(){var t=h(this),n=t.data("jscroll");n&&n.initialized||l(t,e)})}}(jQuery);