From 0261b0c64c9df0a1a6834fa4f31395989244c2a9 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 26 Sep 2012 21:01:54 +0300 Subject: [PATCH] Project activity inifinite scroll paging --- app/controllers/projects_controller.rb | 3 ++- app/views/projects/show.html.haml | 4 ++++ app/views/projects/show.js.haml | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/views/projects/show.js.haml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 170b8892..b4d026f5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -46,7 +46,7 @@ class ProjectsController < ApplicationController def show limit = (params[:limit] || 20).to_i - @events = @project.events.recent.limit(limit) + @events = @project.events.recent.limit(limit).offset(params[:offset] || 0) respond_to do |format| format.html do @@ -57,6 +57,7 @@ class ProjectsController < ApplicationController render "projects/empty" end end + format.js end end diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 21459da2..2c4f55eb 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -2,3 +2,7 @@ = render 'clone_panel' = render "events/event_last_push", event: @last_push .content_list= render @events +.loading.hide + +:javascript + $(function(){ Pager.init(20); }); diff --git a/app/views/projects/show.js.haml b/app/views/projects/show.js.haml new file mode 100644 index 00000000..511f2789 --- /dev/null +++ b/app/views/projects/show.js.haml @@ -0,0 +1,2 @@ +:plain + Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");