From dbf4d80c329c8c4f4d00412b795d0ec48c35e6e9 Mon Sep 17 00:00:00 2001 From: Mike Greiling <mike@pixelcog.com> Date: Tue, 27 Dec 2016 16:30:51 -0600 Subject: [PATCH] move check for preview loading class to top of method --- app/assets/javascripts/preview_markdown.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/preview_markdown.js b/app/assets/javascripts/preview_markdown.js index c06fdf0aa65..89f7e976934 100644 --- a/app/assets/javascripts/preview_markdown.js +++ b/app/assets/javascripts/preview_markdown.js @@ -20,12 +20,17 @@ MarkdownPreview.prototype.ajaxCache = {}; MarkdownPreview.prototype.showPreview = function ($form) { + var mdText; var preview = $form.find('.js-md-preview'); - var mdText = $form.find('textarea.markdown-area').val(); + if (preview.hasClass('md-preview-loading')) { + return; + } + mdText = $form.find('textarea.markdown-area').val(); + if (mdText.trim().length === 0) { preview.text('Nothing to preview.'); this.hideReferencedUsers($form); - } else if (!preview.hasClass('md-preview-loading')) { + } else { preview.addClass('md-preview-loading').text('Loading...'); this.fetchMarkdownPreview(mdText, (function (response) { preview.removeClass('md-preview-loading').html(response.body); -- GitLab