Drop rjs from Infinite scrolling
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
70c2e1d773
commit
33aea41708
12 changed files with 30 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
:plain
|
||||
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
|
1
app/views/events/_events.html.haml
Normal file
1
app/views/events/_events.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= render @events
|
|
@ -1,2 +0,0 @@
|
|||
:plain
|
||||
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
|
|
@ -1,3 +0,0 @@
|
|||
:plain
|
||||
CommitsList.append(#{@commits.count}, "#{escape_javascript(render('projects/commits/commits'))}");
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
:plain
|
||||
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
|
Loading…
Reference in a new issue