Файл: sys/static/js/comments.js
Строк: 62
<?php
/**
* Комментарии DCMS-Social v3
* Версия: 1
*/
jQuery(function($) {
$(document).on('click', '.attachments-item .remove', function() {
var parent = $(this).closest('.attachments-item');
parent.remove();
});
$(document).on('click', '.load-files', function() {
var hash = $(this).data('hash') || '';
var type = $(this).data('type') || false;
var term = $(this).data('term') || false;
var title = $(this).text();
$media = new MediaManager();
$media.open({
selector: '.wrap-choose-manager[data-hash="' + hash + '"]',
title: title,
type: type,
term: term,
onSelected: function(obj) {
var attachments = $('.attachments[data-hash="' + hash + '"]');
obj.forEach(function(file, index) {
attachments.append($('<div/>', {
style: 'background-image: url(' + file.thumbnail + ')',
class: 'attachments-item',
append: [
$('<input/>', {
type: 'hidden',
value: file.file_id,
name: 'attachments[]',
}),
$('<i/>', {
class: file.icon,
}),
$('<span/>', {
class: 'title',
text: file.title,
}),
$('<span/>', {
class: 'remove',
html: '×',
}),
]
}));
});
}
});
});
$(document).on('keyup', '.ds-editor-textarea', function(event) {
var id = $(this).attr('id');
var msg = $(this).val();
msg = msg.replace(new RegExp('r?n','g'), '<br>');
var h = $('.ds-editor-helper[data-hash="' + id + '"]');
h.html(msg);
var height = h.height();
height += 19;
if (event.keyCode == 13) {
height += 16;
}
$(this).css('height', height + 'px');
});
$("form.form-ajax").on("submit", function() {
var formData = new FormData(this);
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: formData,
processData: false,
contentType: false,
success: function(data) {
$('#log').html(data);
},
error: function() {
console.log('Error send');
}
});
return false;
});
});
?>