Commit e0036258 authored by Dries's avatar Dries

Issue #2064063 by Wim Leers: CKEditor onChange handler should be debounced.

parent c6318824
......@@ -53,7 +53,9 @@ function ckeditor_library_info() {
$module_path . '/css/ckeditor.css' => array(),
),
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.debounce'),
array('ckeditor', 'ckeditor'),
array('editor', 'drupal.editor'),
),
......
(function (Drupal, CKEDITOR, $) {
(function (Drupal, debounce, CKEDITOR, $) {
"use strict";
......@@ -31,9 +31,9 @@ Drupal.editors.ckeditor = {
onChange: function (element, callback) {
var editor = CKEDITOR.dom.element.get(element).getEditor();
if (editor) {
editor.on('change', function () {
editor.on('change', debounce(function () {
callback(editor.getData());
});
}, 400));
}
return !!editor;
},
......@@ -269,4 +269,4 @@ $(window).on('dialog:afterclose', function (e, dialog, $element) {
}
});
})(Drupal, CKEDITOR, jQuery);
})(Drupal, Drupal.debounce, CKEDITOR, jQuery);
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