diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-02-08 03:00:49 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-02-08 03:00:49 +0400 |
commit | 4d89322d6785580e9a77e2536b8f2a7db8482664 (patch) | |
tree | 79e80598cecf1410440410590657a3388307ace6 /app/assets/javascripts/pager.js | |
parent | 3d77183c160c57f51f1908bd57312344e34c8524 (diff) |
Snippets - fixed after bootstrap
Project - restyled show page, removed info page
Repository - restyled show page, added download option
Tags - added download options
Diffstat (limited to 'app/assets/javascripts/pager.js')
-rw-r--r-- | app/assets/javascripts/pager.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/assets/javascripts/pager.js b/app/assets/javascripts/pager.js new file mode 100644 index 00000000000..f34f198d850 --- /dev/null +++ b/app/assets/javascripts/pager.js @@ -0,0 +1,44 @@ +var Pager = { + 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, + complete: function(){ $('.loading').hide()}, + dataType: "script"}); + }, + + append: + function(count, html) { + $(".content_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'); + Pager.getOld(); + } + }); + } +} |