From b377e57b5d4d98429bcd641e26abc65d329fd535 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sun, 22 Apr 2018 13:28:10 -0600 Subject: [PATCH] Add sw-text for plain text inputs --- public/index.php | 3 +- public/themes/bootstrap/contact.php | 2 +- public/themes/bootstrap/default.php | 2 +- public/themes/bootstrap/home.php | 2 +- static/css/editor.css | 14 ++++++++++ static/js/editor.js | 43 +++++++++++++++++++++-------- 6 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 static/css/editor.css diff --git a/public/index.php b/public/index.php index 0d30d8f..d542b2d 100644 --- a/public/index.php +++ b/public/index.php @@ -21,11 +21,12 @@ if (isset($_GET['edit'])) { ?> - + \ No newline at end of file diff --git a/public/themes/bootstrap/contact.php b/public/themes/bootstrap/contact.php index 961d2df..6d90bb9 100644 --- a/public/themes/bootstrap/contact.php +++ b/public/themes/bootstrap/contact.php @@ -12,7 +12,7 @@ include __DIR__ . "/inc/header.inc.php";

-

+

diff --git a/public/themes/bootstrap/default.php b/public/themes/bootstrap/default.php index aedbec7..5532466 100644 --- a/public/themes/bootstrap/default.php +++ b/public/themes/bootstrap/default.php @@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";

-
+
diff --git a/public/themes/bootstrap/home.php b/public/themes/bootstrap/home.php index c7cd833..6ec8d80 100644 --- a/public/themes/bootstrap/home.php +++ b/public/themes/bootstrap/home.php @@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";

-
+
diff --git a/static/css/editor.css b/static/css/editor.css new file mode 100644 index 0000000..1f41a6b --- /dev/null +++ b/static/css/editor.css @@ -0,0 +1,14 @@ +/* +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +.sw-text-input { + border: 2px dashed red; + width: 100%; +} + +.note-editor { + border: 2px dashed red !important; +} \ No newline at end of file diff --git a/static/js/editor.js b/static/js/editor.js index f1efed3..a85873f 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -4,25 +4,44 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -$(".sw-editable").summernote({ - airMode: false, - toolbar: [ - ['style', ['bold', 'italic', 'underline', 'clear']], - ['font', ['strikethrough', 'superscript', 'subscript']], - ['fontsize', ['fontsize']], - ['para', ['ul', 'ol']], - ['insert', ['link', 'picture']], - ['misc', ['undo', 'redo', 'fullscreen', 'codeview']] - ], - placeholder: 'Click to edit' +$(document).ready(function () { + $("body").append(""); + + $(".sw-editable").each(function () { + // Remove leading whitespace added by the template + $(this).html($(this).html().trim()); + }); + + $(".sw-editable").summernote({ + airMode: false, + toolbar: [ + ['style', ['bold', 'italic', 'underline', 'clear']], + ['font', ['strikethrough', 'superscript', 'subscript']], + ['fontsize', ['fontsize']], + ['para', ['ul', 'ol']], + ['insert', ['link', 'picture']], + ['misc', ['undo', 'redo', 'fullscreen', 'codeview']] + ], + placeholder: 'Click to edit' + }); + + $(".sw-text").each(function () { + var text = $(this).text().trim(); + var component = $(this).data("component"); + $(this).html(""); + }); }); function saveEdits() { var components = []; $(".sw-editable").each(function (e) { - components[$(this).data("component")] = $(this).html(); + components[$(this).data("component")] = $(this).summernote('code'); + }); + $(".sw-text-input").each(function (e) { + components[$(this).data("component")] = $(this).val(); }); var content = JSON.stringify(components); + console.log(components); $.post(save_url, { action: "saveedits", page: "",