MDL-28987 Forms Library: Added tinyMCE onblur event callback for required tinymce fields
This commit is contained in:
@@ -72,3 +72,28 @@ M.editor_tinymce.filepicker = function(target_id, url, type, win) {
|
||||
});
|
||||
};
|
||||
|
||||
M.editor_tinymce.onblur_event = function(ed) {
|
||||
//Attach event only after tinymce is intialized.
|
||||
if (ed.onInit != undefined) {
|
||||
var s = ed.settings;
|
||||
//Save before event is attached, so that if this event is not generated then textarea should
|
||||
//have loaded contents and submitting form should not throw error.
|
||||
ed.save();
|
||||
|
||||
//Attach blur event for tinymce to call onchange validation function of textarea.
|
||||
var doc = s.content_editable ? ed.getBody() : (tinymce.isGecko ? ed.getDoc() : ed.getWin());
|
||||
tinymce.dom.Event.add(doc, 'blur', function() {
|
||||
//save contents to textarea before calling validation script.
|
||||
ed.save();
|
||||
var element = document.getElementById(ed.id);
|
||||
element.onchange(element);
|
||||
});
|
||||
|
||||
//Add an extra event to make sure after window is blurred because of user clicking
|
||||
//out of tinymce or any popup occured, then error should be cleaned on focusing back.
|
||||
tinymce.dom.Event.add(doc, 'focus', function() {
|
||||
var element = document.getElementById(ed.id);
|
||||
qf_errorHandler(element, '');
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user