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
iv
gitlab-ce
Commits
90cba379
Commit
90cba379
authored
Dec 28, 2012
by
Koen Punt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated graph tooltips and labels
parent
f04597d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
45 deletions
+117
-45
lib/gitlab/graph/commit.rb
lib/gitlab/graph/commit.rb
+4
-2
vendor/assets/javascripts/branch-graph.js
vendor/assets/javascripts/branch-graph.js
+113
-43
No files found.
lib/gitlab/graph/commit.rb
View file @
90cba379
...
@@ -22,14 +22,16 @@ module Gitlab
...
@@ -22,14 +22,16 @@ module Gitlab
h
[
:parents
]
=
self
.
parents
.
collect
do
|
p
|
h
[
:parents
]
=
self
.
parents
.
collect
do
|
p
|
[
p
.
id
,
0
,
0
]
[
p
.
id
,
0
,
0
]
end
end
h
[
:author
]
=
author
.
name
h
[
:author
]
=
{
name:
author
.
name
,
email:
author
.
email
}
h
[
:time
]
=
time
h
[
:time
]
=
time
h
[
:space
]
=
space
h
[
:space
]
=
space
h
[
:refs
]
=
refs
.
collect
{
|
r
|
r
.
name
}.
join
(
" "
)
unless
refs
.
nil?
h
[
:refs
]
=
refs
.
collect
{
|
r
|
r
.
name
}.
join
(
" "
)
unless
refs
.
nil?
h
[
:id
]
=
sha
h
[
:id
]
=
sha
h
[
:date
]
=
date
h
[
:date
]
=
date
h
[
:message
]
=
message
h
[
:message
]
=
message
h
[
:login
]
=
author
.
email
h
h
end
end
...
...
vendor/assets/javascripts/branch-graph.js
View file @
90cba379
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
if
(
cuday
!=
this
.
days
[
mm
][
0
]){
if
(
cuday
!=
this
.
days
[
mm
][
0
]){
// Dates
// Dates
r
.
text
(
offsetX
+
mm
*
20
,
31
,
this
.
days
[
mm
][
0
]).
attr
({
r
.
text
(
offsetX
+
mm
*
20
,
31
,
this
.
days
[
mm
][
0
]).
attr
({
font
:
"
12px Monaco,
Arial
"
,
font
:
"
12px Monaco,
monospace
"
,
fill
:
"
#DDD
"
fill
:
"
#DDD
"
});
});
cuday
=
this
.
days
[
mm
][
0
];
cuday
=
this
.
days
[
mm
][
0
];
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
if
(
cumonth
!=
this
.
days
[
mm
][
1
]){
if
(
cumonth
!=
this
.
days
[
mm
][
1
]){
// Months
// Months
r
.
text
(
offsetX
+
mm
*
20
,
11
,
this
.
days
[
mm
][
1
]).
attr
({
r
.
text
(
offsetX
+
mm
*
20
,
11
,
this
.
days
[
mm
][
1
]).
attr
({
font
:
"
12px Monaco,
Arial
"
,
font
:
"
12px Monaco,
monospace
"
,
fill
:
"
#EEE
"
fill
:
"
#EEE
"
});
});
cumonth
=
this
.
days
[
mm
][
1
];
cumonth
=
this
.
days
[
mm
][
1
];
...
@@ -103,17 +103,16 @@
...
@@ -103,17 +103,16 @@
for
(
i
=
0
;
i
<
this
.
commitCount
;
i
++
)
{
for
(
i
=
0
;
i
<
this
.
commitCount
;
i
++
)
{
var
x
=
offsetX
+
20
*
this
.
commits
[
i
].
time
var
x
=
offsetX
+
20
*
this
.
commits
[
i
].
time
,
y
=
offsetY
+
20
*
this
.
commits
[
i
].
space
;
,
y
=
offsetY
+
20
*
this
.
commits
[
i
].
space
,
c
;
// Draw dot
r
.
circle
(
x
,
y
,
3
).
attr
({
r
.
circle
(
x
,
y
,
3
).
attr
({
fill
:
this
.
colors
[
this
.
commits
[
i
].
space
],
fill
:
this
.
colors
[
this
.
commits
[
i
].
space
],
stroke
:
"
none
"
stroke
:
"
none
"
});
});
// Draw lines
if
(
this
.
commits
[
i
].
refs
)
{
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
}
var
c
;
for
(
var
j
=
0
,
jj
=
this
.
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
for
(
var
j
=
0
,
jj
=
this
.
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
c
=
this
.
preparedCommits
[
this
.
commits
[
i
].
parents
[
j
][
0
]];
c
=
this
.
preparedCommits
[
this
.
commits
[
i
].
parents
[
j
][
0
]];
if
(
c
)
{
if
(
c
)
{
...
@@ -143,6 +142,11 @@
...
@@ -143,6 +142,11 @@
}
}
}
}
}
}
if
(
this
.
commits
[
i
].
refs
)
{
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
}
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
}
}
top
.
toFront
();
top
.
toFront
();
...
@@ -201,13 +205,13 @@
...
@@ -201,13 +205,13 @@
,
shortrefs
=
refs
,
shortrefs
=
refs
,
text
,
textbox
,
rect
;
,
text
,
textbox
,
rect
;
if
(
shortrefs
.
length
>
1
5
){
if
(
shortrefs
.
length
>
1
7
){
// Truncate if longer than 15 chars
// Truncate if longer than 15 chars
shortrefs
=
shortrefs
.
substr
(
0
,
1
3
)
+
"
...
"
;
shortrefs
=
shortrefs
.
substr
(
0
,
1
5
)
+
"
…
"
;
}
}
text
=
r
.
text
(
x
+
5
,
y
+
8
,
shortrefs
).
attr
({
text
=
r
.
text
(
x
+
5
,
y
+
8
+
10
,
shortrefs
).
attr
({
font
:
"
1
2px Monaco, Arial
"
,
font
:
"
1
0px Monaco, monospace
"
,
fill
:
"
#FFF
"
,
fill
:
"
#FFF
"
,
title
:
refs
title
:
refs
});
});
...
@@ -220,22 +224,33 @@
...
@@ -220,22 +224,33 @@
// Create rectangle based on the size of the textbox
// Create rectangle based on the size of the textbox
rect
=
r
.
rect
(
x
,
y
,
textbox
.
width
+
15
,
textbox
.
height
+
5
,
4
).
attr
({
rect
=
r
.
rect
(
x
,
y
,
textbox
.
width
+
15
,
textbox
.
height
+
5
,
4
).
attr
({
fill
:
"
#000
"
,
"
fill
"
:
"
#000
"
,
"
fill-opacity
"
:
.
5
,
"
fill-opacity
"
:
.
7
,
stroke
:
"
none
"
"
stroke
"
:
"
none
"
});
triangle
=
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
"
});
});
// Rotate and reposition rectangle over text
// Rotate and reposition rectangle over text
rect
.
transform
([
rect
.
transform
([
'
r
'
,
90
,
x
,
y
,
'
r
'
,
90
,
x
,
y
,
'
t
'
,
5
,
-
10
'
t
'
,
15
,
-
9
]);
]);
// Set text to front
// Set text to front
text
.
toFront
();
text
.
toFront
();
};
};
BranchGraph
.
prototype
.
appendAnchor
=
function
(
top
,
c
,
x
,
y
)
{
BranchGraph
.
prototype
.
appendAnchor
=
function
(
top
,
c
ommit
,
x
,
y
)
{
var
r
=
this
.
raphael
var
r
=
this
.
raphael
,
options
=
this
.
options
,
options
=
this
.
options
,
anchor
;
,
anchor
;
...
@@ -245,16 +260,13 @@
...
@@ -245,16 +260,13 @@
cursor
:
"
pointer
"
cursor
:
"
pointer
"
})
})
.
click
(
function
(){
.
click
(
function
(){
window
.
location
=
options
.
commit_url
.
replace
(
'
%s
'
,
c
.
id
);
window
.
location
=
options
.
commit_url
.
replace
(
'
%s
'
,
c
ommit
.
id
);
})
})
.
hover
(
function
(){
.
hover
(
function
(){
var
text
=
r
.
text
(
100
,
100
,
c
.
author
+
"
\n
\n
"
+
c
.
id
+
"
\n
\n
"
+
c
.
message
).
attr
({
this
.
tooltip
=
r
.
commitTooltip
(
x
,
y
+
5
,
commit
);
fill
:
"
#fff
"
top
.
push
(
this
.
tooltip
.
insertBefore
(
this
));
});
this
.
popup
=
r
.
tooltip
(
x
,
y
+
5
,
text
,
0
);
top
.
push
(
this
.
popup
.
insertBefore
(
this
));
},
function
(){
},
function
(){
this
.
popup
&&
this
.
popup
.
remove
()
&&
delete
this
.
popu
p
;
this
.
tooltip
&&
this
.
tooltip
.
remove
()
&&
delete
this
.
toolti
p
;
});
});
top
.
push
(
anchor
);
top
.
push
(
anchor
);
};
};
...
@@ -262,23 +274,81 @@
...
@@ -262,23 +274,81 @@
this
.
BranchGraph
=
BranchGraph
;
this
.
BranchGraph
=
BranchGraph
;
}(
this
);
}(
this
);
Raphael
.
fn
.
tooltip
=
function
(
x
,
y
,
set
,
dir
,
size
)
{
Raphael
.
fn
.
commitTooltip
=
function
(
x
,
y
,
commit
){
dir
=
dir
==
null
?
2
:
dir
;
var
nameText
,
idText
,
messageText
size
=
size
||
5
;
,
boxWidth
=
300
x
=
Math
.
round
(
x
);
,
boxHeight
=
200
;
y
=
Math
.
round
(
y
);
var
mmax
=
Math
.
max
nameText
=
this
.
text
(
x
,
y
+
10
,
commit
.
author
.
name
);
,
bb
=
set
.
getBBox
()
idText
=
this
.
text
(
x
,
y
+
35
,
commit
.
id
);
,
w
=
Math
.
round
(
bb
.
width
/
2
)
messageText
=
this
.
text
(
x
,
y
+
50
,
commit
.
message
);
,
h
=
Math
.
round
(
bb
.
height
/
2
)
,
dx
=
[
0
,
w
+
size
*
2
,
0
,
-
w
-
size
*
2
]
textSet
=
this
.
set
(
nameText
,
idText
,
messageText
).
attr
({
,
dy
=
[
-
h
*
2
-
size
*
3
,
-
h
-
size
,
0
,
-
h
-
size
]
"
text-anchor
"
:
"
start
"
,
,
p
=
[
"
M
"
,
x
-
dx
[
dir
],
y
-
dy
[
dir
],
"
l
"
,
-
size
,
(
dir
==
2
)
*
-
size
,
-
mmax
(
w
-
size
,
0
),
0
,
"
a
"
,
size
,
size
,
0
,
0
,
1
,
-
size
,
-
size
,
"
font
"
:
"
12px Monaco, monospace
"
"
l
"
,
0
,
-
mmax
(
h
-
size
,
0
),
(
dir
==
3
)
*
-
size
,
-
size
,
(
dir
==
3
)
*
size
,
-
size
,
0
,
-
mmax
(
h
-
size
,
0
),
"
a
"
,
size
,
size
,
0
,
0
,
1
,
size
,
-
size
,
});
"
l
"
,
mmax
(
w
-
size
,
0
),
0
,
size
,
!
dir
*
-
size
,
size
,
!
dir
*
size
,
mmax
(
w
-
size
,
0
),
0
,
"
a
"
,
size
,
size
,
0
,
0
,
1
,
size
,
size
,
"
l
"
,
0
,
mmax
(
h
-
size
,
0
),
(
dir
==
1
)
*
size
,
size
,
(
dir
==
1
)
*
-
size
,
size
,
0
,
mmax
(
h
-
size
,
0
),
"
a
"
,
size
,
size
,
0
,
0
,
1
,
-
size
,
size
,
nameText
.
attr
({
"
l
"
,
-
mmax
(
w
-
size
,
0
),
0
,
"
z
"
].
join
(
"
,
"
)
"
font
"
:
"
14px Arial
"
,
,
xy
=
[{
x
:
x
,
y
:
y
+
size
*
2
+
h
},
{
x
:
x
-
size
*
2
-
w
,
y
:
y
},
{
x
:
x
,
y
:
y
-
size
*
2
-
h
},
{
x
:
x
+
size
*
2
+
w
,
y
:
y
}][
dir
];
"
font-weight
"
:
"
bold
"
set
.
transform
([
'
t
'
,
xy
.
x
-
w
-
bb
.
x
,
xy
.
y
-
h
-
bb
.
y
]);
});
return
this
.
set
(
this
.
path
(
p
).
attr
({
fill
:
"
#234
"
,
stroke
:
"
none
"
}).
insertBefore
(
set
.
node
?
set
:
set
[
0
]),
set
);
idText
.
attr
({
"
fill
"
:
"
#AAA
"
});
textWrap
(
messageText
,
boxWidth
-
50
);
var
rect
=
this
.
rect
(
x
-
10
,
y
-
10
,
boxWidth
,
100
,
4
).
attr
({
"
fill
"
:
"
#FFF
"
,
"
stroke
"
:
"
#000
"
,
"
stroke-linecap
"
:
"
round
"
,
"
stroke-width
"
:
2
});
var
tooltip
=
this
.
set
(
rect
,
textSet
);
rect
.
attr
({
"
height
"
:
tooltip
.
getBBox
().
height
+
10
,
"
width
"
:
tooltip
.
getBBox
().
width
+
10
});
tooltip
.
transform
([
'
t
'
,
20
,
20
]);
return
tooltip
;
};
};
function
textWrap
(
t
,
width
)
{
var
content
=
t
.
attr
(
"
text
"
);
var
abc
=
"
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
"
;
t
.
attr
({
"
text
"
:
abc
});
var
letterWidth
=
t
.
getBBox
().
width
/
abc
.
length
;
t
.
attr
({
"
text
"
:
content
});
var
words
=
content
.
split
(
"
"
);
var
x
=
0
,
s
=
[];
for
(
var
i
=
0
;
i
<
words
.
length
;
i
++
)
{
var
l
=
words
[
i
].
length
;
if
(
x
+
(
l
*
letterWidth
)
>
width
)
{
s
.
push
(
"
\n
"
);
x
=
0
;
}
x
+=
l
*
letterWidth
;
s
.
push
(
words
[
i
]
+
"
"
);
}
t
.
attr
({
"
text
"
:
s
.
join
(
""
)
});
var
b
=
t
.
getBBox
()
,
h
=
Math
.
abs
(
b
.
y2
)
-
Math
.
abs
(
b
.
y
)
+
1
;
t
.
attr
({
"
y
"
:
b
.
y
+
h
});
}
\ No newline at end of file
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