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
Boxiang Sun
gitlab-ce
Commits
40576b87
Commit
40576b87
authored
Dec 05, 2012
by
Koen Punt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #1509 by converting the entities in js
Converted BranchGraph to some sort of Class
parent
12b4bb59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
173 additions
and
118 deletions
+173
-118
app/views/projects/graph.html.haml
app/views/projects/graph.html.haml
+6
-5
vendor/assets/javascripts/branch-graph.js
vendor/assets/javascripts/branch-graph.js
+167
-113
No files found.
app/views/projects/graph.html.haml
View file @
40576b87
...
@@ -2,13 +2,14 @@
...
@@ -2,13 +2,14 @@
%br
%br
.graph_holder
.graph_holder
%h4
%h4
%small
You can move around the graph by using arrow keys.
%small
You can move around the graph by using
the
arrow keys.
#holder
.graph
#holder
.graph
:javascript
:javascript
var
c
hunk1
=
{
commits
:
#{
@commits_json
}
};
var
c
ommits
=
#{
@commits_json
}
var
days
=
#{
@days_json
}
;
,
days
=
#{
@days_json
}
;
initGraph
(
);
var
branch_graph
=
new
BranchGraph
(
days
,
commits
);
$
(
function
(){
$
(
function
(){
branchGraph
(
$
(
"
#holder
"
)[
0
]);
branch
_graph
.
build
Graph
(
$
(
"
#holder
"
)[
0
]);
GraphNav
.
init
();
GraphNav
.
init
();
});
});
vendor/assets/javascripts/branch-graph.js
View file @
40576b87
var
commits
=
{},
!
function
(){
comms
=
{},
pixelsX
=
[],
pixelsY
=
[],
mmax
=
Math
.
max
,
mtime
=
0
,
mspace
=
0
,
parents
=
{},
ii
=
0
,
colors
=
[
"
#000
"
];
function
initGraph
(){
var
BranchGraph
=
function
(
days
,
commits
){
commits
=
chunk1
.
commits
;
ii
=
commits
.
length
;
this
.
days
=
days
||
{};
this
.
commits
=
commits
||
{};
this
.
comms
=
{};
this
.
pixelsX
=
[];
this
.
pixelsY
=
[];
this
.
mtime
=
0
;
this
.
mspace
=
0
;
this
.
parents
=
{};
this
.
ii
=
0
;
this
.
colors
=
[
"
#000
"
];
this
.
prepareData
();
};
BranchGraph
.
prototype
.
prepareData
=
function
(){
ii
=
this
.
commits
.
length
;
for
(
var
i
=
0
;
i
<
ii
;
i
++
)
{
for
(
var
i
=
0
;
i
<
ii
;
i
++
)
{
for
(
var
j
=
0
,
jj
=
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
for
(
var
j
=
0
,
jj
=
this
.
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
parents
[
commits
[
i
].
parents
[
j
][
0
]]
=
true
;
this
.
parents
[
this
.
commits
[
i
].
parents
[
j
][
0
]]
=
true
;
}
}
mtime
=
Math
.
max
(
mtime
,
commits
[
i
].
time
);
this
.
mtime
=
Math
.
max
(
this
.
mtime
,
this
.
commits
[
i
].
time
);
mspace
=
Math
.
max
(
mspace
,
commits
[
i
].
space
);
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
this
.
commits
[
i
].
space
);
}
}
mtime
=
mtime
+
4
;
this
.
mtime
=
this
.
mtime
+
4
;
mspace
=
mspace
+
10
;
this
.
mspace
=
this
.
mspace
+
10
;
for
(
i
=
0
;
i
<
ii
;
i
++
)
{
for
(
i
=
0
;
i
<
ii
;
i
++
)
{
if
(
commits
[
i
].
id
in
parents
)
{
if
(
this
.
commits
[
i
].
id
in
this
.
parents
)
{
commits
[
i
].
isParent
=
true
;
this
.
commits
[
i
].
isParent
=
true
;
}
}
comms
[
commits
[
i
].
id
]
=
commits
[
i
];
this
.
comms
[
this
.
commits
[
i
].
id
]
=
this
.
commits
[
i
];
}
}
for
(
var
k
=
0
;
k
<
mspace
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
mspace
;
k
++
)
{
colors
.
push
(
Raphael
.
getColor
());
this
.
colors
.
push
(
Raphael
.
getColor
());
}
}
}
};
function
branchGraph
(
holder
)
{
BranchGraph
.
prototype
.
buildGraph
=
function
(
holder
)
{
var
ch
=
mspace
*
20
+
20
,
cw
=
mtime
*
20
+
20
,
var
ch
=
this
.
mspace
*
20
+
20
r
=
Raphael
(
"
holder
"
,
cw
,
ch
),
,
cw
=
this
.
mtime
*
20
+
20
top
=
r
.
set
();
,
r
=
Raphael
(
"
holder
"
,
cw
,
ch
)
var
cuday
=
0
,
cumonth
=
""
;
,
top
=
r
.
set
()
r
.
rect
(
0
,
0
,
days
.
length
*
20
+
80
,
30
).
attr
({
fill
:
"
#222
"
});
,
cuday
=
0
r
.
rect
(
0
,
30
,
days
.
length
*
20
+
80
,
20
).
attr
({
fill
:
"
#444
"
})
;
,
cumonth
=
""
;
for
(
mm
=
0
;
mm
<
days
.
length
;
mm
++
)
{
r
.
rect
(
0
,
0
,
this
.
days
.
length
*
20
+
80
,
30
).
attr
({
fill
:
"
#222
"
});
if
(
days
[
mm
]
!=
null
){
r
.
rect
(
0
,
30
,
this
.
days
.
length
*
20
+
80
,
20
).
attr
({
fill
:
"
#444
"
});
if
(
cuday
!=
days
[
mm
][
0
]){
r
.
text
(
10
+
mm
*
20
,
40
,
days
[
mm
][
0
]).
attr
({
font
:
"
14px Fontin-Sans, Arial
"
,
fill
:
"
#DDD
"
});
for
(
mm
=
0
;
mm
<
this
.
days
.
length
;
mm
++
)
{
cuday
=
days
[
mm
][
0
]
if
(
this
.
days
[
mm
]
!=
null
){
if
(
cuday
!=
this
.
days
[
mm
][
0
]){
r
.
text
(
10
+
mm
*
20
,
40
,
this
.
days
[
mm
][
0
]).
attr
({
font
:
"
14px Fontin-Sans, Arial
"
,
fill
:
"
#DDD
"
});
cuday
=
this
.
days
[
mm
][
0
];
}
}
if
(
cumonth
!=
days
[
mm
][
1
]){
if
(
cumonth
!=
this
.
days
[
mm
][
1
]){
r
.
text
(
10
+
mm
*
20
,
15
,
days
[
mm
][
1
]).
attr
({
font
:
"
14px Fontin-Sans, Arial
"
,
fill
:
"
#EEE
"
});
r
.
text
(
10
+
mm
*
20
,
15
,
this
.
days
[
mm
][
1
]).
attr
({
cumonth
=
days
[
mm
][
1
]
font
:
"
14px Fontin-Sans, Arial
"
,
fill
:
"
#EEE
"
});
cumonth
=
this
.
days
[
mm
][
1
];
}
}
}
}
}
}
for
(
i
=
0
;
i
<
ii
;
i
++
)
{
for
(
i
=
0
;
i
<
ii
;
i
++
)
{
var
x
=
10
+
20
*
commits
[
i
].
time
,
var
x
=
10
+
20
*
this
.
commits
[
i
].
time
y
=
70
+
20
*
commits
[
i
].
space
;
,
y
=
70
+
20
*
this
.
commits
[
i
].
space
;
r
.
circle
(
x
,
y
,
3
).
attr
({
fill
:
colors
[
commits
[
i
].
space
],
stroke
:
"
none
"
});
r
.
circle
(
x
,
y
,
3
).
attr
({
if
(
commits
[
i
].
refs
!=
null
&&
commits
[
i
].
refs
!=
""
)
{
fill
:
this
.
colors
[
this
.
commits
[
i
].
space
],
var
longrefs
=
commits
[
i
].
refs
stroke
:
"
none
"
var
shortrefs
=
commits
[
i
].
refs
;
});
if
(
this
.
commits
[
i
].
refs
!=
null
&&
this
.
commits
[
i
].
refs
!=
""
)
{
var
longrefs
=
this
.
commits
[
i
].
refs
,
shortrefs
=
this
.
commits
[
i
].
refs
;
if
(
shortrefs
.
length
>
15
){
if
(
shortrefs
.
length
>
15
){
shortrefs
=
shortrefs
.
substr
(
0
,
13
)
+
"
...
"
;
shortrefs
=
shortrefs
.
substr
(
0
,
13
)
+
"
...
"
;
}
}
var
t
=
r
.
text
(
x
+
5
,
y
+
5
,
shortrefs
).
attr
({
font
:
"
12px Fontin-Sans, Arial
"
,
fill
:
"
#666
"
,
var
t
=
r
.
text
(
x
+
5
,
y
+
5
,
shortrefs
).
attr
({
title
:
longrefs
,
cursor
:
"
pointer
"
,
rotation
:
"
90
"
});
font
:
"
12px Fontin-Sans, Arial
"
,
fill
:
"
#666
"
,
title
:
longrefs
,
cursor
:
"
pointer
"
,
rotation
:
"
90
"
});
var
textbox
=
t
.
getBBox
();
var
textbox
=
t
.
getBBox
();
t
.
translate
(
textbox
.
height
/-
4
,
textbox
.
width
/
2
);
t
.
translate
(
textbox
.
height
/-
4
,
textbox
.
width
/
2
);
}
}
for
(
var
j
=
0
,
jj
=
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
for
(
var
j
=
0
,
jj
=
this
.
commits
[
i
].
parents
.
length
;
j
<
jj
;
j
++
)
{
var
c
=
comms
[
commits
[
i
].
parents
[
j
][
0
]];
var
c
=
this
.
comms
[
this
.
commits
[
i
].
parents
[
j
][
0
]];
if
(
c
)
{
if
(
c
)
{
var
cx
=
10
+
20
*
c
.
time
,
var
cx
=
10
+
20
*
c
.
time
cy
=
70
+
20
*
c
.
space
;
,
cy
=
70
+
20
*
c
.
space
;
if
(
c
.
space
==
commits
[
i
].
space
)
{
if
(
c
.
space
==
this
.
commits
[
i
].
space
)
{
r
.
path
(
"
M
"
+
(
x
-
5
)
+
"
,
"
+
(
y
+
.
0001
)
+
"
L
"
+
(
15
+
20
*
c
.
time
)
+
"
,
"
+
(
y
+
.
0001
))
r
.
path
(
"
M
"
+
(
x
-
5
)
+
"
,
"
+
(
y
+
.
0001
)
+
"
L
"
+
(
15
+
20
*
c
.
time
)
+
"
,
"
+
(
y
+
.
0001
))
.
attr
({
stroke
:
colors
[
c
.
space
],
"
stroke-width
"
:
2
});
.
attr
({
stroke
:
this
.
colors
[
c
.
space
],
"
stroke-width
"
:
2
});
}
else
if
(
c
.
space
<
commits
[
i
].
space
)
{
}
else
if
(
c
.
space
<
this
.
commits
[
i
].
space
)
{
r
.
path
([
"
M
"
,
x
-
5
,
y
+
.
0001
,
"
l-5-2,0,4,5,-2C
"
,
x
-
5
,
y
,
x
-
17
,
y
+
2
,
x
-
20
,
y
-
5
,
"
L
"
,
cx
,
y
-
5
,
cx
,
cy
])
r
.
path
([
"
M
"
,
x
-
5
,
y
+
.
0001
,
"
l-5-2,0,4,5,-2C
"
,
x
-
5
,
y
,
x
-
17
,
y
+
2
,
x
-
20
,
y
-
5
,
"
L
"
,
cx
,
y
-
5
,
cx
,
cy
])
.
attr
({
stroke
:
colors
[
commits
[
i
].
space
],
"
stroke-width
"
:
2
});
.
attr
({
stroke
:
this
.
colors
[
this
.
commits
[
i
].
space
],
"
stroke-width
"
:
2
});
}
else
{
}
else
{
r
.
path
([
"
M
"
,
x
-
3
,
y
+
6
,
"
l-4,3,4,2,0,-5L
"
,
x
-
10
,
y
+
20
,
"
L
"
,
x
-
10
,
cy
,
cx
,
cy
])
r
.
path
([
"
M
"
,
x
-
3
,
y
+
6
,
"
l-4,3,4,2,0,-5L
"
,
x
-
10
,
y
+
20
,
"
L
"
,
x
-
10
,
cy
,
cx
,
cy
])
.
attr
({
stroke
:
colors
[
c
.
space
],
"
stroke-width
"
:
2
});
.
attr
({
stroke
:
this
.
colors
[
c
.
space
],
"
stroke-width
"
:
2
});
}
}
}
}
}
}
(
function
(
c
,
x
,
y
)
{
(
function
(
c
,
x
,
y
)
{
top
.
push
(
r
.
circle
(
x
,
y
,
10
).
attr
({
fill
:
"
#000
"
,
opacity
:
0
,
cursor
:
"
pointer
"
})
top
.
push
(
r
.
circle
(
x
,
y
,
10
).
attr
({
fill
:
"
#000
"
,
opacity
:
0
,
cursor
:
"
pointer
"
})
.
click
(
function
(){
.
click
(
function
(){
location
.
href
=
location
.
href
.
replace
(
"
graph
"
,
"
commits/
"
+
c
.
id
);
location
.
href
=
location
.
href
.
replace
(
"
graph
"
,
"
commits/
"
+
c
.
id
);
})
})
.
hover
(
function
()
{
.
hover
(
function
()
{
var
s
=
r
.
text
(
100
,
100
,
c
.
author
+
"
\n
\n
"
+
c
.
id
+
"
\n
\n
"
+
c
.
message
).
attr
({
fill
:
"
#fff
"
});
// Create empty node to convert entities to character
var
m
=
$
(
'
<div />
'
).
html
(
c
.
message
).
text
()
,
s
=
r
.
text
(
100
,
100
,
c
.
author
+
"
\n
\n
"
+
c
.
id
+
"
\n
\n
"
+
m
).
attr
({
fill
:
"
#fff
"
});
this
.
popup
=
r
.
popupit
(
x
,
y
+
5
,
s
,
0
);
this
.
popup
=
r
.
popupit
(
x
,
y
+
5
,
s
,
0
);
top
.
push
(
this
.
popup
.
insertBefore
(
this
));
top
.
push
(
this
.
popup
.
insertBefore
(
this
));
},
function
()
{
},
function
()
{
this
.
popup
&&
this
.
popup
.
remove
()
&&
delete
this
.
popup
;
this
.
popup
&&
this
.
popup
.
remove
()
&&
delete
this
.
popup
;
}));
}));
}(
commits
[
i
],
x
,
y
));
}(
this
.
commits
[
i
],
x
,
y
));
}
top
.
toFront
();
top
.
toFront
();
var
hw
=
holder
.
offsetWidth
,
var
hw
=
holder
.
offsetWidth
hh
=
holder
.
offsetHeight
,
,
hh
=
holder
.
offsetHeight
v
=
r
.
rect
(
hw
-
8
,
0
,
4
,
Math
.
pow
(
hh
,
2
)
/
ch
,
2
).
attr
({
fill
:
"
#000
"
,
opacity
:
0
}),
,
v
=
r
.
rect
(
hw
-
8
,
0
,
4
,
Math
.
pow
(
hh
,
2
)
/
ch
,
2
).
attr
({
h
=
r
.
rect
(
0
,
hh
-
8
,
Math
.
pow
(
hw
,
2
)
/
cw
,
4
,
2
).
attr
({
fill
:
"
#000
"
,
opacity
:
0
}),
fill
:
"
#000
"
,
bars
=
r
.
set
(
v
,
h
),
opacity
:
0
drag
,
})
dragger
=
function
(
e
)
{
,
h
=
r
.
rect
(
0
,
hh
-
8
,
Math
.
pow
(
hw
,
2
)
/
cw
,
4
,
2
).
attr
({
fill
:
"
#000
"
,
opacity
:
0
})
,
bars
=
r
.
set
(
v
,
h
)
,
drag
,
dragger
=
function
(
event
)
{
if
(
drag
)
{
if
(
drag
)
{
e
=
e
||
window
.
event
;
event
=
event
||
window
.
event
;
holder
.
scrollLeft
=
drag
.
sl
-
(
e
.
clientX
-
drag
.
x
);
holder
.
scrollLeft
=
drag
.
sl
-
(
event
.
clientX
-
drag
.
x
);
holder
.
scrollTop
=
drag
.
st
-
(
e
.
clientY
-
drag
.
y
);
holder
.
scrollTop
=
drag
.
st
-
(
event
.
clientY
-
drag
.
y
);
}
}
};
};
holder
.
onmousedown
=
function
(
e
)
{
holder
.
onmousedown
=
function
(
event
)
{
e
=
e
||
window
.
event
;
event
=
event
||
window
.
event
;
drag
=
{
x
:
e
.
clientX
,
y
:
e
.
clientY
,
st
:
holder
.
scrollTop
,
sl
:
holder
.
scrollLeft
};
drag
=
{
x
:
event
.
clientX
,
y
:
event
.
clientY
,
st
:
holder
.
scrollTop
,
sl
:
holder
.
scrollLeft
};
document
.
onmousemove
=
dragger
;
document
.
onmousemove
=
dragger
;
bars
.
animate
({
opacity
:
.
5
},
300
);
bars
.
animate
({
opacity
:
.
5
},
300
);
};
};
...
@@ -127,13 +175,19 @@ function branchGraph(holder) {
...
@@ -127,13 +175,19 @@ function branchGraph(holder) {
bars
.
animate
({
opacity
:
0
},
300
);
bars
.
animate
({
opacity
:
0
},
300
);
};
};
holder
.
scrollLeft
=
cw
;
holder
.
scrollLeft
=
cw
;
};
}
};
this
.
BranchGraph
=
BranchGraph
;
}(
this
);
Raphael
.
fn
.
popupit
=
function
(
x
,
y
,
set
,
dir
,
size
)
{
Raphael
.
fn
.
popupit
=
function
(
x
,
y
,
set
,
dir
,
size
)
{
dir
=
dir
==
null
?
2
:
dir
;
dir
=
dir
==
null
?
2
:
dir
;
size
=
size
||
5
;
size
=
size
||
5
;
x
=
Math
.
round
(
x
);
x
=
Math
.
round
(
x
);
y
=
Math
.
round
(
y
);
y
=
Math
.
round
(
y
);
var
bb
=
set
.
getBBox
(),
var
mmax
=
Math
.
max
,
bb
=
set
.
getBBox
(),
w
=
Math
.
round
(
bb
.
width
/
2
),
w
=
Math
.
round
(
bb
.
width
/
2
),
h
=
Math
.
round
(
bb
.
height
/
2
),
h
=
Math
.
round
(
bb
.
height
/
2
),
dx
=
[
0
,
w
+
size
*
2
,
0
,
-
w
-
size
*
2
],
dx
=
[
0
,
w
+
size
*
2
,
0
,
-
w
-
size
*
2
],
...
...
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