diff options
author | Ananya Sen | 2012-05-31 10:13:40 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-31 10:13:40 -0700 |
commit | 286457b4f23974277274ba388afd283e8aa085cb (patch) | |
tree | c21bf791e7c4f572d12f97987ea6b89e74da67fe /js/panels/components-panel.reel/components-panel.js | |
parent | 4d9b481c58090e8f1fc7b0e9d73a81b0f49cccc8 (diff) | |
parent | d49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff) | |
download | ninja-286457b4f23974277274ba388afd283e8aa085cb.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Conflicts:
js/controllers/styles-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/panels/components-panel.reel/components-panel.js')
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 4169423b..3ad1763d 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js | |||
@@ -7,8 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var 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 | NJUtils = require("js/lib/NJUtils").NJUtils; |
10 | 10 | ClassUUID = require("js/components/core/class-uuid").ClassUuid, | |
11 | var PIData = require("js/data/pi/pi-data").PiData; | 11 | PIData = require("js/data/pi/pi-data").PiData; |
12 | 12 | ||
13 | String.prototype.capitalizeFirstChar = function() { | 13 | String.prototype.capitalizeFirstChar = function() { |
14 | return this.charAt(0).toUpperCase() + this.slice(1); | 14 | return this.charAt(0).toUpperCase() + this.slice(1); |
@@ -278,7 +278,7 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
278 | that = this; | 278 | that = this; |
279 | element = this.makeComponent(component.component); | 279 | element = this.makeComponent(component.component); |
280 | 280 | ||
281 | this.application.ninja.currentDocument._window.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { | 281 | this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { |
282 | 282 | ||
283 | //var pos = that.getStageCenter(); | 283 | //var pos = that.getStageCenter(); |
284 | 284 | ||
@@ -295,21 +295,13 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | instance.addEventListener('firstDraw', that, false); | 298 | that.application.ninja.currentDocument.model.setComponentInstance(instance, element); |
299 | |||
300 | that.application.ninja.currentDocument.setComponentInstance(instance, element); | ||
301 | 299 | ||
302 | that.application.ninja.elementMediator.addElements(element, styles); | 300 | that.application.ninja.elementMediator.addElements(element, styles); |
303 | }); | 301 | }); |
304 | 302 | ||
305 | } | 303 | } |
306 | }, | 304 | }, |
307 | |||
308 | handleFirstDraw: { | ||
309 | value: function (e) { | ||
310 | NJevent("addComponentFirstDraw"); | ||
311 | } | ||
312 | }, | ||
313 | 305 | ||
314 | makeComponent: { | 306 | makeComponent: { |
315 | value: function(name) { | 307 | value: function(name) { |
@@ -346,7 +338,7 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
346 | break; | 338 | break; |
347 | case "select": | 339 | case "select": |
348 | el = document.application.njUtils.make("select", null, this.application.ninja.currentDocument); | 340 | el = document.application.njUtils.make("select", null, this.application.ninja.currentDocument); |
349 | document.application.njUtils.createModelForComponent(el, "Select"); | 341 | document.application.njUtils.createModelForComponent(el, "SelectInput"); |
350 | break; | 342 | break; |
351 | case "radioButton": | 343 | case "radioButton": |
352 | el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); | 344 | el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); |
@@ -366,7 +358,7 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
366 | break; | 358 | break; |
367 | case "textarea": | 359 | case "textarea": |
368 | el = document.application.njUtils.make("textarea", null, this.application.ninja.currentDocument); | 360 | el = document.application.njUtils.make("textarea", null, this.application.ninja.currentDocument); |
369 | document.application.njUtils.createModelForComponent(el, "TextArea"); | 361 | document.application.njUtils.createModelForComponent(el, "Textarea"); |
370 | break; | 362 | break; |
371 | case "toggleButton": | 363 | case "toggleButton": |
372 | el = document.application.njUtils.make("button", null, this.application.ninja.currentDocument); | 364 | el = document.application.njUtils.make("button", null, this.application.ninja.currentDocument); |
@@ -392,6 +384,8 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
392 | 384 | ||
393 | } | 385 | } |
394 | 386 | ||
387 | el.setAttribute("data-montage-id", ClassUUID.generate()); | ||
388 | |||
395 | return el; | 389 | return el; |
396 | } | 390 | } |
397 | }, | 391 | }, |
@@ -404,8 +398,8 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
404 | //if(!this.centerStage) { | 398 | //if(!this.centerStage) { |
405 | var top, left; | 399 | var top, left; |
406 | 400 | ||
407 | top = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "height"))) / 2); | 401 | top = (this.application.ninja.stage.canvas.height / 2); // ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.model.documentRoot, "height"))) / 2); |
408 | left = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "width"))) / 2); | 402 | left = (this.application.ninja.stage.canvas.width / 2); //~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.model.documentRoot, "width"))) / 2); |
409 | //this.centerStage = [top, left]; | 403 | //this.centerStage = [top, left]; |
410 | return [left, top]; | 404 | return [left, top]; |
411 | //} | 405 | //} |