projects.js 886 Bytes
Newer Older
1 2 3
var ProjectsList = {
  limit:0,
  offset:0,
gitlabhq's avatar
gitlabhq committed
4

5 6 7 8 9 10
  init:
    function(limit) {
      this.limit=limit;
      this.offset=limit;
      this.initLoadMore();
    },
VSizov's avatar
VSizov committed
11

12 13 14 15 16 17 18 19 20 21
  getOld:
    function() {
      $('.loading').show();
      $.ajax({
        type: "GET",
        url: location.href,
        data: "limit=" + this.limit + "&offset=" + this.offset,
        complete: function(){ $('.loading').hide()},
        dataType: "script"});
    },
gitlabhq's avatar
gitlabhq committed
22

23 24 25 26 27 28 29 30
  append:
    function(count, html) {
      $(".tile").append(html);
      if(count > 0) {
        this.offset += count;
        this.initLoadMore();
      }
    },
31

32 33 34 35 36 37 38 39 40 41
  initLoadMore:
    function() {
      $(window).bind('scroll', function(){
        if($(window).scrollTop() == $(document).height() - $(window).height()){
          $(window).unbind('scroll');
          $('.loading').show();
          ProjectsList.getOld();
        }
      });
    }
42
}