EntityDecorationView.es6.js 864 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @file
  3. * A Backbone view that decorates the in-place editable entity.
  4. */
  5. (function(Drupal, $, Backbone) {
  6. Drupal.quickedit.EntityDecorationView = Backbone.View.extend(
  7. /** @lends Drupal.quickedit.EntityDecorationView# */ {
  8. /**
  9. * Associated with the DOM root node of an editable entity.
  10. *
  11. * @constructs
  12. *
  13. * @augments Backbone.View
  14. */
  15. initialize() {
  16. this.listenTo(this.model, 'change', this.render);
  17. },
  18. /**
  19. * {@inheritdoc}
  20. */
  21. render() {
  22. this.$el.toggleClass(
  23. 'quickedit-entity-active',
  24. this.model.get('isActive'),
  25. );
  26. },
  27. /**
  28. * {@inheritdoc}
  29. */
  30. remove() {
  31. this.setElement(null);
  32. Backbone.View.prototype.remove.call(this);
  33. },
  34. },
  35. );
  36. })(Drupal, jQuery, Backbone);