mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-02 20:59:28 +00:00
91fbabde6f
- Moved application/views/system/message* to application/views/system/messages/ - Adapted code to use those views with the new path - Fixed function getCode in public/js/AjaxLib.js - In public/js/messaging/messageWrite.js is now used AjaxLib.js - Changed method parseMessageText in MessageLib.php to replace the keys of the data parameter - Removed function write from application/controllers/system/Phrases.php - Adapted code in application/controllers/system/Messages.php to use the changed method parseMessageText in MessageLib.php and path of the moved views
138 lines
2.7 KiB
JavaScript
138 lines
2.7 KiB
JavaScript
/**
|
|
* JS used by view system/messages/messageWrite
|
|
*/
|
|
|
|
function tinymcePreviewSetContent()
|
|
{
|
|
if ($("#tinymcePreview"))
|
|
{
|
|
if ($("#recipients").children(":selected").val() > -1)
|
|
{
|
|
parseMessageText($("#recipients").children(":selected").val(), tinyMCE.get("bodyTextArea").getContent());
|
|
}
|
|
else
|
|
{
|
|
tinyMCE.get("tinymcePreview").setContent("");
|
|
}
|
|
}
|
|
}
|
|
|
|
function parseMessageText(receiver_id, text)
|
|
{
|
|
FHC_AjaxClient.ajaxCallGet(
|
|
"system/Messages/parseMessageText",
|
|
{
|
|
person_id: receiver_id,
|
|
text: text
|
|
},
|
|
{
|
|
successCallback: function(data, textStatus, jqXHR) {
|
|
|
|
if (FHC_AjaxClient.hasData(data))
|
|
{
|
|
tinyMCE.get("tinymcePreview").setContent(FHC_AjaxClient.getData(data));
|
|
}
|
|
else if (FHC_AjaxClient.isError(data))
|
|
{
|
|
alert(data.retval);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
$(document).ready(function ()
|
|
{
|
|
tinymce.init({
|
|
selector: "#bodyTextArea",
|
|
plugins: "autoresize",
|
|
autoresize_min_height: 150,
|
|
autoresize_max_height: 600,
|
|
autoresize_bottom_margin: 10
|
|
});
|
|
|
|
tinymce.init({
|
|
menubar: false,
|
|
toolbar: false,
|
|
statusbar: false,
|
|
readonly: 1,
|
|
selector: "#tinymcePreview",
|
|
plugins: "autoresize",
|
|
autoresize_min_height: 150,
|
|
autoresize_bottom_margin: 10
|
|
});
|
|
|
|
if ($("#variables"))
|
|
{
|
|
$("#variables").dblclick(function ()
|
|
{
|
|
if ($("#bodyTextArea"))
|
|
{
|
|
//if editor active add at cursor position, otherwise at end
|
|
if (tinymce.activeEditor.id === "bodyTextArea")
|
|
tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).children(":selected").val());
|
|
else
|
|
tinyMCE.get("bodyTextArea").setContent(tinyMCE.get("bodyTextArea").getContent() + $(this).children(":selected").val());
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($("#recipients"))
|
|
{
|
|
$("#recipients").change(tinymcePreviewSetContent);
|
|
}
|
|
|
|
if ($("#refresh"))
|
|
{
|
|
$("#refresh").click(tinymcePreviewSetContent);
|
|
}
|
|
|
|
if ($("#sendButton") && $("#sendForm"))
|
|
{
|
|
$("#sendButton").click(function ()
|
|
{
|
|
if ($("#subject") && $("#subject").val() != '' && tinyMCE.get("bodyTextArea").getContent() != '')
|
|
{
|
|
$("#sendForm").submit();
|
|
}
|
|
else
|
|
{
|
|
alert("Subject and text are required fields!");
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($("#vorlageDnD"))
|
|
{
|
|
$("#vorlageDnD").change(function ()
|
|
{
|
|
var vorlage_kurzbz = this.value;
|
|
|
|
if (vorlage_kurzbz != '')
|
|
{
|
|
FHC_AjaxClient.ajaxCallGet(
|
|
"system/Messages/getVorlage",
|
|
{
|
|
vorlage_kurzbz: vorlage_kurzbz
|
|
},
|
|
{
|
|
successCallback: function(data, textStatus, jqXHR) {
|
|
|
|
if (FHC_AjaxClient.hasData(data))
|
|
{
|
|
var msg = FHC_AjaxClient.getData(data);
|
|
|
|
tinyMCE.get("bodyTextArea").setContent(msg[0].text);
|
|
$("#subject").val(msg[0].subject);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
$("#subject").focus();
|
|
|
|
});
|