gitlabhq/app/assets/javascripts/commits.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-10-08 23:36:38 +02:00
$(document).ready(function(){
$(".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
2011-11-15 09:34:30 +01:00
var CommitsList = {
2011-11-05 13:26:06 +01:00
ref:null,
limit:0,
offset:0,
2011-11-15 09:34:30 +01:00
init:
function(ref, limit) {
this.ref=ref;
this.limit=limit;
this.offset=limit;
2011-11-05 13:26:06 +01:00
this.initLoadMore();
$('.loading').show();
},
getOld:
2011-11-15 09:34:30 +01:00
function() {
2011-11-05 13:26:06 +01:00
$('.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);
2011-11-15 09:34:30 +01:00
if(count > 0) {
2011-11-05 13:26:06 +01:00
this.offset += count;
this.initLoadMore();
2011-11-15 09:34:30 +01:00
}
2011-11-05 13:26:06 +01:00
},
initLoadMore:
2011-11-15 09:34:30 +01:00
function() {
2011-11-05 13:26:06 +01:00
$(window).bind('scroll', function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
$(window).unbind('scroll');
CommitsList.getOld();
}
});
}
}