core/misc/ajax.js | 3 --- core/modules/edit/js/edit.js | 3 +-- core/modules/edit/js/editors/formEditor.js | 6 ++---- core/modules/edit/js/models/EntityModel.js | 1 - core/modules/edit/js/util.js | 5 ----- core/modules/edit/js/views/EditorView.js | 9 +++++++-- core/modules/editor/js/editor.formattedTextEditor.js | 1 - 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/core/misc/ajax.js b/core/misc/ajax.js index f032cb7..bdff14b 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -136,9 +136,6 @@ Drupal.AjaxError.prototype.constructor = Drupal.AjaxError; * @code * Drupal.behaviors.myCustomAJAXStuff = { * attach: function (context, settings) { - * // We don't want to override the original commands! - * Drupal.ajax['edit-submit'].commands = {}; - * // Now make just the 'insert' command available. * Drupal.ajax['edit-submit'].commands.insert = function (ajax, response, status) { * new_content = $(response.data); * $('#my-wrapper').append(new_content); diff --git a/core/modules/edit/js/edit.js b/core/modules/edit/js/edit.js index a6b344f..c149b3b 100644 --- a/core/modules/edit/js/edit.js +++ b/core/modules/edit/js/edit.js @@ -304,8 +304,7 @@ function loadMissingEditors (callback) { }); // Implement a scoped insert AJAX command: calls the callback after all AJAX // command functions have been executed (hence the deferred calling). - var realInsert = Drupal.ajax.prototype.commands.insert; - loadEditorsAjax.commands = {}; + var realInsert = Drupal.AjaxCommands.prototype.insert; loadEditorsAjax.commands.insert = function (ajax, response, status) { _.defer(function() { callback(); }); realInsert(ajax, response, status); diff --git a/core/modules/edit/js/editors/formEditor.js b/core/modules/edit/js/editors/formEditor.js index 6235579..97d15ac 100644 --- a/core/modules/edit/js/editors/formEditor.js +++ b/core/modules/edit/js/editors/formEditor.js @@ -96,7 +96,7 @@ Drupal.edit.editors.form = Drupal.edit.EditorView.extend({ }; var self = this; Drupal.edit.util.form.load(formOptions, function (form, ajax) { - Drupal.ajax.prototype.commands.insert(ajax, { + Drupal.AjaxCommands.prototype.insert(ajax, { data: form, selector: '#' + id + ' .placeholder' }); @@ -146,8 +146,6 @@ Drupal.edit.editors.form = Drupal.edit.EditorView.extend({ var fieldModel = this.fieldModel; var self = this; - this.formSaveAjax.commands = {}; - // Successfully saved. this.formSaveAjax.commands.editFieldFormSaved = function (ajax, response, status) { delete self.formSaveAjax; @@ -173,7 +171,7 @@ Drupal.edit.editors.form = Drupal.edit.EditorView.extend({ this.formSaveAjax.commands.editFieldForm = function (ajax, response, status) { delete self.formSaveAjax; - Drupal.ajax.prototype.commands.insert(ajax, { + Drupal.AjaxCommands.prototype.insert(ajax, { data: response.data, selector: '#' + $formContainer.attr('id') + ' form' }); diff --git a/core/modules/edit/js/models/EntityModel.js b/core/modules/edit/js/models/EntityModel.js index 4589882..c3332f0 100644 --- a/core/modules/edit/js/models/EntityModel.js +++ b/core/modules/edit/js/models/EntityModel.js @@ -288,7 +288,6 @@ Drupal.edit.EntityModel = Backbone.Model.extend({ progress: { type: 'none' } }); // Entity saved successfully. - entitySaverAjax.commands = {}; entitySaverAjax.commands.editEntitySaved = function(ajax, response, status) { // All fields have been moved from TempStore to permanent storage, update // the "inTempStore" attribute on FieldModels, on the EntityModel and diff --git a/core/modules/edit/js/util.js b/core/modules/edit/js/util.js index 9d63b97..6ab6b27 100644 --- a/core/modules/edit/js/util.js +++ b/core/modules/edit/js/util.js @@ -68,11 +68,6 @@ Drupal.edit.util.form = { progress: { type : null } // No progress indicator. }); // Implement a scoped editFieldForm AJAX command: calls the callback. - formLoaderAjax.commands = { - settings: Drupal.ajax.prototype.commands.settings, - insert: Drupal.ajax.prototype.commands.insert, - add_css: Drupal.ajax.prototype.commands.add_css - }; formLoaderAjax.commands.editFieldForm = function (ajax, response, status) { callback(response.data, ajax); }; diff --git a/core/modules/edit/js/views/EditorView.js b/core/modules/edit/js/views/EditorView.js index 15408ad..fa71ada 100644 --- a/core/modules/edit/js/views/EditorView.js +++ b/core/modules/edit/js/views/EditorView.js @@ -215,8 +215,6 @@ Drupal.edit.EditorView = Backbone.View.extend({ $('#edit_backstage').remove(); } - formSaveAjax.commands = {}; - // Successfully saved. formSaveAjax.commands.editFieldFormSaved = function (ajax, response, status) { removeHiddenForm(); @@ -236,6 +234,13 @@ Drupal.edit.EditorView = Backbone.View.extend({ fieldModel.set('state', 'invalid'); }; + // The editFieldForm AJAX command is only called upon loading the form + // for the first time, and when there are validation errors in the form; + // Form API then marks which form items have errors. This is useful for + // the form-based in-place editor, but pointless for any other: the form + // itself won't be visible at all anyway! So, we just ignore it. + formSaveAjax.commands.editFieldForm = function () {}; + fillAndSubmitForm(editorModel.get('currentValue')); }); }, diff --git a/core/modules/editor/js/editor.formattedTextEditor.js b/core/modules/editor/js/editor.formattedTextEditor.js index 6db2ecf..32fa0e0 100644 --- a/core/modules/editor/js/editor.formattedTextEditor.js +++ b/core/modules/editor/js/editor.formattedTextEditor.js @@ -172,7 +172,6 @@ Drupal.edit.editors.editor = Drupal.edit.EditorView.extend({ // Implement a scoped editorGetUntransformedText AJAX command: calls the // callback. - textLoaderAjax.commands = {}; textLoaderAjax.commands.editorGetUntransformedText = function (ajax, response, status) { callback(response.data); };