Skip to content

Commit 3a426c1

Browse files
committed
added function for replicator sets
1 parent 1f711b6 commit 3a426c1

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

ckeditor/hooks.ckeditor.php

+28-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public function control_panel__add_to_head()
1212
public function control_panel__add_to_foot()
1313
{
1414
if (URL::getCurrent(false) == '/publish') {
15-
$jsPath = Config::getSiteRoot()."_add-ons/ckeditor/ckeditor.js";
15+
$jsPath = Config::getSiteRoot()."_add-ons/ckeditor/ckeditor.js";
1616
$html = '<script src="' . $jsPath . '"></script>';
17-
17+
1818
$html .= "<script>
1919
function initiateCKEditors() {
2020
$('.ckeditor').each(function(){
@@ -23,11 +23,11 @@ function initiateCKEditors() {
2323
}
2424
2525
// initiate CKEditor for field(s) in a newly added grid row
26-
function newRowEditor() {
26+
function newRowEditor() {
2727
2828
// get the right grid field for the clicked 'add row' button
2929
var thisGridTable = $(this).siblings('table.grid');
30-
30+
3131
setTimeout(function() {
3232
// select ckeditor cell in new row
3333
var newRowCell = thisGridTable.find('tbody tr:last td.cell-ckeditor');
@@ -43,15 +43,38 @@ function newRowEditor() {
4343
4444
}
4545
46+
// initiate CKEditor field(s) in replicator sets
47+
function newReplicatorEditor() {
48+
49+
var thisReplicatorParent = $(this).parents('.input-replicator');
50+
51+
setTimeout(function() {
52+
53+
thisReplicatorParent.find('.replicator-set').each(function(){
54+
var thisCkeditorFieldContainer = $(this).find('.ckeditor-container');
55+
56+
if ( !thisCkeditorFieldContainer.find('div.cke').length ) {
57+
thisCkeditorFieldContainer.find('textarea.ckeditor').each(function(){
58+
CKEDITOR.replace( $(this).attr('name') );
59+
});
60+
}
61+
});
62+
63+
}, 50);
64+
65+
}
66+
4667
$(document).ready(function() {
4768
4869
initiateCKEditors();
4970
5071
$('.grid-add-row').click(newRowEditor);
5172
73+
$('.replicator-buttons button').click(newReplicatorEditor);
74+
5275
});
5376
</script>";
54-
77+
5578
return $html;
5679
}
5780
}

0 commit comments

Comments
 (0)