Commit 5c52ca9a authored by Mike Greiling's avatar Mike Greiling

refactor SingleFileDiff class to ES module syntax

parent a23db42e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import './lib/utils/url_utility'; import './lib/utils/url_utility';
import FilesCommentButton from './files_comment_button'; import FilesCommentButton from './files_comment_button';
import SingleFileDiff from './single_file_diff';
const UNFOLD_COUNT = 20; const UNFOLD_COUNT = 20;
let isBound = false; let isBound = false;
...@@ -10,7 +11,11 @@ class Diff { ...@@ -10,7 +11,11 @@ class Diff {
constructor() { constructor() {
const $diffFile = $('.files .diff-file'); const $diffFile = $('.files .diff-file');
$diffFile.singleFileDiff(); $diffFile.each((index, file) => {
if (!$.data(file, 'singleFileDiff')) {
$.data(file, 'singleFileDiff', new SingleFileDiff(file));
}
});
FilesCommentButton.init($diffFile); FilesCommentButton.init($diffFile);
......
...@@ -144,7 +144,6 @@ import './right_sidebar'; ...@@ -144,7 +144,6 @@ import './right_sidebar';
import './search'; import './search';
import './search_autocomplete'; import './search_autocomplete';
import './signin_tabs_memoizer'; import './signin_tabs_memoizer';
import './single_file_diff';
import './smart_interval'; import './smart_interval';
import './snippets_list'; import './snippets_list';
import './star'; import './star';
......
...@@ -7,7 +7,7 @@ const LOADING_HTML = '<i class="fa fa-spinner fa-spin"></i>'; ...@@ -7,7 +7,7 @@ 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 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>'; 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>';
class SingleFileDiff { export default class SingleFileDiff {
constructor(file) { constructor(file) {
this.file = file; this.file = file;
this.toggleDiff = this.toggleDiff.bind(this); this.toggleDiff = this.toggleDiff.bind(this);
...@@ -81,13 +81,3 @@ class SingleFileDiff { ...@@ -81,13 +81,3 @@ class SingleFileDiff {
})(this)); })(this));
} }
} }
$.fn.singleFileDiff = function() {
return this.each(function() {
if (!$.data(this, 'singleFileDiff')) {
return $.data(this, 'singleFileDiff', new window.SingleFileDiff(this));
}
});
};
window.SingleFileDiff = SingleFileDiff;
...@@ -6,7 +6,6 @@ import '~/commit/pipelines/pipelines_bundle'; ...@@ -6,7 +6,6 @@ import '~/commit/pipelines/pipelines_bundle';
import '~/breakpoints'; import '~/breakpoints';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
import '~/diff'; import '~/diff';
import '~/single_file_diff';
import '~/files_comment_button'; import '~/files_comment_button';
import '~/notes'; import '~/notes';
import 'vendor/jquery.scrollTo'; import 'vendor/jquery.scrollTo';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment