diff --git a/core/modules/edit/edit.api.php b/core/modules/edit/edit.api.php index 162c9587736e9faf3f99cc53e8ba8d6151fe5ef7..b5bf4544dcd5b1eaa70f35004366a867f64f0ca5 100644 --- a/core/modules/edit/edit.api.php +++ b/core/modules/edit/edit.api.php @@ -36,10 +36,11 @@ function hook_edit_editor_alter(&$editors) { * following in-place editing in the exact way it was displayed originally), * implement this hook. * - * Edit module integrates with HTML elements with data-edit-id attributes. For - * example: data-edit-id="node/1//und/-". + * Edit module integrates with HTML elements with data-edit-field-id attributes. + * For example: + * data-edit-field-id="node/1//und/-" * After the editing is complete, this hook is invoked on the module with - * the custom render pipeline identifier (last part of data-edit-id) to + * the custom render pipeline identifier (last part of data-edit-field-id) to * re-render the field. Use the same logic used when rendering the field for * the original display. * diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index b08a459172f0058205f97d00066619774ff43fad..9e4d1326203239e950232f8414f46d958b479a70 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -182,7 +182,7 @@ function edit_preprocess_field(&$variables) { // fields") and computed fields are not editable. $definition = $entity->getPropertyDefinition($element['#field_name']); if ($definition && empty($definition['computed'])) { - $variables['attributes']['data-edit-id'] = $entity->entityType() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode']; + $variables['attributes']['data-edit-field-id'] = $entity->entityType() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode']; } } @@ -190,7 +190,7 @@ function edit_preprocess_field(&$variables) { * Implements hook_entity_view_alter(). */ function edit_entity_view_alter(&$build, EntityInterface $entity, EntityDisplay $display) { - $build['#attributes']['data-edit-entity'] = $entity->entityType() . '/' . $entity->id(); + $build['#attributes']['data-edit-entity-id'] = $entity->entityType() . '/' . $entity->id(); } /** diff --git a/core/modules/edit/js/edit.js b/core/modules/edit/js/edit.js index dab4522f9306e43bab9a5f5930012a8a41c8cd2a..b8afb6cbab848a61cb66b588a9039d51ca758d64 100644 --- a/core/modules/edit/js/edit.js +++ b/core/modules/edit/js/edit.js @@ -64,7 +64,7 @@ Drupal.behaviors.edit = { // immediately. New fields will be unable to be processed immediately, but // will instead be queued to have their metadata fetched, which occurs below // in fetchMissingMetaData(). - $(context).find('[data-edit-id]').once('edit').each(function (index, fieldElement) { + $(context).find('[data-edit-field-id]').once('edit').each(function (index, fieldElement) { processField(fieldElement); }); @@ -119,9 +119,9 @@ Drupal.edit = { * processed. */ $(document).on('drupalContextualLinkAdded', function (event, data) { - if (data.$region.is('[data-edit-entity]')) { + if (data.$region.is('[data-edit-entity-id]')) { var contextualLink = { - entityID: data.$region.attr('data-edit-entity'), + entityID: data.$region.attr('data-edit-entity-id'), el: data.$el[0], region: data.$region[0] }; @@ -169,11 +169,11 @@ function initEdit (bodyElement) { * Fetch the field's metadata; queue or initialize it (if EntityModel exists). * * @param DOM fieldElement - * A Drupal Field API field's DOM element with a data-edit-id attribute. + * A Drupal Field API field's DOM element with a data-edit-field-id attribute. */ function processField (fieldElement) { var metadata = Drupal.edit.metadata; - var fieldID = fieldElement.getAttribute('data-edit-id'); + var fieldID = fieldElement.getAttribute('data-edit-field-id'); var entityID = extractEntityID(fieldID); // Early-return if metadata for this field is missing. @@ -428,7 +428,7 @@ function initializeEntityContextualLink (contextualLink) { * The context within which to delete. */ function deleteContainedModelsAndQueues($context) { - $context.find('[data-edit-entity]').addBack('[data-edit-entity]').each(function (index, entityElement) { + $context.find('[data-edit-entity-id]').addBack('[data-edit-entity-id]').each(function (index, entityElement) { // Delete entity model. // @todo change to findWhere() as soon as we have Backbone 1.0 in Drupal // core. @see https://drupal.org/node/1800022 @@ -450,7 +450,7 @@ function deleteContainedModelsAndQueues($context) { contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion); }); - $context.find('[data-edit-id]').addBack('[data-edit-id]').each(function (index, fieldElement) { + $context.find('[data-edit-field-id]').addBack('[data-edit-field-id]').each(function (index, fieldElement) { // Delete field models. Drupal.edit.collections.fields.chain() .filter(function (fieldModel) { return fieldModel.get('el') === fieldElement; }) diff --git a/core/modules/edit/js/models/FieldModel.js b/core/modules/edit/js/models/FieldModel.js index 8b06521a70498a424629631fbd056c48b3da8bb5..159a47378f36ca07e7492247987bb2b30a749aaf 100644 --- a/core/modules/edit/js/models/FieldModel.js +++ b/core/modules/edit/js/models/FieldModel.js @@ -38,8 +38,8 @@ Drupal.edit.FieldModel = Backbone.Model.extend({ // purposes: so that EditorDecorationView.renderChanged() can react to it. inTempStore: false, // The full HTML representation of this field (with the element that has - // the data-edit-id as the outer element). Used to propagate changes from - // this field instance to other instances of the same field. + // the data-edit-field-id as the outer element). Used to propagate changes + // from this field instance to other instances of the same field. html: null }, diff --git a/core/modules/edit/js/views/EditorView.js b/core/modules/edit/js/views/EditorView.js index bd24b9cf39c52618c9a97de0c1055ffd80f254a5..408989b17dfa0f3e330880f7d4c680876d1af9e9 100644 --- a/core/modules/edit/js/views/EditorView.js +++ b/core/modules/edit/js/views/EditorView.js @@ -52,7 +52,7 @@ Drupal.edit.EditorView = Backbone.View.extend({ * * For some single cardinality fields, it may be necessary or useful to * not in-place edit (and hence decorate) the DOM element with the - * data-edit-id attribute (which is the field's wrapper), but a specific + * data-edit-field-id attribute (which is the field's wrapper), but a specific * element within the field's wrapper. * e.g. using a WYSIWYG editor on a body field should happen on the DOM * element containing the text itself, not on the field wrapper. diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php index 95296ce4209636c2a75584ba5d4ef5e98b7a79c2..4c815e1fcc590f39c6381e9a88a97755fc1ea726 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php @@ -82,8 +82,8 @@ public function testUserWithoutPermission() { $this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/createjs/editingWidgets/formwidget.js']), "'form' in-place editor not loaded."); // HTML annotation must always exist (to not break the render cache). - $this->assertRaw('data-edit-entity="node/1"'); - $this->assertRaw('data-edit-id="node/1/body/und/full"'); + $this->assertRaw('data-edit-entity-id="node/1"'); + $this->assertRaw('data-edit-field-id="node/1/body/und/full"'); // Retrieving the metadata should result in an empty 403 response. $post = array('fields[0]' => 'node/1/body/und/full'); @@ -138,8 +138,8 @@ public function testUserWithPermission() { $this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/createjs/editingWidgets/formwidget.js']), "'form' in-place editor not loaded."); // HTML annotation must always exist (to not break the render cache). - $this->assertRaw('data-edit-entity="node/1"'); - $this->assertRaw('data-edit-id="node/1/body/und/full"'); + $this->assertRaw('data-edit-entity-id="node/1"'); + $this->assertRaw('data-edit-field-id="node/1/body/und/full"'); // There should be only one revision so far. $revisions = node_revision_list(node_load(1)); @@ -299,7 +299,7 @@ public function testPseudoFields() { $this->drupalGet('node/1'); // Check that the data- attribute is not added. - $this->assertNoRaw('data-edit-id="node/1/edit_test_pseudo_field/und/default"'); + $this->assertNoRaw('data-edit-field-id="node/1/edit_test_pseudo_field/und/default"'); } /**