diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js index 22c4486..8b5c0ec 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.js +++ b/core/modules/ckeditor/js/ckeditor.admin.js @@ -768,11 +768,41 @@ Drupal.ckeditor = { function openGroupNameDialog (view, $group) { var $dialog; + function validateSubmit (form) { + var $form = $(form); + if ($form.hasClass('errors')) { + return true; + } + else if (form.elements[0].value.length === 0) { + $form + .addClass('errors') + .find('input') + .addClass('error') + .attr('aria-invalid', 'true'); + $('
' + Drupal.t('Please provide a name for the button group.') + '
').insertAfter(form.elements[0]); + return true; + } + return false; + } + + /** + * + */ function closeDialog (action, form) { + + // Validate that a group name was provided. + if(form && validateSubmit(form)) { + return; + } + + // Call the jQuery UI dialog close method. $dialog.close(action); + // The processing marker can be deleted since the dialog has been closed. delete view.isProcessing; + // React to the dialog button press. if (action === 'apply') { + // Apply the provided name to the button group label. view.namePlaceholderGroup($group, Drupal.checkPlain(form.elements[0].value)); // Remove placeholder classes so that new placeholders will be // inserted. @@ -781,7 +811,8 @@ function openGroupNameDialog (view, $group) { view.model.set('isDirty', true); } else { - // Cancel the sort. + // Cancel any sorting in the configuration area. + $('.ckeditor-toolbar-configuration').find('.ui-sortable').sortable('cancel'); } }