Remove more Markdown references

This commit is contained in:
Pablo Vazquez 2018-09-17 13:47:03 +02:00
parent 02a7014bf4
commit cede3e75db
2 changed files with 26 additions and 39 deletions

View File

@ -40,11 +40,6 @@ $(document).on('click','body .comment-action-reply',function(e){
parentDiv.after(commentForm); parentDiv.after(commentForm);
// document.getElementById('comment_field').focus(); // document.getElementById('comment_field').focus();
$(commentField).focus(); $(commentField).focus();
// Convert Markdown
var convert = new Markdown.getSanitizingConverter().makeHtml;
var preview = $('.comment-reply-preview-md');
preview.html(convert($(commentField).val()));
$('.comment-reply-field').addClass('filled'); $('.comment-reply-field').addClass('filled');
}); });
@ -59,10 +54,6 @@ $(document).on('click','body .comment-action-cancel',function(e){
delete commentField.dataset.originalParentId; delete commentField.dataset.originalParentId;
$(commentField).val(''); $(commentField).val('');
// Convert Markdown
var convert = new Markdown.getSanitizingConverter().makeHtml;
var preview = $('.comment-reply-preview-md');
preview.html(convert($(commentField).val()));
$('.comment-reply-field').removeClass('filled'); $('.comment-reply-field').removeClass('filled');
$('.comment-container').removeClass('is-replying'); $('.comment-container').removeClass('is-replying');

View File

@ -101,41 +101,37 @@ script(type="text/javascript").
var page_title = 'Edit: {{ node.name }} - {{ project.name }} — Blender Cloud'; var page_title = 'Edit: {{ node.name }} - {{ project.name }} — Blender Cloud';
DocumentTitleAPI.set_page_title(page_title); DocumentTitleAPI.set_page_title(page_title);
/* Build the markdown preview when typing in textarea */ var $contentField = $('.form-group.description textarea'),
var convert = new Markdown.getSanitizingConverter(); $contentPreview = $('<div class="node-edit-form-md-preview" />').insertAfter($contentField);
Markdown.Extra.init(convert);
convert = convert.makeHtml;
var $textarea = $('.form-group.description textarea'), function parseDescriptionContent(content) {
$loader = $('<div class="md-preview-loading"><i class="pi-spin spin"></i></div>').insertAfter($textarea),
$preview = $('<div class="node-edit-form-md-preview" />').insertAfter($loader);
$loader.hide(); $.ajax({
url: "{{ url_for('nodes.preview_markdown')}}",
type: 'post',
data: {content: content},
headers: {"X-CSRFToken": csrf_token},
headers: {},
dataType: 'json'
})
.done(function (data) {
$contentPreview.html(data.content);
})
.fail(function (err) {
toastr.error(xhrErrorResponseMessage(err), 'Parsing failed');
});
}
// Delay function to not start converting heavy posts immediately var options = {
var delay = (function(){ callback: parseDescriptionContent,
var timer = 0; wait: 750,
return function(callback, ms){ highlight: false,
clearTimeout (timer); allowSubmit: false,
timer = setTimeout(callback, ms); captureLength: 2
}; }
})();
$textarea.keyup(function() { $contentField.typeWatch(options);
/* If there's an iframe (YouTube embed), delay markdown convert 1.5s */
if (/iframe/i.test($textarea.val())) {
$loader.show();
delay(function(){
// Convert markdown
$preview.html(convert($textarea.val()));
$loader.hide();
}, 1500 );
} else {
// Convert markdown
$preview.html(convert($textarea.val()));
}
}).trigger('keyup');
$('input, textarea').keypress(function () { $('input, textarea').keypress(function () {
// Unused: save status of the page as 'edited' // Unused: save status of the page as 'edited'