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
Jérome Perrin
gitlab-ce
Commits
916c61fc
Commit
916c61fc
authored
Mar 21, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: clean up code.
parent
1f6b6b6c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
app/assets/javascripts/branch-graph.js.coffee
app/assets/javascripts/branch-graph.js.coffee
+21
-20
No files found.
app/assets/javascripts/branch-graph.js.coffee
View file @
916c61fc
...
@@ -5,6 +5,10 @@ class BranchGraph
...
@@ -5,6 +5,10 @@ class BranchGraph
@
mspace
=
0
@
mspace
=
0
@
parents
=
{}
@
parents
=
{}
@
colors
=
[
"#000"
]
@
colors
=
[
"#000"
]
@
offsetX
=
120
@
offsetY
=
20
@
unitTime
=
20
@
unitSpace
=
10
@
load
()
@
load
()
load
:
->
load
:
->
...
@@ -47,24 +51,21 @@ class BranchGraph
...
@@ -47,24 +51,21 @@ class BranchGraph
buildGraph
:
->
buildGraph
:
->
graphHeight
=
$
(
@
element
).
height
()
graphHeight
=
$
(
@
element
).
height
()
graphWidth
=
$
(
@
element
).
width
()
graphWidth
=
$
(
@
element
).
width
()
ch
=
Math
.
max
(
graphHeight
,
@
mtime
*
20
+
100
)
ch
=
Math
.
max
(
graphHeight
,
@
unitTime
*
@
mtime
+
100
)
cw
=
Math
.
max
(
graphWidth
,
@
mspace
*
10
+
260
)
cw
=
Math
.
max
(
graphWidth
,
@
unitSpace
*
@
mspace
+
260
)
r
=
Raphael
(
@
element
.
get
(
0
),
cw
,
ch
)
@
r
=
r
=
Raphael
(
@
element
.
get
(
0
),
cw
,
ch
)
top
=
r
.
set
()
top
=
r
.
set
()
cuday
=
0
cuday
=
0
cumonth
=
""
cumonth
=
""
@
offsetX
=
120
barHeight
=
Math
.
max
(
graphHeight
,
@
unitTime
*
@
days
.
length
+
320
)
@
offsetY
=
20
barHeight
=
Math
.
max
(
graphHeight
,
@
days
.
length
*
20
+
320
)
@
scrollLeft
=
cw
@
raphael
=
r
r
.
rect
(
0
,
0
,
20
,
barHeight
).
attr
fill
:
"#222"
r
.
rect
(
0
,
0
,
20
,
barHeight
).
attr
fill
:
"#222"
r
.
rect
(
20
,
0
,
20
,
barHeight
).
attr
fill
:
"#444"
r
.
rect
(
20
,
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
]
# Dates
# Dates
r
.
text
(
30
,
@
offsetY
+
mm
*
20
,
day
[
0
])
r
.
text
(
30
,
@
offsetY
+
@
unitTime
*
mm
,
day
[
0
])
.
attr
(
.
attr
(
font
:
"12px Monaco, monospace"
font
:
"12px Monaco, monospace"
fill
:
"#DDD"
fill
:
"#DDD"
...
@@ -73,7 +74,7 @@ class BranchGraph
...
@@ -73,7 +74,7 @@ class BranchGraph
if
cumonth
isnt
day
[
1
]
if
cumonth
isnt
day
[
1
]
# Months
# Months
r
.
text
(
10
,
@
offsetY
+
mm
*
20
,
day
[
1
])
r
.
text
(
10
,
@
offsetY
+
@
unitTime
*
mm
,
day
[
1
])
.
attr
(
.
attr
(
font
:
"12px Monaco, monospace"
font
:
"12px Monaco, monospace"
fill
:
"#EEE"
fill
:
"#EEE"
...
@@ -81,8 +82,8 @@ class BranchGraph
...
@@ -81,8 +82,8 @@ class BranchGraph
cumonth
=
day
[
1
]
cumonth
=
day
[
1
]
for
commit
in
@
commits
for
commit
in
@
commits
x
=
@
offsetX
+
10
*
(
@
mspace
-
commit
.
space
)
x
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
commit
.
space
)
y
=
@
offsetY
+
20
*
commit
.
time
y
=
@
offsetY
+
@
unitTime
*
commit
.
time
@
drawDot
(
x
,
y
,
commit
)
@
drawDot
(
x
,
y
,
commit
)
...
@@ -126,7 +127,7 @@ class BranchGraph
...
@@ -126,7 +127,7 @@ class BranchGraph
element
.
scrollTop
element
.
scrollTop
()
+
50
if
event
.
keyCode
is
40
element
.
scrollTop
element
.
scrollTop
()
+
50
if
event
.
keyCode
is
40
appendLabel
:
(
x
,
y
,
refs
)
->
appendLabel
:
(
x
,
y
,
refs
)
->
r
=
@
r
aphael
r
=
@
r
shortrefs
=
refs
shortrefs
=
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
...
@@ -156,7 +157,7 @@ class BranchGraph
...
@@ -156,7 +157,7 @@ class BranchGraph
text
.
toFront
()
text
.
toFront
()
appendAnchor
:
(
top
,
commit
,
x
,
y
)
->
appendAnchor
:
(
top
,
commit
,
x
,
y
)
->
r
=
@
r
aphael
r
=
@
r
options
=
@
options
options
=
@
options
anchor
=
r
.
circle
(
x
,
y
,
10
).
attr
(
anchor
=
r
.
circle
(
x
,
y
,
10
).
attr
(
fill
:
"#000"
fill
:
"#000"
...
@@ -173,19 +174,19 @@ class BranchGraph
...
@@ -173,19 +174,19 @@ class BranchGraph
top
.
push
anchor
top
.
push
anchor
drawDot
:
(
x
,
y
,
commit
)
->
drawDot
:
(
x
,
y
,
commit
)
->
r
=
@
r
aphael
r
=
@
r
r
.
circle
(
x
,
y
,
3
).
attr
(
r
.
circle
(
x
,
y
,
3
).
attr
(
fill
:
@
colors
[
commit
.
space
]
fill
:
@
colors
[
commit
.
space
]
stroke
:
"none"
stroke
:
"none"
)
)
drawLines
:
(
x
,
y
,
commit
)
->
drawLines
:
(
x
,
y
,
commit
)
->
r
=
@
r
aphael
r
=
@
r
for
parent
in
commit
.
parents
for
parent
in
commit
.
parents
parentCommit
=
@
preparedCommits
[
parent
[
0
]]
parentCommit
=
@
preparedCommits
[
parent
[
0
]]
parentY
=
@
offsetY
+
20
*
parentCommit
.
time
parentY
=
@
offsetY
+
@
unitTime
*
parentCommit
.
time
parentX1
=
@
offsetX
+
10
*
(
@
mspace
-
parentCommit
.
space
)
parentX1
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
parentCommit
.
space
)
parentX2
=
@
offsetX
+
10
*
(
@
mspace
-
parent
[
1
])
parentX2
=
@
offsetX
+
@
unitSpace
*
(
@
mspace
-
parent
[
1
])
if
parentCommit
.
space
is
commit
.
space
and
parentCommit
.
space
is
parent
[
1
]
if
parentCommit
.
space
is
commit
.
space
and
parentCommit
.
space
is
parent
[
1
]
r
.
path
([
"M"
,
x
,
y
,
"L"
,
parentX1
,
parentY
]).
attr
(
r
.
path
([
"M"
,
x
,
y
,
"L"
,
parentX1
,
parentY
]).
attr
(
...
@@ -235,7 +236,7 @@ class BranchGraph
...
@@ -235,7 +236,7 @@ class BranchGraph
markCommit
:
(
x
,
y
,
commit
,
graphHeight
)
->
markCommit
:
(
x
,
y
,
commit
,
graphHeight
)
->
if
commit
.
id
is
@
options
.
commit_id
if
commit
.
id
is
@
options
.
commit_id
r
=
@
r
aphael
r
=
@
r
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
...
...
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