summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-02-12 23:52:27 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-02-12 23:52:27 +0200
commitece9f50fb1076c1efee54b4ab3b161f2cac70046 (patch)
tree1e4073f7dad6890e9de48a187dca315d25fe5da7 /app
parent48bc4fc214934160af39958c70f3adb6d7e00b5a (diff)
downloadgitlab-ce-ece9f50fb1076c1efee54b4ab3b161f2cac70046.tar.gz
fixed unworking infinite scroll
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/commits.js15
-rw-r--r--app/assets/javascripts/note.js23
-rw-r--r--app/assets/javascripts/pager.js22
-rw-r--r--app/assets/javascripts/projects.js42
-rw-r--r--app/controllers/commits_controller.rb2
-rw-r--r--app/views/commits/index.html.haml2
-rw-r--r--app/views/notes/_load.js.haml5
-rw-r--r--app/views/projects/index.html.haml4
-rw-r--r--app/views/projects/index.js.haml2
10 files changed, 52 insertions, 66 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 5782f0afc75..1a011c7d43e 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -10,6 +10,7 @@
//= require jquery.ui.selectmenu
//= require jquery.tagify
//= require jquery.cookie
+//= require jquery.endless-scroll
//= require modernizr
//= require chosen
//= require raphael
diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js
index bb06df55c6e..b31fe485896 100644
--- a/app/assets/javascripts/commits.js
+++ b/app/assets/javascripts/commits.js
@@ -2,6 +2,7 @@ var CommitsList = {
ref:null,
limit:0,
offset:0,
+ disable:false,
init:
function(ref, limit) {
@@ -36,15 +37,21 @@ var CommitsList = {
$("#commits_list").append(html);
if(count > 0) {
this.offset += count;
- this.initLoadMore();
+ } else {
+ this.disable = true;
}
},
initLoadMore:
function() {
- $(window).bind('scroll', function(){
- if($(window).scrollTop() == $(document).height() - $(window).height()){
- $(window).unbind('scroll');
+ $(document).endlessScroll({
+ bottomPixels: 400,
+ fireDelay: 1000,
+ fireOnce:true,
+ ceaseFire: function() {
+ return CommitsList.disable;
+ },
+ callback: function(i) {
CommitsList.getOld();
}
});
diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js
index c791623b91d..831150ffbdb 100644
--- a/app/assets/javascripts/note.js
+++ b/app/assets/javascripts/note.js
@@ -3,6 +3,7 @@ var NoteList = {
first_id: 0,
last_id: 0,
resource_name: null,
+disable:false,
init:
function(resource_name, first_id, last_id) {
@@ -26,9 +27,12 @@ getOld:
append:
function(id, html) {
- this.first_id = id;
- $("#notes-list").append(html);
- this.initLoadMore();
+ if(this.first_id == id) {
+ this.disable = true;
+ } else {
+ this.first_id = id;
+ $("#notes-list").append(html);
+ }
},
replace:
@@ -76,11 +80,16 @@ initRefresh:
initLoadMore:
function() {
- $(window).bind('scroll', function(){
- if($(window).scrollTop() == $(document).height() - $(window).height()){
- $(window).unbind('scroll');
+ $(document).endlessScroll({
+ bottomPixels: 400,
+ fireDelay: 1000,
+ fireOnce:true,
+ ceaseFire: function() {
+ return NoteList.disable;
+ },
+ callback: function(i) {
NoteList.getOld();
}
- });
+ });
}
}
diff --git a/app/assets/javascripts/pager.js b/app/assets/javascripts/pager.js
index f34f198d850..d42ae1e05d1 100644
--- a/app/assets/javascripts/pager.js
+++ b/app/assets/javascripts/pager.js
@@ -1,11 +1,10 @@
var Pager = {
- ref:null,
limit:0,
offset:0,
+ disable:false,
init:
- function(ref, limit) {
- this.ref=ref;
+ function(limit) {
this.limit=limit;
this.offset=limit;
this.initLoadMore();
@@ -28,17 +27,24 @@ var Pager = {
$(".content_list").append(html);
if(count > 0) {
this.offset += count;
- this.initLoadMore();
+ } else {
+ this.disable = true;
}
},
initLoadMore:
function() {
- $(window).bind('scroll', function(){
- if($(window).scrollTop() == $(document).height() - $(window).height()){
- $(window).unbind('scroll');
+ $(document).endlessScroll({
+ bottomPixels: 400,
+ fireDelay: 1000,
+ fireOnce:true,
+ ceaseFire: function() {
+ return Pager.disable;
+ },
+ callback: function(i) {
+ $('.loading').show();
Pager.getOld();
}
- });
+ });
}
}
diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js
deleted file mode 100644
index 90de73a112d..00000000000
--- a/app/assets/javascripts/projects.js
+++ /dev/null
@@ -1,42 +0,0 @@
-var ProjectsList = {
- limit:0,
- offset:0,
-
- init:
- function(limit) {
- this.limit=limit;
- this.offset=limit;
- this.initLoadMore();
- },
-
- 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) {
- $(".tile").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');
- $('.loading').show();
- ProjectsList.getOld();
- }
- });
- }
-}
diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb
index 74ea018a150..18f2758794e 100644
--- a/app/controllers/commits_controller.rb
+++ b/app/controllers/commits_controller.rb
@@ -13,7 +13,7 @@ class CommitsController < ApplicationController
def index
@repo = project.repo
- @limit, @offset = (params[:limit] || 20), (params[:offset] || 0)
+ @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
@commits = @project.commits(@ref, params[:path], @limit, @offset)
respond_to do |format|
diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml
index a1a5eed796b..048ee733cb5 100644
--- a/app/views/commits/index.html.haml
+++ b/app/views/commits/index.html.haml
@@ -26,6 +26,6 @@
- if @commits.count == @limit
:javascript
$(function(){
- CommitsList.init("#{@ref}", 20);
+ CommitsList.init("#{@ref}", #{@limit});
});
diff --git a/app/views/notes/_load.js.haml b/app/views/notes/_load.js.haml
index 62d44fe1d5f..8d1b83f4708 100644
--- a/app/views/notes/_load.js.haml
+++ b/app/views/notes/_load.js.haml
@@ -14,3 +14,8 @@
- else
:plain
+
+- else
+ - if params[:first_id]
+ :plain
+ NoteList.append(#{params[:first_id]}, "");
diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml
index c52a7f85819..32c4685fe0c 100644
--- a/app/views/projects/index.html.haml
+++ b/app/views/projects/index.html.haml
@@ -3,7 +3,7 @@
%small= "( #{current_user.projects.count} )"
%hr
- unless @projects.empty?
- %div.tile= render "tile"
+ %div.content_list= render "tile"
-# If projects requris paging
-# We add ajax loader & init script
@@ -13,7 +13,7 @@
:javascript
$(function(){
- ProjectsList.init(16);
+ Pager.init(#{@limit});
});
- else
%h2 Nothing here
diff --git a/app/views/projects/index.js.haml b/app/views/projects/index.js.haml
index 25da7cb4202..15bbd9730d0 100644
--- a/app/views/projects/index.js.haml
+++ b/app/views/projects/index.js.haml
@@ -1,2 +1,2 @@
:plain
- ProjectsList.append(#{@projects.count}, "#{escape_javascript(render(:partial => 'projects/tile'))}");
+ Pager.append(#{@projects.count}, "#{escape_javascript(render(:partial => 'projects/tile'))}");