remove django-markdown and handle preview manually
This commit is contained in:
parent
4995c19560
commit
7e3173c7c0
32 changed files with 335 additions and 16478 deletions
25
tracker/static/js/markdown-preview.js
Normal file
25
tracker/static/js/markdown-preview.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
var csrftoken = $.cookie('csrftoken');
|
||||
|
||||
function csrfSafeMethod(method) {
|
||||
// these HTTP methods do not require CSRF protection
|
||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||
}
|
||||
$.ajaxSetup({
|
||||
beforeSend: function(xhr, settings) {
|
||||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('a[href="#preview"]').on("show.bs.tab", function (e) {
|
||||
$('#preview-content').html('Loading preview...');
|
||||
var comment = $('#markdown-content').val();
|
||||
$.post(markdown_preview_url, {'data': comment})
|
||||
.done(function(data, textStatus) {
|
||||
$('#preview-content').html(data);
|
||||
})
|
||||
.fail(function () {
|
||||
$('#preview-content').html('Sorry, an error occured.');
|
||||
});
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue