'fields_list' => $fields_list,
'form_name' => $form_name,
'form_title' => DynamicField::getFormTitle($form_name),
- 'page_title' => _T("Dynamic fields configuration")
+ 'page_title' => _T("Dynamic fields configuration"),
+ 'html_editor' => true,
+ 'html_editor_active' => $this->preferences->pref_editor_enabled
+
];
$tpl = 'pages/configuration_dynamic_fields.html.twig';
'form_name' => $form_name,
'perm_names' => DynamicField::getPermsNames(),
'mode' => (($request->getHeaderLine('X-Requested-With') === 'XMLHttpRequest') ? 'ajax' : ''),
- 'df' => $df
+ 'df' => $df,
+ 'html_editor' => true,
+ 'html_editor_active' => $this->preferences->pref_editor_enabled
];
// display page
* - modal_approve_text: modal's approve button's text.
* - modal_approve_icon: modal's approve button's icon.
* - modal_cancel_text: modal's cancel button's text.
+ * - modal_action_onshow: additionnal code to execute on modal's onShow event.
*
* @see loader.js.twig
* @see modal.js.twig
modal_cancel_text: modal_cancel_text,
} %}
},
+ {# FIXME: variables modal.js.twig know and that are not explicitely redefined are autmatically passed! #}
error: function() {
{% include "elements/js/modal.js.twig" with {
modal_title_twig: _T("An error occurred :(")|e("js"),
inline: false,
addTouchEvents: false,
});
+{% if modal_action_onshow is defined %}
+ {{ modal_action_onshow|raw }}
+{% endif %}
}
<script type="text/javascript" src="{{ base_path() }}/assets/js/formatting.js"></script>
<script type="text/javascript" src="{{ base_path() }}/assets/js/summernote.min.js"></script>
<script type="text/javascript" src="{{ base_path() }}/assets/js/lang/summernote-{{ i18n.getID()|replace({'_': '-'}) }}.min.js"></script>
- <script language="javascript">
- function activateMailingEditor() {
- if(!$('#mailing_html').attr('checked')){
- $('#mailing_html').attr('checked', true);
- }
-
- $('input#html_editor_active').attr('value', '1');
- $('#activate_editor').remove();
- $('#summernote_toggler').html('<a class="ui blue tertiary button" href="javascript:deactivateMailingEditor();" id="deactivate_editor">{{ _T("Deactivate HTML editor") }}</a>');
-
- $('#mailing_corps').summernote({
+ <script type="text/javascript">
+ function activateHtmlEditor(elt) {
+ elt.summernote({
lang: '{{ i18n.getID()|replace({'_': '-'}) }}',
disableDragAndDrop: true,
height: 240,
}
}
});
- $('#mailing_corps').summernote('focus');
+ elt.summernote('focus');
+ }
+
+ function deactivateHtmlEditor(elt) {
+ elt.summernote('destroy');
+ }
+
+ function activateMailingEditor() {
+ if(!$('#mailing_html').attr('checked')){
+ $('#mailing_html').attr('checked', true);
+ }
+
+ $('input#html_editor_active').attr('value', '1');
+ $('#activate_editor').remove();
+ $('#summernote_toggler').html('<a class="ui blue tertiary button" href="javascript:deactivateMailingEditor();" id="deactivate_editor">{{ _T("Deactivate HTML editor") }}</a>');
+
+ activateHtmlEditor($('#mailing_corps'));
}
function deactivateMailingEditor() {
- $('#mailing_corps').summernote('destroy');
+ deactivateHtmlEditor($('#mailing_corps'));
$('#deactivate_editor').remove();
$('#summernote_toggler').html('<a class="ui blue tertiary button" href="javascript:activateMailingEditor();" id="activate_editor">{{ _T("Activate HTML editor") }}</a>');
}
{% block javascripts %}
<script>
- $('#field_information').summernote({
- lang: '{{ i18n.getID()|replace({'_': '-'}) }}',
- height: 240,
- toolbar: [
- ['style', ['style']],
- ['font', ['bold', 'italic', 'strikethrough', 'clear']],
- ['para', ['ul', 'ol', 'paragraph']],
- ['insert', ['link', 'picture']],
- ['view', ['codeview', 'help']]
- ],
- styleTags: [
- 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
- ]
+ $(function() {
+ activateHtmlEditor($('#field_information'));
});
- $('#field_information').summernote('focus');
-
</script>
{% endblock %}
modal_title_twig: _T("Edit field")|e("js"),
modal_class: "tiny",
modal_content_class: "scrolling",
- modal_onapprove: modal_onapprove
+ modal_onapprove: modal_onapprove,
+ modal_action_onshow: "activateHtmlEditor($('#field_information'));"
} %}
}
_editDynField();