Commit d614b49e authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic

Bug 1624142: Stopped Cover letter pieform to update when other pieform submitted

Added conditions to javascript to stop the creation
of a new TinyMCE editor for a cover letter
everytime a Personal Information pieform was submitted

behatnotneeded

Change-Id: I3088cc13bcb9167807dfbe545f63e872b45a42b9
parent dc852194
......@@ -109,4 +109,4 @@ function simple_resumefield_error(form, data) {
editbutton.click();
}
}
}
\ No newline at end of file
}
......@@ -23,7 +23,7 @@ $_PIEFORM_WYSIWYGS = array();
*/
function pieform_element_wysiwyg(Pieform $form, $element) {
global $_PIEFORM_WYSIWYGS;
$_PIEFORM_WYSIWYGS[] = $form->get_name() . '_' . $element['name'];
$_PIEFORM_WYSIWYGS[$form->get_name()] = $form->get_name() . '_' . $element['name'];
if (is_html_editor_enabled()) {
if (!$form->get_property('elementclasses')) {
$element['class'] = isset($element['class']) && $element['class'] !== '' ? $element['class'] . ' wysiwyg' : 'wysiwyg';
......@@ -79,20 +79,25 @@ function pieform_element_wysiwyg_rule_required(Pieform $form, $value, $element,
function pieform_element_wysiwyg_get_headdata() {
global $_PIEFORM_WYSIWYGS;
if (is_html_editor_enabled() && !empty($_PIEFORM_WYSIWYGS)) {
$result = '<script type="application/javascript">'
. "\nvar editor_to_focus;"
. "\nPieformManager.connect('onsubmit', null, tinyMCE.triggerSave);"
. "\nPieformManager.connect('onload', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $editor) {
$result .= " tinyMCE.execCommand('mceAddEditor', false, '$editor');\n";
$result .= " $('{$editor}').focus = function() {\n";
$result .= " editor_to_focus = '$editor';\n";
foreach ($_PIEFORM_WYSIWYGS as $name => $editor) {
$result .= " if (!arguments[0] || arguments[0]=='{$name}') {\n";
$result .= " tinyMCE.execCommand('mceAddEditor', false, '$editor');\n";
$result .= " $('{$editor}').focus = function() {\n";
$result .= " editor_to_focus = '$editor';\n";
$result .= " };\n";
$result .= " };\n";
}
$result .= "});\nPieformManager.connect('onreply', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $editor) {
$result .= " tinyMCE.execCommand('mceRemoveEditor', false, '$editor');\n";
foreach ($_PIEFORM_WYSIWYGS as $name => $editor) {
$result .= " if (!arguments[0] || arguments[0]=='{$name}') {\n";
$result .= " tinyMCE.execCommand('mceRemoveEditor', false, '$editor');\n";
$result .= " };\n";
}
$result .= "});</script>";
safe_require('artefact', 'file');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment