Drop rjs from Infinite scrolling

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-11-28 11:38:20 +02:00
parent 70c2e1d773
commit 33aea41708
No known key found for this signature in database
GPG key ID: 2CEAFD2671262EC2
12 changed files with 30 additions and 21 deletions

View file

@ -4,13 +4,13 @@ class CommitsList
limit: 0
offset: 0
@disable = false
@showProgress: ->
$('.loading').show()
@hideProgress: ->
$('.loading').hide()
@init: (ref, limit) ->
$(".day-commits-table li.commit").live 'click', (event) ->
if event.target.nodeName != "A"
@ -21,7 +21,7 @@ class CommitsList
@data.ref = ref
@data.limit = limit
@data.offset = limit
this.initLoadMore()
this.showProgress()
@ -32,7 +32,9 @@ class CommitsList
url: location.href
data: @data
complete: this.hideProgress
dataType: "script"
success: (data) ->
CommitsList.append(data.count, data.html)
dataType: "json"
@append: (count, html) ->
$("#commits-list").append(html)
@ -40,7 +42,7 @@ class CommitsList
@data.offset += count
else
@disable = true
@initLoadMore: ->
$(document).unbind('scroll')
$(document).endlessScroll

View file

@ -19,8 +19,9 @@
data: "limit=" + @limit + "&offset=" + @offset
complete: ->
$(".loading").hide()
dataType: "script"
success: (data) ->
Pager.append(data.count, data.html)
dataType: "json"
append: (count, html) ->
$(".content_list").append html

View file

@ -174,4 +174,18 @@ class ApplicationController < ActionController::Base
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters)
end
# JSON for infinite scroll via Pager object
def pager_json(partial, count)
html = render_to_string(
partial,
layout: false,
formats: [:html]
)
render json: {
html: html,
count: count
}
end
end

View file

@ -22,7 +22,7 @@ class DashboardController < ApplicationController
respond_to do |format|
format.html
format.js
format.json { pager_json("events/_events", @events.count) }
format.atom { render layout: false }
end
end

View file

@ -38,7 +38,7 @@ class GroupsController < ApplicationController
respond_to do |format|
format.html
format.js
format.json { pager_json("events/_events", @events.count) }
format.atom { render layout: false }
end
end

View file

@ -16,7 +16,7 @@ class Projects::CommitsController < Projects::ApplicationController
respond_to do |format|
format.html # index.html.erb
format.js
format.json { pager_json("projects/commits/_commits", @commits.size) }
format.atom { render layout: false }
end
end

View file

@ -73,7 +73,7 @@ class ProjectsController < ApplicationController
render :show, layout: user_layout
end
end
format.js
format.json { pager_json("events/_events", @events.count) }
end
end

View file

@ -1,2 +0,0 @@
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");

View file

@ -0,0 +1 @@
= render @events

View file

@ -1,2 +0,0 @@
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");

View file

@ -1,3 +0,0 @@
:plain
CommitsList.append(#{@commits.count}, "#{escape_javascript(render('projects/commits/commits'))}");

View file

@ -1,2 +0,0 @@
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");