From e00362582c7d66694cf2971b1ac36589640ab511 Mon Sep 17 00:00:00 2001 From: Dries <dries@buytaert.net> Date: Tue, 5 Nov 2013 21:06:11 -0500 Subject: [PATCH] Issue #2064063 by Wim Leers: CKEditor onChange handler should be debounced. --- core/modules/ckeditor/ckeditor.module | 2 ++ core/modules/ckeditor/js/ckeditor.js | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 4202cfd9aeec..a33ecf2eb308 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -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'), ), diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js index 2d1d42648c07..d6baf172cd05 100644 --- a/core/modules/ckeditor/js/ckeditor.js +++ b/core/modules/ckeditor/js/ckeditor.js @@ -1,4 +1,4 @@ -(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); -- GitLab