Add sw-text for plain text inputs
This commit is contained in:
parent
ac90969eec
commit
b377e57b5d
@ -21,11 +21,12 @@ if (isset($_GET['edit'])) {
|
|||||||
?>
|
?>
|
||||||
<link href="<?php echo URL; ?>/static/css/summernote-lite.css" rel="stylesheet" />
|
<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/summernote-lite.js"></script>
|
||||||
<script src="<?php echo URL; ?>/static/js/editor.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
var save_url = "<?php echo URL; ?>/action.php";
|
var save_url = "<?php echo URL; ?>/action.php";
|
||||||
|
var static_dir = "<?php echo URL; ?>/static";
|
||||||
var page_slug = "<?php getpageslug(); ?>";
|
var page_slug = "<?php getpageslug(); ?>";
|
||||||
</script>
|
</script>
|
||||||
|
<script src="<?php echo URL; ?>/static/js/editor.js"></script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -12,7 +12,7 @@ include __DIR__ . "/inc/header.inc.php";
|
|||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="display-4"><?php get_page_title(); ?></h1>
|
<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>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="display-4"><?php get_page_title(); ?></h1>
|
<h1 class="display-4"><?php get_page_title(); ?></h1>
|
||||||
<div class="ml-2 lead">
|
<div class="ml-2 lead">
|
||||||
<div class="sw-editable" data-component="lead">
|
<div class="sw-text" data-component="lead">
|
||||||
<?php get_component("lead"); ?>
|
<?php get_component("lead"); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@ include __DIR__ . "/inc/header.inc.php";
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="display-4"><?php get_page_title(); ?></h1>
|
<h1 class="display-4"><?php get_page_title(); ?></h1>
|
||||||
<div class="ml-2 lead">
|
<div class="ml-2 lead">
|
||||||
<div class="sw-editable" data-component="lead">
|
<div class="sw-text" data-component="lead">
|
||||||
<?php get_component("lead"); ?>
|
<?php get_component("lead"); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
14
static/css/editor.css
Normal file
14
static/css/editor.css
Normal file
@ -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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(".sw-editable").summernote({
|
$(document).ready(function () {
|
||||||
airMode: false,
|
$("body").append("<link href=\"" + static_dir + "/css/editor.css\" rel=\"stylesheet\" />");
|
||||||
toolbar: [
|
|
||||||
['style', ['bold', 'italic', 'underline', 'clear']],
|
$(".sw-editable").each(function () {
|
||||||
['font', ['strikethrough', 'superscript', 'subscript']],
|
// Remove leading whitespace added by the template
|
||||||
['fontsize', ['fontsize']],
|
$(this).html($(this).html().trim());
|
||||||
['para', ['ul', 'ol']],
|
});
|
||||||
['insert', ['link', 'picture']],
|
|
||||||
['misc', ['undo', 'redo', 'fullscreen', 'codeview']]
|
$(".sw-editable").summernote({
|
||||||
],
|
airMode: false,
|
||||||
placeholder: 'Click to edit'
|
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() {
|
function saveEdits() {
|
||||||
var components = [];
|
var components = [];
|
||||||
$(".sw-editable").each(function (e) {
|
$(".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);
|
var content = JSON.stringify(components);
|
||||||
|
console.log(components);
|
||||||
$.post(save_url, {
|
$.post(save_url, {
|
||||||
action: "saveedits",
|
action: "saveedits",
|
||||||
page: "",
|
page: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user