summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2013-11-13 15:26:44 (GMT)
committerwebchick2013-11-13 15:26:44 (GMT)
commit0871544264d8062cf7bc78eb4d4e319b45f2f149 (patch)
tree92b7f5ab24aa2e5872bfa205de4266e7ec41d3d2
parentb810cf1dbd0c5b67ea12815195e846bba1984392 (diff)
Issue #2133869 by Wim Leers: Clean up Edit's data- attributes.
-rw-r--r--core/modules/edit/edit.api.php7
-rw-r--r--core/modules/edit/edit.module4
-rw-r--r--core/modules/edit/js/edit.js14
-rw-r--r--core/modules/edit/js/models/FieldModel.js4
-rw-r--r--core/modules/edit/js/views/EditorView.js2
-rw-r--r--core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php10
6 files changed, 21 insertions, 20 deletions
diff --git a/core/modules/edit/edit.api.php b/core/modules/edit/edit.api.php
index 162c958..b5bf454 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/<field-name>/und/<module-name>-<custom-id>".
+ * Edit module integrates with HTML elements with data-edit-field-id attributes.
+ * For example:
+ * data-edit-field-id="node/1/<field-name>/und/<module-name>-<custom-id>"
* 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 b08a459..9e4d132 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 dab4522..b8afb6c 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 8b06521..159a473 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 bd24b9c..408989b 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 95296ce..4c815e1 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 @@ class EditLoadingTest extends WebTestBase {
$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 @@ class EditLoadingTest extends WebTestBase {
$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 @@ class EditLoadingTest extends WebTestBase {
$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"');
}
/**