BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
dfe7b143
Commit
dfe7b143
authored
Jun 30, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor single_file_diff.js to use ES class syntax
parent
bb918a2f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
single_file_diff.js
app/assets/javascripts/single_file_diff.js
+13
-18
No files found.
app/assets/javascripts/single_file_diff.js
View file @
dfe7b143
...
...
@@ -2,18 +2,13 @@
import
FilesCommentButton
from
'./files_comment_button'
;
window
.
SingleFileDiff
=
(
function
()
{
var
COLLAPSED_HTML
,
ERROR_HTML
,
LOADING_HTML
,
WRAPPER
;
const
WRAPPER
=
'<div class="diff-content"></div>'
;
const
LOADING_HTML
=
'<i class="fa fa-spinner fa-spin"></i>'
;
const
ERROR_HTML
=
'<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>'
;
const
COLLAPSED_HTML
=
'<div class="nothing-here-block diff-collapsed">This diff is collapsed. <a class="click-to-expand">Click to expand it.</a></div>'
;
WRAPPER
=
'<div class="diff-content"></div>'
;
LOADING_HTML
=
'<i class="fa fa-spinner fa-spin"></i>'
;
ERROR_HTML
=
'<div class="nothing-here-block"><i class="fa fa-warning"></i> Could not load diff</div>'
;
COLLAPSED_HTML
=
'<div class="nothing-here-block diff-collapsed">This diff is collapsed. <a class="click-to-expand">Click to expand it.</a></div>'
;
function
SingleFileDiff
(
file
)
{
class
SingleFileDiff
{
constructor
(
file
)
{
this
.
file
=
file
;
this
.
toggleDiff
=
this
.
toggleDiff
.
bind
(
this
);
this
.
content
=
$
(
'.diff-content'
,
this
.
file
);
...
...
@@ -37,7 +32,7 @@ window.SingleFileDiff = (function() {
}).
bind
(
this
));
}
SingleFileDiff
.
prototype
.
toggleDiff
=
function
(
$target
,
cb
)
{
toggleDiff
(
$target
,
cb
)
{
if
(
!
$target
.
hasClass
(
'js-file-title'
)
&&
!
$target
.
hasClass
(
'click-to-expand'
)
&&
!
$target
.
hasClass
(
'diff-toggle-caret'
))
return
;
this
.
isOpen
=
!
this
.
isOpen
;
if
(
!
this
.
isOpen
&&
!
this
.
hasError
)
{
...
...
@@ -58,9 +53,9 @@ window.SingleFileDiff = (function() {
this
.
$toggleIcon
.
addClass
(
'fa-caret-down'
).
removeClass
(
'fa-caret-right'
);
return
this
.
getContentHTML
(
cb
);
}
}
;
}
SingleFileDiff
.
prototype
.
getContentHTML
=
function
(
cb
)
{
getContentHTML
(
cb
)
{
this
.
collapsedContent
.
hide
();
this
.
loadingContent
.
show
();
$
.
get
(
this
.
diffForPath
,
(
function
(
_this
)
{
...
...
@@ -84,10 +79,8 @@ window.SingleFileDiff = (function() {
if
(
cb
)
cb
();
};
})(
this
));
};
return
SingleFileDiff
;
})();
}
}
$
.
fn
.
singleFileDiff
=
function
()
{
return
this
.
each
(
function
()
{
...
...
@@ -96,3 +89,5 @@ $.fn.singleFileDiff = function() {
}
});
};
window
.
SingleFileDiff
=
SingleFileDiff
;
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