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
Tatuya Kamada
gitlab-ce
Commits
351c9521
Commit
351c9521
authored
Mar 19, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: extract method.
parent
96a58421
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
53 deletions
+63
-53
app/assets/javascripts/branch-graph.js.coffee
app/assets/javascripts/branch-graph.js.coffee
+63
-53
No files found.
app/assets/javascripts/branch-graph.js.coffee
View file @
351c9521
...
...
@@ -53,10 +53,10 @@ class BranchGraph
top
=
r
.
set
()
cuday
=
0
cumonth
=
""
offsetX
=
20
offsetY
=
60
@
offsetX
=
20
@
offsetY
=
60
barWidth
=
Math
.
max
(
graphWidth
,
@
days
.
length
*
20
+
320
)
scrollLeft
=
cw
@
scrollLeft
=
cw
@
raphael
=
r
r
.
rect
(
0
,
0
,
barWidth
,
20
).
attr
fill
:
"#222"
r
.
rect
(
0
,
20
,
barWidth
,
20
).
attr
fill
:
"#444"
...
...
@@ -64,7 +64,7 @@ class BranchGraph
for
day
,
mm
in
@
days
if
cuday
isnt
day
[
0
]
# Dates
r
.
text
(
offsetX
+
mm
*
20
,
31
,
day
[
0
])
r
.
text
(
@
offsetX
+
mm
*
20
,
31
,
day
[
0
])
.
attr
(
font
:
"12px Monaco, monospace"
fill
:
"#DDD"
...
...
@@ -73,7 +73,7 @@ class BranchGraph
if
cumonth
isnt
day
[
1
]
# Months
r
.
text
(
offsetX
+
mm
*
20
,
11
,
day
[
1
])
r
.
text
(
@
offsetX
+
mm
*
20
,
11
,
day
[
1
])
.
attr
(
font
:
"12px Monaco, monospace"
fill
:
"#EEE"
...
...
@@ -81,61 +81,21 @@ class BranchGraph
cumonth
=
day
[
1
]
for
commit
in
@
commits
x
=
offsetX
+
20
*
commit
.
time
y
=
offsetY
+
10
*
commit
.
space
# Draw dot
r
.
circle
(
x
,
y
,
3
).
attr
(
fill
:
@
colors
[
commit
.
space
]
stroke
:
"none"
)
x
=
@
offsetX
+
20
*
commit
.
time
y
=
@
offsetY
+
10
*
commit
.
space
# Draw lines
for
parent
in
commit
.
parents
parentCommit
=
@
preparedCommits
[
parent
[
0
]]
parentX
=
offsetX
+
20
*
parentCommit
.
time
parentY1
=
offsetY
+
10
*
parentCommit
.
space
parentY2
=
offsetY
+
10
*
parent
[
1
]
if
parentCommit
.
space
is
commit
.
space
and
parentCommit
.
space
is
parent
[
1
]
r
.
path
([
"M"
,
x
,
y
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
parentCommit
.
space
]
"stroke-width"
:
2
)
@
drawDot
(
x
,
y
,
commit
)
else
if
parentCommit
.
space
<
commit
.
space
if
y
is
parentY2
r
.
path
([
"M"
,
x
-
5
,
y
,
"l-5,-2,0,4,5,-2"
,
"L"
,
x
-
10
,
y
,
"L"
,
x
-
15
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
commit
.
space
]
"stroke-width"
:
2
)
@
drawLines
(
x
,
y
,
commit
)
else
r
.
path
([
"M"
,
x
-
3
,
y
-
6
,
"l-4,-3,4,-2,0,5"
,
"L"
,
x
-
5
,
y
-
10
,
"L"
,
x
-
10
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
commit
.
space
]
"stroke-width"
:
2
)
@
appendLabel
(
x
,
y
,
commit
.
refs
)
if
commit
.
refs
else
r
.
path
([
"M"
,
x
-
3
,
y
+
6
,
"l-4,3,4,2,0,-5"
,
"L"
,
x
-
5
,
y
+
10
,
"L"
,
x
-
10
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
parentCommit
.
space
]
"stroke-width"
:
2
)
@
appendAnchor
(
top
,
commit
,
x
,
y
)
@
appendLabel
x
,
y
,
commit
.
refs
if
commit
.
refs
# Mark commit and displayed in the center
if
commit
.
id
is
@
options
.
commit_id
r
.
path
([
"M"
,
x
,
y
-
5
,
"L"
,
x
+
4
,
y
-
15
,
"L"
,
x
-
4
,
y
-
15
,
"Z"
]).
attr
(
fill
:
"#000"
"fill-opacity"
:
.
7
stroke
:
"none"
)
scrollLeft
=
x
-
graphWidth
/
2
@
appendAnchor
top
,
commit
,
x
,
y
@
markCommit
(
x
,
y
,
commit
,
graphWidth
)
top
.
toFront
()
@
element
.
scrollLeft
scrollLeft
@
element
.
scrollLeft
@
scrollLeft
@
bindEvents
()
bindEvents
:
->
...
...
@@ -211,6 +171,56 @@ class BranchGraph
)
top
.
push
anchor
drawDot
:
(
x
,
y
,
commit
)
->
r
=
@
raphael
r
.
circle
(
x
,
y
,
3
).
attr
(
fill
:
@
colors
[
commit
.
space
]
stroke
:
"none"
)
drawLines
:
(
x
,
y
,
commit
)
->
r
=
@
raphael
for
parent
in
commit
.
parents
parentCommit
=
@
preparedCommits
[
parent
[
0
]]
parentX
=
@
offsetX
+
20
*
parentCommit
.
time
parentY1
=
@
offsetY
+
10
*
parentCommit
.
space
parentY2
=
@
offsetY
+
10
*
parent
[
1
]
if
parentCommit
.
space
is
commit
.
space
and
parentCommit
.
space
is
parent
[
1
]
r
.
path
([
"M"
,
x
,
y
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
parentCommit
.
space
]
"stroke-width"
:
2
)
else
if
parentCommit
.
space
<
commit
.
space
if
y
is
parentY2
r
.
path
([
"M"
,
x
-
5
,
y
,
"l-5,-2,0,4,5,-2"
,
"L"
,
x
-
10
,
y
,
"L"
,
x
-
15
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
commit
.
space
]
"stroke-width"
:
2
)
else
r
.
path
([
"M"
,
x
-
3
,
y
-
6
,
"l-4,-3,4,-2,0,5"
,
"L"
,
x
-
5
,
y
-
10
,
"L"
,
x
-
10
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
commit
.
space
]
"stroke-width"
:
2
)
else
r
.
path
([
"M"
,
x
-
3
,
y
+
6
,
"l-4,3,4,2,0,-5"
,
"L"
,
x
-
5
,
y
+
10
,
"L"
,
x
-
10
,
parentY2
,
"L"
,
parentX
+
5
,
parentY2
,
"L"
,
parentX
,
parentY1
]).
attr
(
stroke
:
@
colors
[
parentCommit
.
space
]
"stroke-width"
:
2
)
markCommit
:
(
x
,
y
,
commit
,
graphWidth
)
->
if
commit
.
id
is
@
options
.
commit_id
r
=
@
raphael
r
.
path
([
"M"
,
x
,
y
-
5
,
"L"
,
x
+
4
,
y
-
15
,
"L"
,
x
-
4
,
y
-
15
,
"Z"
]).
attr
(
fill
:
"#000"
"fill-opacity"
:
.
7
stroke
:
"none"
)
# Displayed in the center
@
scrollLeft
=
x
-
graphWidth
/
2
Raphael
::
commitTooltip
=
(
x
,
y
,
commit
)
->
boxWidth
=
300
boxHeight
=
200
...
...
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