Skip to content

Commit a325a94

Browse files
committed
fix(textareafield): compatibility with GLPI 9.10
backport of chande detection in textarea from Formcreator 2.13
1 parent 7f2ff1a commit a325a94

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

js/scripts.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,10 +1812,28 @@ function pluginFormcreatorInitializeTag(fieldName, rand) {
18121812
* Initialize a textarea field
18131813
*/
18141814
function pluginFormcreatorInitializeTextarea(fieldName, rand) {
1815-
var field = $('[name="' + fieldName + '"]');
1816-
field.on("change", function(e) {
1817-
plugin_formcreator.showFields($(field[0].form));
1818-
});
1815+
if (tinyMCE.majorVersion < 5) {
1816+
var field = $('[name="' + fieldName + '"]');
1817+
field.on("change", function(e) {
1818+
plugin_formcreator.showFields($(field[0].form));
1819+
});
1820+
} else {
1821+
var i = 0;
1822+
var e;
1823+
while (e = tinymce.get(i++)) {
1824+
var field = $('[name="' + fieldName + '"]');
1825+
var form = field[0].form;
1826+
if (e.formElement != form) {
1827+
continue;
1828+
}
1829+
// https://stackoverflow.com/a/63342064
1830+
e.on('input NodeChange', function(e) {
1831+
tinyMCE.triggerSave();
1832+
plugin_formcreator.showFields($(form));
1833+
});
1834+
return;
1835+
}
1836+
}
18191837
}
18201838

18211839
/**

0 commit comments

Comments
 (0)