ComunicWeb/assets/js/components/comments/editor.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Comments editor
*
* @author Pierre HUBERT
*/
ComunicWeb.components.comments.editor = {
/**
* Open the comments editor
*
* @param {Object} infos Informations about the comment to edit
* @param {HTMLElement} root Comment root element
*/
open: function(infos, root){
//Prepare input callback
var inputCallback = function(result){
//Check if edition was cancelled
if(!result)
return;
//Try to update comment content
ComunicWeb.components.comments.interface.edit(infos.ID, result, function(result){
//Check for error
if(result.error){
2018-08-05 14:29:49 +00:00
ComunicWeb.common.notificationSystem.showNotification(lang("comments_editor_err_update"), "danger");
return;
}
//Else perform next actions
2018-01-27 17:49:05 +00:00
//Reload the comment
ComunicWeb.components.comments.actions.reload(infos.ID, root);
});
}
//Prompt the user to enter the new content of the comment
ComunicWeb.common.messages.inputString(
2018-08-05 14:29:49 +00:00
lang("comments_editor_title"),
lang("comments_editor_notice"),
infos.content,
inputCallback
);
}
}