Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
85c468ec
Commit
85c468ec
authored
Apr 24, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render graph partially.
parent
63b58b94
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
27 deletions
+55
-27
app/assets/javascripts/branch-graph.js.coffee
app/assets/javascripts/branch-graph.js.coffee
+55
-27
No files found.
app/assets/javascripts/branch-graph.js.coffee
View file @
85c468ec
...
@@ -9,6 +9,7 @@ class BranchGraph
...
@@ -9,6 +9,7 @@ class BranchGraph
@
offsetY
=
20
@
offsetY
=
20
@
unitTime
=
30
@
unitTime
=
30
@
unitSpace
=
10
@
unitSpace
=
10
@
prev_start
=
-
1
@
load
()
@
load
()
load
:
->
load
:
->
...
@@ -24,10 +25,18 @@ class BranchGraph
...
@@ -24,10 +25,18 @@ class BranchGraph
prepareData
:
(
@
days
,
@
commits
)
->
prepareData
:
(
@
days
,
@
commits
)
->
@
collectParents
()
@
collectParents
()
@
graphHeight
=
$
(
@
element
).
height
()
@
graphWidth
=
$
(
@
element
).
width
()
ch
=
Math
.
max
(
@
graphHeight
,
@
offsetY
+
@
unitTime
*
@
mtime
+
150
)
cw
=
Math
.
max
(
@
graphWidth
,
@
offsetX
+
@
unitSpace
*
@
mspace
+
300
)
@
r
=
Raphael
(
@
element
.
get
(
0
),
cw
,
ch
)
@
top
=
@
r
.
set
()
@
barHeight
=
Math
.
max
(
@
graphHeight
,
@
unitTime
*
@
days
.
length
+
320
)
for
c
in
@
commits
for
c
in
@
commits
c
.
isParent
=
true
if
c
.
id
of
@
parents
c
.
isParent
=
true
if
c
.
id
of
@
parents
@
preparedCommits
[
c
.
id
]
=
c
@
preparedCommits
[
c
.
id
]
=
c
@
markCommit
(
c
)
@
collectColors
()
@
collectColors
()
...
@@ -49,18 +58,12 @@ class BranchGraph
...
@@ -49,18 +58,12 @@ class BranchGraph
k
++
k
++
buildGraph
:
->
buildGraph
:
->
graphHeight
=
$
(
@
element
).
height
()
r
=
@
r
graphWidth
=
$
(
@
element
).
width
()
ch
=
Math
.
max
(
graphHeight
,
@
offsetY
+
@
unitTime
*
@
mtime
+
150
)
cw
=
Math
.
max
(
graphWidth
,
@
offsetX
+
@
unitSpace
*
@
mspace
+
300
)
@
r
=
r
=
Raphael
(
@
element
.
get
(
0
),
cw
,
ch
)
top
=
r
.
set
()
cuday
=
0
cuday
=
0
cumonth
=
""
cumonth
=
""
barHeight
=
Math
.
max
(
graphHeight
,
@
unitTime
*
@
days
.
length
+
320
)
r
.
rect
(
0
,
0
,
26
,
barHeight
).
attr
fill
:
"#222"
r
.
rect
(
0
,
0
,
26
,
@
barHeight
).
attr
fill
:
"#222"
r
.
rect
(
26
,
0
,
20
,
barHeight
).
attr
fill
:
"#444"
r
.
rect
(
26
,
0
,
20
,
@
barHeight
).
attr
fill
:
"#444"
for
day
,
mm
in
@
days
for
day
,
mm
in
@
days
if
cuday
isnt
day
[
0
]
if
cuday
isnt
day
[
0
]
...
@@ -81,7 +84,26 @@ class BranchGraph
...
@@ -81,7 +84,26 @@ class BranchGraph
)
)
cumonth
=
day
[
1
]
cumonth
=
day
[
1
]
for
commit
in
@
commits
@
renderPartialGraph
()
@
bindEvents
()
renderPartialGraph
:
->
start
=
Math
.
floor
((
@
element
.
scrollTop
()
-
@
offsetY
)
/
@
unitTime
)
-
10
start
=
0
if
start
<
0
end
=
start
+
40
end
=
@
commits
.
length
if
@
commits
.
length
<
end
if
@
prev_start
==
-
1
or
Math
.
abs
(
@
prev_start
-
start
)
>
10
i
=
start
@
prev_start
=
start
while
i
<
end
commit
=
@
commits
[
i
]
i
+=
1
if
commit
.
hasDrawn
isnt
true
x
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
commit
.
space
)
x
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
commit
.
space
)
y
=
@
offsetY
+
@
unitTime
*
commit
.
time
y
=
@
offsetY
+
@
unitTime
*
commit
.
time
...
@@ -89,14 +111,13 @@ class BranchGraph
...
@@ -89,14 +111,13 @@ class BranchGraph
@
drawLines
(
x
,
y
,
commit
)
@
drawLines
(
x
,
y
,
commit
)
@
appendLabel
(
x
,
y
,
commit
.
refs
)
if
commit
.
refs
@
appendLabel
(
x
,
y
,
commit
)
@
appendAnchor
(
top
,
commit
,
x
,
y
)
@
appendAnchor
(
x
,
y
,
commit
)
@
markCommit
(
x
,
y
,
commit
,
graphHeight
)
commit
.
hasDrawn
=
true
top
.
toFront
()
@
top
.
toFront
()
@
bindEvents
()
bindEvents
:
->
bindEvents
:
->
drag
=
{}
drag
=
{}
...
@@ -114,9 +135,10 @@ class BranchGraph
...
@@ -114,9 +135,10 @@ class BranchGraph
$
(
window
).
on
"mousemove"
,
dragger
$
(
window
).
on
"mousemove"
,
dragger
$
(
window
).
on
$
(
window
).
on
mouseup
:
-
>
mouseup
:
=
>
$
(
window
).
off
"mousemove"
,
dragger
$
(
window
).
off
"mousemove"
,
dragger
keydown
:
(
event
)
->
@
renderPartialGraph
()
keydown
:
(
event
)
=>
# left
# left
element
.
scrollLeft
element
.
scrollLeft
()
-
50
if
event
.
keyCode
is
37
element
.
scrollLeft
element
.
scrollLeft
()
-
50
if
event
.
keyCode
is
37
# top
# top
...
@@ -125,17 +147,20 @@ class BranchGraph
...
@@ -125,17 +147,20 @@ class BranchGraph
element
.
scrollLeft
element
.
scrollLeft
()
+
50
if
event
.
keyCode
is
39
element
.
scrollLeft
element
.
scrollLeft
()
+
50
if
event
.
keyCode
is
39
# bottom
# bottom
element
.
scrollTop
element
.
scrollTop
()
+
50
if
event
.
keyCode
is
40
element
.
scrollTop
element
.
scrollTop
()
+
50
if
event
.
keyCode
is
40
@
renderPartialGraph
()
appendLabel
:
(
x
,
y
,
commit
)
->
return
unless
commit
.
refs
appendLabel
:
(
x
,
y
,
refs
)
->
r
=
@
r
r
=
@
r
shortrefs
=
refs
shortrefs
=
commit
.
refs
# Truncate if longer than 15 chars
# Truncate if longer than 15 chars
shortrefs
=
shortrefs
.
substr
(
0
,
15
)
+
"…"
if
shortrefs
.
length
>
17
shortrefs
=
shortrefs
.
substr
(
0
,
15
)
+
"…"
if
shortrefs
.
length
>
17
text
=
r
.
text
(
x
+
4
,
y
,
shortrefs
).
attr
(
text
=
r
.
text
(
x
+
4
,
y
,
shortrefs
).
attr
(
"text-anchor"
:
"start"
"text-anchor"
:
"start"
font
:
"10px Monaco, monospace"
font
:
"10px Monaco, monospace"
fill
:
"#FFF"
fill
:
"#FFF"
title
:
refs
title
:
commit
.
refs
)
)
textbox
=
text
.
getBBox
()
textbox
=
text
.
getBBox
()
# Create rectangle based on the size of the textbox
# Create rectangle based on the size of the textbox
...
@@ -156,8 +181,9 @@ class BranchGraph
...
@@ -156,8 +181,9 @@ class BranchGraph
# Set text to front
# Set text to front
text
.
toFront
()
text
.
toFront
()
appendAnchor
:
(
top
,
commit
,
x
,
y
)
->
appendAnchor
:
(
x
,
y
,
commit
)
->
r
=
@
r
r
=
@
r
top
=
@
top
options
=
@
options
options
=
@
options
anchor
=
r
.
circle
(
x
,
y
,
10
).
attr
(
anchor
=
r
.
circle
(
x
,
y
,
10
).
attr
(
fill
:
"#000"
fill
:
"#000"
...
@@ -240,16 +266,18 @@ class BranchGraph
...
@@ -240,16 +266,18 @@ class BranchGraph
stroke
:
color
stroke
:
color
"stroke-width"
:
2
)
"stroke-width"
:
2
)
markCommit
:
(
x
,
y
,
commit
,
graphHeigh
t
)
->
markCommit
:
(
commi
t
)
->
if
commit
.
id
is
@
options
.
commit_id
if
commit
.
id
is
@
options
.
commit_id
r
=
@
r
r
=
@
r
x
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
commit
.
space
)
y
=
@
offsetY
+
@
unitTime
*
commit
.
time
r
.
path
([
"M"
,
x
+
5
,
y
,
"L"
,
x
+
15
,
y
+
4
,
"L"
,
x
+
15
,
y
-
4
,
"Z"
]).
attr
(
r
.
path
([
"M"
,
x
+
5
,
y
,
"L"
,
x
+
15
,
y
+
4
,
"L"
,
x
+
15
,
y
-
4
,
"Z"
]).
attr
(
fill
:
"#000"
fill
:
"#000"
"fill-opacity"
:
.
5
"fill-opacity"
:
.
5
stroke
:
"none"
stroke
:
"none"
)
)
# Displayed in the center
# Displayed in the center
@
element
.
scrollTop
(
y
-
graphHeight
/
2
)
@
element
.
scrollTop
(
y
-
@
graphHeight
/
2
)
Raphael
::
commitTooltip
=
(
x
,
y
,
commit
)
->
Raphael
::
commitTooltip
=
(
x
,
y
,
commit
)
->
boxWidth
=
300
boxWidth
=
300
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment