Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor fixes for version 8. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions blocks/vivid_simple_accordion/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<div class="form-group">
<label class="col-xs-3 control-label" for="description<%=sort%>"><?=t('Description:')?></label>
<div class="col-xs-9">
<textarea class="redactor-content" name="description[]" id="description<%=sort%>"><%=description%></textarea>
<textarea id="description<%=sort%>" class="editor-content editor-content-<?php echo $bID?>" name="<?php echo $view->field('description'); ?>[]"><%=description%></textarea>
</div>
</div>
<div class="form-group">
Expand All @@ -100,7 +100,12 @@
var deleteItem = function(i) {
var confirmDelete = confirm('<?php echo t('Are you sure?') ?>');
if(confirmDelete == true) {
$(".item[data-order='"+i+"']").remove();
var $el = $(".item[data-order='"+i+"']");
var itemId = $el.find('.editor-content').attr('id');
if (typeof CKEDITOR === 'object') {
CKEDITOR.instances[itemId].destroy();
}
$el.remove();
indexItems();
}
};
Expand Down Expand Up @@ -131,6 +136,11 @@ function indexItems(){

//use when using Redactor (wysiwyg)
var CCM_EDITOR_SECURITY_TOKEN = "<?php echo Loader::helper('validation/token')->generate('editor')?>";

<?php
$editorJavascript = Core::make('editor')->outputStandardEditorInitJSFunction();
?>
var launchEditor = <?=$editorJavascript?>;

//Define container and items
var itemsContainer = $('.items-container');
Expand Down Expand Up @@ -171,18 +181,14 @@ function indexItems(){
//Init Index
indexItems();

//Init Redactor
$('.redactor-content').redactor({
minHeight: '200',
'concrete5': {
filemanager: <?php echo $fp->canAccessFileManager()?>,
sitemap: <?php echo $tp->canAccessSitemap()?>,
lightbox: true
//Init editor
$(function() { // activate editors
if ($('.editor-content-<?php echo $bID?>').length) {
launchEditor($('.editor-content-<?php echo $bID?>'));
}
});

//CREATE NEW ITEM

$('.btn-add-item').click(function(){

//Use the template to create a new item.
Expand All @@ -202,14 +208,7 @@ function indexItems(){
thisModal.scrollTop(newItem.offset().top);

//Init Redactor
newItem.find('.redactor-content').redactor({
minHeight: '100',
'concrete5': {
filemanager: <?php echo $fp->canAccessFileManager()?>,
sitemap: <?php echo $tp->canAccessSitemap()?>,
lightbox: true
}
});
launchEditor(newItem.find('.editor-content'));

//Init Index
indexItems();
Expand Down