##// END OF EJS Templates
Updated version. Use "neboard dev" label for the development version of site
Updated version. Use "neboard dev" label for the development version of site

File last commit:

r1217:1037d51e default
r1222:604935b9 2.8.3 default
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();
})
})