##// END OF EJS Templates
Moved post image to a separate model. Each post (as of model) can contain multiple images now. The image shown to the user is got with get_first_image method
Moved post image to a separate model. Each post (as of model) can contain multiple images now. The image shown to the user is got with get_first_image method

File last commit:

r686:64d75fce default
r693:641dff39 1.8-dev
Show More
form.js
45 lines | 1.2 KiB | application/javascript | JavascriptLexer
var isCompact = true;
$('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 compactForm = $('.swappable-form-compact');
var fullForm = $('.swappable-form-full');
function swapForm() {
compactForm.toggle();
fullForm.toggle();
if (isCompact) {
var oldText = compactForm.find('textarea')[0].value;
fullForm.find('textarea')[0].value = oldText;
} else {
var oldText = fullForm.find('textarea')[0].value;
compactForm.find('textarea')[0].value = oldText;
}
isCompact = !isCompact;
scrollToBottom();
}
if (compactForm.length > 0) {
fullForm.toggle();
}