From cf61d1545bffb25a807706fb56b2fe7f291adc2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 6 Mar 2012 09:45:23 -0800 Subject: Create element models based on nodeName. Signed-off-by: Nivesh Rajbhandari --- js/lib/NJUtils.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'js/lib/NJUtils.js') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index e16715a4..4f1082f9 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -116,7 +116,39 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: Selection and model should be based on the element type makeModelFromElement: { value: function(el) { - this.makeElementModel(el, "Div", "block", false); + var selection = "div", + controller = "block", + isShape = false; + switch(el.nodeName.toLowerCase()) + { + case "div": + break; + case "img": + selection = "image"; + controller = "image"; + break; + case "video": + selection = "video"; + controller = "video"; + break; + case "canvas": + isShape = el.getAttribute("data-RDGE-id"); + if(isShape) + { + // TODO - Need more info about the shape + selection = "canvas"; + controller = "shape"; + } + else + { + selection = "canvas"; + controller = "canvas"; + } + break; + case "shape": + break; + } + this.makeElementModel(el, selection, controller, isShape); } }, -- cgit v1.2.3 From c0a1164b5e84098e005f076de5eddd0e60387286 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 20 Mar 2012 14:21:29 -0700 Subject: Fixing the selection issues Signed-off-by: Valerio Virgillito --- js/lib/NJUtils.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'js/lib/NJUtils.js') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 4f1082f9..904aa41e 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -96,15 +96,45 @@ exports.NJUtils = Object.create(Object.prototype, { value: function(el, selection, controller, isShape) { var p3d = Montage.create(Properties3D).init(el); var shapeProps = null; + var pi = controller + "Pi"; + if(isShape) { shapeProps = Montage.create(ShapeModel); } + if(el.controller) { + + var componentInfo = Montage.getInfoForObject(el.controller); + var componentName = componentInfo.objectName.toLowerCase(); + + controller = "component"; + isShape = false; + + switch(componentName) { + case "feedreader": + selection = "Feed Reader"; + pi = "FeedReaderPi"; + break; + case "map": + selection = "Map"; + pi = "MapPi"; + break; + case "youtubechannel": + selection = "Youtube Channel"; + pi = "YoutubeChannelPi"; + break; + case "picasacarousel": + selection = "Picasa Carousel"; + pi = "PicasaCarouselPi"; + break; + } + } + el.elementModel = Montage.create(ElementModel, { type: { value: el.nodeName}, selection: { value: selection}, controller: { value: ControllerFactory.getController(controller)}, - pi: { value: controller + "Pi"}, + pi: { value: pi}, props3D: { value: p3d}, shapeModel: { value: shapeProps} }); -- cgit v1.2.3