From 4b5cc9cf1f01552f61c08b9299b6e99366432e03 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Apr 2012 15:36:03 -0700 Subject: Added a body controller Signed-off-by: Valerio Virgillito --- js/models/properties-3d.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/models') diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index c1270c3b..e571e505 100755 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -5,8 +5,7 @@ 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, - NJUtils = require("js/lib/NJUtils").NJUtils; + Component = require("montage/ui/component").Component; exports.Properties3D = Montage.create(Component, { -- cgit v1.2.3 From 1ccc4d6dcff232b00763a5a49d7ad7a91f78ad3f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 26 Apr 2012 13:24:51 -0700 Subject: Fixing the element model and adding get element Signed-off-by: Valerio Virgillito --- js/models/element-model.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index fa02fd38..0e199a67 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -4,7 +4,10 @@ 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; +var Montage = require("montage/core/core").Montage, + Properties3D = require("js/models/properties-3d").Properties3D, + ShapeModel = require("js/models/shape-model").ShapeModel, + ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory; exports.ElementModel = Montage.create(Montage, { key: { value: "_model_"}, @@ -16,36 +19,36 @@ exports.ElementModel = Montage.create(Montage, { id: { value: "" }, classList: { value: null }, - defaultRule: { value: null }, top: { value: null }, left: { value: null }, width: { value: null }, height: { value: null }, - - /** - * Properties 3D - */ props3D: { value: null }, - /** - * Shape Info - */ isShape: { value: false }, shapeModel: { value: null }, - - /** - * SnapManager 2d Snap Cache Info - */ isIn2DSnapCache : { value: false }, - /** - * Color info - */ fill: { value: null }, stroke: { value: null }, + initialize: { + value: function(type, selection, controller, isShape) { + /* + this.type = type; + this.selection = selection; + + controller: { value: ControllerFactory.getController(controller)}, + pi: { value: pi}, + props3D: { value: p3d}, + shapeModel: { value: shapeProps}, + isShape: { value: isShape} + */ + } + }, + getProperty: { value: function(property) { var key = this.key + property; -- cgit v1.2.3 From d2a5fcbaed6b3c3377edecbc27e6a2818b79be40 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 2 May 2012 15:34:49 -0700 Subject: Nesting absolute element in the Tag tool. Refactoring element creation and element models Signed-off-by: Valerio Virgillito --- js/models/element-model.js | 61 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index 0e199a67..72d61806 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -4,10 +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, - Properties3D = require("js/models/properties-3d").Properties3D, - ShapeModel = require("js/models/shape-model").ShapeModel, - ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory; +var Montage = require("montage/core/core").Montage, + Properties3D = require("js/models/properties-3d").Properties3D, + ShapeModel = require("js/models/shape-model").ShapeModel, + ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory, + PiData = require("js/data/pi/pi-data").PiData; exports.ElementModel = Montage.create(Montage, { key: { value: "_model_"}, @@ -35,17 +36,47 @@ exports.ElementModel = Montage.create(Montage, { stroke: { value: null }, initialize: { - value: function(type, selection, controller, isShape) { - /* - this.type = type; - this.selection = selection; - - controller: { value: ControllerFactory.getController(controller)}, - pi: { value: pi}, - props3D: { value: p3d}, - shapeModel: { value: shapeProps}, - isShape: { value: isShape} - */ + value: function(el, isShape) { + var elementName, controller; + + elementName = el.nodeName.toLowerCase(); + controller = this.elementNameToController(elementName); + + this.type = el.nodeName; + this.selection = elementName; + this.controller = ControllerFactory.getController(controller); + this.pi = this.elementNameToPi(elementName); + this.props3D = Montage.create(Properties3D); + + //shapeModel: { value: shapeProps}, +// isShape: { value: isShape} + + return this; + + } + }, + + elementNameToController: { + value: function(name) { + if(name === "div" || name === "custom") { + return "block"; + } else if(name === "img") { + return "image"; + } else { + return name; + } + } + }, + + elementNameToPi: { + value: function(name) { + var piString = name + "Pi"; + + if(!PiData.hasOwnProperty(piString)) { + piString = "blockPi"; + } + + return piString; } }, -- cgit v1.2.3 From 2078bfa96afaef40acb4edac99848ba55e808ef1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 15:15:21 -0700 Subject: Refactor creating elements. Removed makeNJElement and separated the model creation Signed-off-by: Valerio Virgillito --- js/models/element-model.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index 72d61806..966158e4 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -32,24 +32,38 @@ exports.ElementModel = Montage.create(Montage, { shapeModel: { value: null }, isIn2DSnapCache : { value: false }, + isComponent: { value: false }, + fill: { value: null }, stroke: { value: null }, initialize: { - value: function(el, isShape) { + value: function(el, isShape, selection, isComponent) { var elementName, controller; elementName = el.nodeName.toLowerCase(); - controller = this.elementNameToController(elementName); this.type = el.nodeName; - this.selection = elementName; - this.controller = ControllerFactory.getController(controller); - this.pi = this.elementNameToPi(elementName); + this.selection = selection ? selection : elementName; + + if(isComponent) { + controller = "component"; + this.pi = this.elementNameToPi(selection.replace(/\s+/g, '')); + this.isComponent = true; + } else { + controller = this.elementNameToController(elementName); + this.pi = this.elementNameToPi(elementName); + } + this.props3D = Montage.create(Properties3D); - //shapeModel: { value: shapeProps}, -// isShape: { value: isShape} + if(isShape) { + this.controller = ControllerFactory.getController("shape"); + this.shapeModel = Montage.create(ShapeModel); + this.isShape = true; + } else { + this.controller = ControllerFactory.getController(controller); + } return this; -- cgit v1.2.3