aboutsummaryrefslogtreecommitdiff
path: root/js/lib/NJUtils.js
diff options
context:
space:
mode:
authorhwc4872012-06-12 15:52:35 -0700
committerhwc4872012-06-12 15:52:35 -0700
commit9490f816924e9e9c9970ef9384241c07ec0a6e9f (patch)
treef44449a2e0055e21960a5513fb3a0738a91db528 /js/lib/NJUtils.js
parentb7a41cbd5a30d32f524ee60e2dfdf9c65c7ec55b (diff)
parent6854a72504f57903bd5de003e377f2aefb02d0da (diff)
downloadninja-9490f816924e9e9c9970ef9384241c07ec0a6e9f.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts: assets/canvas-runtime.js js/io/system/ninjalibrary.json js/mediators/element-mediator.js
Diffstat (limited to 'js/lib/NJUtils.js')
-rwxr-xr-xjs/lib/NJUtils.js124
1 files changed, 2 insertions, 122 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 7dd4c9e8..b35e29bc 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -90,38 +90,14 @@ exports.NJUtils = Montage.create(Component, {
90 } 90 }
91 }, 91 },
92 92
93 createModel: {
94 value: function(el) {
95 el.elementModel = Montage.create(ElementModel).initialize(el);
96 }
97 },
98
99 createModelWithShape: {
100 value: function(el, selection) {
101 el.elementModel = Montage.create(ElementModel).initialize(el, true, selection);
102 }
103 },
104
105 createModelWithSelection: {
106 value: function(el, selection) {
107 el.elementModel = Montage.create(ElementModel).initialize(el, false, selection);
108 }
109 },
110
111 createModelForComponent: {
112 value: function(el, selection) {
113 el.elementModel = Montage.create(ElementModel).initialize(el, false, selection, true);
114 }
115 },
116
117 // TODO: Find a better place for this method 93 // TODO: Find a better place for this method
118 stylesFromDraw: { 94 stylesFromDraw: {
119 value: function(element, width, height, drawData, pos) { 95 value: function(element, width, height, drawData, pos) {
120 var styles = {}; 96 var styles = {};
121 97
122 styles['position'] = pos ? pos: "absolute"; 98 styles['position'] = pos ? pos: "absolute";
123 styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * width)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; 99 styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * width)) - this.application.ninja.currentDocument.model.domContainer.offsetLeft + 'px';
124 styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * height)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; 100 styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * height)) - this.application.ninja.currentDocument.model.domContainer.offsetTop + 'px';
125 styles['width'] = width + 'px'; 101 styles['width'] = width + 'px';
126 styles['height'] = height + 'px'; 102 styles['height'] = height + 'px';
127 103
@@ -166,102 +142,6 @@ exports.NJUtils = Montage.create(Component, {
166 } 142 }
167 }, 143 },
168 144
169 ///// Element Model creation for existing elements
170 ///// TODO: find a different place for this function
171 makeElementModel: {
172 value: function(el, selection, controller, isShape) {
173 var p3d = Montage.create(Properties3D);
174
175 var shapeProps = null;
176 var pi = controller + "Pi";
177
178 if(isShape) {
179 shapeProps = Montage.create(ShapeModel);
180 }
181
182 if(el.controller) {
183
184 var componentInfo = Montage.getInfoForObject(el.controller);
185 var componentName = componentInfo.objectName.toLowerCase();
186
187 controller = "component";
188 isShape = false;
189
190 switch(componentName) {
191 case "feedreader":
192 selection = "Feed Reader";
193 pi = "FeedReaderPi";
194 break;
195 case "map":
196 selection = "Map";
197 pi = "MapPi";
198 break;
199 case "youtubechannel":
200 selection = "Youtube Channel";
201 pi = "YoutubeChannelPi";
202 break;
203 case "picasacarousel":
204 selection = "Picasa Carousel";
205 pi = "PicasaCarouselPi";
206 break;
207 }
208 }
209
210 el.elementModel = Montage.create(ElementModel, {
211 type: { value: el.nodeName},
212 selection: { value: selection},
213 controller: { value: ControllerFactory.getController(controller)},
214 pi: { value: pi},
215 props3D: { value: p3d},
216 shapeModel: { value: shapeProps},
217 isShape: { value: isShape}
218 });
219
220
221 }
222 },
223
224 ///// Element Model creation for existing elements based on element type.
225 ///// TODO: Selection and model should be based on the element type
226 makeModelFromElement: {
227 value: function(el) {
228 var selection = "div",
229 controller = "block",
230 isShape = false;
231 switch(el.nodeName.toLowerCase())
232 {
233 case "div":
234 break;
235 case "img":
236 selection = "image";
237 controller = "image";
238 break;
239 case "video":
240 selection = "video";
241 controller = "video";
242 break;
243 case "canvas":
244 isShape = el.getAttribute("data-RDGE-id");
245 if(isShape) {
246 // TODO - Need more info about the shape
247 selection = "canvas";
248 controller = "shape";
249 isShape = true;
250 } else {
251 selection = "canvas";
252 controller = "canvas";
253 }
254 break;
255 case "shape":
256 break;
257 }
258 this.makeElementModel(el, selection, controller, isShape);
259 if(el.elementModel && el.elementModel.props3D) {
260 el.elementModel.props3D.init(el, (selection === "Stage"));
261 }
262 }
263 },
264
265 ///// Removes all child nodes and returns node 145 ///// Removes all child nodes and returns node
266 ///// Accepts a single node, or an array of dom nodes 146 ///// Accepts a single node, or an array of dom nodes
267 empty : { 147 empty : {