From ac24875103799c7198b1b1cb01d15b415d118354 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 17:12:37 -0700 Subject: removing the search bar component Signed-off-by: Valerio Virgillito --- js/panels/components-panel.reel/components-panel.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'js/panels/components-panel.reel/components-panel.js') diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 3ad1763d..5a9d2ca5 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -39,11 +39,6 @@ exports.ComponentsPanel = Montage.create(Component, { "dataFile" : "node_modules/components-data/picasa-carousel.json", "component": "picasa-carousel" }, - { - "text": "Search Bar", - "dataFile" : "node_modules/components-data/searchfield.json", - "component": "searchfield" - }, { "text": "Youtube Channel", "dataFile" : "node_modules/components-data/youtube-channel.json", @@ -351,7 +346,6 @@ exports.ComponentsPanel = Montage.create(Component, { el.setAttribute("type", "range"); break; case "textfield": - case "searchfield": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); document.application.njUtils.createModelForComponent(el, "Textfield"); el.setAttribute("type", "text"); -- cgit v1.2.3 From 563935933c191093b8ccd88fd1377775c5641b0d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 4 Jun 2012 23:33:32 -0700 Subject: components fix: adding a first draw event to components Adding a first draw allows the component to have the right element so that ninja can use it's controller to get the component instance Signed-off-by: Valerio Virgillito --- .../components-panel.reel/components-panel.js | 56 ++++++++++++++-------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'js/panels/components-panel.reel/components-panel.js') diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 5a9d2ca5..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 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - NJUtils = require("js/lib/NJUtils").NJUtils; - ClassUUID = require("js/components/core/class-uuid").ClassUuid, - PIData = require("js/data/pi/pi-data").PiData; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + ElementController = require("js/controllers/elements/element-controller").ElementController, + ClassUUID = require("js/components/core/class-uuid").ClassUuid, + PIData = require("js/data/pi/pi-data").PiData; String.prototype.capitalizeFirstChar = function() { return this.charAt(0).toUpperCase() + this.slice(1); @@ -273,28 +273,42 @@ exports.ComponentsPanel = Montage.create(Component, { that = this; element = this.makeComponent(component.component); - this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, + {name: component.name, path: component.module, firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this}}, + function(instance, element) { - //var pos = that.getStageCenter(); + //var pos = that.getStageCenter(); - var styles = { - 'position': 'absolute', - 'left' : that.dragPosition[0] + 'px', - 'top' : that.dragPosition[1] + 'px' - }; + var styles = { + 'position': 'absolute', + 'left' : that.dragPosition[0] + 'px', + 'top' : that.dragPosition[1] + 'px' + }; - var defaultStyles = component.defaultStyles; - if(defaultStyles) { - for(var n in defaultStyles) { - styles[n] = defaultStyles[n]; + var defaultStyles = component.defaultStyles; + if(defaultStyles) { + for(var n in defaultStyles) { + styles[n] = defaultStyles[n]; + } } - } - - that.application.ninja.currentDocument.model.setComponentInstance(instance, element); - that.application.ninja.elementMediator.addElements(element, styles); - }); +// that.application.ninja.currentDocument.model.setComponentInstance(instance, element); + //that.application.ninja.elementMediator.addElements(element, styles); + ElementController.addElement(element, styles); + }); + + } + }, + + componentInstanceOnFirstDraw: { + value: function(instance) { + // Temporary hack until the element model rework goes into place + // TODO: Remove this once we have the element model define property code in place. + if(!instance.element.elementModel) { + this.application.njUtils.makeModelFromElement(instance.element); + } + this.application.ninja.elementMediator.addElements(instance.element); } }, -- cgit v1.2.3