f0ad4cc471840bc7abc68109f8de08549305d4ca
[yaffs-website] / web / core / modules / ckeditor / js / models / Model.es6.js
1 /**
2  * @file
3  * A Backbone Model for the state of a CKEditor toolbar configuration .
4  */
5
6 (function(Drupal, Backbone) {
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(
15     /** @lends Drupal.ckeditor.Model# */ {
16       /**
17        * Default values.
18        *
19        * @type {object}
20        */
21       defaults: /** @lends Drupal.ckeditor.Model# */ {
22         /**
23          * The CKEditor configuration that is being manipulated through the UI.
24          */
25         activeEditorConfig: null,
26
27         /**
28          * The textarea that contains the serialized representation of the active
29          * CKEditor configuration.
30          */
31         $textarea: null,
32
33         /**
34          * Tracks whether the active toolbar DOM structure has been changed. When
35          * true, activeEditorConfig needs to be updated, and when that is updated,
36          * $textarea will also be updated.
37          */
38         isDirty: false,
39
40         /**
41          * The configuration for the hidden CKEditor instance that is used to
42          * build the features metadata.
43          */
44         hiddenEditorConfig: null,
45
46         /**
47          * A hash that maps buttons to features.
48          */
49         buttonsToFeatures: null,
50
51         /**
52          * A hash, keyed by a feature name, that details CKEditor plugin features.
53          */
54         featuresMetadata: null,
55
56         /**
57          * Whether the button group names are currently visible.
58          */
59         groupNamesVisible: false,
60       },
61
62       /**
63        * @method
64        */
65       sync() {
66         // Push the settings into the textarea.
67         this.get('$textarea').val(
68           JSON.stringify(this.get('activeEditorConfig')),
69         );
70       },
71     },
72   );
73 })(Drupal, Backbone);