Model.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @file
  3. * A Backbone Model for the state of a CKEditor toolbar configuration .
  4. */
  5. (function (Drupal, Backbone) {
  6. 'use strict';
  7. /**
  8. * Backbone model for the CKEditor toolbar configuration state.
  9. *
  10. * @constructor
  11. *
  12. * @augments Backbone.Model
  13. */
  14. Drupal.ckeditor.Model = Backbone.Model.extend(/** @lends Drupal.ckeditor.Model# */{
  15. /**
  16. * Default values.
  17. *
  18. * @type {object}
  19. */
  20. defaults: /** @lends Drupal.ckeditor.Model# */{
  21. /**
  22. * The CKEditor configuration that is being manipulated through the UI.
  23. */
  24. activeEditorConfig: null,
  25. /**
  26. * The textarea that contains the serialized representation of the active
  27. * CKEditor configuration.
  28. */
  29. $textarea: null,
  30. /**
  31. * Tracks whether the active toolbar DOM structure has been changed. When
  32. * true, activeEditorConfig needs to be updated, and when that is updated,
  33. * $textarea will also be updated.
  34. */
  35. isDirty: false,
  36. /**
  37. * The configuration for the hidden CKEditor instance that is used to
  38. * build the features metadata.
  39. */
  40. hiddenEditorConfig: null,
  41. /**
  42. * A hash that maps buttons to features.
  43. */
  44. buttonsToFeatures: null,
  45. /**
  46. * A hash, keyed by a feature name, that details CKEditor plugin features.
  47. */
  48. featuresMetadata: null,
  49. /**
  50. * Whether the button group names are currently visible.
  51. */
  52. groupNamesVisible: false
  53. },
  54. /**
  55. * @method
  56. */
  57. sync: function () {
  58. // Push the settings into the textarea.
  59. this.get('$textarea').val(JSON.stringify(this.get('activeEditorConfig')));
  60. }
  61. });
  62. })(Drupal, Backbone);