From 7fcb10270f9e19415f8452c261c2d0c86916a29a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:54:02 -0700 Subject: fixed the 3d grid when switching documents and some cleanup Signed-off-by: Valerio Virgillito --- js/models/app-model.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'js/models') diff --git a/js/models/app-model.js b/js/models/app-model.js index 1c599a32..ceba653e 100755 --- a/js/models/app-model.js +++ b/js/models/app-model.js @@ -9,6 +9,32 @@ var Montage = require("montage/core/core").Montage, exports.AppModel = Montage.create(Component, { + _currentDocument: { + value : null + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + if(this._currentDocument && this._currentDocument.currentView === "design") { + this._currentDocument.model.draw3DGrid = this.show3dGrid; + } + + this._currentDocument = value; + + if(this._currentDocument && this._currentDocument.currentView === "design") { + this.show3dGrid = this._currentDocument.model.draw3DGrid; + } + + } + }, + _livePreview: { value: false }, -- cgit v1.2.3 From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/models/element-model.js | 96 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index 966158e4..ea25e5b1 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -10,7 +10,101 @@ var Montage = require("montage/core/core").Montage, ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory, PiData = require("js/data/pi/pi-data").PiData; -exports.ElementModel = Montage.create(Montage, { +var modelGenerator = exports.modelGenerator = function() { + var info = getInfoForElement(this); + + Object.defineProperty(this, "_model", { + configurable: true, + enumerable: false, + writable: true, + value: Montage.create(elmo, { + type: { value: info.type}, + selection: { value: info.selection}, + controller: { value: info.controller}, + pi: { value: info.pi}, + props3D: { value: info.props3d}, + shapeModel: { value: info.shapeModel}, + isShape: { value: info.isShape} + }) + }); + + if(this._model.selection === "body") { + this._model.props3D.init(this, true); + } else { + this._model.props3D.init(this, false); + } + + return this._model; +}; + +var getInfoForElement = function(el) { + var elementName, controller, pi, shapeModel = null, isShape = false, isComponent = false; + + elementName = el.nodeName.toLowerCase(); + controller = elementNameToController(elementName); + pi = elementNameToPi(elementName); + + // Element is a shape + if(el.getAttribute("data-RDGE-id")) { + controller = "shape"; + shapeModel = Montage.create(ShapeModel); + isShape = true; + } + + // TODO: Add this in case there is no controller for the component + /* + if(el.getAttribute("data-montage-id")) { + elementName = null; + this.isComponent = true; + } + */ + + // Element is a component + if(el.controller) { + var componentInfo = Montage.getInfoForObject(el.controller); + var componentName = componentInfo.objectName;//.toLowerCase(); + + controller = "component"; + elementName = componentName; + pi = elementNameToPi(componentName.replace(/\s+/g, '')); + isComponent = true; + } + + return { + type: el.nodeName, + selection: elementName, + controller: ControllerFactory.getController(controller), + pi: pi, + props3d: Montage.create(Properties3D), + shapeModel: shapeModel, + isShape: isShape, + isComponent: isComponent + } +}; + +var elementNameToController = function(name) { + if(name === "div" || name === "custom") { + return "block"; + } else if(name === "img") { + return "image"; + } else { + return name; + } +}; + +var elementNameToPi = function(name) { + if(!name) return null; + + var piString = name + "Pi"; + + if(!PiData.hasOwnProperty(piString)) { + piString = "blockPi"; + } + + return piString; +}; + +var elmo = exports.ElementModel = Montage.create(Montage, { key: { value: "_model_"}, type: { value: null }, // Tag type that was created -- cgit v1.2.3 From 488ae8d98deb30009cb8b5b2da464fe52940050b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 6 Jun 2012 16:20:25 -0700 Subject: fixing a rotation and zoom bug Signed-off-by: Valerio Virgillito --- js/models/element-model.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index ea25e5b1..c9fb58d8 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -28,9 +28,7 @@ var modelGenerator = exports.modelGenerator = function() { }) }); - if(this._model.selection === "body") { - this._model.props3D.init(this, true); - } else { + if(this._model.selection !== "body") { this._model.props3D.init(this, false); } -- cgit v1.2.3 From 21098080e7716379ceefefca5f3cc1850ac78fa7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 7 Jun 2012 15:17:19 -0700 Subject: Body PI fixes. Signed-off-by: Nivesh Rajbhandari --- js/models/element-model.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js/models') diff --git a/js/models/element-model.js b/js/models/element-model.js index c9fb58d8..76f15b21 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -49,6 +49,12 @@ var getInfoForElement = function(el) { isShape = true; } + if(el.nodeName.toLowerCase() === "ninja-content") { + elementName = "body"; + controller = elementNameToController(elementName); + pi = elementNameToPi(elementName); + } + // TODO: Add this in case there is no controller for the component /* if(el.getAttribute("data-montage-id")) { -- cgit v1.2.3