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
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
app/assets/javascripts/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