From ac1df7691a72d95e33b48e33426ffdb3da03870e Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 11 Nov 2022 13:54:25 +0100 Subject: [PATCH] - Added new view application/views/system/messages/FAShtmlWriteTemplate.php to be used with FAS/SeaMonkey and TinyMCE3 - Replaced TinyMCE V4 with V5 - Dropped TinyMCE V4 - Added new JS public/js/messaging/fasMessageWrite.js to be included by application/views/system/messages/FAShtmlWriteTemplate.php --- .../system/messages/FASMessages.php | 4 +- application/views/person/bpk/bpkDetails.php | 1 - .../system/infocenter/infocenterDetails.php | 2 +- .../infocenter/infocenterZgvDetails.php | 2 +- .../system/messages/FAShtmlWriteTemplate.php | 197 ++++++++++++++++++ .../views/system/messages/ajaxRead.php | 2 +- .../views/system/messages/ajaxWrite.php | 2 +- .../views/system/messages/ajaxWriteReply.php | 2 +- .../views/system/messages/htmlWriteReply.php | 2 +- .../system/messages/htmlWriteTemplate.php | 2 +- .../views/system/vorlage/templatetextEdit.php | 2 +- application/views/templates/FHC-Common.php | 2 +- application/views/templates/FHC-Footer.php | 4 +- application/views/templates/FHC-Header.php | 3 - application/views/templates/header.php | 2 +- application/views/widgets/tinymce.php | 5 +- public/css/{TinyMCE.css => TinyMCE5.css} | 0 public/js/messaging/fasMessageWrite.js | 140 +++++++++++++ public/js/messaging/messageWrite.js | 11 +- public/js/messaging/write.js | 2 +- 20 files changed, 363 insertions(+), 24 deletions(-) create mode 100644 application/views/system/messages/FAShtmlWriteTemplate.php rename public/css/{TinyMCE.css => TinyMCE5.css} (100%) create mode 100644 public/js/messaging/fasMessageWrite.js diff --git a/application/controllers/system/messages/FASMessages.php b/application/controllers/system/messages/FASMessages.php index 55d1da25f..e2169af9b 100644 --- a/application/controllers/system/messages/FASMessages.php +++ b/application/controllers/system/messages/FASMessages.php @@ -37,7 +37,7 @@ class FASMessages extends Auth_Controller // Loads the view to write a new message with a template $this->load->view( - 'system/messages/htmlWriteTemplate', + 'system/messages/FAShtmlWriteTemplate', $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents) ); } @@ -53,7 +53,7 @@ class FASMessages extends Auth_Controller // Loads the view to write a new message with a template $this->load->view( - 'system/messages/htmlWriteTemplate', + 'system/messages/FAShtmlWriteTemplate', $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents, $message_id, $recipient_id) ); } diff --git a/application/views/person/bpk/bpkDetails.php b/application/views/person/bpk/bpkDetails.php index 198065c24..6b7d4430d 100644 --- a/application/views/person/bpk/bpkDetails.php +++ b/application/views/person/bpk/bpkDetails.php @@ -9,7 +9,6 @@ 'jqueryui1' => true, 'ajaxlib' => true, 'tablesorter2' => true, - 'tinymce4' => true, 'sbadmintemplate3' => true, 'addons' => true, 'navigationwidget' => true, diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 158feeb2c..15eca90c2 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -8,7 +8,7 @@ 'dialoglib' => true, 'ajaxlib' => true, 'tablesorter2' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'sbadmintemplate3' => true, 'addons' => true, 'navigationwidget' => true, diff --git a/application/views/system/infocenter/infocenterZgvDetails.php b/application/views/system/infocenter/infocenterZgvDetails.php index cf3ffad8b..bf9f69e18 100644 --- a/application/views/system/infocenter/infocenterZgvDetails.php +++ b/application/views/system/infocenter/infocenterZgvDetails.php @@ -10,7 +10,7 @@ 'dialoglib' => true, 'ajaxlib' => true, 'tablesorter2' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'sbadmintemplate3' => true, 'addons' => true, 'navigationwidget' => true, diff --git a/application/views/system/messages/FAShtmlWriteTemplate.php b/application/views/system/messages/FAShtmlWriteTemplate.php new file mode 100644 index 000000000..691629c10 --- /dev/null +++ b/application/views/system/messages/FAShtmlWriteTemplate.php @@ -0,0 +1,197 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a new message or reply using templates', + 'jquery3' => true, + 'jqueryui1' => true, + 'bootstrap3' => true, + 'ajaxlib' => true, + 'fontawesome4' => true, + 'tinymce3' => true, + 'sbadmintemplate3' => true, + 'dialoglib' => true, + 'widgets' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/fasMessageWrite.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + +
+
+
+ + + 19 ? 19 : count($variables); + echo $this->widgetlib->widget( + 'MultipleDropdown_widget', + array('elements' => success($variables)), + array( + 'name' => 'variables[]', + 'id' => 'variables', + 'size' => $size, + 'multiple' => true + ) + ); + ?> +
+
+
+ + + 5 ? 5 : count($user_fields); + echo $this->widgetlib->widget( + 'MultipleDropdown_widget', + array('elements' => success($user_fields)), + array( + 'name' => 'user_fields[]', + 'id' => 'user_fields', + 'size' => $size, + 'multiple' => true + ) + ); + ?> +
+
+
+
+
+
+ + widgetlib->widget( + 'Vorlage_widget', + array('oe_kurzbz' => $organisationUnits, 'isAdmin' => $senderIsAdmin), + array('name' => 'vorlage', 'id' => 'vorlageDnD') + ); + ?> + +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+ widgetlib->widget( + 'Dropdown_widget', + array( + 'elements' => success($recipientsArray), + 'emptyElement' => ucfirst($this->p->t('global', 'empfaenger')).'...' + ), + array( + 'name' => 'recipients[]', + 'id' => 'recipients' + ) + ); + ?> + + + p->t('ui', 'refresh')); ?> + + +
+
+
+
+
+ +
+ + + + + +
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> + diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 2cb88708e..4c1a77deb 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -12,7 +12,7 @@ 'tabulator4' => true, 'ajaxlib' => true, 'dialoglib' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 3b1582f22..b3a598506 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -10,7 +10,7 @@ 'sbadmintemplate3' => true, 'ajaxlib' => true, 'dialoglib' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 0a496c93e..08dc188fa 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -10,7 +10,7 @@ 'sbadmintemplate3' => true, 'ajaxlib' => true, 'dialoglib' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index 9106d802b..d2150c1fb 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -6,7 +6,7 @@ 'jquery3' => true, 'bootstrap3' => true, 'fontawesome4' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'sbadmintemplate3' => true, 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 761e05f96..42a31f374 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -8,7 +8,7 @@ 'bootstrap3' => true, 'ajaxlib' => true, 'fontawesome4' => true, - 'tinymce4' => true, + 'tinymce5' => true, 'sbadmintemplate3' => true, 'dialoglib' => true, 'widgets' => true, diff --git a/application/views/system/vorlage/templatetextEdit.php b/application/views/system/vorlage/templatetextEdit.php index 42efc1519..cc2487959 100644 --- a/application/views/system/vorlage/templatetextEdit.php +++ b/application/views/system/vorlage/templatetextEdit.php @@ -1,5 +1,5 @@ load->view('templates/header', array('title' => 'VorlageEdit', 'tinymce4' => true, 'jsonforms' => true)); + $this->load->view('templates/header', array('title' => 'VorlageEdit', 'tinymce5' => true, 'jsonforms' => true)); ?>
diff --git a/application/views/templates/FHC-Common.php b/application/views/templates/FHC-Common.php index dd1d8ae1c..27282bc11 100644 --- a/application/views/templates/FHC-Common.php +++ b/application/views/templates/FHC-Common.php @@ -23,7 +23,7 @@ $tablesorter2 = isset($tablesorter2) ? $tablesorter2 : false; $tabulator4 = isset($tabulator4) ? $tabulator4 : false; $tabulator5 = isset($tabulator5) ? $tabulator5 : false; - $tinymce4 = isset($tinymce4) ? $tinymce4 : false; + $tinymce3 = isset($tinymce3) ? $tinymce3 : false; $tinymce5 = isset($tinymce5) ? $tinymce5 : false; $vue3 = isset($vue3) ? $vue3 : false; $primevue3 = isset($primevue3) ? $primevue3 : false; diff --git a/application/views/templates/FHC-Footer.php b/application/views/templates/FHC-Footer.php index 0c3782fea..ee13c69d2 100644 --- a/application/views/templates/FHC-Footer.php +++ b/application/views/templates/FHC-Footer.php @@ -100,8 +100,8 @@ // Tabulator 5 JS if ($tabulator5 === true) generateJSsInclude('vendor/olifolkerd/tabulator5/dist/js/tabulator.min.js'); - // Tinymce 4 JS - if ($tinymce4 === true) generateJSsInclude('vendor/tinymce/tinymce4/tinymce.min.js'); + // Tinymce 3 JS + if ($tinymce3 === true) generateJSsInclude('include/tiny_mce/tiny_mce.js'); // Tinymce 5 JS if ($tinymce5 === true) generateJSsInclude('vendor/tinymce/tinymce5/tinymce.min.js'); diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index aa63541c5..47eea34ec 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -79,9 +79,6 @@ // Tabulator 5 CSS if ($tabulator5 === true) generateCSSsInclude('vendor/olifolkerd/tabulator5/dist/css/tabulator_bootstrap5.min.css'); - // Tinymce 4 CSS - if ($tinymce4 === true) generateCSSsInclude('public/css/TinyMCE4.css'); - // Tinymce 5 CSS if ($tinymce5 === true) generateCSSsInclude('public/css/TinyMCE5.css'); diff --git a/application/views/templates/header.php b/application/views/templates/header.php index 637eb3c7a..e75acca4f 100644 --- a/application/views/templates/header.php +++ b/application/views/templates/header.php @@ -95,7 +95,7 @@ if($jqueryV1 && $jqueryV2) show_error("Two JQuery versions used: composer and in - + diff --git a/application/views/widgets/tinymce.php b/application/views/widgets/tinymce.php index 3e2093e55..618cb4836 100644 --- a/application/views/widgets/tinymce.php +++ b/application/views/widgets/tinymce.php @@ -5,5 +5,6 @@ plugins: [], toolbar: "" }); - - < name="" style="">> + +< name="" style="">> + diff --git a/public/css/TinyMCE.css b/public/css/TinyMCE5.css similarity index 100% rename from public/css/TinyMCE.css rename to public/css/TinyMCE5.css diff --git a/public/js/messaging/fasMessageWrite.js b/public/js/messaging/fasMessageWrite.js new file mode 100644 index 000000000..d32f80fac --- /dev/null +++ b/public/js/messaging/fasMessageWrite.js @@ -0,0 +1,140 @@ +// ******************************************************** +// JS used by view system/messages/htmlWriteTemplate +// ******************************************************** + +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.ajaxCallPost( + "system/messages/Messages/parseMessageText", + { + receiver_id: receiver_id, + text: text, + type: $("#type").val() + }, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.hasData(data)) + { + tinyMCE.get("tinymcePreview").setContent(FHC_AjaxClient.getData(data)); + } + else if (FHC_AjaxClient.isError(data)) + { + FHC_DialogLib.alertError(data.retval); + } + } + } + ); +} + +$(document).ready(function () +{ + + tinymce.init({ + theme : "advanced", + mode : "textareas" + }); + + 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 ($("#user_fields")) + { + $("#user_fields").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 + { + FHC_DialogLib.alertInfo("Subject and text are required fields!"); + } + }); + } + + if ($("#vorlageDnD")) + { + $("#vorlageDnD").change(function () + { + var vorlage_kurzbz = this.value; + + if (vorlage_kurzbz != '') + { + FHC_AjaxClient.ajaxCallGet( + "system/messages/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(); + +}); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 8b1d73bdf..382e79948 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -42,8 +42,8 @@ function parseMessageText(receiver_id, text) ); } -$(document).ready(function () -{ +$(document).ready(function () { + tinymce.init({ selector: "#bodyTextArea", plugins: "autoresize", @@ -60,7 +60,12 @@ $(document).ready(function () menubar: false, toolbar: false, statusbar: false, - readonly: 1 + readonly: 1, + autoresize_on_init: false, + autoresize_min_height: 400, + autoresize_max_height: 700, + autoresize_bottom_margin: 10, + auto_focus: "bodyTextArea" }); if ($("#variables")) diff --git a/public/js/messaging/write.js b/public/js/messaging/write.js index 1370fb2e0..bff451c2e 100644 --- a/public/js/messaging/write.js +++ b/public/js/messaging/write.js @@ -63,7 +63,7 @@ $(document).ready(function () { tinymce.init({ selector: "#body", plugins: "autoresize", - autoresize_min_height: 150, + autoresize_min_height: 300, autoresize_max_height: 600, autoresize_bottom_margin: 10 });