refactor SingleFileDiff class to ES module syntax
This commit is contained in:
parent
a23db42e07
commit
5c52ca9a0c
4 changed files with 7 additions and 14 deletions
|
@ -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 {
|
||||||
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';
|
||||||
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>';
|
||||||
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 {
|
||||||
})(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';
|
||||||
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';
|
||||||
|
|
Loading…
Reference in a new issue