-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |