aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js')
-rw-r--r--node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js274
1 files changed, 274 insertions, 0 deletions
diff --git a/node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js b/node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js
new file mode 100644
index 00000000..90342d81
--- /dev/null
+++ b/node_modules/montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel/rich-text-linkpopup.js
@@ -0,0 +1,274 @@
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/overlays/rich-text-resizer.reel"
8 @requires montage/core/core
9 @requires montage/ui/component
10*/
11var Montage = require("montage").Montage,
12 Component = require("ui/component").Component;
13
14/**
15 @class module:"montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel".RichTextLinkPopup
16 @extends module:montage/ui/component.Component
17*/
18exports.RichTextLinkPopup = Montage.create(Component,/** @lends module:"montage/ui/rich-text-editor/overlays/rich-text-linkpopup.reel".RichTextLinkPopup# */ {
19
20 /**
21 Description TODO
22 @private
23 */
24 _isActive: {
25 enumerable: false,
26 value: false
27 },
28 /**
29 Description TODO
30 @private
31 */
32 _editor: {
33 enumerable: false,
34 value: null
35 },
36
37 /**
38 Description TODO
39 @private
40 */
41 target: {
42 enumerable: false,
43 value: null
44 },
45
46 /**
47 Description TODO
48 @private
49 */
50 _needsReset: {
51 enumerable: false,
52 value: false
53 },
54
55 /**
56 Description TODO
57 @type {Function}
58 */
59 initWithEditor: {
60 value: function(editor) {
61 this._editor = editor;
62 }
63 },
64
65 /**
66 Description TODO
67 @type {Function}
68 */
69 editorMouseUp: {
70 value: function(event) {
71 var element;
72
73 if (this._editor.activeOverlay != this) {
74 // Check if the caret is inside an image within an anchor element
75 if (event.target.nodeName == "IMG") {
76 element = event.target;
77 while (element && element != this._element) {
78 if (element.nodeName == "A") {
79 if (element != this.target) {
80 this.target = element;
81 this._needsReset = true;
82 if (this._isActive) {
83 this.needsDraw = true;
84 } else {
85 this._editor.showOverlay(this);
86 }
87 }
88 return true;
89 }
90 element = element.parentElement;
91 }
92 }
93 }
94 }
95 },
96
97 /**
98 Description TODO
99 @type {Function}
100 */
101 editorTouchEnd: {
102 value: function(event) {
103 this.editorMouseUp(event);
104 }
105 },
106
107 /**
108 Description TODO
109 @type {Function}
110 */
111 editorSelectionDidChange: {
112 value: function(range) {
113 var element;
114
115 // Check if the caret is inside an anchor element
116 if (range && range.collapsed) {
117 element = range.commonAncestorContainer;
118 while (element && element != this._element) {
119 if (element.nodeName == "A") {
120 if (element != this.target) {
121 this.target = element;
122 this._needsReset = true;
123 if (this._isActive) {
124 this.needsDraw = true;
125 } else {
126 this._editor.showOverlay(this);
127 }
128 }
129 return true;
130 }
131 element = element.parentElement;
132 }
133 }
134
135 if (this._editor.activeOverlay == this) {
136 this._editor.hideOverlay();
137 }
138
139 return false;
140 }
141 },
142
143 /**
144 Description TODO
145 @function
146 */
147 didBecomeActive: {
148 value: function() {
149 this._isActive = true;
150 window.addEventListener("resize", this, false);
151 }
152 },
153
154 /**
155 Description TODO
156 @function
157 */
158 didBecomeInactive: {
159 value: function() {
160 this._isActive = false;
161 window.removeEventListener("resize", this, false);
162
163 //Reset the resizer internal
164 this.target = null;
165 this._needsReset = false;
166 }
167 },
168
169 /**
170 Description TODO
171 @function
172 */
173 prepareForDraw: {
174 enumerable: false,
175 value: function() {
176 this._popupExtraWidth = this.element.offsetWidth;
177 }
178 },
179
180 /**
181 Description TODO
182 @function
183 */
184 draw: {
185 enumerable: false,
186 value: function() {
187 var element = this.element,
188 target = this.target,
189 editorElement = this._editor.innerElement;
190
191 if (this._needsReset) {