From 44d75ed17d56055ed9dbb8f91867bbdbc68924fa Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 18 Mar 2012 22:21:14 -0700 Subject: fixing the selection of components. Temporary workaround for now. Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 13 ++++++++----- js/controllers/selection-controller.js | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 83450d0f..260ee8a0 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -11,6 +11,8 @@ exports.ComponentController = Montage.create(ElementController, { getProperty: { value: function(el, prop) { + var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + switch(prop) { case "id": case "class": @@ -19,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, { case "width": case "height": if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { - return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; + return component[prop]; } else { return ElementController.getProperty(el, prop, true); } default: - return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; + return component[prop]; } } }, setProperty: { value: function(el, p, value) { + var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + switch(p) { case "id": case "class": @@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, { case "width": case "height": if(el.nodeName === "IMG" && (p === "width" || p === "height")) { - this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; + component[p] = value; } else { ElementController.setProperty(el, p, value); } break; default: if(p === "min" || p === "max") value = parseFloat(value); - - this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; + component[p] = value; break; } diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 154fb7f8..fa82d4cc 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -6,7 +6,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + NJUtils = require("js/lib/NJUtils").NJUtils; exports.SelectionController = Montage.create(Component, { @@ -154,6 +155,28 @@ exports.SelectionController = Montage.create(Component, { this._isDocument = true; } + if(item && item.controller && !item.elementModel.isComponent) { + var componentInfo = Montage.getInfoForObject(item.controller); + var componentName = componentInfo.objectName.toLowerCase(); + switch(componentName) { + case "feedreader": + NJUtils.makeElementModel(item, "Feed Reader", "component", false); + item.elementModel.pi = "FeedReaderPi"; + item.elementModel.isComponent = true; + break; + case "map": + NJUtils.makeElementModel(item, "Map", "component", false); + item.elementModel.pi = "MapPi"; + item.elementModel.isComponent = true; + break; + case "youtubechannel": + NJUtils.makeElementModel(item, "Youtube Channel", "component", false); + item.elementModel.pi = "YoutubeChannelPi"; + item.elementModel.isComponent = true; + break; + } + } + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); } -- cgit v1.2.3