##// END OF EJS Templates
Merged with defaul
Merged with defaul

File last commit:

r1217:1037d51e default
r1241:1b60b7d2 merge decentral
Show More
form.js
43 lines | 1.1 KiB | application/javascript | JavascriptLexer
$('input[name=image]').wrap($('<div class="file_wrap"></div>'));
$('body').on('change', 'input[name=image]', function(event) {
var file = event.target.files[0];
if(file.type.match('image.*')) {
var fileReader = new FileReader();
fileReader.addEventListener("load", function(event) {
var wrapper = $('.file_wrap');
wrapper.find('.file-thumb').remove();
wrapper.append(
$('<div class="file-thumb" style="background-image: url('+event.target.result+')"></div>')
);
});
fileReader.readAsDataURL(file);
}
});
var form = $('#form');
$('textarea').keypress(function(event) {
if (event.which == 13 && event.ctrlKey) {
form.submit();
}
});
$('#preview-button').click(function() {
var data = {
raw_text: $('textarea').val()
}
var diffUrl = '/api/preview/';
$.post(diffUrl,
data,
function(data) {
var previewTextBlock = $('#preview-text');
previewTextBlock.html(data);
previewTextBlock.show();
})
})