diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-11-05 16:26:06 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-11-05 16:26:06 +0400 |
commit | 5eecbfdb10f97a216b585e7bddcbbd68f71f6ccc (patch) | |
tree | d9e7b9f1b51da73118fa9775e1d05f7c1f76c649 /app/assets/javascripts/commits.js | |
parent | 586c53ea0594a327b346c6fed38528a1f508c9e1 (diff) |
commit paging fixes
Diffstat (limited to 'app/assets/javascripts/commits.js')
-rw-r--r-- | app/assets/javascripts/commits.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js index a62e9330ffc..bef7ed74bee 100644 --- a/app/assets/javascripts/commits.js +++ b/app/assets/javascripts/commits.js @@ -7,3 +7,51 @@ $(document).ready(function(){ } }); }); + + + +var CommitsList = { + +ref:null, +limit:0, +offset:0, + +init: + function(ref, limit) { + this.ref=ref; + this.limit=limit; + this.offset=limit; + this.initLoadMore(); + $('.loading').show(); + }, + +getOld: + function() { + $('.loading').show(); + $.ajax({ + type: "GET", + url: location.href, + data: "limit=" + this.limit + "&offset=" + this.offset + "&ref=" + this.ref, + complete: function(){ $('.loading').hide()}, + dataType: "script"}); + }, + +append: + function(count, html) { + $("#commits_list").append(html); + if(count > 0) { + this.offset += count; + this.initLoadMore(); + } + }, + +initLoadMore: + function() { + $(window).bind('scroll', function(){ + if($(window).scrollTop() == $(document).height() - $(window).height()){ + $(window).unbind('scroll'); + CommitsList.getOld(); + } + }); + } +} |