diff options
author | Pushkar Joshi | 2012-04-19 14:12:45 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-19 14:12:45 -0700 |
commit | 9f32d7e5454db3189209fc68a286a7fdb0c31fe8 (patch) | |
tree | a51c2bf67839a25158c30752b44fdea0eac28b9d /node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js | |
parent | dc1e8dde18c40cf740bd2fe09165784e0d415fab (diff) | |
parent | 6d33345a9e609e36539d2efa25569f5eeb04a2af (diff) | |
download | ninja-9f32d7e5454db3189209fc68a286a7fdb0c31fe8.tar.gz |
Merge branch 'master' into pentool
Conflicts:
js/helper-classes/3D/view-utils.js
Diffstat (limited to 'node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js')
-rw-r--r-- | node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js | 568 |
1 files changed, 568 insertions, 0 deletions
diff --git a/node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js b/node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js new file mode 100644 index 00000000..c8a00ef8 --- /dev/null +++ b/node_modules/montage/ui/rich-text-editor/overlays/rich-text-resizer.reel/rich-text-resizer.js | |||
@@ -0,0 +1,568 @@ | |||
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/core/geometry/point | ||
10 | @requires montage/ui/component | ||
11 | @requires montage/ui/dom | ||
12 | */ | ||
13 | var Montage = require("montage").Montage, | ||
14 | Component = require("ui/component").Component, | ||
15 | dom = require("ui/dom"), | ||
16 | Point = require("core/geometry/point").Point; | ||
17 | |||
18 | /** | ||
19 | @class module:"montage/ui/rich-text-editor/overlays/rich-text-resizer.reel".RichTextResizer | ||
20 | @extends module:montage/ui/component.Component | ||
21 | */ | ||
22 | exports.RichTextResizer = Montage.create(Component,/** @lends module:"montage/ui/rich-text-editor/overlays/rich-text-resizer.reel".RichTextResizer# */ { | ||
23 | |||
24 | /** | ||
25 | Description TODO | ||
26 | @private | ||
27 | */ | ||
28 | _isActive: { | ||
29 | enumerable: false, | ||
30 | value: false | ||
31 | }, | ||
32 | /** | ||
33 | Description TODO | ||
34 | @private | ||
35 | */ | ||
36 | _editor: { | ||
37 | enumerable: false, | ||
38 | value: null | ||
39 | }, | ||
40 | |||
41 | /** | ||
42 | Description TODO | ||
43 | @private | ||
44 | */ | ||
45 | target: { | ||
46 | enumerable: false, | ||
47 | value: null | ||
48 | }, | ||
49 | |||
50 | /** | ||
51 | Description TODO | ||
52 | @private | ||
53 | */ | ||
54 | _draggedElement: { | ||
55 | enumerable: false, | ||
56 | value: null | ||
57 | }, | ||
58 | |||
59 | /** | ||
60 | Description TODO | ||
61 | @private | ||
62 | */ | ||
63 | _needsReset: { | ||
64 | enumerable: false, | ||
65 | value: false | ||
66 | }, | ||
67 | |||
68 | /** | ||
69 | Description TODO | ||
70 | @type {Function} | ||
71 | */ | ||
72 | initWithEditor: { | ||
73 | value: function(editor) { | ||
74 | this._editor = editor; | ||
75 | } | ||
76 | }, | ||
77 | |||
78 | /** | ||
79 | Description TODO | ||
80 | @type {Function} | ||
81 | */ | ||
82 | editorMouseDown: { | ||
83 | value: function(event) { | ||
84 | var target = event.target; | ||
85 | |||
86 | if (this._isActive && target === this.element) { | ||
87 | event.preventDefault(); | ||
88 | event.stopPropagation(); | ||
89 | return true; | ||
90 | } | ||
91 | } | ||
92 | }, | ||
93 | |||
94 | /** | ||
95 | Description TODO | ||
96 | @type {Function} | ||
97 | */ | ||
98 | editorTouchStart: { | ||
99 | value: function(event) { | ||
100 | this.editorMouseDown(event); | ||
101 | } | ||
102 | }, | ||
103 | |||
104 | /** | ||
105 | Description TODO | ||
106 | @type {Function} | ||
107 | */ | ||
108 | editorMouseUp: { | ||
109 | value: function(event) { | ||
110 | var target = event.target, | ||
111 | previousTarget = this.target; | ||
112 | |||
113 | // Ignore this call if we are curently capturing the pointer | ||
114 | if (this._observedPointer) { | ||
115 | return true; | ||
116 | } else { | ||
117 | if (target === this.element && this._editor.activeOverlay == this) { | ||
118 | this._editor.hideOverlay(); | ||
119 | // We need to stop the event propagation to prevent the selection to be reset | ||
120 | event.target = this.target; // Retarget the event | ||
121 | event.preventDefault(); | ||
122 | event.stopPropagation(); | ||
123 | } else if (target.tagName === "IMG") { | ||
124 | if (target !== previousTarget) { | ||
125 | if (previousTarget) { | ||
126 | previousTarget.classList.remove("montage-resizer-element"); | ||
127 | if (previousTarget.classList.length == 0) { | ||
128 | previousTarget.removeAttribute("class"); | ||
129 | } | ||
130 | } | ||
131 | this.target = target; | ||
132 | this._needsReset = true; | ||
133 | if (this._isActive) { | ||
134 | this.needsDraw = true; | ||
135 | } else { | ||
136 | this._ignoreNextSelectionchanged = true; | ||
137 | this._editor.showOverlay(this); | ||
138 | } | ||
139 | } | ||
140 | event.preventDefault(); | ||
141 | event.stopPropagation(); | ||
142 | return true; | ||
143 | } else if (this._editor.activeOverlay == this) { | ||
144 | this._editor.hideOverlay(); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | return false; | ||
149 | } | ||
150 | }, | ||
151 | |||
152 | /** | ||
153 | Description TODO | ||
154 | @type {Function} | ||
155 | */ | ||
156 | editorTouchEnd: { | ||
157 | value: function(event) { | ||
158 | this.editorMouseUp(event); | ||
159 | } | ||
160 | }, | ||
161 | |||
162 | /** | ||
163 | Description TODO | ||
164 | @type {Function} | ||
165 | */ | ||
166 | editorSelectionDidChange: { | ||
167 | value: function(range) { | ||
168 | if (this._ignoreNextSelectionchanged) { | ||
169 | this._ignoreNextSelectionchanged = false; | ||
170 | } else if (this._editor.activeOverlay == this) { | ||
171 | this._editor.hideOverlay(); | ||
172 | } | ||
173 | |||
174 | return false; | ||
175 | } | ||
176 | }, | ||
177 | |||
178 | /** | ||
179 | Description TODO | ||
180 | @function | ||
181 | */ | ||
182 | draw: { | ||
183 | enumerable: false, | ||
184 |