README.md | 1 - edit.info | 2 +- edit.module | 50 ++++++++++---------- includes/form.inc | 8 +--- includes/pages.inc | 22 ++------- js/app.js | 12 ++++- js/backbone.drupalform.js | 10 ++++ js/createjs/editable.js | 17 ++++--- js/createjs/editingWidgets/drupalalohawidget.js | 12 +++-- .../editingWidgets/drupalcontenteditablewidget.js | 10 ++-- js/createjs/editingWidgets/formwidget.js | 13 ++--- js/createjs/storage.js | 11 ++++- js/edit.js | 10 +++- js/models/edit-app-model.js | 10 ++++ js/routers/edit-router.js | 8 +++- js/theme.js | 6 +++ js/util.js | 12 ++--- js/viejs/SparkEditService.js | 12 +++-- js/views/fielddecorator-view.js | 15 ++++-- js/views/menu-view.js | 8 +++- js/views/modal-view.js | 8 ++-- js/views/overlay-view.js | 14 ++++-- js/views/toolbar-view.js | 17 ++++--- 23 files changed, 176 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index 81dd994..391048c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Requirements -- Please apply this core patch: http://drupal.org/files/field_api_single_field-1821906-5.patch - Please also apply the included core patch "text.patch". Without it, you wont' be able to use direct editing, with or without WYSIWYG. - Optionally, if you also want WYSIWYG editing, install the latest version of Aloha Editor for Drupal 8: http://drupal.org/project/aloha diff --git a/edit.info b/edit.info index 630c825..5298534 100644 --- a/edit.info +++ b/edit.info @@ -1,6 +1,6 @@ name = Edit description = In-place content editing. -package = User interface +package = Core core = 8.x dependencies[] = field diff --git a/edit.module b/edit.module index 1d0c70c..0e11895 100644 --- a/edit.module +++ b/edit.module @@ -2,10 +2,10 @@ /** * @file - * Provides inline content editing functionality for fields and entities. + * Provides in-place content editing functionality for fields. * - * The Edit module makes content editable inline. Rather than having to visit a - * separate page to edit content, it may be edited in-place. + * The Edit module makes content editable in-place. Rather than having to visit + * a separate page to edit content, it may be edited in-place. * * Technically, this module adds classes and data- attributes to fields and * entities, enabling them for in-place editing. @@ -16,8 +16,6 @@ use Drupal\field\FieldInstance; // @todo Get rid of missing-api.inc by improving Entity API. module_load_include('inc', 'edit', 'includes/missing-api'); -// @todo Get rid of text.inc once Edit is committed by moving this logic into text.module. -module_load_include('inc', 'edit', 'includes/text'); /** * Implements hook_menu() @@ -190,13 +188,13 @@ function edit_field_attach_view_alter(&$output, $context) { // Special case for this special mode. if ($context['display'] == 'edit-render-without-transformation-filters') { $children = element_children($output); - $field = reset($children); - $langcode = $output[$field]['#language']; - foreach (array_keys($output[$field]['#items']) as $item) { - $text = $output[$field]['#items'][$item]['value']; - $format_id = $output[$field]['#items'][$item]['format']; + $field_name = reset($children); + $langcode = $output[$field_name]['#language']; + foreach (array_keys($output[$field_name]['#items']) as $item) { + $text = $output[$field_name]['#items'][$item]['value']; + $format_id = $output[$field_name]['#items'][$item]['format']; $untransformed = check_markup($text, $format_id, $langcode, FALSE, array(FILTER_TYPE_TRANSFORM_REVERSIBLE, FILTER_TYPE_TRANSFORM_IRREVERSIBLE)); - $output[$field][$item]['#markup'] = $untransformed; + $output[$field_name][$item]['#markup'] = $untransformed; } } } @@ -206,29 +204,29 @@ function edit_field_attach_view_alter(&$output, $context) { */ function edit_preprocess_field(&$variables) { $entity = $variables['element']['#object']; - $name = $variables['element']['#field_name']; + $field_name = $variables['element']['#field_name']; $langcode = $variables['element']['#language']; $view_mode = $variables['element']['#view_mode']; $formatter_type = $variables['element']['#formatter']; - $field = $entity->{$name}[$langcode]; - $instance_info = field_info_instance($entity->entityType(), $name, $entity->bundle()); + $items = $entity->{$field_name}[$langcode];; + $instance = field_info_instance($entity->entityType(), $field_name, $entity->bundle()); $entity_access = edit_entity_access('update', $entity->entityType(), $entity); - $field_access = field_access('edit', $name, $entity->entityType(), $entity); - $editability = _edit_analyze_field_editability($field, $instance_info, $formatter_type); + $field_access = field_access('edit', $field_name, $entity->entityType(), $entity); + $editability = _edit_analyze_field_editability($items, $instance, $formatter_type); if ($entity_access && $field_access && $editability != 'disabled') { global $editbar; $editbar = TRUE; // Mark this field as editable and provide metadata through data- attributes. - $variables['attributes']['data-edit-field-label'] = $instance_info->definition['label']; - $variables['attributes']['data-edit-id'] = $entity->entityType() . ':' . $entity->id() . ':' . $name . ':' . $langcode . ':' . $view_mode; + $variables['attributes']['data-edit-field-label'] = $instance->definition['label']; + $variables['attributes']['data-edit-id'] = $entity->entityType() . ':' . $entity->id() . ':' . $field_name . ':' . $langcode . ':' . $view_mode; $variables['attributes']['class'][] = 'edit-field'; $variables['attributes']['class'][] = 'edit-allowed'; $variables['attributes']['class'][] = 'edit-type-' . $editability; if ($editability == 'direct-with-wysiwyg') { $variables['attributes']['class'][] = 'edit-type-direct'; - $format_id = $entity->{$name}[$langcode][0]['format']; + $format_id = $entity->{$field_name}[$langcode][0]['format']; _edit_preprocess_field_wysiwyg($variables, $format_id); } } @@ -274,7 +272,7 @@ function _edit_preprocess_field_wysiwyg(&$variables, $format_id) { * * @param array $field * The field's field array. - * @param FieldInstance $instance_info + * @param FieldInstance $instance * The field's instance info. * @param string $formatter_type * The field's formatter type name. @@ -282,8 +280,8 @@ function _edit_preprocess_field_wysiwyg(&$variables, $format_id) { * @return string * The editability: 'disabled', 'form', 'direct' or 'direct-with-wysiwyg'. */ -function _edit_analyze_field_editability($field, FieldInstance $instance_info, $formatter_type) { - $name = $instance_info->definition['field_name']; +function _edit_analyze_field_editability($items, FieldInstance $instance, $formatter_type) { + $field_name = $instance['field_name']; // If the formatter doesn't contain the edit property, default it to 'form' // editability, which should always work. @@ -303,8 +301,8 @@ function _edit_analyze_field_editability($field, FieldInstance $instance_info, $ // If directly editable, check the cardinality. If the cardinality is greater // than 1, use a form to edit the field. if ($editability == 'direct') { - $info = field_info_field($name); - if ($info['cardinality'] != 1) { + $field = field_info_field($field_name); + if ($field['cardinality'] != 1) { $editability = 'form'; } } @@ -318,8 +316,8 @@ function _edit_analyze_field_editability($field, FieldInstance $instance_info, $ // On the other hand, if it is configured to use text processing; then we // must check whether 'direct-with-wysiwyg' or 'form' editability should be // used. - if (!empty($instance_info->definition['settings']['text_processing'])) { - $format_id = $field[0]['format']; + if (!empty($instance['settings']['text_processing'])) { + $format_id = $items[0]['format']; $editability = _edit_wysiwyg_analyze_field_editability($format_id); } } diff --git a/includes/form.inc b/includes/form.inc index 573f162..6936a2f 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -107,12 +107,6 @@ function _simplify_edit_field_edit_form(&$form) { } } } - - // Handle pseudo-fields that are language-independent, such as title, - // author, and creation date. - elseif (empty($form[$element]['#language'])) { - $form[$element]['#title_display'] = 'invisible'; - } } // Make it easy for the JavaScript to identify the submit button. @@ -121,6 +115,8 @@ function _simplify_edit_field_edit_form(&$form) { /** * Validate field editing form. + * + * @todo: clean up once http://drupal.org/node/1846648 is solved. */ function edit_field_form_validate($form, &$form_state) { $entity = $form_state['entity']; diff --git a/includes/pages.inc b/includes/pages.inc index 8fc1477..d29e87b 100644 --- a/includes/pages.inc +++ b/includes/pages.inc @@ -34,12 +34,7 @@ function edit_field_edit($entity_type, $entity_id, $field_name, $langcode, $view throw new NotFoundHttpException(); } - $entities = entity_load_multiple($entity_type, array($entity_id)); - if (!$entities) { - throw new NotFoundHttpException(); - } - - $entity = reset($entities); + $entity = entity_load($entity_type, $entity_id); if (!$entity) { throw new NotFoundHttpException(); } @@ -75,12 +70,10 @@ function edit_field_edit($entity_type, $entity_id, $field_name, $langcode, $view $id = "$entity_type:$entity_id:$field_name:$langcode:$view_mode"; if (!empty($form_state['executed'])) { - $form_state['entity']->save(); - + // Retrieve the updated entity, save it and render only the modified field. + $entity = $form_state['entity']; + $entity->save(); $options = array('field_name' => $field_name); - // Reload the entity. This is necessary for some fields; otherwise we'd - // render the field without the updated values. - $entity = entity_load($entity_type, $entity_id, TRUE); field_attach_prepare_view($entity->entityType(), array($entity->id() => $entity), $view_mode, $langcode, $options); $output = field_attach_view($entity->entityType(), $entity, $view_mode, $langcode, $options); @@ -146,12 +139,7 @@ function edit_text_field_render_without_transformation_filters($entity_type, $en throw new NotFoundHttpException(); } - $entities = entity_load_multiple($entity_type, array($entity_id)); - if (!$entities) { - throw new NotFoundHttpException(); - } - - $entity = reset($entities); + $entity = entity_load($entity_type, $entity_id); if (!$entity) { throw new NotFoundHttpException(); } diff --git a/js/app.js b/js/app.js index 49aab71..b18675c 100644 --- a/js/app.js +++ b/js/app.js @@ -1,4 +1,11 @@ -(function ($, undefined) { +/** + * @file + * A Backbone View that is the central app controller. + */ +(function ($, _, Backbone, Drupal, VIE) { + +"use strict"; + Drupal.edit = Drupal.edit || {}; Drupal.edit.EditAppView = Backbone.View.extend({ vie: null, @@ -303,4 +310,5 @@ }); } }); -})(jQuery); + +})(jQuery, _, Backbone, Drupal, VIE); diff --git a/js/backbone.drupalform.js b/js/backbone.drupalform.js index 67facaf..3285af7 100644 --- a/js/backbone.drupalform.js +++ b/js/backbone.drupalform.js @@ -1,3 +1,11 @@ +/** + * @file + * Backbone.sync implementation for Edit. This is the beating heart. + */ +(function (jQuery, Backbone, Drupal) { + +"use strict"; + Backbone.defaultSync = Backbone.sync; Backbone.sync = function(method, model, options) { if (options.editor.options.editorName === 'form') { @@ -146,3 +154,5 @@ Backbone.syncDirect = function(method, model, options) { } } }; + +})(jQuery, Backbone, Drupal); diff --git a/js/createjs/editable.js b/js/createjs/editable.js index 9713c32..cc34498 100644 --- a/js/createjs/editable.js +++ b/js/createjs/editable.js @@ -1,9 +1,11 @@ -(function (jQuery, undefined) { - // # Create.js editing widget for Spark - // - // This widget inherits from the Create.js editable widget to accommodate - // for the fact that Spark is using custom data attributes and not RDFa - // to communicate editable fields. +/** + * @file + * Determines which editor to use based on a class attribute. + */ +(function (jQuery, Drupal) { + +"use strict"; + jQuery.widget('Drupal.createEditable', jQuery.Midgard.midgardEditable, { _create: function () { this.vie = this.options.vie; @@ -37,4 +39,5 @@ return 'form'; } }); -})(jQuery); + +})(jQuery, Drupal); diff --git a/js/createjs/editingWidgets/drupalalohawidget.js b/js/createjs/editingWidgets/drupalalohawidget.js index b080d53..c972911 100644 --- a/js/createjs/editingWidgets/drupalalohawidget.js +++ b/js/createjs/editingWidgets/drupalalohawidget.js @@ -1,12 +1,13 @@ /** - * @file drupalalohawidget.js - * + * @file * Override of Create.js' default Aloha Editor widget. * - * This does in fact use zero code of jQuery.create.alohaWidget. + * NOTE: This does in fact use zero code of jQuery.create.alohaWidget. */ +(function (jQuery, Drupal) { + +"use strict"; -(function (jQuery, undefined) { jQuery.widget('Drupal.drupalAlohaWidget', jQuery.Create.alohaWidget, { // @todo: actually use this when restoring original content, but for that we @@ -154,4 +155,5 @@ jQuery('#edit_backstage form').remove(); } }); -})(jQuery); + +})(jQuery, Drupal); diff --git a/js/createjs/editingWidgets/drupalcontenteditablewidget.js b/js/createjs/editingWidgets/drupalcontenteditablewidget.js index 51d8539..a9c9c46 100644 --- a/js/createjs/editingWidgets/drupalcontenteditablewidget.js +++ b/js/createjs/editingWidgets/drupalcontenteditablewidget.js @@ -1,10 +1,11 @@ /** - * @file drupalcontenteditablewidget.js - * + * @file * Override of Create.js' default "base" (plain contentEditable) widget. */ +(function (jQuery, Drupal) { + +"use strict"; -(function (jQuery, undefined) { jQuery.widget('Drupal.drupalContentEditableWidget', jQuery.Create.editWidget, { /** @@ -108,4 +109,5 @@ jQuery('#edit_backstage form').remove(); } }); -})(jQuery); + +})(jQuery, Drupal); diff --git a/js/createjs/editingWidgets/formwidget.js b/js/createjs/editingWidgets/formwidget.js index 1f5f8a3..94ad3f5 100644 --- a/js/createjs/editingWidgets/formwidget.js +++ b/js/createjs/editingWidgets/formwidget.js @@ -1,11 +1,11 @@ /** - * @file drupalformwidget.js - * + * @file * Form-based Create.js widget for structured content in Drupal. */ +(function ($, Drupal) { + +"use strict"; -(function ($, undefined) { - // Drupal form-based editing widget for Create.js $.widget('Drupal.drupalFormWidget', $.Create.editWidget, { id: null, @@ -76,7 +76,7 @@ this.id = 'edit-form-for-' + propertyID.replace(/\//g, '_'); // Render form container. - this.$formContainer = jQuery(Drupal.theme('editFormContainer', { + this.$formContainer = $(Drupal.theme('editFormContainer', { id: this.id, loadingMsg: Drupal.t('Loading…')} )); @@ -147,4 +147,5 @@ this.$formContainer = null; } }); -})(jQuery); + +})(jQuery, Drupal); diff --git a/js/createjs/storage.js b/js/createjs/storage.js index 00da4ef..580ff82 100644 --- a/js/createjs/storage.js +++ b/js/createjs/storage.js @@ -1,4 +1,11 @@ -(function (jQuery, undefined) { - // Subclass jQuery.Midgard.midgardStorage just to have consistent namespaces. +/** + * @file + * Subclasses jQuery.Midgard.midgardStorage to have consistent namespaces. + */ +(function(jQuery) { + +"use strict"; + jQuery.widget('Drupal.createStorage', jQuery.Midgard.midgardStorage, {}); + })(jQuery); diff --git a/js/edit.js b/js/edit.js index 7afd177..22c976c 100644 --- a/js/edit.js +++ b/js/edit.js @@ -1,4 +1,10 @@ -(function ($, VIE) { +/** + * @file + * Behaviors for Edit, including the one that initializes Edit's EditAppView. + */ +(function ($, Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; @@ -38,4 +44,4 @@ Drupal.edit.init = function() { Backbone.history.start(); }; -})(jQuery, VIE); +})(jQuery, Backbone, Drupal); diff --git a/js/models/edit-app-model.js b/js/models/edit-app-model.js index 464741b..b6ff36f 100644 --- a/js/models/edit-app-model.js +++ b/js/models/edit-app-model.js @@ -1,3 +1,11 @@ +/** + * @file + * A Backbone Model that models the current Edit application state. + */ +(function(Backbone, Drupal) { + +"use strict"; + Drupal.edit = Drupal.edit || {}; Drupal.edit.models = Drupal.edit.models || {}; Drupal.edit.models.EditAppModel = Backbone.Model.extend({ @@ -10,3 +18,5 @@ Drupal.edit.models.EditAppModel = Backbone.Model.extend({ activeModal: null } }); + +})(Backbone, Drupal); diff --git a/js/routers/edit-router.js b/js/routers/edit-router.js index 19c885b..4d7b196 100644 --- a/js/routers/edit-router.js +++ b/js/routers/edit-router.js @@ -1,8 +1,10 @@ /** - * @file edit-router.js - * + * @file * A Backbone Router enabling URLs to make the user enter edit mode directly. */ +(function(Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.routers = {}; @@ -48,3 +50,5 @@ Drupal.edit.routers.EditRouter = Backbone.Router.extend({ } } }); + +})(Backbone, Drupal); diff --git a/js/theme.js b/js/theme.js index 9e5d14b..4853246 100644 --- a/js/theme.js +++ b/js/theme.js @@ -1,5 +1,11 @@ +/** + * @file + * Provides overridable theme functions for all of Edit's client-side HTML. + */ (function($) { +"use strict"; + /** * Theme function for the overlay of the Edit module. * diff --git a/js/util.js b/js/util.js index 3d86a57..6b0044b 100644 --- a/js/util.js +++ b/js/util.js @@ -1,10 +1,10 @@ -(function($) { - /** - * @file util.js - * - * Utilities for Edit module. + * @file + * Provides utility functions for Edit. */ +(function($, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.util = Drupal.edit.util || {}; @@ -137,4 +137,4 @@ Drupal.edit.util.form = { } }; -})(jQuery); +})(jQuery, Drupal); diff --git a/js/viejs/SparkEditService.js b/js/viejs/SparkEditService.js index fa492fd..ff95266 100644 --- a/js/viejs/SparkEditService.js +++ b/js/viejs/SparkEditService.js @@ -1,5 +1,10 @@ -// VIE DOM parsing service for Spark Edit -(function () { +/** + * @file + * VIE DOM parsing service for Edit. + */ +(function(jQuery, _, Drupal, VIE) { + +"use strict"; VIE.prototype.SparkEditService = function (options) { var defaults = { @@ -199,4 +204,5 @@ return predicates; } }; -})(); + +})(jQuery, _, Drupal, VIE); diff --git a/js/views/fielddecorator-view.js b/js/views/fielddecorator-view.js index 491114c..01a4e83 100644 --- a/js/views/fielddecorator-view.js +++ b/js/views/fielddecorator-view.js @@ -1,11 +1,14 @@ /** - * @file fielddecorator-view.js - * + * @file * A Backbone View that decorates properties. + * * It listens to state changes of the property editor. * * @todo rename to propertydecorator-view.js + PropertyDecorationView. */ +(function($, Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.views = Drupal.edit.views || {}; @@ -148,7 +151,7 @@ Drupal.edit.views.FieldDecorationView = Backbone.View.extend({ // While editing, don't show *any* other editors. // @todo: revisit this once https://github.com/bergie/create/issues/133 is solved. - jQuery('.edit-candidate').not('.edit-editing').removeClass('edit-editable'); + $('.edit-candidate').not('.edit-editing').removeClass('edit-editable'); if (editorName === 'form') { this.$el.addClass('edit-belowoverlay'); @@ -166,7 +169,7 @@ Drupal.edit.views.FieldDecorationView = Backbone.View.extend({ // Make the other editors show up again. // @todo: revisit this once https://github.com/bergie/create/issues/133 is solved. - jQuery('.edit-candidate').addClass('edit-editable'); + $('.edit-candidate').addClass('edit-editable'); if (editorName === 'form') { this.$el.removeClass('edit-belowoverlay'); @@ -309,7 +312,7 @@ Drupal.edit.views.FieldDecorationView = Backbone.View.extend({ * occurs to/from *another* element, then call the given callback. */ _ignoreHoveringVia: function(event, closest, callback) { - if (jQuery(event.relatedTarget).closest(closest).length > 0) { + if ($(event.relatedTarget).closest(closest).length > 0) { event.stopPropagation(); } else { @@ -317,3 +320,5 @@ Drupal.edit.views.FieldDecorationView = Backbone.View.extend({ } } }); + +})(jQuery, Backbone, Drupal); diff --git a/js/views/menu-view.js b/js/views/menu-view.js index 085e562..834f743 100644 --- a/js/views/menu-view.js +++ b/js/views/menu-view.js @@ -1,8 +1,10 @@ /** - * @file menu-view.js - * + * @file * A Backbone View that provides the app-level interactive menu. */ +(function($, _, Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.views = Drupal.edit.views || {}; @@ -36,3 +38,5 @@ Drupal.edit.views.MenuView = Backbone.View.extend({ .parent().addClass('active'); } }); + +})(jQuery, _, Backbone, Drupal); diff --git a/js/views/modal-view.js b/js/views/modal-view.js index 76d0085..0f3c0aa 100644 --- a/js/views/modal-view.js +++ b/js/views/modal-view.js @@ -1,10 +1,10 @@ /** - * @file modal-view.js - * + * @file * A Backbone View that provides an interactive modal. */ +(function($, Backbone, Drupal) { -(function($) { +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.views = Drupal.edit.views || {}; @@ -105,4 +105,4 @@ Drupal.edit.views.ModalView = Backbone.View.extend({ } }); -})(jQuery); +})(jQuery, Backbone, Drupal); diff --git a/js/views/overlay-view.js b/js/views/overlay-view.js index db8d150..d41f091 100644 --- a/js/views/overlay-view.js +++ b/js/views/overlay-view.js @@ -1,11 +1,13 @@ /** - * @file overlay-view.js - * + * @file * A Backbone View that provides the app-level overlay. * * The overlay sits on top of the existing content, the properties that are * candidates for editing sit on top of the overlay. */ +(function ($, _, Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.views = Drupal.edit.views || {}; @@ -55,12 +57,12 @@ Drupal.edit.views.OverlayView = Backbone.View.extend({ */ render: function() { this.setElement( - jQuery(Drupal.theme('editOverlay', {})) + $(Drupal.theme('editOverlay', {})) .appendTo('body') .addClass('edit-animate-slow edit-animate-invisible') ); // Animations - this.$el.css('top', jQuery('#navbar').outerHeight()); + this.$el.css('top', $('#navbar').outerHeight()); this.$el.removeClass('edit-animate-invisible'); }, @@ -74,7 +76,9 @@ Drupal.edit.views.OverlayView = Backbone.View.extend({ .bind(Drupal.edit.util.constants.transitionEnd, function (event) { that.$el.remove(); // @todo - should the overlay really do this? - jQuery('.edit-form-container, .edit-toolbar-container, #edit_modal, .edit-curtain, .edit-validation-errors').remove(); + $('.edit-form-container, .edit-toolbar-container, #edit_modal, .edit-curtain, .edit-validation-errors').remove(); }); } }); + +})(jQuery, _, Backbone, Drupal); diff --git a/js/views/toolbar-view.js b/js/views/toolbar-view.js index 72bfef3..55b5da3 100644 --- a/js/views/toolbar-view.js +++ b/js/views/toolbar-view.js @@ -1,10 +1,13 @@ /** - * @file toolbar-view.js - * + * @file * A Backbone View that provides an interactive toolbar (1 per property editor). + * * It listens to state changes of the property editor. It also triggers state * changes in response to user interactions with the toolbar, including saving. */ +(function ($, _, Backbone, Drupal) { + +"use strict"; Drupal.edit = Drupal.edit || {}; Drupal.edit.views = Drupal.edit.views || {}; @@ -134,7 +137,7 @@ Drupal.edit.views.ToolbarView = Backbone.View.extend({ // Replace the old content with the new content. var updatedField = entity.get(predicate + '/rendered'); - var $inner = jQuery(updatedField).html(); + var $inner = $(updatedField).html(); editor.element.html($inner); // @todo: VIE doesn't seem to like this? :) It seems that if I delete/ @@ -160,7 +163,7 @@ Drupal.edit.views.ToolbarView = Backbone.View.extend({ .prepend(validationErrorMessages); } else { - var $errors = jQuery('
') + var $errors = $('
') .append(validationErrorMessages); editor.element .addClass('edit-validation-error') @@ -191,7 +194,7 @@ Drupal.edit.views.ToolbarView = Backbone.View.extend({ */ onMouseLeave: function(event) { var el = this.editor.element[0]; - if (event.relatedTarget != el && !jQuery.contains(el, event.relatedTarget)) { + if (event.relatedTarget != el && !$.contains(el, event.relatedTarget)) { this.editor.element.trigger('mouseleave.edit'); } event.stopPropagation(); @@ -344,7 +347,7 @@ Drupal.edit.views.ToolbarView = Backbone.View.extend({ */ render: function () { // Render toolbar. - this.setElement(jQuery(Drupal.theme('editToolbarContainer', { + this.setElement($(Drupal.theme('editToolbarContainer', { id: this.getId() }))); @@ -441,3 +444,5 @@ Drupal.edit.views.ToolbarView = Backbone.View.extend({ return this.$el.find('.edit-toolbar .edit-toolgroup.' + toolgroup); } }); + +})(jQuery, _, Backbone, Drupal);