From d6e724d90fd8a5fd93ef1f4963e22ccaf29b06de Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 1 Aug 2016 10:21:57 +0100 Subject: Moved method to compile components from window into diffnotesapp --- .../javascripts/diff_notes/diff_notes_bundle.js.es6 | 19 ++++++++++--------- app/assets/javascripts/merge_request_tabs.js | 4 ++-- app/assets/javascripts/notes.js | 8 ++++---- app/assets/javascripts/single_file_diff.js | 12 +++++++++--- 4 files changed, 25 insertions(+), 18 deletions(-) (limited to 'app/assets') diff --git a/app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6 b/app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6 index b0cce29fa04..22d9cf6c857 100644 --- a/app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6 +++ b/app/assets/javascripts/diff_notes/diff_notes_bundle.js.es6 @@ -13,6 +13,16 @@ $(() => { 'resolve-btn': ResolveBtn, 'resolve-discussion-btn': ResolveDiscussionBtn, 'comment-and-resolve-btn': CommentAndResolveBtn + }, + methods: { + compileComponents: function () { + const $components = $('resolve-btn, resolve-discussion-btn, jump-to-discussion'); + if ($components.length) { + $components.each(function () { + DiffNotesApp.$compile($(this).get(0)); + }); + } + } } }); @@ -22,13 +32,4 @@ $(() => { 'resolve-count': ResolveCount } }); - - window.compileVueComponentsForDiffNotes = function () { - const $components = $('resolve-btn, resolve-discussion-btn, jump-to-discussion'); - if ($components.length) { - $components.each(function () { - DiffNotesApp.$compile($(this).get(0)); - }); - } - } }); diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 8574a4e3370..ff1416af31b 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -120,8 +120,8 @@ return function(data) { $('#diffs').html(data.html); - if (compileVueComponentsForDiffNotes) { - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); } gl.utils.localTimeAgo($('.js-timeago', 'div#diffs')); diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 3c93d86994d..ab169d04804 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -300,8 +300,8 @@ discussionContainer.append(note_html); } - if (compileVueComponentsForDiffNotes) { - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); } gl.utils.localTimeAgo($('.js-timeago', note_html), false); @@ -429,8 +429,8 @@ $note_li.replaceWith($html); - if (compileVueComponentsForDiffNotes) { - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); } }; diff --git a/app/assets/javascripts/single_file_diff.js b/app/assets/javascripts/single_file_diff.js index 70e80b57f91..9d181586b1d 100644 --- a/app/assets/javascripts/single_file_diff.js +++ b/app/assets/javascripts/single_file_diff.js @@ -36,11 +36,15 @@ if (!this.isOpen && !this.hasError) { this.content.hide(); this.collapsedContent.show(); - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); + } } else if (this.content) { this.collapsedContent.hide(); this.content.show(); - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); + } } else { return this.getContentHTML(); } @@ -55,7 +59,9 @@ if (data.html) { _this.content = $(data.html); _this.content.syntaxHighlight(); - compileVueComponentsForDiffNotes(); + if (DiffNotesApp) { + DiffNotesApp.compileComponents(); + } } else { _this.hasError = true; _this.content = $(ERROR_HTML); -- cgit v1.2.1