BigW Consortium Gitlab

Commit 038b3049 by Dmitriy Zaporozhets

Merge branch 'drop_rjs' of /home/git/repositories/gitlab/gitlabhq

parents 70c2e1d7 33aea417
......@@ -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
......
: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