Add sw-text for plain text inputs

master
Skylar Ittner 6 years ago
parent ac90969eec
commit b377e57b5d

@ -21,11 +21,12 @@ if (isset($_GET['edit'])) {
?>
<link href="<?php echo URL; ?>/static/css/summernote-lite.css" rel="stylesheet" />
<script src="<?php echo URL; ?>/static/js/summernote-lite.js"></script>
<script src="<?php echo URL; ?>/static/js/editor.js"></script>
<script>
var save_url = "<?php echo URL; ?>/action.php";
var static_dir = "<?php echo URL; ?>/static";
var page_slug = "<?php getpageslug(); ?>";
</script>
<script src="<?php echo URL; ?>/static/js/editor.js"></script>
<?php
}
?>

@ -12,7 +12,7 @@ include __DIR__ . "/inc/header.inc.php";
<div class="jumbotron">
<div class="container">
<h1 class="display-4"><?php get_page_title(); ?></h1>
<p class="ml-2 lead sw-editable" data-component="lead"><?php get_component("lead"); ?></p>
<p class="ml-2 lead sw-text" data-component="lead"><?php get_component("lead"); ?></p>
</div>
</div>
<div class="container">

@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";
<div class="container">
<h1 class="display-4"><?php get_page_title(); ?></h1>
<div class="ml-2 lead">
<div class="sw-editable" data-component="lead">
<div class="sw-text" data-component="lead">
<?php get_component("lead"); ?>
</div>
</div>

@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";
<div class="container">
<h1 class="display-4"><?php get_page_title(); ?></h1>
<div class="ml-2 lead">
<div class="sw-editable" data-component="lead">
<div class="sw-text" data-component="lead">
<?php get_component("lead"); ?>
</div>
</div>

@ -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;
}

@ -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("<link href=\"" + static_dir + "/css/editor.css\" rel=\"stylesheet\" />");
$(".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("<input type=\"text\" data-component=\"" + component + "\" class=\"sw-text-input\" value=\"" + text + "\" placeholder=\"Click to edit\">");
});
});
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: "",

Loading…
Cancel
Save