From f91e64235eb03c889ff4f5577c3e3480cd0d787f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 13 Apr 2012 00:30:19 -0700 Subject: removing _undo array and _targets array and use object instead of matching arrays to set properties Signed-off-by: Valerio Virgillito --- js/controllers/elements/canvas-controller.js | 8 ---- js/controllers/elements/element-controller.js | 19 +++------ js/controllers/elements/stage-controller.js | 58 +++++++++++---------------- 3 files changed, 28 insertions(+), 57 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index b5df3911..7af7e824 100755 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js @@ -33,13 +33,5 @@ exports.CanvasController = Montage.create(ElementController, { ElementController.setProperty(el, p, value); } } - }, - - setProperties: { - value: function(el, props, index) { - for(var p in props) { - el.elementModel.controller.setProperty(el, p, props[p][index]); - } - } } }); \ No newline at end of file diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 0f17dd46..35a543ac 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -48,16 +48,6 @@ exports.ElementController = Montage.create(Component, { setProperties: { value: function(element, properties) { - /* Array of properties is not supported yet - if(Array.isArray(properties)) { - - elements.forEach(function(property) { - this.application.ninja.stylesController.setElementStyle(element, p, props[p][index]); - }); - } else { - } - */ - for(var property in properties) { this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); } @@ -239,15 +229,16 @@ exports.ElementController = Montage.create(Component, { // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat" set3DProperties: { - value: function(el, props, index, update3DModel) { - var dist = props[index]["dist"], - mat = props[index]["mat"]; + value: function(el, props, update3DModel) { + var dist = props["dist"], + mat = props["mat"]; + this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform-style", "preserve-3d"); // TODO - We don't support perspective on individual elements yet -// this.application.ninja.stylesController.setElementStyle(el, "-webkit-perspective", dist); + // this.application.ninja.stylesController.setElementStyle(el, "-webkit-perspective", dist); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index f376e40f..3ef7dacc 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -31,46 +31,34 @@ exports.StageController = Montage.create(ElementController, { } }, + // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat" set3DProperties: { - value: function(el, props, index, update3DModel) { - var dist = props[index]["dist"], - mat = props[index]["mat"]; - this.application.ninja.stylesController.setElementStyle(el, - "-webkit-transform", - "perspective(" + dist + ") " + - "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", - true); - - el.elementModel.props3D.matrix3d = mat; - el.elementModel.props3D.perspectiveDist = dist; - - // TODO - Move this to matrix class - if(this._isRotated(mat)) - { - this.application.ninja.currentDocument.stageBG.style.display = "none"; - } - else - { - this.application.ninja.stylesController.setElementStyle(this.application.ninja.currentDocument.stageBG, - "-webkit-transform", - "perspective(" + dist + ") " + - "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", - true); - - this.application.ninja.currentDocument.stageBG.elementModel.props3D.matrix3d = mat; - this.application.ninja.currentDocument.stageBG.elementModel.props3D.perspectiveDist = dist; - this.application.ninja.currentDocument.stageBG.style.display = "block"; - } + value: function(el, props, update3DModel) { + var dist = props["dist"], mat = props["mat"]; + this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true); + + el.elementModel.props3D.matrix3d = mat; + el.elementModel.props3D.perspectiveDist = dist; - this.application.ninja.stage.updatedStage = true; + // TODO - Move this to matrix class + if(this._isRotated(mat)) { + this.application.ninja.currentDocument.stageBG.style.display = "none"; + } else { + this.application.ninja.stylesController.setElementStyle(this.application.ninja.currentDocument.stageBG, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true); - if(update3DModel) - { - this._update3DProperties(el, mat, dist); + this.application.ninja.currentDocument.stageBG.elementModel.props3D.matrix3d = mat; + this.application.ninja.currentDocument.stageBG.elementModel.props3D.perspectiveDist = dist; + this.application.ninja.currentDocument.stageBG.style.display = "block"; + } + + this.application.ninja.stage.updatedStage = true; + + if(update3DModel) { + this._update3DProperties(el, mat, dist); + } } - } - }, + }, getProperty: { value: function(el, p) { -- cgit v1.2.3