Skip to content

Commit

Permalink
fixing tinymce preload
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Feb 12, 2024
1 parent 4fdc2ea commit 11f051b
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions deform/templates/richtext.pt
Original file line number Diff line number Diff line change
@@ -1,55 +1,38 @@
<div tal:define="delayed_load delayed_load|field.widget.delayed_load;
tinymce_options tinymce_options|field.widget.tinymce_options;
error_class error_class|field.widget.error_class;
oid oid|field.oid;
name name|field.name;"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="deform"
tal:omit-tag="">

<style type="text/css">
.deform .tinymce-preload{
border: 1px solid #CCC;
height: 240px;
display: block;
}
</style>
<textarea id="${oid}" name="${name}"
tal:content="cstruct"
class="tinymce form-control ${field.error and error_class or ''}" />
<textarea id="${oid}" name="${name}"
class="tinymce form-control" tal:content="cstruct" />
<!--!
NB: disable delayed_load on error redisplay of form, since
that might result in non-HTML-escaped interpolation of
user input.
-->
<span id="${oid}-preload" class="tinymce-preload"
tal:condition="delayed_load and not field.error"
tal:content="structure cstruct" />
<script type="text/javascript">
(function($){
deform.addCallback('${oid}', function(oid) {
var options = {
language: '<tal:block i18n:translate="language-code">en</tal:block>',
body_class: 'form-control',
<tal:block condition="tinymce_options">${tinymce_options},</tal:block>
selector: '#' + oid
};
var jqoid = $('#' + oid);
var jqoid_preload = $('#' + oid + '-preload');
if (jqoid_preload.length == 0) {
tinyMCE.init(options);
} else {
jqoid.hide();
jqoid_preload.one('click', function(){
jqoid.show();
jqoid_preload.remove();
tinyMCE.init(options);
});
}
});
$().bind('form.pre.serialize', function(event, $form, options) {
tinyMCE.triggerSave();
});
deform.addCallback('${oid}', function(oid) {
var options = {
language: '<tal:block i18n:translate="language-code">en</tal:block>',
body_class: 'form-control',
<tal:block condition="tinymce_options">${tinymce_options},</tal:block>
elements: oid
};
var jqoid = $('#' + oid);
if ('${delayed_load and not field.error}' == 'True') {
jqoid.one('click', function(){
tinyMCE.init(options);
});
} else {
tinyMCE.init(options);
}
});
$().bind('form.pre.serialize', function(event, $form, options) {
tinyMCE.triggerSave();
});
})(jQuery);
</script>
</div>

0 comments on commit 11f051b

Please sign in to comment.