BranchGraph now loads async

Centralized keyboard and drag events for BranchGraph
This commit is contained in:
Koen Punt 2012-12-07 19:06:46 +01:00
parent 40576b8709
commit e1282d507f
6 changed files with 123 additions and 95 deletions

View file

@ -18,10 +18,3 @@ $ ->
# Ref switcher
$('.project-refs-select').on 'change', ->
$(@).parents('form').submit()
class @GraphNav
@init: ->
$('.graph svg').css 'position', 'relative'
$('body').bind 'keyup', (e) ->
$('.graph svg').animate(left: '+=400') if e.keyCode is 37 # left
$('.graph svg').animate(left: '-=400') if e.keyCode is 39 # right

View file

@ -83,9 +83,19 @@ class ProjectsController < ProjectResourceController
end
def graph
graph = Gitlab::Graph::JsonBuilder.new(project)
respond_to do |format|
format.html
format.json do
graph = Gitlab::Graph::JsonBuilder.new(project)
#@days_json, @commits_json = graph.days_json, graph.commits_json
render :text => graph.to_json
end
end
@days_json, @commits_json = graph.days_json, graph.commits_json
end
def destroy

View file

@ -4,12 +4,10 @@
%h4
%small You can move around the graph by using the arrow keys.
#holder.graph
.loading
:javascript
var commits = #{@commits_json}
, days = #{@days_json};
var branch_graph = new BranchGraph(days, commits);
var branch_graph;
$(function(){
branch_graph.buildGraph($("#holder")[0]);
GraphNav.init();
branch_graph = new BranchGraph($("#holder"), '#{url_for :controller => 'projects', :action => 'graph'}');
});