diff --git a/core/modules/ckeditor/js/admin/views/ConfigurationKeyboardView.js b/core/modules/ckeditor/js/admin/views/ConfigurationKeyboardView.js
index 037de37..2fe1d8b 100644
--- a/core/modules/ckeditor/js/admin/views/ConfigurationKeyboardView.js
+++ b/core/modules/ckeditor/js/admin/views/ConfigurationKeyboardView.js
@@ -153,7 +153,7 @@
view = this;
// Attempt to move the button to the new toolbar position.
- registerButtonMove(this, $button, function (result) {
+ Drupal.ckeditor.registerButtonMove(this, $button, function (result) {
// Put the button back if the registration failed.
// If the button was in a row, then it was in the active toolbar
@@ -204,7 +204,7 @@
// Firefox has issues because the page focus is shifted to the dialog
// along with the keydown event.
window.setTimeout(function () {
- openGroupNameDialog(view, $(event.currentTarget));
+ Drupal.ckeditor.openGroupNameDialog(view, $(event.currentTarget));
}, 0);
event.preventDefault();
event.stopPropagation();
@@ -249,7 +249,7 @@
$group.closest('.ckeditor-row')[dir]().find('.ckeditor-toolbar-groups').eq(0).prepend($group);
}
- registerGroupMove(this, $group);
+ Drupal.ckeditor.registerGroupMove(this, $group);
$group.trigger('focus');
event.preventDefault();
event.stopPropagation();
diff --git a/core/modules/ckeditor/js/admin/views/ConfigurationVisualView.js b/core/modules/ckeditor/js/admin/views/ConfigurationVisualView.js
index 01ac623..1f26cd9 100644
--- a/core/modules/ckeditor/js/admin/views/ConfigurationVisualView.js
+++ b/core/modules/ckeditor/js/admin/views/ConfigurationVisualView.js
@@ -61,7 +61,7 @@
*/
onGroupNameClick: function (event) {
var $group = $(event.currentTarget).closest('.ckeditor-toolbar-group');
- openGroupNameDialog(this, $group);
+ Drupal.ckeditor.openGroupNameDialog(this, $group);
event.stopPropagation();
event.preventDefault();
@@ -102,7 +102,7 @@
// Pass in a DOM fragment of a placeholder group so that the new group
// name can be applied to it.
- openGroupNameDialog(this, $(Drupal.theme('ckeditorToolbarGroup')), insertNewGroup);
+ Drupal.ckeditor.openGroupNameDialog(this, $(Drupal.theme('ckeditorToolbarGroup')), insertNewGroup);
event.preventDefault();
},
@@ -117,7 +117,7 @@
*/
endGroupDrag: function (event, ui) {
var view = this;
- registerGroupMove(this, ui.item, function (success) {
+ Drupal.ckeditor.registerGroupMove(this, ui.item, function (success) {
if (!success) {
// Cancel any sorting in the configuration area.
view.$el.find('.ckeditor-toolbar-configuration').find('.ui-sortable').sortable('cancel');
@@ -150,7 +150,7 @@
*/
endButtonDrag: function (event, ui) {
var view = this;
- registerButtonMove(this, ui.item, function (success) {
+ Drupal.ckeditor.registerButtonMove(this, ui.item, function (success) {
if (!success) {
// Cancel any sorting in the configuration area.
view.$el.find('.ui-sortable').sortable('cancel');
diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js
index d5cfe49..48c7053 100644
--- a/core/modules/ckeditor/js/ckeditor.admin.js
+++ b/core/modules/ckeditor/js/ckeditor.admin.js
@@ -77,264 +77,264 @@
// A hash of Model instances.
models: {},
- };
- /**
- * Translates a change in CKEditor config DOM structure into the config model.
- *
- * If the button is moved within an existing group, the DOM structure is simply
- * translated to a configuration model. If the button is moved into a new group
- * placeholder, then a process is launched to name that group before the button
- * move is translated into configuration.
- *
- * @param Backbone.View view
- * The Backbone View that invoked this function.
- * @param jQuery $button
- * A jQuery set that contains an li element that wraps a button element.
- * @param function callback
- * A callback to invoke after the button group naming modal dialog has been
- * closed.
- */
- function registerButtonMove(view, $button, callback) {
- var $group = $button.closest('.ckeditor-toolbar-group');
-
- // If dropped in a placeholder button group, the user must name it.
- if ($group.hasClass('placeholder')) {
+ /**
+ * Translates a change in CKEditor config DOM structure into the config model.
+ *
+ * If the button is moved within an existing group, the DOM structure is simply
+ * translated to a configuration model. If the button is moved into a new group
+ * placeholder, then a process is launched to name that group before the button
+ * move is translated into configuration.
+ *
+ * @param Backbone.View view
+ * The Backbone View that invoked this function.
+ * @param jQuery $button
+ * A jQuery set that contains an li element that wraps a button element.
+ * @param function callback
+ * A callback to invoke after the button group naming modal dialog has been
+ * closed.
+ */
+ registerButtonMove: function (view, $button, callback) {
+ var $group = $button.closest('.ckeditor-toolbar-group');
- if (view.isProcessing) {
- return;
- }
- view.isProcessing = true;
+ // If dropped in a placeholder button group, the user must name it.
+ if ($group.hasClass('placeholder')) {
- openGroupNameDialog(view, $group, callback);
- }
- else {
- view.model.set('isDirty', true);
- callback(true);
- }
- }
+ if (view.isProcessing) {
+ return;
+ }
+ view.isProcessing = true;
- /**
- * Translates a change in CKEditor config DOM structure into the config model.
- *
- * Each row has a placeholder group at the end of the row. A user may not move
- * an existing button group past the placeholder group at the end of a row.
- *
- * @param Backbone.View view
- * The Backbone View that invoked this function.
- * @param jQuery $group
- * A jQuery set that contains an li element that wraps a group of buttons.
- */
- function registerGroupMove(view, $group) {
- // Remove placeholder classes if necessary.
- var $row = $group.closest('.ckeditor-row');
- if ($row.hasClass('placeholder')) {
- $row.removeClass('placeholder');
- }
- // If there are any rows with just a placeholder group, mark the row as a
- // placeholder.
- $row.parent().children().each(function () {
- var $row = $(this);
- if ($row.find('.ckeditor-toolbar-group').not('.placeholder').length === 0) {
- $row.addClass('placeholder');
+ this.openGroupNameDialog(view, $group, callback);
}
- });
- view.model.set('isDirty', true);
- }
-
- /**
- * Opens a Drupal dialog with a form for changing the title of a button group.
- *
- * @param Backbone.View view
- * The Backbone View that invoked this function.
- * @param jQuery $group
- * A jQuery set that contains an li element that wraps a group of buttons.
- * @param function callback
- * A callback to invoke after the button group naming modal dialog has been
- * closed.
- */
- function openGroupNameDialog(view, $group, callback) {
- callback = callback || function () {};
+ else {
+ view.model.set('isDirty', true);
+ callback(true);
+ }
+ },
/**
- * Validates the string provided as a button group title.
+ * Translates a change in CKEditor config DOM structure into the config model.
+ *
+ * Each row has a placeholder group at the end of the row. A user may not move
+ * an existing button group past the placeholder group at the end of a row.
*
- * @param DOM form
- * The form DOM element that contains the input with the new button group
- * title string.
- * @return Boolean
- * Returns true when an error exists, otherwise returns false.
+ * @param Backbone.View view
+ * The Backbone View that invoked this function.
+ * @param jQuery $group
+ * A jQuery set that contains an li element that wraps a group of buttons.
*/
- function validateForm(form) {
- if (form.elements[0].value.length === 0) {
- var $form = $(form);
- if (!$form.hasClass('errors')) {
- $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;
+ registerGroupMove: function (view, $group) {
+ // Remove placeholder classes if necessary.
+ var $row = $group.closest('.ckeditor-row');
+ if ($row.hasClass('placeholder')) {
+ $row.removeClass('placeholder');
}
- return false;
- }
+ // If there are any rows with just a placeholder group, mark the row as a
+ // placeholder.
+ $row.parent().children().each(function () {
+ var $row = $(this);
+ if ($row.find('.ckeditor-toolbar-group').not('.placeholder').length === 0) {
+ $row.addClass('placeholder');
+ }
+ });
+ view.model.set('isDirty', true);
+ },
/**
- * Attempts to close the dialog; Validates user input.
+ * Opens a Drupal dialog with a form for changing the title of a button group.
*
- * @param String action
- * The dialog action chosen by the user: 'apply' or 'cancel'.
- * @param DOM form
- * The form DOM element that contains the input with the new button group
- * title string.
+ * @param Backbone.View view
+ * The Backbone View that invoked this function.
+ * @param jQuery $group
+ * A jQuery set that contains an li element that wraps a group of buttons.
+ * @param function callback
+ * A callback to invoke after the button group naming modal dialog has been
+ * closed.
*/
- function closeDialog(action, form) {
+ openGroupNameDialog: function (view, $group, callback) {
+ callback = callback || function () {};
/**
- * Closes the dialog when the user cancels or supplies valid data.
+ * Validates the string provided as a button group title.
+ *
+ * @param DOM form
+ * The form DOM element that contains the input with the new button group
+ * title string.
+ * @return Boolean
+ * Returns true when an error exists, otherwise returns false.
*/
- function shutdown() {
- dialog.close(action);
-
- // The processing marker can be deleted since the dialog has been closed.
- delete view.isProcessing;
+ function validateForm(form) {
+ if (form.elements[0].value.length === 0) {
+ var $form = $(form);
+ if (!$form.hasClass('errors')) {
+ $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;
}
/**
- * Applies a string as the name of a CKEditor button group.
+ * Attempts to close the dialog; Validates user input.
*
- * @param jQuery $group
- * A jQuery set that contains an li element that wraps a group of buttons.
- * @param String name
- * The new name of the CKEditor button group.
+ * @param String action
+ * The dialog action chosen by the user: 'apply' or 'cancel'.
+ * @param DOM form
+ * The form DOM element that contains the input with the new button group
+ * title string.
*/
- function namePlaceholderGroup($group, name) {
- // If it's currently still a placeholder, then that means we're creating
- // a new group, and we must do some extra work.
- if ($group.hasClass('placeholder')) {
- // Remove all whitespace from the name, lowercase it and ensure
- // HTML-safe encoding, then use this as the group ID for CKEditor
- // configuration UI accessibility purposes only.
- var groupID = 'ckeditor-toolbar-group-aria-label-for-' + Drupal.checkPlain(name.toLowerCase().replace(/ /g, '-'));
+ function closeDialog(action, form) {
+
+ /**
+ * Closes the dialog when the user cancels or supplies valid data.
+ */
+ function shutdown() {
+ dialog.close(action);
+
+ // The processing marker can be deleted since the dialog has been closed.
+ delete view.isProcessing;
+ }
+
+ /**
+ * Applies a string as the name of a CKEditor button group.
+ *
+ * @param jQuery $group
+ * A jQuery set that contains an li element that wraps a group of buttons.
+ * @param String name
+ * The new name of the CKEditor button group.
+ */
+ function namePlaceholderGroup($group, name) {
+ // If it's currently still a placeholder, then that means we're creating
+ // a new group, and we must do some extra work.
+ if ($group.hasClass('placeholder')) {
+ // Remove all whitespace from the name, lowercase it and ensure
+ // HTML-safe encoding, then use this as the group ID for CKEditor
+ // configuration UI accessibility purposes only.
+ var groupID = 'ckeditor-toolbar-group-aria-label-for-' + Drupal.checkPlain(name.toLowerCase().replace(/ /g, '-'));
+ $group
+ // Update the group container.
+ .removeAttr('aria-label')
+ .attr('data-drupal-ckeditor-type', 'group')
+ .attr('tabindex', 0)
+ // Update the group heading.
+ .children('.ckeditor-toolbar-group-name')
+ .attr('id', groupID)
+ .end()
+ // Update the group items.
+ .children('.ckeditor-toolbar-group-buttons')
+ .attr('aria-labelledby', groupID);
+ }
+
$group
- // Update the group container.
- .removeAttr('aria-label')
- .attr('data-drupal-ckeditor-type', 'group')
- .attr('tabindex', 0)
- // Update the group heading.
+ .attr('data-drupal-ckeditor-toolbar-group-name', name)
.children('.ckeditor-toolbar-group-name')
- .attr('id', groupID)
- .end()
- // Update the group items.
- .children('.ckeditor-toolbar-group-buttons')
- .attr('aria-labelledby', groupID);
+ .text(name);
}
- $group
- .attr('data-drupal-ckeditor-toolbar-group-name', name)
- .children('.ckeditor-toolbar-group-name')
- .text(name);
- }
-
- // Invoke a user-provided callback and indicate failure.
- if (action === 'cancel') {
- shutdown();
- callback(false, $group);
- return;
- }
+ // Invoke a user-provided callback and indicate failure.
+ if (action === 'cancel') {
+ shutdown();
+ callback(false, $group);
+ return;
+ }
- // Validate that a group name was provided.
- if (form && validateForm(form)) {
- return;
- }
+ // Validate that a group name was provided.
+ if (form && validateForm(form)) {
+ return;
+ }
- // React to application of a valid group name.
- if (action === 'apply') {
- shutdown();
- // Apply the provided name to the button group label.
- namePlaceholderGroup($group, Drupal.checkPlain(form.elements[0].value));
- // Remove placeholder classes so that new placeholders will be
- // inserted.
- $group.closest('.ckeditor-row.placeholder').addBack().removeClass('placeholder');
+ // React to application of a valid group name.
+ if (action === 'apply') {
+ shutdown();
+ // Apply the provided name to the button group label.
+ namePlaceholderGroup($group, Drupal.checkPlain(form.elements[0].value));
+ // Remove placeholder classes so that new placeholders will be
+ // inserted.
+ $group.closest('.ckeditor-row.placeholder').addBack().removeClass('placeholder');
- // Invoke a user-provided callback and indicate success.
- callback(true, $group);
+ // Invoke a user-provided callback and indicate success.
+ callback(true, $group);
- // Signal that the active toolbar DOM structure has changed.
- view.model.set('isDirty', true);
+ // Signal that the active toolbar DOM structure has changed.
+ view.model.set('isDirty', true);
+ }
}
- }
- // Create a Drupal dialog that will get a button group name from the user.
- var $ckeditorButtonGroupNameForm = $(Drupal.theme('ckeditorButtonGroupNameForm'));
- var dialog = Drupal.dialog($ckeditorButtonGroupNameForm.get(0), {
- title: Drupal.t('Button group name'),
- dialogClass: 'ckeditor-name-toolbar-group',
- resizable: false,
- buttons: [
- {
- text: Drupal.t('Apply'),
- click: function () {
- closeDialog('apply', this);
+ // Create a Drupal dialog that will get a button group name from the user.
+ var $ckeditorButtonGroupNameForm = $(Drupal.theme('ckeditorButtonGroupNameForm'));
+ var dialog = Drupal.dialog($ckeditorButtonGroupNameForm.get(0), {
+ title: Drupal.t('Button group name'),
+ dialogClass: 'ckeditor-name-toolbar-group',
+ resizable: false,
+ buttons: [
+ {
+ text: Drupal.t('Apply'),
+ click: function () {
+ closeDialog('apply', this);
+ },
+ primary: true
},
- primary: true
- },
- {
- text: Drupal.t('Cancel'),
- click: function () {
- closeDialog('cancel');
- }
- }
- ],
- open: function () {
- var form = this;
- var $form = $(this);
- var $widget = $form.parent();
- $widget.find('.ui-dialog-titlebar-close').remove();
- // Set a click handler on the input and button in the form.
- $widget.on('keypress.ckeditor', 'input, button', function (event) {
- // React to enter key press.
- if (event.keyCode === 13) {
- var $target = $(event.currentTarget);
- var data = $target.data('ui-button');
- var action = 'apply';
- // Assume 'apply', but take into account that the user might have
- // pressed the enter key on the dialog buttons.
- if (data && data.options && data.options.label) {
- action = data.options.label.toLowerCase();
+ {
+ text: Drupal.t('Cancel'),
+ click: function () {
+ closeDialog('cancel');
}
- closeDialog(action, form);
- event.stopPropagation();
- event.stopImmediatePropagation();
- event.preventDefault();
}
- });
- // Announce to the user that a modal dialog is open.
- var text = Drupal.t('Editing the name of the new button group in a dialog.');
- if ($group.attr('data-drupal-ckeditor-toolbar-group-name') !== undefined) {
- text = Drupal.t('Editing the name of the "@groupName" button group in a dialog.', {
- '@groupName': $group.attr('data-drupal-ckeditor-toolbar-group-name')
+ ],
+ open: function () {
+ var form = this;
+ var $form = $(this);
+ var $widget = $form.parent();
+ $widget.find('.ui-dialog-titlebar-close').remove();
+ // Set a click handler on the input and button in the form.
+ $widget.on('keypress.ckeditor', 'input, button', function (event) {
+ // React to enter key press.
+ if (event.keyCode === 13) {
+ var $target = $(event.currentTarget);
+ var data = $target.data('ui-button');
+ var action = 'apply';
+ // Assume 'apply', but take into account that the user might have
+ // pressed the enter key on the dialog buttons.
+ if (data && data.options && data.options.label) {
+ action = data.options.label.toLowerCase();
+ }
+ closeDialog(action, form);
+ event.stopPropagation();
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ }
});
+ // Announce to the user that a modal dialog is open.
+ var text = Drupal.t('Editing the name of the new button group in a dialog.');
+ if ($group.attr('data-drupal-ckeditor-toolbar-group-name') !== undefined) {
+ text = Drupal.t('Editing the name of the "@groupName" button group in a dialog.', {
+ '@groupName': $group.attr('data-drupal-ckeditor-toolbar-group-name')
+ });
+ }
+ Drupal.announce(text);
+ },
+ close: function (event) {
+ // Automatically destroy the DOM element that was used for the dialog.
+ $(event.target).remove();
}
- Drupal.announce(text);
- },
- close: function (event) {
- // Automatically destroy the DOM element that was used for the dialog.
- $(event.target).remove();
- }
- });
- // A modal dialog is used because the user must provide a button group name
- // or cancel the button placement before taking any other action.
- dialog.showModal();
-
- $(document.querySelector('.ckeditor-name-toolbar-group').querySelector('input'))
- // When editing, set the "group name" input in the form to the current value.
- .attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name'))
- // Focus on the "group name" input in the form.
- .trigger('focus');
- }
+ });
+ // A modal dialog is used because the user must provide a button group name
+ // or cancel the button placement before taking any other action.
+ dialog.showModal();
+
+ $(document.querySelector('.ckeditor-name-toolbar-group').querySelector('input'))
+ // When editing, set the "group name" input in the form to the current value.
+ .attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name'))
+ // Focus on the "group name" input in the form.
+ .trigger('focus');
+ }
+ };
/**
* Automatically shows/hides settings of buttons-only CKEditor plugins.