aboutsummaryrefslogtreecommitdiff
path: root/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/labs/rich-text-editor.reel/rich-text-editor.js')
-rw-r--r--node_modules/labs/rich-text-editor.reel/rich-text-editor.js1668
1 files changed, 1668 insertions, 0 deletions
diff --git a/node_modules/labs/rich-text-editor.reel/rich-text-editor.js b/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
new file mode 100644
index 00000000..3fece294
--- /dev/null
+++ b/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
@@ -0,0 +1,1668 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module "montage/ui/rich-text-editor.reel"
8 @requires montage/core/core
9*/
10var Montage = require("montage/core/core").Montage,
11 Component = require("montage/ui/component").Component,
12 MutableEvent = require("montage/core/event/mutable-event").MutableEvent,
13 Resizer = require("node_modules/labs/rich-text-editor.reel/rich-text-resizer").Resizer,
14 Sanitizer = require("node_modules/labs/rich-text-editor.reel/rich-text-sanitizer").Sanitizer;
15
16/**
17 @class module:"montage/ui/rich-text-editor.reel".RichTextEditor
18 @extends module:montage/ui/component.Component
19*/
20exports.RichTextEditor = Montage.create(Component,/** @lends module:"montage/ui/rich-text-editor.reel".RichTextEditor# */ {
21
22 /**
23 Description TODO
24 @private
25 */
26 _hasSelectionChangeEvent: {
27 enumerable: false,
28 value: null // Need to be preset to null, will be set to true or false later on
29 },
30
31 /**
32 Description TODO
33 @private
34 */
35 _uniqueId: {
36 enumerable: false,
37 value: Math.floor(Math.random() * 1000) + "-" + Math.floor(Math.random() * 1000)
38 },
39
40 /**
41 Description TODO
42 @private
43 */
44 _needsSelectionReset: {
45 enumerable: false,
46 value: false
47 },
48
49 /**
50 Description TODO
51 @private
52 */
53 _selectionChangeTimer: {
54 enumerable: false,
55 value: null
56 },
57
58 /**
59 Description TODO
60 @private
61 */
62 _activeLink: {
63 enumerable: false,
64 value: null
65 },
66
67 /**
68 Description TODO
69 @private
70 */
71 _needsActiveLinkOn: {
72 enumerable: false,
73 value: false
74 },
75
76 /**
77 Description TODO
78 @private
79 */
80 _hasFocus: {
81 enumerable: false,
82 value: false
83 },
84
85 /**
86 Description TODO
87 @type {Function}
88 */
89 hasFocus: {
90 enumerable: true,
91 get: function() {
92 return this._hasFocus;
93 }
94 },
95
96 /**
97 Description TODO
98 @private
99 */
100 _dirty: {
101 enumerable: false,
102 value: false
103 },
104
105 /**
106 Description TODO
107 @private
108 */
109 _value: {
110 enumerable: false,
111 value: ""
112 },
113
114 /**
115 Description TODO
116 @type {Function}
117 */
118 value: {
119 enumerable: true,
120 serializable: true,
121 get: function() {
122 var contentNode = this.element.firstChild,
123 content;
124
125 if (this._dirtyValue) {
126 if (this._resizer) {
127 contentNode = this._resizer.cleanup(contentNode);
128 }
129
130 contentNode = this._cleanupActiveLink(contentNode);
131
132 content = contentNode ? contentNode.innerHTML : "";
133 if (content == "<br>") {
134 // when the contentEditable div is emptied, Chrome add a <br>, let's filter it out
135 content = "";
136 }
137 if (this._sanitizer) {
138 content = this._sanitizer.didGetValue(content, this._uniqueId);
139 }
140
141 this._value = content;
142 this._dirtyValue = false;
143 }
144 return this._value;
145 },
146 set: function(value) {
147 if (this._value !== value || this._dirtyValue) {
148 if (this._resizer) {
149 this._needsHideResizer = true;
150 }
151
152 if (this._sanitizer) {
153 value = this._sanitizer.willSetValue(value, this._uniqueId);
154 }
155 this._value = value;
156 this._dirtyValue = false;
157 this._dirtyTextValue = true;
158 this._needsSelectionReset = true;
159 this._needsResetContent = true;
160 this.needsDraw = true;
161 }
162 }
163 },
164
165 /**
166 Description TODO
167 @private
168 */
169 _textValue: {
170 enumerable: false,
171 value: ""
172 },
173
174 /**
175 Description TODO
176 @type {Function}
177 */
178 textValue: {
179 enumerable: true,
180 get: function() {
181 var contentNode = this.element.firstChild,
182 childNodes;
183
184 if (this._dirtyTextValue) {
185 if (contentNode) {
186 if (this._resizer) {
187 contentNode = this._resizer.cleanup(contentNode);
188 }
189 contentNode = this._cleanupActiveLink(contentNode);
190 }
191
192 this._textValue = contentNode ? this._innerText(contentNode) : "";
193 this._dirtyTextValue = false;
194 }
195 return this._textValue;
196 },
197 set: function (value) {
198 if (this._textValue !== value || this._dirtyTextValue) {
199 if (this._resizer) {
200 this._needsHideResizer = true;
201 }
202
203 this._textValue = value;
204 this._dirtyTextValue = false;
205 this._dirtyValue = true;
206 this._needsSelectionReset = true;
207 this._needsResetContent = true;
208 this.needsDraw = true;
209 }
210 }
211 },
212
213 /**
214 Description TODO
215 @type {}
216 */
217 delegate: {
218 enumerable: true,
219 value: null
220 },
221