gitlabhq/app/assets/javascripts/commits.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

2011-11-15 09:34:30 +01:00
var CommitsList = {
ref:null,
limit:0,
offset:0,
2012-02-12 22:52:27 +01:00
disable:false,
2011-11-05 13:26:06 +01:00
init:
function(ref, limit) {
$(".day-commits-table li.commit").live('click', function(e){
if(e.target.nodeName != "A") {
location.href = $(this).attr("url");
e.stopPropagation();
return false;
}
});
2011-11-05 13:26:06 +01:00
this.ref=ref;
this.limit=limit;
this.offset=limit;
2011-11-05 13:26:06 +01:00
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"});
},
2011-11-05 13:26:06 +01:00
append:
function(count, html) {
$("#commits_list").append(html);
if(count > 0) {
this.offset += count;
2012-02-12 22:52:27 +01:00
} else {
this.disable = true;
2011-11-05 13:26:06 +01:00
}
},
initLoadMore:
function() {
2012-02-12 22:52:27 +01:00
$(document).endlessScroll({
bottomPixels: 400,
fireDelay: 1000,
fireOnce:true,
ceaseFire: function() {
return CommitsList.disable;
},
callback: function(i) {
CommitsList.getOld();
}
});
}
2011-11-05 13:26:06 +01:00
}