Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
28e640ae
Commit
28e640ae
authored
Aug 16, 2018
by
Robert Lyon
Committed by
Gerrit Code Review
Aug 16, 2018
Browse files
Merge "Bug 1783685: Allow more than 1 TinyMCE field in the same pieform"
parents
bb3b983e
be24b5bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/form/elements/wysiwyg.php
View file @
28e640ae
...
...
@@ -23,7 +23,7 @@ $_PIEFORM_WYSIWYGS = array();
*/
function
pieform_element_wysiwyg
(
Pieform
$form
,
$element
)
{
global
$_PIEFORM_WYSIWYGS
;
$_PIEFORM_WYSIWYGS
[
$form
->
get_name
()]
=
$form
->
get_name
()
.
'_'
.
$element
[
'name'
];
$_PIEFORM_WYSIWYGS
[
$form
->
get_name
()]
[
$element
[
'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'
;
...
...
@@ -85,18 +85,22 @@ function pieform_element_wysiwyg_get_headdata() {
.
"
\n
var editor_to_focus;"
.
"
\n
PieformManager.connect('onsubmit', null, tinyMCE.triggerSave);"
.
"
\n
PieformManager.connect('onload', null, function() {\n"
;
foreach
(
$_PIEFORM_WYSIWYGS
as
$name
=>
$editor
)
{
foreach
(
$_PIEFORM_WYSIWYGS
as
$name
=>
$editor
s
)
{
$result
.
=
" if (!arguments[0] || arguments[0]=='
{
$name
}
') {\n"
;
$result
.
=
" tinyMCE.execCommand('mceAddEditor', false, '
$editor
');
\n
"
;
$result
.
=
" jQuery('#
{
$editor
}
').on('focus', function() {\n"
;
$result
.
=
" editor_to_focus = '
$editor
';
\n
"
;
$result
.
=
" });
\n
"
;
foreach
(
$editors
as
$editorname
=>
$editor
)
{
$result
.
=
" tinyMCE.execCommand('mceAddEditor', false, '
$editor
');
\n
"
;
$result
.
=
" jQuery('#
{
$editor
}
').on('focus', function() {\n"
;
$result
.
=
" editor_to_focus = '
$editor
';
\n
"
;
$result
.
=
" });
\n
"
;
}
$result
.
=
" };
\n
"
;
}
$result
.
=
"});
\n
PieformManager.connect('onreply', null, function() {\n"
;
foreach
(
$_PIEFORM_WYSIWYGS
as
$name
=>
$editor
)
{
foreach
(
$_PIEFORM_WYSIWYGS
as
$name
=>
$editor
s
)
{
$result
.
=
" if (!arguments[0] || arguments[0]=='
{
$name
}
') {\n"
;
$result
.
=
" tinyMCE.execCommand('mceRemoveEditor', false, '
$editor
');
\n
"
;
foreach
(
$editors
as
$editorname
=>
$editor
)
{
$result
.
=
" tinyMCE.execCommand('mceRemoveEditor', false, '
$editor
');
\n
"
;
}
$result
.
=
" };
\n
"
;
}
$result
.
=
"});</script>"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment