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