aboutsummaryrefslogtreecommitdiff
path: root/js/panels/components-panel.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/components-panel.reel')
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js64
1 files changed, 28 insertions, 36 deletions
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js
index 5a9d2ca5..e6b7a6e3 100755
--- a/js/panels/components-panel.reel/components-panel.js
+++ b/js/panels/components-panel.reel/components-panel.js
@@ -4,11 +4,11 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component,
9 NJUtils = require("js/lib/NJUtils").NJUtils; 9 ElementController = require("js/controllers/elements/element-controller").ElementController,
10 ClassUUID = require("js/components/core/class-uuid").ClassUuid, 10 ClassUUID = require("js/components/core/class-uuid").ClassUuid,
11 PIData = require("js/data/pi/pi-data").PiData; 11 PIData = require("js/data/pi/pi-data").PiData;
12 12
13String.prototype.capitalizeFirstChar = function() { 13String.prototype.capitalizeFirstChar = function() {
14 return this.charAt(0).toUpperCase() + this.slice(1); 14 return this.charAt(0).toUpperCase() + this.slice(1);
@@ -273,28 +273,35 @@ exports.ComponentsPanel = Montage.create(Component, {
273 that = this; 273 that = this;
274 element = this.makeComponent(component.component); 274 element = this.makeComponent(component.component);
275 275
276 this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { 276 this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element,
277 {name: component.name, path: component.module, firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this}},
278 function(instance, element) {
277 279
278 //var pos = that.getStageCenter(); 280 //var pos = that.getStageCenter();
279 281
280 var styles = { 282 var styles = {
281 'position': 'absolute', 283 'position': 'absolute',
282 'left' : that.dragPosition[0] + 'px', 284 'left' : that.dragPosition[0] + 'px',
283 'top' : that.dragPosition[1] + 'px' 285 'top' : that.dragPosition[1] + 'px'
284 }; 286 };
285 287
286 var defaultStyles = component.defaultStyles; 288 var defaultStyles = component.defaultStyles;
287 if(defaultStyles) { 289 if(defaultStyles) {
288 for(var n in defaultStyles) { 290 for(var n in defaultStyles) {
289 styles[n] = defaultStyles[n]; 291 styles[n] = defaultStyles[n];
292 }
290 } 293 }
291 }
292
293 that.application.ninja.currentDocument.model.setComponentInstance(instance, element);
294 294
295 that.application.ninja.elementMediator.addElements(element, styles); 295 //that.application.ninja.elementMediator.addElements(element, styles);
296 }); 296 ElementController.addElement(element, styles);
297 });
298
299 }
300 },
297 301
302 componentInstanceOnFirstDraw: {
303 value: function(instance) {
304 this.application.ninja.elementMediator.addElements(instance.element);
298 } 305 }
299 }, 306 },
300 307
@@ -305,75 +312,60 @@ exports.ComponentsPanel = Montage.create(Component, {
305 switch(name) { 312 switch(name) {
306 case "anchor": 313 case "anchor":
307 el = document.application.njUtils.make("a", null, this.application.ninja.currentDocument); 314 el = document.application.njUtils.make("a", null, this.application.ninja.currentDocument);
308 document.application.njUtils.createModelForComponent(el, "Anchor");
309 el.setAttribute("href", "http://www.motorola.com"); 315 el.setAttribute("href", "http://www.motorola.com");
310 el.innerHTML = "link"; 316 el.innerHTML = "link";
311 break; 317 break;
312 case "button": 318 case "button":
313 el = document.application.njUtils.make(name, null, this.application.ninja.currentDocument); 319 el = document.application.njUtils.make(name, null, this.application.ninja.currentDocument);
314 document.application.njUtils.createModelForComponent(el, "Button");
315 el.setAttribute("type", "button"); 320 el.setAttribute("type", "button");
316 el.innerHTML = "Button"; 321 el.innerHTML = "Button";
317 break; 322 break;
318 case "checkbox": 323 case "checkbox":
319 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); 324 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument);
320 document.application.njUtils.createModelForComponent(el, "Checkbox");
321 el.setAttribute("type", "checkbox"); 325 el.setAttribute("type", "checkbox");
322 break; 326 break;
323 case "imageComponent": 327 case "imageComponent":
324 el = document.application.njUtils.make("image", null, this.application.ninja.currentDocument); 328 el = document.application.njUtils.make("image", null, this.application.ninja.currentDocument);
325 document.application.njUtils.createModelForComponent(el, "Image");
326 el.setAttribute("width", 200); 329 el.setAttribute("width", 200);
327 el.setAttribute("height", 200); 330 el.setAttribute("height", 200);
328 break; 331 break;
329 case "numberInput": 332 case "numberInput":
330 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); 333 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument);
331 document.application.njUtils.createModelForComponent(el, "Number Input");
332 el.setAttribute("type", "number"); 334 el.setAttribute("type", "number");
333 break; 335 break;
334 case "select": 336 case "select":
335 el = document.application.njUtils.make("select", null, this.application.ninja.currentDocument); 337 el = document.application.njUtils.make("select", null, this.application.ninja.currentDocument);
336 document.application.njUtils.createModelForComponent(el, "SelectInput");
337 break; 338 break;
338 case "radioButton": 339 case "radioButton":
339 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); 340 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument);
340 document.application.njUtils.createModelForComponent(el, "Radio Button");
341 el.setAttribute("type", "radio"); 341 el.setAttribute("type", "radio");
342 break; 342 break;
343 case "rangeInput": 343 case "rangeInput":
344 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); 344 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument);
345 document.application.njUtils.createModelForComponent(el, "Range Input");
346 el.setAttribute("type", "range"); 345 el.setAttribute("type", "range");
347 break; 346 break;
348 case "textfield": 347 case "textfield":
349 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); 348 el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument);
350 document.application.njUtils.createModelForComponent(el, "Textfield");
351 el.setAttribute("type", "text"); 349 el.setAttribute("type", "text");
352 break; 350 break;
353 case "textarea": 351 case "textarea":
354 el = document.application.njUtils.make("textarea", null, this.application.ninja.currentDocument); 352 el = document.application.njUtils.make("textarea", null, this.application.ninja.currentDocument);
355 document.application.njUtils.createModelForComponent(el, "Textarea");
356 break; 353 break;
357 case "toggleButton": 354 case "toggleButton":
358 el = document.application.njUtils.make("button", null, this.application.ninja.currentDocument); 355 el = document.application.njUtils.make("button", null, this.application.ninja.currentDocument);
359 document.application.njUtils.createModelForComponent(el, "Toggle Button");
360 el.innerHTML = "Off"; 356 el.innerHTML = "Off";
361 break; 357 break;
362 case "map": 358 case "map":
363 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); 359 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
364 document.application.njUtils.createModelForComponent(el, "Map");
365 break; 360 break;
366 case "feedreader": 361 case "feedreader":
367 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); 362 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
368 document.application.njUtils.createModelForComponent(el, "Feed Reader");
369 break; 363 break;
370 case "picasa-carousel": 364 case "picasa-carousel":
371 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); 365 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
372 document.application.njUtils.createModelForComponent(el, "Picasa Carousel");
373 break; 366 break;
374 case "youtube-channel": 367 case "youtube-channel":
375 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); 368 el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
376 document.application.njUtils.createModelForComponent(el, "Youtube Channel");
377 break; 369 break;
378 370
379 } 371 }