|
|
@ -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: "",
|
|
|
|