diff options
author | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-06-06 07:54:11 -0700 |
commit | cfa1402ac2ce831a83a9d4263d06c452c157a414 (patch) | |
tree | adb8f1f1ad1c4dd1e7e9eee1bd206f1ec338d20c /js/panels/components-panel.reel | |
parent | 8606ee7ec851cb0a971e7556eba5d9386f1b3639 (diff) | |
parent | 5ba54dc275b07e7b2d0ed14751761d1e663d3d14 (diff) | |
download | ninja-cfa1402ac2ce831a83a9d4263d06c452c157a414.tar.gz |
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/panels/components-panel.reel')
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 3ad1763d..0b453c4a 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 | ||
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 | 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 | ||
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); |
@@ -40,11 +40,6 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
40 | "component": "picasa-carousel" | 40 | "component": "picasa-carousel" |
41 | }, | 41 | }, |
42 | { | 42 | { |
43 | "text": "Search Bar", | ||
44 | "dataFile" : "node_modules/components-data/searchfield.json", | ||
45 | "component": "searchfield" | ||
46 | }, | ||
47 | { | ||
48 | "text": "Youtube Channel", | 43 | "text": "Youtube Channel", |
49 | "dataFile" : "node_modules/components-data/youtube-channel.json", | 44 | "dataFile" : "node_modules/components-data/youtube-channel.json", |
50 | "component": "youtube-channel" | 45 | "component": "youtube-channel" |
@@ -278,31 +273,45 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
278 | that = this; | 273 | that = this; |
279 | element = this.makeComponent(component.component); | 274 | element = this.makeComponent(component.component); |
280 | 275 | ||
281 | 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) { | ||
282 | 279 | ||
283 | //var pos = that.getStageCenter(); | 280 | //var pos = that.getStageCenter(); |
284 | 281 | ||
285 | var styles = { | 282 | var styles = { |
286 | 'position': 'absolute', | 283 | 'position': 'absolute', |
287 | 'left' : that.dragPosition[0] + 'px', | 284 | 'left' : that.dragPosition[0] + 'px', |
288 | 'top' : that.dragPosition[1] + 'px' | 285 | 'top' : that.dragPosition[1] + 'px' |
289 | }; | 286 | }; |
290 | 287 | ||
291 | var defaultStyles = component.defaultStyles; | 288 | var defaultStyles = component.defaultStyles; |
292 | if(defaultStyles) { | 289 | if(defaultStyles) { |
293 | for(var n in defaultStyles) { | 290 | for(var n in defaultStyles) { |
294 | styles[n] = defaultStyles[n]; | 291 | styles[n] = defaultStyles[n]; |
292 | } | ||
295 | } | 293 | } |
296 | } | ||
297 | |||
298 | that.application.ninja.currentDocument.model.setComponentInstance(instance, element); | ||
299 | 294 | ||
300 | that.application.ninja.elementMediator.addElements(element, styles); | 295 | // that.application.ninja.currentDocument.model.setComponentInstance(instance, element); |
301 | }); | 296 | |
297 | //that.application.ninja.elementMediator.addElements(element, styles); | ||
298 | ElementController.addElement(element, styles); | ||
299 | }); | ||
302 | 300 | ||
303 | } | 301 | } |
304 | }, | 302 | }, |
305 | 303 | ||
304 | componentInstanceOnFirstDraw: { | ||
305 | value: function(instance) { | ||
306 | // Temporary hack until the element model rework goes into place | ||
307 | // TODO: Remove this once we have the element model define property code in place. | ||
308 | if(!instance.element.elementModel) { | ||
309 | this.application.njUtils.makeModelFromElement(instance.element); | ||
310 | } | ||
311 | this.application.ninja.elementMediator.addElements(instance.element); | ||
312 | } | ||
313 | }, | ||
314 | |||
306 | makeComponent: { | 315 | makeComponent: { |
307 | value: function(name) { | 316 | value: function(name) { |
308 | var el; | 317 | var el; |
@@ -351,7 +360,6 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
351 | el.setAttribute("type", "range"); | 360 | el.setAttribute("type", "range"); |
352 | break; | 361 | break; |
353 | case "textfield": | 362 | case "textfield": |
354 | case "searchfield": | ||
355 | el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); | 363 | el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); |
356 | document.application.njUtils.createModelForComponent(el, "Textfield"); | 364 | document.application.njUtils.createModelForComponent(el, "Textfield"); |
357 | el.setAttribute("type", "text"); | 365 | el.setAttribute("type", "text"); |