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
Jérome Perrin
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 @@
...
@@ -2,18 +2,13 @@
import
FilesCommentButton
from
'
./files_comment_button
'
;
import
FilesCommentButton
from
'
./files_comment_button
'
;
window
.
SingleFileDiff
=
(
function
()
{
const
WRAPPER
=
'
<div class="diff-content"></div>
'
;
var
COLLAPSED_HTML
,
ERROR_HTML
,
LOADING_HTML
,
WRAPPER
;
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>
'
;
class
SingleFileDiff
{
constructor
(
file
)
{
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
)
{
this
.
file
=
file
;
this
.
file
=
file
;
this
.
toggleDiff
=
this
.
toggleDiff
.
bind
(
this
);
this
.
toggleDiff
=
this
.
toggleDiff
.
bind
(
this
);
this
.
content
=
$
(
'
.diff-content
'
,
this
.
file
);
this
.
content
=
$
(
'
.diff-content
'
,
this
.
file
);
...
@@ -37,7 +32,7 @@ window.SingleFileDiff = (function() {
...
@@ -37,7 +32,7 @@ window.SingleFileDiff = (function() {
}).
bind
(
this
));
}).
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
;
if
(
!
$target
.
hasClass
(
'
js-file-title
'
)
&&
!
$target
.
hasClass
(
'
click-to-expand
'
)
&&
!
$target
.
hasClass
(
'
diff-toggle-caret
'
))
return
;
this
.
isOpen
=
!
this
.
isOpen
;
this
.
isOpen
=
!
this
.
isOpen
;
if
(
!
this
.
isOpen
&&
!
this
.
hasError
)
{
if
(
!
this
.
isOpen
&&
!
this
.
hasError
)
{
...
@@ -58,9 +53,9 @@ window.SingleFileDiff = (function() {
...
@@ -58,9 +53,9 @@ window.SingleFileDiff = (function() {
this
.
$toggleIcon
.
addClass
(
'
fa-caret-down
'
).
removeClass
(
'
fa-caret-right
'
);
this
.
$toggleIcon
.
addClass
(
'
fa-caret-down
'
).
removeClass
(
'
fa-caret-right
'
);
return
this
.
getContentHTML
(
cb
);
return
this
.
getContentHTML
(
cb
);
}
}
}
;
}
SingleFileDiff
.
prototype
.
getContentHTML
=
function
(
cb
)
{
getContentHTML
(
cb
)
{
this
.
collapsedContent
.
hide
();
this
.
collapsedContent
.
hide
();
this
.
loadingContent
.
show
();
this
.
loadingContent
.
show
();
$
.
get
(
this
.
diffForPath
,
(
function
(
_this
)
{
$
.
get
(
this
.
diffForPath
,
(
function
(
_this
)
{
...
@@ -84,10 +79,8 @@ window.SingleFileDiff = (function() {
...
@@ -84,10 +79,8 @@ window.SingleFileDiff = (function() {
if
(
cb
)
cb
();
if
(
cb
)
cb
();
};
};
})(
this
));
})(
this
));
};
}
}
return
SingleFileDiff
;
})();
$
.
fn
.
singleFileDiff
=
function
()
{
$
.
fn
.
singleFileDiff
=
function
()
{
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
...
@@ -96,3 +89,5 @@ $.fn.singleFileDiff = 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