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/document/document-html.js | 6 ++++++ js/document/html-document.js | 10 +++++++--- js/lib/NJUtils.js | 14 ++++++------- js/models/element-model.js | 35 ++++++++++++++++++--------------- js/panels/properties.reel/properties.js | 1 + 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/js/document/document-html.js b/js/document/document-html.js index b19ca0d0..24eb4f47 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -310,6 +310,12 @@ exports.HtmlDocument = Montage.create(Component, { } }, + GetElementFromPoint: { + value: function(x, y) { + return this._window.getElement(x,y); + } + }, + // Handler for user content main reel. Gets called once the main reel of the template // gets deserialized. // Setting up the currentSelectedContainer to the document body. diff --git a/js/document/html-document.js b/js/document/html-document.js index 3876670c..3dbf96ce 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -759,10 +759,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { //TODO Finish this implementation once we start caching Core Elements // Assign a model to the UserContent and add the ViewPort reference to it. NJUtils.makeElementModel(this.documentRoot, "Stage", "stage"); - //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport"); - NJUtils.makeElementModel(this.stageBG, "Stage", "stage"); + NJUtils.makeElementModel(this.stageBG, "Stage", "stage"); NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage"); - + + // Initialize the 3D properties + this.documentRoot.elementModel.props3D.init(this.documentRoot, true); + this.stageBG.elementModel.props3D.init(this.stageBG, true); + this.iframe.contentWindow.document.getElementById("Viewport").elementModel.props3D.init(this.iframe.contentWindow.document.getElementById("Viewport"), true); + for(i = 0; i < this._stylesheets.length; i++) { if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) { this.documentRoot.elementModel.defaultRule = this._stylesheets[i]; diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 67bb59c4..dae128e4 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,10 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { + //el.elementModel = Montage.create(ElementModel).initialize(el.nodeName, selection, controller, isShape); + var p3d = Montage.create(Properties3D); - if(selection === "Stage") { - p3d.init(el, true); - } + var shapeProps = null; var pi = controller + "Pi"; @@ -143,6 +143,7 @@ exports.NJUtils = Object.create(Object.prototype, { isShape: { value: isShape} }); + } }, @@ -167,15 +168,12 @@ exports.NJUtils = Object.create(Object.prototype, { break; case "canvas": isShape = el.getAttribute("data-RDGE-id"); - if(isShape) - { + if(isShape) { // TODO - Need more info about the shape selection = "canvas"; controller = "shape"; isShape = true; - } - else - { + } else { selection = "canvas"; controller = "canvas"; } 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; diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index b21014c1..ee90cd64 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -174,6 +174,7 @@ exports.Properties = Montage.create(Component, { handleSelectionChange: { value: function(event) { if(event.detail.isDocument) { + if(this.application.ninja.currentDocument.documentRoot.nodeName.toLowerCase() === "body") return; this.displayStageProperties(); } else { if(this.application.ninja.selectedElements.length === 1) { -- cgit v1.2.3