2018-07-12 20:03:31 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// FORM START
|
|
|
|
echo Bootstrap::formOpen(array(
|
|
|
|
'id'=>'jsform',
|
|
|
|
'class'=>'d-flex flex-column h-100'
|
|
|
|
));
|
|
|
|
|
|
|
|
// Token CSRF
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'tokenCSRF',
|
|
|
|
'value'=>$security->getTokenCSRF()
|
|
|
|
));
|
2018-05-02 19:59:45 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Parent
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'parent',
|
|
|
|
'value'=>$page->parent()
|
|
|
|
));
|
2018-07-07 12:04:34 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// UUID
|
|
|
|
// The UUID is generated in the controller
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'uuid',
|
|
|
|
'value'=>$uuid
|
|
|
|
));
|
2018-05-02 19:59:45 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Type = published, draft, sticky, static
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'type',
|
|
|
|
'value'=>$page->type()
|
|
|
|
));
|
2018-05-02 19:59:45 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Cover image
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'coverImage',
|
|
|
|
'value'=>$page->coverImage(false)
|
|
|
|
));
|
2018-07-17 19:13:01 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Content
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'content',
|
|
|
|
'value'=>''
|
|
|
|
));
|
2018-05-02 19:59:45 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Current page key
|
|
|
|
echo Bootstrap::formInputHidden(array(
|
|
|
|
'name'=>'key',
|
|
|
|
'value'=>$page->key()
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- TOOLBAR -->
|
2018-10-30 16:12:44 +01:00
|
|
|
<div id="jseditorToolbar">
|
2018-11-07 15:40:22 +01:00
|
|
|
<div id="jseditorToolbarRight" class="btn-group btn-group-sm float-right" role="group" aria-label="Toolbar right">
|
2018-10-30 16:12:44 +01:00
|
|
|
<button type="button" class="btn btn-light" id="jsmediaManagerOpenModal" data-toggle="modal" data-target="#jsmediaManagerModal"><span class="oi oi-image"></span> <?php $L->p('Images') ?></button>
|
|
|
|
<button type="button" class="btn btn-light" id="jsoptionsSidebar" style="z-index:30"><span class="oi oi-cog"></span> <?php $L->p('Options') ?></button>
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
2018-05-02 19:59:45 +02:00
|
|
|
|
2018-11-07 15:40:22 +01:00
|
|
|
<div id="jseditorToolbarLeft">
|
2019-01-04 14:18:40 +01:00
|
|
|
<button type="button" class="btn btn-sm btn-primary" id="jsbuttonSave"><?php echo $L->g('Save') ?></button>
|
2018-11-02 00:19:00 +01:00
|
|
|
|
2019-01-04 14:18:40 +01:00
|
|
|
<!-- <?php if (count($page->children())==0): ?>
|
2018-11-07 15:40:22 +01:00
|
|
|
<button type="button" class="btn btn-sm btn-danger" id="jsbuttonDelete" data-toggle="modal" data-target="#jsdeletePageModal"><?php $L->p('Delete') ?></button>
|
2019-01-04 14:18:40 +01:00
|
|
|
<?php endif; ?> -->
|
|
|
|
|
|
|
|
<span class="d-inline-block align-middle ml-1">
|
2019-02-22 18:34:51 +01:00
|
|
|
<div class="switch" style="width:<?php echo max(100,Text::length($L->g('Publish'))* 15) ?>px">
|
2019-01-04 14:18:40 +01:00
|
|
|
<input type="radio" class="switch-input" name="switch" value="" id="jsPublishSwitch" <?php echo (!$page->draft()?'checked':'') ?>>
|
2019-01-16 12:47:38 +01:00
|
|
|
<label for="jsPublishSwitch" class="switch-label switch-label-off"><?php $L->p('Publish') ?></label>
|
2019-01-04 14:18:40 +01:00
|
|
|
<input type="radio" class="switch-input" name="switch" value="" id="jsDraftSwitch" <?php echo ($page->draft()?'checked':'') ?>>
|
2019-01-16 12:47:38 +01:00
|
|
|
<label for="jsDraftSwitch" class="switch-label switch-label-on"><?php $L->p('Draft') ?></label>
|
2019-01-04 14:18:40 +01:00
|
|
|
<span class="switch-selection"></span>
|
|
|
|
</div>
|
|
|
|
</span>
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
2018-12-30 13:35:31 +01:00
|
|
|
|
|
|
|
<?php if($page->scheduled()): ?>
|
|
|
|
<div class="alert alert-warning p-1 mt-1 mb-0"><?php $L->p('scheduled') ?>: <?php echo $page->date(SCHEDULED_DATE_FORMAT) ?></div>
|
|
|
|
<?php endif; ?>
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
<script>
|
2018-07-25 23:42:00 +02:00
|
|
|
$(document).ready(function() {
|
2018-10-30 16:12:44 +01:00
|
|
|
$("#jsoptionsSidebar").on("click", function() {
|
|
|
|
$("#jseditorSidebar").toggle();
|
|
|
|
$("#jsshadow").toggle();
|
2018-10-17 22:35:30 +02:00
|
|
|
});
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
$("#jsshadow").on("click", function() {
|
|
|
|
$("#jseditorSidebar").toggle();
|
|
|
|
$("#jsshadow").toggle();
|
2018-07-25 23:42:00 +02:00
|
|
|
});
|
|
|
|
});
|
2018-10-30 16:12:44 +01:00
|
|
|
</script>
|
2018-10-17 22:35:30 +02:00
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
<!-- SIDEBAR OPTIONS -->
|
|
|
|
<div id="jseditorSidebar">
|
|
|
|
<nav>
|
|
|
|
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
|
|
|
<a class="nav-link active show" id="nav-general-tab" data-toggle="tab" href="#nav-general" role="tab" aria-controls="general"><?php $L->p('General') ?></a>
|
|
|
|
<a class="nav-link" id="nav-advanced-tab" data-toggle="tab" href="#nav-advanced" role="tab" aria-controls="advanced"><?php $L->p('Advanced') ?></a>
|
|
|
|
<a class="nav-link" id="nav-seo-tab" data-toggle="tab" href="#nav-seo" role="tab" aria-controls="seo"><?php $L->p('SEO') ?></a>
|
2018-07-07 12:04:34 +02:00
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
</nav>
|
|
|
|
|
2018-10-30 22:26:29 +01:00
|
|
|
<div class="tab-content pr-3 pl-3 pb-3">
|
2018-10-30 16:12:44 +01:00
|
|
|
<div id="nav-general" class="tab-pane fade show active" role="tabpanel" aria-labelledby="general-tab">
|
|
|
|
<?php
|
|
|
|
// Category
|
|
|
|
echo Bootstrap::formSelectBlock(array(
|
|
|
|
'name'=>'category',
|
|
|
|
'label'=>$L->g('Category'),
|
|
|
|
'selected'=>$page->categoryKey(),
|
|
|
|
'class'=>'',
|
|
|
|
'emptyOption'=>'- '.$L->g('Uncategorized').' -',
|
|
|
|
'options'=>$categories->getKeyNameArray()
|
|
|
|
));
|
2018-10-17 22:35:30 +02:00
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Description
|
|
|
|
echo Bootstrap::formTextareaBlock(array(
|
|
|
|
'name'=>'description',
|
|
|
|
'label'=>$L->g('Description'),
|
|
|
|
'selected'=>'',
|
|
|
|
'class'=>'',
|
|
|
|
'value'=>$page->description(),
|
|
|
|
'rows'=>3,
|
|
|
|
'placeholder'=>$L->get('this-field-can-help-describe-the-content')
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- Cover Image -->
|
|
|
|
<?php
|
|
|
|
$coverImage = $page->coverImage(false);
|
|
|
|
$externalCoverImage = '';
|
|
|
|
if (filter_var($coverImage, FILTER_VALIDATE_URL)) {
|
|
|
|
$coverImage = '';
|
|
|
|
$externalCoverImage = $page->coverImage(false);
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100"><?php $L->p('Cover Image') ?></label>
|
|
|
|
<div>
|
2019-03-07 16:13:47 +01:00
|
|
|
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo (empty($coverImage) ? HTML_PATH_CORE_IMG.'default.svg' : $page->coverImage() ) ?>" />
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
<div class="mt-2 text-center">
|
|
|
|
<button type="button" id="jsbuttonSelectCoverImage" class="btn btn-primary btn-sm"><?php echo $L->g('Select cover image') ?></button>
|
|
|
|
<button type="button" id="jsbuttonRemoveCoverImage" class="btn btn-secondary btn-sm"><?php echo $L->g('Remove cover image') ?></button>
|
2018-07-07 12:04:34 +02:00
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#jscoverImagePreview").on("click", function() {
|
|
|
|
openMediaManager();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#jsbuttonSelectCoverImage").on("click", function() {
|
|
|
|
openMediaManager();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#jsbuttonRemoveCoverImage").on("click", function() {
|
|
|
|
$("#jscoverImage").val('');
|
2019-03-07 16:13:47 +01:00
|
|
|
$("#jscoverImagePreview").attr('src', HTML_PATH_CORE_IMG+'default.svg');
|
2018-10-30 16:12:44 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2018-07-07 12:04:34 +02:00
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
<div id="nav-advanced" class="tab-pane fade" role="tabpanel" aria-labelledby="advanced-tab">
|
|
|
|
<?php
|
2018-10-17 22:35:30 +02:00
|
|
|
// Date
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
2018-10-17 22:35:30 +02:00
|
|
|
'name'=>'date',
|
|
|
|
'label'=>$L->g('Date'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'value'=>$page->dateRaw(),
|
|
|
|
'tip'=>$L->g('date-format-format')
|
|
|
|
));
|
|
|
|
|
|
|
|
// Type
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formSelectBlock(array(
|
2019-01-04 14:18:40 +01:00
|
|
|
'name'=>'typeSelector',
|
2018-10-17 22:35:30 +02:00
|
|
|
'label'=>$L->g('Type'),
|
|
|
|
'selected'=>$page->type(),
|
|
|
|
'options'=>array(
|
2019-01-28 20:30:52 +01:00
|
|
|
'published'=>'- '.$L->g('Default').' -',
|
2018-10-17 22:35:30 +02:00
|
|
|
'sticky'=>$L->g('Sticky'),
|
|
|
|
'static'=>$L->g('Static')
|
|
|
|
),
|
|
|
|
'tip'=>''
|
|
|
|
));
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Position
|
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
|
|
|
'name'=>'position',
|
|
|
|
'label'=>$L->g('Position'),
|
|
|
|
'tip'=>$L->g('Field used when ordering content by position'),
|
|
|
|
'value'=>$page->position()
|
|
|
|
));
|
|
|
|
|
|
|
|
// Tags
|
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
|
|
|
'name'=>'tags',
|
|
|
|
'label'=>$L->g('Tags'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'tip'=>$L->g('Write the tags separated by comma'),
|
|
|
|
'value'=>$page->tags()
|
|
|
|
));
|
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Parent
|
|
|
|
try {
|
|
|
|
$parentKey = $page->parent();
|
|
|
|
$parent = new Page($parentKey);
|
|
|
|
$parentValue = $parent->title();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$parentValue = '';
|
|
|
|
}
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
2018-10-17 22:35:30 +02:00
|
|
|
'name'=>'parentTMP',
|
|
|
|
'label'=>$L->g('Parent'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'tip'=>$L->g('Start typing a page title to see a list of suggestions.'),
|
|
|
|
'value'=>$parentValue
|
|
|
|
));
|
|
|
|
|
|
|
|
// Template
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
2018-10-17 22:35:30 +02:00
|
|
|
'name'=>'template',
|
|
|
|
'label'=>$L->g('Template'),
|
|
|
|
'placeholder'=>'',
|
2018-10-30 16:12:44 +01:00
|
|
|
'value'=>$page->template(),
|
|
|
|
'tip'=>$L->g('Write a template name to filter the page in the theme and change the style of the page.')
|
2018-10-17 22:35:30 +02:00
|
|
|
));
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
|
|
|
'name'=>'externalCoverImage',
|
|
|
|
'label'=>$L->g('External cover image'),
|
|
|
|
'placeholder'=>"https://",
|
|
|
|
'value'=>$externalCoverImage,
|
|
|
|
'tip'=>$L->g('Set a cover image from external URL, such as a CDN or some server dedicated for images.')
|
|
|
|
));
|
|
|
|
|
|
|
|
// Username
|
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
|
|
|
'name'=>'',
|
|
|
|
'label'=>$L->g('Author'),
|
2018-10-17 22:35:30 +02:00
|
|
|
'placeholder'=>'',
|
2018-11-09 00:59:06 +01:00
|
|
|
'value'=>$page->username(),
|
2018-10-30 16:12:44 +01:00
|
|
|
'tip'=>'',
|
|
|
|
'disabled'=>true
|
2018-10-17 22:35:30 +02:00
|
|
|
));
|
2018-10-30 16:12:44 +01:00
|
|
|
?>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
// Changes in External cover image input
|
|
|
|
$("#jsexternalCoverImage").change(function() {
|
|
|
|
$("#jscoverImage").val( $(this).val() );
|
|
|
|
});
|
|
|
|
|
|
|
|
// Parent
|
|
|
|
$("#jsparentTMP").change(function() {
|
|
|
|
var parent = $("#jsparentTMP").val();
|
|
|
|
if (parent.length===0) {
|
|
|
|
$("#jsparent").val("");
|
|
|
|
}
|
|
|
|
});
|
2018-10-17 22:35:30 +02:00
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Datepicker
|
|
|
|
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
|
|
|
|
|
|
|
|
// Parent autocomplete
|
|
|
|
var parentsXHR;
|
|
|
|
var parentsList; // Keep the parent list returned to get the key by the title page
|
|
|
|
$("#jsparentTMP").autoComplete({
|
|
|
|
minChars: 1,
|
|
|
|
source: function(term, response) {
|
|
|
|
// Prevent call inmediatly another ajax request
|
|
|
|
try { parentsXHR.abort(); } catch(e){}
|
|
|
|
// Get the list of parent pages by title (term)
|
|
|
|
parentsXHR = $.getJSON(HTML_PATH_ADMIN_ROOT+"ajax/get-parents", {query: term},
|
|
|
|
function(data) {
|
|
|
|
parentsList = data;
|
|
|
|
term = term.toLowerCase();
|
|
|
|
var matches = [];
|
|
|
|
for (var title in data) {
|
|
|
|
if (~title.toLowerCase().indexOf(term))
|
|
|
|
matches.push(title);
|
|
|
|
}
|
|
|
|
response(matches);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onSelect: function(event, term, item) {
|
|
|
|
// parentsList = array( pageTitle => pageKey )
|
|
|
|
var parentKey = parentsList[term];
|
|
|
|
$("#jsparent").attr("value", parentKey);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<div id="nav-seo" class="tab-pane fade" role="tabpanel" aria-labelledby="seo-tab">
|
|
|
|
<?php
|
2018-10-17 22:35:30 +02:00
|
|
|
// Friendly URL
|
2018-10-30 16:12:44 +01:00
|
|
|
echo Bootstrap::formInputTextBlock(array(
|
2018-10-17 22:35:30 +02:00
|
|
|
'name'=>'slug',
|
|
|
|
'tip'=>$L->g('URL associated with the content'),
|
|
|
|
'label'=>$L->g('Friendly URL'),
|
|
|
|
'placeholder'=>$L->g('Leave empty for autocomplete by Bludit.'),
|
|
|
|
'value'=>$page->slug()
|
|
|
|
));
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Robots
|
2018-10-17 22:35:30 +02:00
|
|
|
echo Bootstrap::formCheckbox(array(
|
|
|
|
'name'=>'noindex',
|
|
|
|
'label'=>'Robots',
|
|
|
|
'labelForCheckbox'=>$L->g('apply-code-noindex-code-to-this-page'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'checked'=>$page->noindex(),
|
|
|
|
'tip'=>$L->g('This tells search engines not to show this page in their search results.')
|
|
|
|
));
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Robots
|
2018-10-17 22:35:30 +02:00
|
|
|
echo Bootstrap::formCheckbox(array(
|
|
|
|
'name'=>'nofollow',
|
|
|
|
'label'=>'',
|
|
|
|
'labelForCheckbox'=>$L->g('apply-code-nofollow-code-to-this-page'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'checked'=>$page->nofollow(),
|
|
|
|
'tip'=>$L->g('This tells search engines not to follow links on this page.')
|
|
|
|
));
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
// Robots
|
2018-10-17 22:35:30 +02:00
|
|
|
echo Bootstrap::formCheckbox(array(
|
|
|
|
'name'=>'noarchive',
|
|
|
|
'label'=>'',
|
|
|
|
'labelForCheckbox'=>$L->g('apply-code-noarchive-code-to-this-page'),
|
|
|
|
'placeholder'=>'',
|
|
|
|
'checked'=>$page->noarchive(),
|
|
|
|
'tip'=>$L->g('This tells search engines not to save a cached copy of this page.')
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-30 16:12:44 +01:00
|
|
|
</div>
|
2018-10-17 22:35:30 +02:00
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
<!-- Title -->
|
|
|
|
<div class="form-group mt-1 mb-1">
|
|
|
|
<input id="jstitle" name="title" type="text" class="form-control form-control-lg rounded-0" value="<?php echo $page->title() ?>" placeholder="<?php $L->p('Enter title') ?>">
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
|
|
|
|
2018-10-30 16:12:44 +01:00
|
|
|
<!-- Editor -->
|
2019-01-30 17:53:10 +01:00
|
|
|
<textarea id="jseditor" class="editable h-100" style=""><?php echo $page->contentRaw(false) ?></textarea>
|
2018-10-30 16:12:44 +01:00
|
|
|
|
2018-05-02 19:59:45 +02:00
|
|
|
</form>
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
<!-- Modal for Delete page -->
|
|
|
|
<div id="jsdeletePageModal" class="modal" tabindex="-1" role="dialog">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-body">
|
2018-11-28 22:01:55 +01:00
|
|
|
<h3><?php $L->p('Delete content') ?></h3>
|
|
|
|
<p><?php $L->p('Are you sure you want to delete this page') ?></p>
|
2018-10-17 22:35:30 +02:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
2018-11-28 22:01:55 +01:00
|
|
|
<button type="button" class="btn btn-link" data-dismiss="modal"><?php $L->p('Cancel') ?></button>
|
2018-10-17 22:35:30 +02:00
|
|
|
<button type="button" class="btn btn-danger" data-dismiss="modal" id="jsbuttonDeleteAccept"><?php $L->p('Delete') ?></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#jsbuttonDeleteAccept").on("click", function() {
|
|
|
|
$("#jstype").val("delete");
|
|
|
|
$("#jscontent").val("");
|
|
|
|
$("#jsform").submit();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
|
2018-07-10 18:37:46 +02:00
|
|
|
<!-- Modal for Media Manager -->
|
|
|
|
<?php include(PATH_ADMIN_THEMES.'booty/html/media.php'); ?>
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
<script>
|
2018-05-02 19:59:45 +02:00
|
|
|
$(document).ready(function() {
|
2017-01-10 17:43:38 +01:00
|
|
|
|
2019-02-03 14:29:37 +01:00
|
|
|
// Define function if they doesn't exist
|
|
|
|
// This helps if the user doesn't activate any plugin as editor
|
|
|
|
if (typeof editorGetContent != "function") {
|
|
|
|
window.editorGetContent = function(){
|
|
|
|
return $("#jseditor").val();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (typeof editorInsertMedia != "function") {
|
|
|
|
window.editorInsertMedia = function(filename){
|
|
|
|
$("#jseditor").val($('#jseditor').val()+'<img src="'+filename+'" alt="">');
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-01-04 14:18:40 +01:00
|
|
|
// Button Save
|
2018-10-17 22:35:30 +02:00
|
|
|
$("#jsbuttonSave").on("click", function() {
|
2019-01-28 20:30:52 +01:00
|
|
|
// If the switch is setted to "published", get the value from the selector
|
|
|
|
if ($("#jsPublishSwitch").is(':checked')) {
|
|
|
|
var value = $("#jstypeSelector option:selected").val();
|
|
|
|
$("#jstype").val(value);
|
|
|
|
} else {
|
|
|
|
$("#jstype").val("draft");
|
2019-01-04 14:18:40 +01:00
|
|
|
}
|
2018-10-17 22:35:30 +02:00
|
|
|
|
|
|
|
// Get the content
|
2018-07-03 23:04:08 +02:00
|
|
|
$("#jscontent").val( editorGetContent() );
|
2018-10-17 22:35:30 +02:00
|
|
|
|
|
|
|
// Submit the form
|
2018-05-08 23:25:18 +02:00
|
|
|
$("#jsform").submit();
|
|
|
|
});
|
|
|
|
|
2017-01-10 17:43:38 +01:00
|
|
|
// Button Save as draft
|
2018-10-17 22:35:30 +02:00
|
|
|
$("#jsbuttonDraft").on("click", function() {
|
|
|
|
// Set the type as draft
|
2018-07-17 19:13:01 +02:00
|
|
|
$("#jstype").val("draft");
|
2017-01-10 17:43:38 +01:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Get the content
|
|
|
|
$("#jscontent").val( editorGetContent() );
|
2018-05-08 23:25:18 +02:00
|
|
|
|
2018-10-17 22:35:30 +02:00
|
|
|
// Submit the form
|
|
|
|
$("#jsform").submit();
|
2018-10-03 00:19:19 +02:00
|
|
|
});
|
|
|
|
|
2018-10-21 15:00:15 +02:00
|
|
|
// Autosave
|
2018-07-12 20:03:31 +02:00
|
|
|
// Autosave works when the content of the page is bigger than 100 characters
|
2018-10-30 16:17:15 +01:00
|
|
|
var currentContent = editorGetContent();
|
2018-05-08 23:25:18 +02:00
|
|
|
setInterval(function() {
|
2018-05-08 00:15:40 +02:00
|
|
|
var uuid = $("#jsuuid").val();
|
|
|
|
var title = $("#jstitle").val();
|
2018-05-08 23:25:18 +02:00
|
|
|
var content = editorGetContent();
|
2018-10-30 16:12:44 +01:00
|
|
|
var ajax = new bluditAjax();
|
2018-10-30 16:17:15 +01:00
|
|
|
// Call autosave only when the user change the content
|
|
|
|
if (currentContent!=content) {
|
|
|
|
currentContent = content;
|
|
|
|
// showAlert is the function to display an alert defined in alert.php
|
|
|
|
ajax.autosave(uuid, title, content, showAlert);
|
|
|
|
}
|
2018-07-07 12:04:34 +02:00
|
|
|
},1000*60*AUTOSAVE_INTERVAL);
|
2018-05-08 00:15:40 +02:00
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
});
|
2018-05-02 19:59:45 +02:00
|
|
|
</script>
|