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
cc3e488c
Commit
cc3e488c
authored
Apr 20, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Satisfy eslint
parent
36e7b322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
18 deletions
+7
-18
app/assets/javascripts/blob/viewer/index.js
app/assets/javascripts/blob/viewer/index.js
+7
-18
No files found.
app/assets/javascripts/blob/viewer/index.js
View file @
cc3e488c
``
/* eslint-disable no-new */
/* eslint-disable no-new */
/* global Flash */
/* global Flash */
export
default
class
BlobViewer
{
export
default
class
BlobViewer
{
constructor
()
{
constructor
()
{
...
@@ -50,7 +50,7 @@ export default class BlobViewer {
...
@@ -50,7 +50,7 @@ export default class BlobViewer {
if
(
this
.
simpleViewer
.
getAttribute
(
'
data-loaded
'
))
{
if
(
this
.
simpleViewer
.
getAttribute
(
'
data-loaded
'
))
{
this
.
copySourceBtn
.
setAttribute
(
'
title
'
,
'
Copy source to clipboard
'
);
this
.
copySourceBtn
.
setAttribute
(
'
title
'
,
'
Copy source to clipboard
'
);
this
.
copySourceBtn
.
classList
.
remove
(
'
disabled
'
);
this
.
copySourceBtn
.
classList
.
remove
(
'
disabled
'
);
}
else
if
(
this
.
activeViewer
==
this
.
simpleViewer
)
{
}
else
if
(
this
.
activeViewer
==
=
this
.
simpleViewer
)
{
this
.
copySourceBtn
.
setAttribute
(
'
title
'
,
'
Wait for the source to load to copy it to the clipboard
'
);
this
.
copySourceBtn
.
setAttribute
(
'
title
'
,
'
Wait for the source to load to copy it to the clipboard
'
);
this
.
copySourceBtn
.
classList
.
add
(
'
disabled
'
);
this
.
copySourceBtn
.
classList
.
add
(
'
disabled
'
);
}
else
{
}
else
{
...
@@ -61,12 +61,11 @@ export default class BlobViewer {
...
@@ -61,12 +61,11 @@ export default class BlobViewer {
$
(
this
.
copySourceBtn
).
tooltip
(
'
fixTitle
'
);
$
(
this
.
copySourceBtn
).
tooltip
(
'
fixTitle
'
);
}
}
loadViewer
(
viewerParam
,
resolve
,
reject
)
{
loadViewer
(
viewerParam
)
{
const
viewer
=
viewerParam
;
const
viewer
=
viewerParam
;
const
url
=
viewer
.
getAttribute
(
'
data-url
'
);
const
url
=
viewer
.
getAttribute
(
'
data-url
'
);
if
(
!
url
||
viewer
.
getAttribute
(
'
data-loaded
'
)
||
viewer
.
getAttribute
(
'
data-loading
'
))
{
if
(
!
url
||
viewer
.
getAttribute
(
'
data-loaded
'
)
||
viewer
.
getAttribute
(
'
data-loading
'
))
{
if
(
resolve
)
resolve
();
return
;
return
;
}
}
...
@@ -76,9 +75,6 @@ export default class BlobViewer {
...
@@ -76,9 +75,6 @@ export default class BlobViewer {
url
,
url
,
dataType
:
'
JSON
'
,
dataType
:
'
JSON
'
,
})
})
.
fail
(()
=>
{
if
(
reject
)
reject
();
})
.
done
((
data
)
=>
{
.
done
((
data
)
=>
{
viewer
.
innerHTML
=
data
.
html
;
viewer
.
innerHTML
=
data
.
html
;
$
(
viewer
).
syntaxHighlight
();
$
(
viewer
).
syntaxHighlight
();
...
@@ -88,16 +84,14 @@ export default class BlobViewer {
...
@@ -88,16 +84,14 @@ export default class BlobViewer {
this
.
$blobContentHolder
.
trigger
(
'
highlight:line
'
);
this
.
$blobContentHolder
.
trigger
(
'
highlight:line
'
);
this
.
toggleCopyButtonState
();
this
.
toggleCopyButtonState
();
if
(
resolve
)
resolve
();
});
});
}
}
switchToViewer
(
name
)
{
switchToViewer
(
name
)
{
const
newViewer
=
document
.
querySelector
(
`.blob-viewer[data-type='
${
name
}
']`
);
const
newViewer
=
document
.
querySelector
(
`.blob-viewer[data-type='
${
name
}
']`
);
if
(
this
.
activeViewer
==
newViewer
)
return
;
if
(
this
.
activeViewer
==
=
newViewer
)
return
;
const
oldButton
=
document
.
querySelector
(
'
.js-blob-viewer-switcher.active
'
)
const
oldButton
=
document
.
querySelector
(
'
.js-blob-viewer-switcher.active
'
)
;
const
newButton
=
document
.
querySelector
(
`.js-blob-viewer-switcher[data-viewer='
${
name
}
']`
);
const
newButton
=
document
.
querySelector
(
`.js-blob-viewer-switcher[data-viewer='
${
name
}
']`
);
const
oldViewer
=
document
.
querySelector
(
`.blob-viewer:not([data-type='
${
name
}
'])`
);
const
oldViewer
=
document
.
querySelector
(
`.blob-viewer:not([data-type='
${
name
}
'])`
);
...
@@ -113,18 +107,13 @@ export default class BlobViewer {
...
@@ -113,18 +107,13 @@ export default class BlobViewer {
if
(
oldViewer
)
{
if
(
oldViewer
)
{
oldViewer
.
classList
.
add
(
'
hidden
'
);
oldViewer
.
classList
.
add
(
'
hidden
'
);
}
}
newViewer
.
classList
.
remove
(
'
hidden
'
);
newViewer
.
classList
.
remove
(
'
hidden
'
);
this
.
activeViewer
=
newViewer
;
this
.
activeViewer
=
newViewer
;
this
.
toggleCopyButtonState
();
this
.
toggleCopyButtonState
();
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
loadViewer
(
newViewer
);
this
.
loadViewer
(
newViewer
,
resolve
,
reject
);
})
.
catch
(()
=>
{
new
Flash
(
'
Error loading 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