Commit 33aea417 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Drop rjs from Infinite scrolling

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 70c2e1d7
...@@ -4,13 +4,13 @@ class CommitsList ...@@ -4,13 +4,13 @@ class CommitsList
limit: 0 limit: 0
offset: 0 offset: 0
@disable = false @disable = false
@showProgress: -> @showProgress: ->
$('.loading').show() $('.loading').show()
@hideProgress: -> @hideProgress: ->
$('.loading').hide() $('.loading').hide()
@init: (ref, limit) -> @init: (ref, limit) ->
$(".day-commits-table li.commit").live 'click', (event) -> $(".day-commits-table li.commit").live 'click', (event) ->
if event.target.nodeName != "A" if event.target.nodeName != "A"
...@@ -21,7 +21,7 @@ class CommitsList ...@@ -21,7 +21,7 @@ class CommitsList
@data.ref = ref @data.ref = ref
@data.limit = limit @data.limit = limit
@data.offset = limit @data.offset = limit
this.initLoadMore() this.initLoadMore()
this.showProgress() this.showProgress()
...@@ -32,7 +32,9 @@ class CommitsList ...@@ -32,7 +32,9 @@ class CommitsList
url: location.href url: location.href
data: @data data: @data
complete: this.hideProgress complete: this.hideProgress
dataType: "script" success: (data) ->
CommitsList.append(data.count, data.html)
dataType: "json"
@append: (count, html) -> @append: (count, html) ->
$("#commits-list").append(html) $("#commits-list").append(html)
...@@ -40,7 +42,7 @@ class CommitsList ...@@ -40,7 +42,7 @@ class CommitsList
@data.offset += count @data.offset += count
else else
@disable = true @disable = true
@initLoadMore: -> @initLoadMore: ->
$(document).unbind('scroll') $(document).unbind('scroll')
$(document).endlessScroll $(document).endlessScroll
......
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
data: "limit=" + @limit + "&offset=" + @offset data: "limit=" + @limit + "&offset=" + @offset
complete: -> complete: ->
$(".loading").hide() $(".loading").hide()
success: (data) ->
dataType: "script" Pager.append(data.count, data.html)
dataType: "json"
append: (count, html) -> append: (count, html) ->
$(".content_list").append html $(".content_list").append html
......
...@@ -174,4 +174,18 @@ class ApplicationController < ActionController::Base ...@@ -174,4 +174,18 @@ class ApplicationController < ActionController::Base
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present? filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters) @event_filter ||= EventFilter.new(filters)
end 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 end
...@@ -22,7 +22,7 @@ class DashboardController < ApplicationController ...@@ -22,7 +22,7 @@ class DashboardController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.json { pager_json("events/_events", @events.count) }
format.atom { render layout: false } format.atom { render layout: false }
end end
end end
......
...@@ -38,7 +38,7 @@ class GroupsController < ApplicationController ...@@ -38,7 +38,7 @@ class GroupsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.json { pager_json("events/_events", @events.count) }
format.atom { render layout: false } format.atom { render layout: false }
end end
end end
......
...@@ -16,7 +16,7 @@ class Projects::CommitsController < Projects::ApplicationController ...@@ -16,7 +16,7 @@ class Projects::CommitsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js format.json { pager_json("projects/commits/_commits", @commits.size) }
format.atom { render layout: false } format.atom { render layout: false }
end end
end end
......
...@@ -73,7 +73,7 @@ class ProjectsController < ApplicationController ...@@ -73,7 +73,7 @@ class ProjectsController < ApplicationController
render :show, layout: user_layout render :show, layout: user_layout
end end
end end
format.js format.json { pager_json("events/_events", @events.count) }
end end
end end
......
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
:plain
CommitsList.append(#{@commits.count}, "#{escape_javascript(render('projects/commits/commits'))}");
:plain
Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment