Commit dbf4d80c authored by Mike Greiling's avatar Mike Greiling

move check for preview loading class to top of method

parent 8c1f287c
...@@ -20,12 +20,17 @@ ...@@ -20,12 +20,17 @@
MarkdownPreview.prototype.ajaxCache = {}; MarkdownPreview.prototype.ajaxCache = {};
MarkdownPreview.prototype.showPreview = function ($form) { MarkdownPreview.prototype.showPreview = function ($form) {
var mdText;
var preview = $form.find('.js-md-preview'); 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) { if (mdText.trim().length === 0) {
preview.text('Nothing to preview.'); preview.text('Nothing to preview.');
this.hideReferencedUsers($form); this.hideReferencedUsers($form);
} else if (!preview.hasClass('md-preview-loading')) { } else {
preview.addClass('md-preview-loading').text('Loading...'); preview.addClass('md-preview-loading').text('Loading...');
this.fetchMarkdownPreview(mdText, (function (response) { this.fetchMarkdownPreview(mdText, (function (response) {
preview.removeClass('md-preview-loading').html(response.body); preview.removeClass('md-preview-loading').html(response.body);
......
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