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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
700e760f
Commit
700e760f
authored
Nov 15, 2019
by
minghuan lei
Committed by
Kushal Pandya
Nov 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Remove IIFEs from branch_graph.js"
parent
5555f05a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
62 deletions
+55
-62
app/assets/javascripts/network/branch_graph.js
app/assets/javascripts/network/branch_graph.js
+50
-62
changelogs/unreleased/34607-Remove-IIFEs-from-branch_graph-js.yml
...gs/unreleased/34607-Remove-IIFEs-from-branch_graph-js.yml
+5
-0
No files found.
app/assets/javascripts/network/branch_graph.js
View file @
700e760f
/* eslint-disable func-names, no-var, one-var,
no-loop-func,
consistent-return, camelcase */
/* eslint-disable func-names, no-var, one-var, consistent-return, camelcase */
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
__
}
from
'
../locale
'
;
import
{
__
}
from
'
../locale
'
;
import
axios
from
'
../lib/utils/axios_utils
'
;
import
axios
from
'
../lib/utils/axios_utils
'
;
import
Raphael
from
'
./raphael
'
;
import
Raphael
from
'
./raphael
'
;
export
default
(
function
()
{
export
default
class
BranchGraph
{
function
BranchGraph
(
element1
,
options1
)
{
constructor
(
element1
,
options1
)
{
this
.
element
=
element1
;
this
.
element
=
element1
;
this
.
options
=
options1
;
this
.
options
=
options1
;
this
.
scrollTop
=
this
.
scrollTop
.
bind
(
this
);
this
.
scrollTop
=
this
.
scrollTop
.
bind
(
this
);
...
@@ -28,7 +28,7 @@ export default (function() {
...
@@ -28,7 +28,7 @@ export default (function() {
this
.
load
();
this
.
load
();
}
}
BranchGraph
.
prototype
.
load
=
function
()
{
load
()
{
axios
axios
.
get
(
this
.
options
.
url
)
.
get
(
this
.
options
.
url
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
...
@@ -37,9 +37,9 @@ export default (function() {
...
@@ -37,9 +37,9 @@ export default (function() {
this
.
buildGraph
();
this
.
buildGraph
();
})
})
.
catch
(()
=>
__
(
'
Error fetching network graph.
'
));
.
catch
(()
=>
__
(
'
Error fetching network graph.
'
));
}
;
}
BranchGraph
.
prototype
.
prepareData
=
function
(
days
,
commits
)
{
prepareData
(
days
,
commits
)
{
var
c
,
ch
,
cw
,
j
,
len
,
ref
;
var
c
,
ch
,
cw
,
j
,
len
,
ref
;
this
.
days
=
days
;
this
.
days
=
days
;
this
.
commits
=
commits
;
this
.
commits
=
commits
;
...
@@ -61,19 +61,17 @@ export default (function() {
...
@@ -61,19 +61,17 @@ export default (function() {
this
.
markCommit
(
c
);
this
.
markCommit
(
c
);
}
}
return
this
.
collectColors
();
return
this
.
collectColors
();
}
;
}
BranchGraph
.
prototype
.
collectParents
=
function
()
{
collectParents
()
{
var
c
,
j
,
len
,
p
,
ref
,
results
;
var
c
,
j
,
len
,
p
,
ref
,
results
;
var
l
,
len1
,
ref1
,
results1
;
ref
=
this
.
commits
;
ref
=
this
.
commits
;
results
=
[];
results
=
[];
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
+=
1
)
{
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
+=
1
)
{
c
=
ref
[
j
];
c
=
ref
[
j
];
this
.
mtime
=
Math
.
max
(
this
.
mtime
,
c
.
time
);
this
.
mtime
=
Math
.
max
(
this
.
mtime
,
c
.
time
);
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
c
.
space
);
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
c
.
space
);
results
.
push
(
function
()
{
var
l
,
len1
,
ref1
,
results1
;
ref1
=
c
.
parents
;
ref1
=
c
.
parents
;
results1
=
[];
results1
=
[];
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
+=
1
)
{
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
+=
1
)
{
...
@@ -81,14 +79,12 @@ export default (function() {
...
@@ -81,14 +79,12 @@ export default (function() {
this
.
parents
[
p
[
0
]]
=
true
;
this
.
parents
[
p
[
0
]]
=
true
;
results1
.
push
((
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
p
[
1
])));
results1
.
push
((
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
p
[
1
])));
}
}
return
results1
;
results
.
push
(
results1
);
}.
call
(
this
),
);
}
}
return
results
;
return
results
;
}
;
}
BranchGraph
.
prototype
.
collectColors
=
function
()
{
collectColors
()
{
var
k
,
results
;
var
k
,
results
;
k
=
0
;
k
=
0
;
results
=
[];
results
=
[];
...
@@ -100,9 +96,9 @@ export default (function() {
...
@@ -100,9 +96,9 @@ export default (function() {
results
.
push
((
k
+=
1
));
results
.
push
((
k
+=
1
));
}
}
return
results
;
return
results
;
}
;
}
BranchGraph
.
prototype
.
buildGraph
=
function
()
{
buildGraph
()
{
var
cuday
,
cumonth
,
day
,
len
,
mm
,
ref
;
var
cuday
,
cumonth
,
day
,
len
,
mm
,
ref
;
const
{
r
}
=
this
;
const
{
r
}
=
this
;
cuday
=
0
;
cuday
=
0
;
...
@@ -138,9 +134,9 @@ export default (function() {
...
@@ -138,9 +134,9 @@ export default (function() {
}
}
this
.
renderPartialGraph
();
this
.
renderPartialGraph
();
return
this
.
bindEvents
();
return
this
.
bindEvents
();
}
;
}
BranchGraph
.
prototype
.
renderPartialGraph
=
function
()
{
renderPartialGraph
()
{
var
commit
,
end
,
i
,
isGraphEdge
,
start
,
x
,
y
;
var
commit
,
end
,
i
,
isGraphEdge
,
start
,
x
,
y
;
start
=
Math
.
floor
((
this
.
element
.
scrollTop
()
-
this
.
offsetY
)
/
this
.
unitTime
)
-
10
;
start
=
Math
.
floor
((
this
.
element
.
scrollTop
()
-
this
.
offsetY
)
/
this
.
unitTime
)
-
10
;
if
(
start
<
0
)
{
if
(
start
<
0
)
{
...
@@ -170,49 +166,43 @@ export default (function() {
...
@@ -170,49 +166,43 @@ export default (function() {
}
}
return
this
.
top
.
toFront
();
return
this
.
top
.
toFront
();
}
}
}
;
}
BranchGraph
.
prototype
.
bindEvents
=
function
()
{
bindEvents
()
{
const
{
element
}
=
this
;
const
{
element
}
=
this
;
return
$
(
element
).
scroll
(
return
$
(
element
).
scroll
(()
=>
this
.
renderPartialGraph
());
(
function
(
_this
)
{
}
return
function
()
{
return
_this
.
renderPartialGraph
();
};
})(
this
),
);
};
BranchGraph
.
prototype
.
scrollDown
=
functio
n
()
{
scrollDow
n
()
{
this
.
element
.
scrollTop
(
this
.
element
.
scrollTop
()
+
50
);
this
.
element
.
scrollTop
(
this
.
element
.
scrollTop
()
+
50
);
return
this
.
renderPartialGraph
();
return
this
.
renderPartialGraph
();
}
;
}
BranchGraph
.
prototype
.
scrollUp
=
function
()
{
scrollUp
()
{
this
.
element
.
scrollTop
(
this
.
element
.
scrollTop
()
-
50
);
this
.
element
.
scrollTop
(
this
.
element
.
scrollTop
()
-
50
);
return
this
.
renderPartialGraph
();
return
this
.
renderPartialGraph
();
}
;
}
BranchGraph
.
prototype
.
scrollLeft
=
function
()
{
scrollLeft
()
{
this
.
element
.
scrollLeft
(
this
.
element
.
scrollLeft
()
-
50
);
this
.
element
.
scrollLeft
(
this
.
element
.
scrollLeft
()
-
50
);
return
this
.
renderPartialGraph
();
return
this
.
renderPartialGraph
();
}
;
}
BranchGraph
.
prototype
.
scrollRight
=
function
()
{
scrollRight
()
{
this
.
element
.
scrollLeft
(
this
.
element
.
scrollLeft
()
+
50
);
this
.
element
.
scrollLeft
(
this
.
element
.
scrollLeft
()
+
50
);
return
this
.
renderPartialGraph
();
return
this
.
renderPartialGraph
();
}
;
}
BranchGraph
.
prototype
.
scrollBottom
=
function
()
{
scrollBottom
()
{
return
this
.
element
.
scrollTop
(
this
.
element
.
find
(
'
svg
'
).
height
());
return
this
.
element
.
scrollTop
(
this
.
element
.
find
(
'
svg
'
).
height
());
}
;
}
BranchGraph
.
prototype
.
scrollTop
=
function
()
{
scrollTop
()
{
return
this
.
element
.
scrollTop
(
0
);
return
this
.
element
.
scrollTop
(
0
);
}
;
}
BranchGraph
.
prototype
.
appendLabel
=
function
(
x
,
y
,
commit
)
{
appendLabel
(
x
,
y
,
commit
)
{
var
label
,
rect
,
shortrefs
,
text
,
textbox
;
var
label
,
rect
,
shortrefs
,
text
,
textbox
;
if
(
!
commit
.
refs
)
{
if
(
!
commit
.
refs
)
{
...
@@ -248,9 +238,9 @@ export default (function() {
...
@@ -248,9 +238,9 @@ export default (function() {
label
.
transform
([
'
t
'
,
-
rect
.
getBBox
().
width
-
15
,
0
]);
label
.
transform
([
'
t
'
,
-
rect
.
getBBox
().
width
-
15
,
0
]);
// Set text to front
// Set text to front
return
text
.
toFront
();
return
text
.
toFront
();
}
;
}
BranchGraph
.
prototype
.
appendAnchor
=
function
(
x
,
y
,
commit
)
{
appendAnchor
(
x
,
y
,
commit
)
{
const
{
r
,
top
,
options
}
=
this
;
const
{
r
,
top
,
options
}
=
this
;
const
anchor
=
r
const
anchor
=
r
.
circle
(
x
,
y
,
10
)
.
circle
(
x
,
y
,
10
)
...
@@ -270,9 +260,9 @@ export default (function() {
...
@@ -270,9 +260,9 @@ export default (function() {
},
},
);
);
return
top
.
push
(
anchor
);
return
top
.
push
(
anchor
);
}
;
}
BranchGraph
.
prototype
.
drawDot
=
function
(
x
,
y
,
commit
)
{
drawDot
(
x
,
y
,
commit
)
{
const
{
r
}
=
this
;
const
{
r
}
=
this
;
r
.
circle
(
x
,
y
,
3
).
attr
({
r
.
circle
(
x
,
y
,
3
).
attr
({
fill
:
this
.
colors
[
commit
.
space
],
fill
:
this
.
colors
[
commit
.
space
],
...
@@ -293,9 +283,9 @@ export default (function() {
...
@@ -293,9 +283,9 @@ export default (function() {
'
text-anchor
'
:
'
start
'
,
'
text-anchor
'
:
'
start
'
,
font
:
'
14px Monaco, monospace
'
,
font
:
'
14px Monaco, monospace
'
,
});
});
}
;
}
BranchGraph
.
prototype
.
drawLines
=
function
(
x
,
y
,
commit
)
{
drawLines
(
x
,
y
,
commit
)
{
var
arrow
,
color
,
i
,
len
,
offset
,
parent
,
parentCommit
,
parentX1
,
parentX2
,
parentY
,
route
;
var
arrow
,
color
,
i
,
len
,
offset
,
parent
,
parentCommit
,
parentX1
,
parentX2
,
parentY
,
route
;
const
{
r
}
=
this
;
const
{
r
}
=
this
;
const
ref
=
commit
.
parents
;
const
ref
=
commit
.
parents
;
...
@@ -344,9 +334,9 @@ export default (function() {
...
@@ -344,9 +334,9 @@ export default (function() {
);
);
}
}
return
results
;
return
results
;
}
;
}
BranchGraph
.
prototype
.
markCommit
=
function
(
commit
)
{
markCommit
(
commit
)
{
if
(
commit
.
id
===
this
.
options
.
commit_id
)
{
if
(
commit
.
id
===
this
.
options
.
commit_id
)
{
const
{
r
}
=
this
;
const
{
r
}
=
this
;
const
x
=
this
.
offsetX
+
this
.
unitSpace
*
(
this
.
mspace
-
commit
.
space
);
const
x
=
this
.
offsetX
+
this
.
unitSpace
*
(
this
.
mspace
-
commit
.
space
);
...
@@ -359,7 +349,5 @@ export default (function() {
...
@@ -359,7 +349,5 @@ export default (function() {
// Displayed in the center
// Displayed in the center
return
this
.
element
.
scrollTop
(
y
-
this
.
graphHeight
/
2
);
return
this
.
element
.
scrollTop
(
y
-
this
.
graphHeight
/
2
);
}
}
};
}
}
return
BranchGraph
;
})();
changelogs/unreleased/34607-Remove-IIFEs-from-branch_graph-js.yml
0 → 100644
View file @
700e760f
---
title
:
Remove IIFEs from branch_graph.js
merge_request
:
20008
author
:
minghuan lei
type
:
other
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