From ac4ad56992e16fad6e8b176382923b927fc1c9a7 Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Tue, 1 Oct 2024 22:21:59 +0100 Subject: [PATCH 1/3] Hopefully fixed issue #17 - stop adding unwanted tags into html --- cms/js/cms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/js/cms.js b/cms/js/cms.js index b30c23c..b97941b 100644 --- a/cms/js/cms.js +++ b/cms/js/cms.js @@ -39,7 +39,7 @@ $(document).ready(function () { images_upload_credentials: true, force_br_newlines: false, force_p_newlines: false, - forced_root_block: '', + forced_root_block: false, setup: function (editor) { editor.on('init', function (e) { editor.setContent(content); From c1e050ded507547cdb906785a043d347faeb9943 Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Tue, 1 Oct 2024 22:32:57 +0100 Subject: [PATCH 2/3] Added feedback when saving page content --- cms/controller/index.php | 5 +++-- cms/index.php | 2 +- cms/js/cms.js | 43 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/cms/controller/index.php b/cms/controller/index.php index 6fdbc01..0f86130 100644 --- a/cms/controller/index.php +++ b/cms/controller/index.php @@ -4,11 +4,12 @@ require_once "../init.php"; switch ($_REQUEST["action"]) { case "save": + header('Content-type: application/json'); if (!empty($_POST['uri']) && !empty($_POST['content'])) { $_SESSION['core']->saveContent($_POST['uri'], $_POST['content']); - echo 'Page Updated.'; + echo json_encode(array('message'=>'Page has been saved')); } else { - echo 'Unable to save page'; + echo json_encode(array('error'=>'Unable to save page')); } break; diff --git a/cms/index.php b/cms/index.php index e37fc7c..3729787 100644 --- a/cms/index.php +++ b/cms/index.php @@ -24,7 +24,7 @@ require_once "init.php"; - +
diff --git a/cms/js/cms.js b/cms/js/cms.js index b97941b..fcd3cd9 100644 --- a/cms/js/cms.js +++ b/cms/js/cms.js @@ -39,7 +39,7 @@ $(document).ready(function () { images_upload_credentials: true, force_br_newlines: false, force_p_newlines: false, - forced_root_block: false, + newline_behavior: 'linebreak', setup: function (editor) { editor.on('init', function (e) { editor.setContent(content); @@ -77,6 +77,11 @@ $(document).ready(function () { uri: $('#frameContainer').contents().get(0).location.pathname, content: new XMLSerializer().serializeToString($('#frameContainer').contents().get(0)) }, function (data) { + if( typeof data.error == "undefined") { + showMessage(data.message,"success"); + } else { + showMessage(data.message,"error"); + } // alert(data) }); }); @@ -188,4 +193,38 @@ $(document).ready(function () { }); }); -}); \ No newline at end of file +}); + +function showMessage(message, type) { + var messageBar = $('#message-bar'); + + // Set the text message + messageBar.text(message); + + // Set the color based on the type + if (type === 'error') { + messageBar.css('background-color', 'red'); + } else if (type === 'success') { + messageBar.css('background-color', 'green'); + } + + // Set the full width and position + messageBar.css({ + 'width': '100%', + 'position': 'fixed', + 'top': '0', + 'left': '0', + 'padding': '10px', + 'color': 'white', + 'text-align': 'center', + 'z-index': '9999' + }); + + // Show the message bar + messageBar.slideDown(); + + // Hide the bar after 5 seconds + setTimeout(function() { + messageBar.slideUp(); + }, 5000); +} \ No newline at end of file From 2b4999f65cb6cd286af30681a2cc30541844059a Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Tue, 1 Oct 2024 22:35:20 +0100 Subject: [PATCH 3/3] Refined feedback --- cms/js/cms.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cms/js/cms.js b/cms/js/cms.js index fcd3cd9..fc874db 100644 --- a/cms/js/cms.js +++ b/cms/js/cms.js @@ -116,14 +116,15 @@ $(document).ready(function () { }, success: function (response) { if (typeof response.error != "undefined") { - alert(response.error); + showMessage(response.error,"error"); } else { + showMessage("New page Created","success"); $('#frameContainer').contents().get(0).location.href = response.url; $("#newPageForm").dialog("close"); // Close the modal on success } }, error: function () { - alert('Failed to create the new page.'); + showMessage("Failed to create the new page (API error)","error"); } }); }); @@ -195,6 +196,11 @@ $(document).ready(function () { }); +/** + * Show A message bar across the top of the screen for a few seconds + * @param message - string - message to be shown + * @param type - string "success" or "error" + */ function showMessage(message, type) { var messageBar = $('#message-bar');