From 24c630ab7ed24fc94fd62c195270c852140fe91b Mon Sep 17 00:00:00 2001 From: fabrizio Date: Fri, 20 Feb 2015 15:33:27 +0100 Subject: [PATCH 1/6] Checking existence of $next object --- jquery.jscroll.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jquery.jscroll.js b/jquery.jscroll.js index 829bdb7..5794617 100644 --- a/jquery.jscroll.js +++ b/jquery.jscroll.js @@ -121,6 +121,7 @@ function _setBindings() { var $next = $e.find(_options.nextSelector).first(); + if($next.length == 0) return false; // patched for null nextSelector object - by FabrizioT if (_options.autoTrigger && (_options.autoTriggerUntil === false || _options.autoTriggerUntil > 0)) { _nextWrap($next); if (_$body.height() <= _$window.height()) { @@ -206,4 +207,4 @@ var jscroll = new jScroll($this, m); }); }; -})(jQuery); \ No newline at end of file +})(jQuery); From 296dd361dd5471f942e6641df79da8322843b2f7 Mon Sep 17 00:00:00 2001 From: fabrizio Date: Fri, 20 Feb 2015 15:36:13 +0100 Subject: [PATCH 2/6] updating jquery.jscroll.min.js --- jquery.jscroll.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.jscroll.min.js b/jquery.jscroll.min.js index f39469a..7069bae 100644 --- a/jquery.jscroll.min.js +++ b/jquery.jscroll.min.js @@ -12,4 +12,4 @@ * @author Philip Klauzinski * @requires jQuery v1.4.3+ */ -(function(b){b.jscroll={defaults:{debug:false,autoTrigger:true,autoTriggerUntil:false,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:false}};var a=function(e,g){var o=e.data("jscroll"),n=(typeof g==="function")?{callback:g}:g,p=b.extend({},b.jscroll.defaults,n,o||{}),c=(e.css("overflow-y")==="visible"),l=e.find(p.nextSelector).first(),v=b(window),h=b("body"),q=c?v:e,m=b.trim(l.attr("href")+" "+p.contentSelector);e.data("jscroll",b.extend({},o,{initialized:true,waiting:false,nextHref:m}));r();k();t();function k(){var x=b(p.loadingHtml).filter("img").attr("src");if(x){var w=new Image();w.src=x}}function r(){if(!e.find(".jscroll-inner").length){e.contents().wrapAll('
')}}function d(w){if(p.pagingSelector){var x=w.closest(p.pagingSelector).hide()}else{var x=w.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();if(!x.length){w.wrap('
').parent().hide()}}}function j(){return q.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function i(){r();var D=e.find("div.jscroll-inner").first(),B=e.data("jscroll"),C=parseInt(e.css("borderTopWidth")),y=isNaN(C)?0:C,x=parseInt(e.css("paddingTop"))+y,A=c?q.scrollTop():e.offset().top,z=D.length?D.offset().top:0,w=Math.ceil(A-z+q.height()+x);if(!B.waiting&&w+p.padding>=D.outerHeight()){f("info","jScroll:",D.outerHeight()-w,"from bottom. Loading next request...");return u()}}function s(w){w=w||e.data("jscroll");if(!w||!w.nextHref){f("warn","jScroll: nextSelector not found - destroying");j();return false}else{t();return true}}function t(){var w=e.find(p.nextSelector).first();if(p.autoTrigger&&(p.autoTriggerUntil===false||p.autoTriggerUntil>0)){d(w);if(h.height()<=v.height()){i()}q.unbind(".jscroll").bind("scroll.jscroll",function(){return i()});if(p.autoTriggerUntil>0){p.autoTriggerUntil--}}else{q.unbind(".jscroll");w.bind("click.jscroll",function(){d(w);u();return false})}}function u(){var x=e.find("div.jscroll-inner").first(),w=e.data("jscroll");w.waiting=true;x.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
");return e.animate({scrollTop:x.outerHeight()},0,function(){x.find("div.jscroll-added").last().load(w.nextHref,function(A,z,B){if(z==="error"){return j()}var y=b(this).find(p.nextSelector).first();w.waiting=false;w.nextHref=y.attr("href")?b.trim(y.attr("href")+" "+p.contentSelector):false;b(".jscroll-next-parent",e).remove();s();if(p.callback){p.callback.call(this)}f("dir",w)})})}function f(w){if(p.debug&&typeof console==="object"&&(typeof w==="object"||typeof console[w]==="function")){if(typeof w==="object"){var y=[];for(var x in w){if(typeof console[x]==="function"){y=(w[x].length)?w[x]:[w[x]];console[x].apply(console,y)}else{console.log.apply(console,y)}}}else{console[w].apply(console,Array.prototype.slice.call(arguments,1))}}}b.extend(e.jscroll,{destroy:j});return e};b.fn.jscroll=function(c){return this.each(function(){var f=b(this),e=f.data("jscroll");if(e&&e.initialized){return}var d=new a(f,c)})}})(jQuery); \ No newline at end of file +!function(t){t.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1}};var n=function(n,e){function r(){var n=t(p.loadingHtml).filter("img").attr("src");if(n){var e=new Image;e.src=n}}function l(){n.find(".jscroll-inner").length||n.contents().wrapAll('
')}function o(t){if(p.pagingSelector)var n=t.closest(p.pagingSelector).hide();else{var n=t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();n.length||t.wrap('
').parent().hide()}}function i(){return m.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function c(){l();var t=n.find("div.jscroll-inner").first(),e=n.data("jscroll"),r=parseInt(n.css("borderTopWidth")),o=isNaN(r)?0:r,i=parseInt(n.css("paddingTop"))+o,c=j?m.scrollTop():n.offset().top,a=t.length?t.offset().top:0,s=Math.ceil(c-a+m.height()+i);return!e.waiting&&s+p.padding>=t.outerHeight()?(f("info","jScroll:",t.outerHeight()-s,"from bottom. Loading next request..."),d()):void 0}function a(t){return t=t||n.data("jscroll"),t&&t.nextHref?(s(),!0):(f("warn","jScroll: nextSelector not found - destroying"),i(),!1)}function s(){var t=n.find(p.nextSelector).first();return 0==t.length?!1:void(p.autoTrigger&&(p.autoTriggerUntil===!1||p.autoTriggerUntil>0)?(o(t),b.height()<=v.height()&&c(),m.unbind(".jscroll").bind("scroll.jscroll",function(){return c()}),p.autoTriggerUntil>0&&p.autoTriggerUntil--):(m.unbind(".jscroll"),t.bind("click.jscroll",function(){return o(t),d(),!1})))}function d(){var e=n.find("div.jscroll-inner").first(),r=n.data("jscroll");return r.waiting=!0,e.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
"),n.animate({scrollTop:e.outerHeight()},0,function(){e.find("div.jscroll-added").last().load(r.nextHref,function(e,l){if("error"===l)return i();var o=t(this).find(p.nextSelector).first();r.waiting=!1,r.nextHref=o.attr("href")?t.trim(o.attr("href")+" "+p.contentSelector):!1,t(".jscroll-next-parent",n).remove(),a(),p.callback&&p.callback.call(this),f("dir",r)})})}function f(t){if(p.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var n=[];for(var e in t)"function"==typeof console[e]?(n=t[e].length?t[e]:[t[e]],console[e].apply(console,n)):console.log.apply(console,n)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))}var u=n.data("jscroll"),g="function"==typeof e?{callback:e}:e,p=t.extend({},t.jscroll.defaults,g,u||{}),j="visible"===n.css("overflow-y"),h=n.find(p.nextSelector).first(),v=t(window),b=t("body"),m=j?v:n,x=t.trim(h.attr("href")+" "+p.contentSelector);return n.data("jscroll",t.extend({},u,{initialized:!0,waiting:!1,nextHref:x})),l(),r(),s(),t.extend(n.jscroll,{destroy:i}),n};t.fn.jscroll=function(e){return this.each(function(){var r=t(this),l=r.data("jscroll");if(!l||!l.initialized){new n(r,e)}})}}(jQuery); From 5a4544c00a86831feec5930662806b1ba7e29b71 Mon Sep 17 00:00:00 2001 From: fabrizio Date: Fri, 20 Feb 2015 15:59:56 +0100 Subject: [PATCH 3/6] added onLoadComplete option --- jquery.jscroll.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jquery.jscroll.js b/jquery.jscroll.js index 5794617..49f8bb5 100644 --- a/jquery.jscroll.js +++ b/jquery.jscroll.js @@ -25,7 +25,8 @@ nextSelector: 'a:last', contentSelector: '', pagingSelector: '', - callback: false + callback: false, + onLoadComplete: false } }; @@ -149,6 +150,7 @@ data = $e.data('jscroll'); data.waiting = true; + $inner.append('
') .children('.jscroll-added').last() .html('
' + _options.loadingHtml + '
'); @@ -158,6 +160,11 @@ if (status === 'error') { return _destroy(); } + + if (_options.onLoadComplete) { + _options.onLoadComplete.call(this); + } + var $next = $(this).find(_options.nextSelector).first(); data.waiting = false; data.nextHref = $next.attr('href') ? $.trim($next.attr('href') + ' ' + _options.contentSelector) : false; From 8e140ae8aa54021eddaab133a7aff926d8c37f2f Mon Sep 17 00:00:00 2001 From: fabrizio Date: Fri, 20 Feb 2015 16:00:50 +0100 Subject: [PATCH 4/6] Updated jquery.jscroll.min.js --- jquery.jscroll.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.jscroll.min.js b/jquery.jscroll.min.js index 7069bae..46d24d0 100644 --- a/jquery.jscroll.min.js +++ b/jquery.jscroll.min.js @@ -12,4 +12,4 @@ * @author Philip Klauzinski * @requires jQuery v1.4.3+ */ -!function(t){t.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1}};var n=function(n,e){function r(){var n=t(p.loadingHtml).filter("img").attr("src");if(n){var e=new Image;e.src=n}}function l(){n.find(".jscroll-inner").length||n.contents().wrapAll('
')}function o(t){if(p.pagingSelector)var n=t.closest(p.pagingSelector).hide();else{var n=t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();n.length||t.wrap('
').parent().hide()}}function i(){return m.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function c(){l();var t=n.find("div.jscroll-inner").first(),e=n.data("jscroll"),r=parseInt(n.css("borderTopWidth")),o=isNaN(r)?0:r,i=parseInt(n.css("paddingTop"))+o,c=j?m.scrollTop():n.offset().top,a=t.length?t.offset().top:0,s=Math.ceil(c-a+m.height()+i);return!e.waiting&&s+p.padding>=t.outerHeight()?(f("info","jScroll:",t.outerHeight()-s,"from bottom. Loading next request..."),d()):void 0}function a(t){return t=t||n.data("jscroll"),t&&t.nextHref?(s(),!0):(f("warn","jScroll: nextSelector not found - destroying"),i(),!1)}function s(){var t=n.find(p.nextSelector).first();return 0==t.length?!1:void(p.autoTrigger&&(p.autoTriggerUntil===!1||p.autoTriggerUntil>0)?(o(t),b.height()<=v.height()&&c(),m.unbind(".jscroll").bind("scroll.jscroll",function(){return c()}),p.autoTriggerUntil>0&&p.autoTriggerUntil--):(m.unbind(".jscroll"),t.bind("click.jscroll",function(){return o(t),d(),!1})))}function d(){var e=n.find("div.jscroll-inner").first(),r=n.data("jscroll");return r.waiting=!0,e.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
"),n.animate({scrollTop:e.outerHeight()},0,function(){e.find("div.jscroll-added").last().load(r.nextHref,function(e,l){if("error"===l)return i();var o=t(this).find(p.nextSelector).first();r.waiting=!1,r.nextHref=o.attr("href")?t.trim(o.attr("href")+" "+p.contentSelector):!1,t(".jscroll-next-parent",n).remove(),a(),p.callback&&p.callback.call(this),f("dir",r)})})}function f(t){if(p.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var n=[];for(var e in t)"function"==typeof console[e]?(n=t[e].length?t[e]:[t[e]],console[e].apply(console,n)):console.log.apply(console,n)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))}var u=n.data("jscroll"),g="function"==typeof e?{callback:e}:e,p=t.extend({},t.jscroll.defaults,g,u||{}),j="visible"===n.css("overflow-y"),h=n.find(p.nextSelector).first(),v=t(window),b=t("body"),m=j?v:n,x=t.trim(h.attr("href")+" "+p.contentSelector);return n.data("jscroll",t.extend({},u,{initialized:!0,waiting:!1,nextHref:x})),l(),r(),s(),t.extend(n.jscroll,{destroy:i}),n};t.fn.jscroll=function(e){return this.each(function(){var r=t(this),l=r.data("jscroll");if(!l||!l.initialized){new n(r,e)}})}}(jQuery); +!function(t){t.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1,onLoadComplete:!1}};var e=function(e,n){function l(){var e=t(p.loadingHtml).filter("img").attr("src");if(e){var n=new Image;n.src=e}}function r(){e.find(".jscroll-inner").length||e.contents().wrapAll('
')}function o(t){if(p.pagingSelector)var e=t.closest(p.pagingSelector).hide();else{var e=t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();e.length||t.wrap('
').parent().hide()}}function i(){return b.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function a(){r();var t=e.find("div.jscroll-inner").first(),n=e.data("jscroll"),l=parseInt(e.css("borderTopWidth")),o=isNaN(l)?0:l,i=parseInt(e.css("paddingTop"))+o,a=j?b.scrollTop():e.offset().top,c=t.length?t.offset().top:0,s=Math.ceil(a-c+b.height()+i);return!n.waiting&&s+p.padding>=t.outerHeight()?(f("info","jScroll:",t.outerHeight()-s,"from bottom. Loading next request..."),d()):void 0}function c(t){return t=t||e.data("jscroll"),t&&t.nextHref?(s(),!0):(f("warn","jScroll: nextSelector not found - destroying"),i(),!1)}function s(){var t=e.find(p.nextSelector).first();return 0==t.length?!1:void(p.autoTrigger&&(p.autoTriggerUntil===!1||p.autoTriggerUntil>0)?(o(t),m.height()<=v.height()&&a(),b.unbind(".jscroll").bind("scroll.jscroll",function(){return a()}),p.autoTriggerUntil>0&&p.autoTriggerUntil--):(b.unbind(".jscroll"),t.bind("click.jscroll",function(){return o(t),d(),!1})))}function d(){var n=e.find("div.jscroll-inner").first(),l=e.data("jscroll");return l.waiting=!0,n.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
"),e.animate({scrollTop:n.outerHeight()},0,function(){n.find("div.jscroll-added").last().load(l.nextHref,function(n,r){if("error"===r)return i();p.onLoadComplete&&p.onLoadComplete.call(this);var o=t(this).find(p.nextSelector).first();l.waiting=!1,l.nextHref=o.attr("href")?t.trim(o.attr("href")+" "+p.contentSelector):!1,t(".jscroll-next-parent",e).remove(),c(),p.callback&&p.callback.call(this),f("dir",l)})})}function f(t){if(p.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var e=[];for(var n in t)"function"==typeof console[n]?(e=t[n].length?t[n]:[t[n]],console[n].apply(console,e)):console.log.apply(console,e)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))}var u=e.data("jscroll"),g="function"==typeof n?{callback:n}:n,p=t.extend({},t.jscroll.defaults,g,u||{}),j="visible"===e.css("overflow-y"),h=e.find(p.nextSelector).first(),v=t(window),m=t("body"),b=j?v:e,x=t.trim(h.attr("href")+" "+p.contentSelector);return e.data("jscroll",t.extend({},u,{initialized:!0,waiting:!1,nextHref:x})),r(),l(),s(),t.extend(e.jscroll,{destroy:i}),e};t.fn.jscroll=function(n){return this.each(function(){var l=t(this),r=l.data("jscroll");if(!r||!r.initialized){new e(l,n)}})}}(jQuery); From 3d504dee25ad3b89e9c5b40a885d0fad575a4736 Mon Sep 17 00:00:00 2001 From: fabrizio Date: Mon, 23 Feb 2015 21:32:34 +0100 Subject: [PATCH 5/6] Update jquery.jscroll.js --- jquery.jscroll.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.jscroll.js b/jquery.jscroll.js index 49f8bb5..9bede3a 100644 --- a/jquery.jscroll.js +++ b/jquery.jscroll.js @@ -156,14 +156,15 @@ .html('
' + _options.loadingHtml + '
'); return $e.animate({scrollTop: $inner.outerHeight()}, 0, function() { + $inner.find('div.jscroll-added').last().load(data.nextHref, function(r, status, xhr) { if (status === 'error') { return _destroy(); } - if (_options.onLoadComplete) { - _options.onLoadComplete.call(this); - } + if (_options.onLoadComplete) { + _options.onLoadComplete.call(this,data.nextHref); + } var $next = $(this).find(_options.nextSelector).first(); data.waiting = false; From e21dd21393008b968cae50b15e6f7c3160a1435e Mon Sep 17 00:00:00 2001 From: fabrizio Date: Mon, 23 Feb 2015 21:42:14 +0100 Subject: [PATCH 6/6] Update jquery.jscroll.min.js --- jquery.jscroll.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.jscroll.min.js b/jquery.jscroll.min.js index 46d24d0..6650f71 100644 --- a/jquery.jscroll.min.js +++ b/jquery.jscroll.min.js @@ -12,4 +12,4 @@ * @author Philip Klauzinski * @requires jQuery v1.4.3+ */ -!function(t){t.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1,onLoadComplete:!1}};var e=function(e,n){function l(){var e=t(p.loadingHtml).filter("img").attr("src");if(e){var n=new Image;n.src=e}}function r(){e.find(".jscroll-inner").length||e.contents().wrapAll('
')}function o(t){if(p.pagingSelector)var e=t.closest(p.pagingSelector).hide();else{var e=t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();e.length||t.wrap('
').parent().hide()}}function i(){return b.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function a(){r();var t=e.find("div.jscroll-inner").first(),n=e.data("jscroll"),l=parseInt(e.css("borderTopWidth")),o=isNaN(l)?0:l,i=parseInt(e.css("paddingTop"))+o,a=j?b.scrollTop():e.offset().top,c=t.length?t.offset().top:0,s=Math.ceil(a-c+b.height()+i);return!n.waiting&&s+p.padding>=t.outerHeight()?(f("info","jScroll:",t.outerHeight()-s,"from bottom. Loading next request..."),d()):void 0}function c(t){return t=t||e.data("jscroll"),t&&t.nextHref?(s(),!0):(f("warn","jScroll: nextSelector not found - destroying"),i(),!1)}function s(){var t=e.find(p.nextSelector).first();return 0==t.length?!1:void(p.autoTrigger&&(p.autoTriggerUntil===!1||p.autoTriggerUntil>0)?(o(t),m.height()<=v.height()&&a(),b.unbind(".jscroll").bind("scroll.jscroll",function(){return a()}),p.autoTriggerUntil>0&&p.autoTriggerUntil--):(b.unbind(".jscroll"),t.bind("click.jscroll",function(){return o(t),d(),!1})))}function d(){var n=e.find("div.jscroll-inner").first(),l=e.data("jscroll");return l.waiting=!0,n.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
"),e.animate({scrollTop:n.outerHeight()},0,function(){n.find("div.jscroll-added").last().load(l.nextHref,function(n,r){if("error"===r)return i();p.onLoadComplete&&p.onLoadComplete.call(this);var o=t(this).find(p.nextSelector).first();l.waiting=!1,l.nextHref=o.attr("href")?t.trim(o.attr("href")+" "+p.contentSelector):!1,t(".jscroll-next-parent",e).remove(),c(),p.callback&&p.callback.call(this),f("dir",l)})})}function f(t){if(p.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var e=[];for(var n in t)"function"==typeof console[n]?(e=t[n].length?t[n]:[t[n]],console[n].apply(console,e)):console.log.apply(console,e)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))}var u=e.data("jscroll"),g="function"==typeof n?{callback:n}:n,p=t.extend({},t.jscroll.defaults,g,u||{}),j="visible"===e.css("overflow-y"),h=e.find(p.nextSelector).first(),v=t(window),m=t("body"),b=j?v:e,x=t.trim(h.attr("href")+" "+p.contentSelector);return e.data("jscroll",t.extend({},u,{initialized:!0,waiting:!1,nextHref:x})),r(),l(),s(),t.extend(e.jscroll,{destroy:i}),e};t.fn.jscroll=function(n){return this.each(function(){var l=t(this),r=l.data("jscroll");if(!r||!r.initialized){new e(l,n)}})}}(jQuery); +!function(t){t.jscroll={defaults:{debug:!1,autoTrigger:!0,autoTriggerUntil:!1,loadingHtml:"Loading...",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:!1,onLoadComplete:!1}};var e=function(e,n){function l(){var e=t(p.loadingHtml).filter("img").attr("src");if(e){var n=new Image;n.src=e}}function r(){e.find(".jscroll-inner").length||e.contents().wrapAll('
')}function o(t){if(p.pagingSelector)var e=t.closest(p.pagingSelector).hide();else{var e=t.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();e.length||t.wrap('
').parent().hide()}}function i(){return b.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function a(){r();var t=e.find("div.jscroll-inner").first(),n=e.data("jscroll"),l=parseInt(e.css("borderTopWidth")),o=isNaN(l)?0:l,i=parseInt(e.css("paddingTop"))+o,a=j?b.scrollTop():e.offset().top,c=t.length?t.offset().top:0,s=Math.ceil(a-c+b.height()+i);return!n.waiting&&s+p.padding>=t.outerHeight()?(f("info","jScroll:",t.outerHeight()-s,"from bottom. Loading next request..."),d()):void 0}function c(t){return t=t||e.data("jscroll"),t&&t.nextHref?(s(),!0):(f("warn","jScroll: nextSelector not found - destroying"),i(),!1)}function s(){var t=e.find(p.nextSelector).first();return 0==t.length?!1:void(p.autoTrigger&&(p.autoTriggerUntil===!1||p.autoTriggerUntil>0)?(o(t),m.height()<=v.height()&&a(),b.unbind(".jscroll").bind("scroll.jscroll",function(){return a()}),p.autoTriggerUntil>0&&p.autoTriggerUntil--):(b.unbind(".jscroll"),t.bind("click.jscroll",function(){return o(t),d(),!1})))}function d(){var n=e.find("div.jscroll-inner").first(),l=e.data("jscroll");return l.waiting=!0,n.append('
').children(".jscroll-added").last().html('
'+p.loadingHtml+"
"),e.animate({scrollTop:n.outerHeight()},0,function(){n.find("div.jscroll-added").last().load(l.nextHref,function(n,r){if("error"===r)return i();p.onLoadComplete&&p.onLoadComplete.call(this,l.nextHref);var o=t(this).find(p.nextSelector).first();l.waiting=!1,l.nextHref=o.attr("href")?t.trim(o.attr("href")+" "+p.contentSelector):!1,t(".jscroll-next-parent",e).remove(),c(),p.callback&&p.callback.call(this),f("dir",l)})})}function f(t){if(p.debug&&"object"==typeof console&&("object"==typeof t||"function"==typeof console[t]))if("object"==typeof t){var e=[];for(var n in t)"function"==typeof console[n]?(e=t[n].length?t[n]:[t[n]],console[n].apply(console,e)):console.log.apply(console,e)}else console[t].apply(console,Array.prototype.slice.call(arguments,1))}var u=e.data("jscroll"),g="function"==typeof n?{callback:n}:n,p=t.extend({},t.jscroll.defaults,g,u||{}),j="visible"===e.css("overflow-y"),h=e.find(p.nextSelector).first(),v=t(window),m=t("body"),b=j?v:e,x=t.trim(h.attr("href")+" "+p.contentSelector);return e.data("jscroll",t.extend({},u,{initialized:!0,waiting:!1,nextHref:x})),r(),l(),s(),t.extend(e.jscroll,{destroy:i}),e};t.fn.jscroll=function(n){return this.each(function(){var l=t(this),r=l.data("jscroll");if(!r||!r.initialized){new e(l,n)}})}}(jQuery);