From 48d4dd0f0570f4ac3556f228846ed0fd98a674e5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 9 Apr 2012 16:47:56 -0700 Subject: setProperties to the montage undo/redo Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index fda3a3c5..adac1420 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -47,9 +47,19 @@ exports.ElementController = Montage.create(Component, { }, setProperties: { - value: function(el, props, index) { - for(var p in props) { - this.application.ninja.stylesController.setElementStyle(el, p, props[p][index]); + 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]); } } }, -- cgit v1.2.3 From 6885e66a1f668f34699145f0da231c5d4ecbe666 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 10 Apr 2012 11:07:36 -0700 Subject: some code cleanup Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 90 +++++++++------------------ 1 file changed, 29 insertions(+), 61 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index adac1420..b8411ac0 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -75,37 +75,29 @@ exports.ElementController = Montage.create(Component, { // borderSide : "top", "right", "bottom", or "left" getColor: { value: function(el, isFill, borderSide) { - var colorObj, - color, - image; + var colorObj, color, image; // Return cached value if one exists - if(isFill) - { - if(el.elementModel.fill) - { + if(isFill) { + if(el.elementModel.fill) { return el.elementModel.fill; } //TODO: Once logic for color and gradient is established, this needs to be revised color = this.getProperty(el, "background-color"); image = this.getProperty(el, "background-image"); - } - else - { + } else { // Try getting border color from specific side first - if(borderSide) - { + if(borderSide) { color = this.getProperty(el, "border-" + borderSide + "-color"); image = this.getProperty(el, "border-" + borderSide + "-image"); } // If no color was found, look up the shared border color - if(!color && !image) - { - if(el.elementModel.stroke) - { + if(!color && !image) { + if(el.elementModel.stroke) { return el.elementModel.stroke; } + color = this.getProperty(el, "border-color"); image = this.getProperty(el, "border-image"); } @@ -122,17 +114,12 @@ exports.ElementController = Montage.create(Component, { } // Update cache - if(isFill) - { + if(isFill) { el.elementModel.fill = colorObj; - } - else if(!borderSide) - { + } else if(!borderSide) { // TODO - Need to update border style and width also el.elementModel.stroke = colorObj; - } - else - { + } else { // TODO - Should update specific border sides too } @@ -143,10 +130,9 @@ exports.ElementController = Montage.create(Component, { setColor: { value: function(el, color, isFill) { var mode = color.mode; - if(isFill) - { - if(mode) - { + + if(isFill) { + if(mode) { switch (mode) { case 'nocolor': this.setProperty(el, "background-image", "none"); @@ -162,12 +148,10 @@ exports.ElementController = Montage.create(Component, { this.setProperty(el, "background-color", color.color.css); } } + el.elementModel.fill = color; - } - else - { - if(mode) - { + } else { + if(mode) { switch (mode) { case 'nocolor': this.setProperty(el, "border-image", "none"); @@ -177,20 +161,16 @@ exports.ElementController = Montage.create(Component, { case 'gradient': this.setProperty(el, "border-image", color.color.css); this.setProperty(el, "border-color", "none"); - if(color.borderInfo) - { - this.setProperty(el, "border-width", color.borderInfo.borderWidth + - color.borderInfo.borderUnits); + if(color.borderInfo) { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); this.setProperty(el, "border-style", color.borderInfo.borderStyle); } break; default: this.setProperty(el, "border-image", "none"); this.setProperty(el, "border-color", color.color.css); - if(color.borderInfo) - { - this.setProperty(el, "border-width", color.borderInfo.borderWidth + - color.borderInfo.borderUnits); + if(color.borderInfo) { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); this.setProperty(el, "border-style", color.borderInfo.borderStyle); } } @@ -219,8 +199,7 @@ exports.ElementController = Montage.create(Component, { // Routines to get/set 3D properties get3DProperty: { value: function(el, prop) { - if(el.elementModel && el.elementModel.props3D) - { + if(el.elementModel && el.elementModel.props3D) { return el.elementModel.props3D[prop]; } } @@ -228,16 +207,12 @@ exports.ElementController = Montage.create(Component, { getMatrix: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) - { + if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) { return el.elementModel.props3D.matrix3d.slice(0); - } - else - { + } else { var mat; - if (el) - { + if (el) { mat = this.application.ninja.stylesController.getMatrixFromElement(el, false); if (!mat) { mat = Matrix.I(4); @@ -252,12 +227,9 @@ exports.ElementController = Montage.create(Component, { getPerspectiveDist: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) - { + if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { return el.elementModel.props3D.perspectiveDist; - } - else - { + } else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); if(dist == null) { dist = 1400; @@ -274,16 +246,12 @@ exports.ElementController = Montage.create(Component, { 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) + ")"); + this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; - if(update3DModel) - { + if(update3DModel) { this._update3DProperties(el, mat, dist); } } -- cgit v1.2.3 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') 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 From 7ed5215332123d16f819a7a26c651af520a68669 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 13 Apr 2012 16:37:19 -0700 Subject: Fixing the shape border Signed-off-by: Valerio Virgillito --- js/controllers/elements/shapes-controller.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 14cdc473..cd7fa16d 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -74,12 +74,9 @@ exports.ShapesController = Montage.create(CanvasController, { w += delta; h += delta; } - this.application.ninja.elementMediator.setProperties([el], - { "left": [l + "px"], - "top": [t + "px"], - "width": [w + "px"], - "height": [h + "px"] }, - eventType, source ); + + this.application.ninja.elementMediator.setProperties([{element:el, properties:{left: l + "px", top: t + "px", width: w + "px", height:h + "px"}}], eventType, source); + } el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(val); el.elementModel.shapeModel.GLGeomObj.buildBuffers(); -- cgit v1.2.3 From 2a87a750f06003fc62e8e0e73983e14ce24fc7a7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 17 Apr 2012 10:19:20 -0700 Subject: IKNinja-1477 - Cannot preflight Fill color if WebGL Line shape is selected. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 50 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 14cdc473..a446ef05 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -399,8 +399,8 @@ exports.ShapesController = Montage.create(CanvasController, { if(isFill) { // Properties Panel asks for fill color even for shapes that only have strokes - // Check that shape object has a getFillColor method before getting fills - if(el.elementModel.shapeModel.GLGeomObj.getFillColor) + // Check that shape object supports fills + if(el.elementModel.shapeModel.GLGeomObj.canFill) { return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getFillColor()); } @@ -497,28 +497,36 @@ exports.ShapesController = Montage.create(CanvasController, { webGl; if(isFill) { - if(mode) + // skip shape types that don't have fill color + if(el.elementModel.shapeModel.GLGeomObj.canFill) { - switch (mode) { - case 'nocolor': - el.elementModel.shapeModel.GLGeomObj.setFillColor(null); - break; - case 'gradient': - if(el.elementModel.shapeModel.useWebGl) - { - this._setGradientMaterial(el, color.color.gradientMode, isFill); - } - el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops}); - break; - default: - if(el.elementModel.shapeModel.useWebGl) - { - this._setFlatMaterial(el, isFill); - } - webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); - el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); + if(mode) + { + switch (mode) { + case 'nocolor': + el.elementModel.shapeModel.GLGeomObj.setFillColor(null); + break; + case 'gradient': + if(el.elementModel.shapeModel.useWebGl) + { + this._setGradientMaterial(el, color.color.gradientMode, isFill); + } + el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops}); + break; + default: + if(el.elementModel.shapeModel.useWebGl) + { + this._setFlatMaterial(el, isFill); + } + webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); + el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); + } } } + else + { + return; + } } else { -- cgit v1.2.3 From 078208d02205f54808db888bbdbe5f69b3abba4b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 17 Apr 2012 11:53:27 -0700 Subject: Adding back setProperties for canvas because width and height values need to be set as attributes instead of styles. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/canvas-controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index 7af7e824..b8894c18 100755 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js @@ -33,5 +33,13 @@ exports.CanvasController = Montage.create(ElementController, { ElementController.setProperty(el, p, value); } } + }, + + setProperties: { + value: function(element, properties) { + for(var property in properties) { + this.setProperty(element, property, properties[property]); + } + } } }); \ No newline at end of file -- cgit v1.2.3 From c58dc96130c7eb5d964af53e9ad6e80bba5e647f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 18 Apr 2012 17:24:40 -0700 Subject: initial stage web template Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ddaeb061..e56c3e31 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -10,8 +10,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/html-document").HTMLDocument, - TextDocument = require("js/document/text-document").TextDocument, - DocumentController; + TextDocument = require("js/document/text-document").TextDocument; //////////////////////////////////////////////////////////////////////// // var DocumentController = exports.DocumentController = Montage.create(Component, { @@ -19,6 +18,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: false }, + webTemplate: { + value: false + }, + _documents: { value: [] }, @@ -65,6 +68,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("styleSheetDirty", this, false); this.eventManager.addEventListener("addComponentFirstDraw", this, false); + + // Temporary add listeners for the new stage templates + this.eventManager.addEventListener("executeWebpageOpen", this, false); + this.eventManager.addEventListener("executeNewWebpage", this, false); } }, @@ -130,6 +137,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, + handleExecuteWebpageOpen: { + value: function(event) { + this.webTemplate = true; + this.handleExecuteFileOpen(event); + } + }, + + handleExecuteNewWebpage: { + value: function(event) { + this.webTemplate = true; + this.handleExecuteNewFile(event); + } + }, + handleExecuteNewFile: { value: function(event) { var newFileSettings = event._event.settings || {}; @@ -235,7 +256,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.creatingNewFile = true;//flag for timeline to identify new file flow this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); - }else if(!!response && !response.success){ + } else if(!!response && !response.success){ //Todo: restrict directory path to the sandbox, in the dialog itself alert("Unable to create file.\n [Error: Forbidden directory]"); } @@ -313,7 +334,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, switch (doc.extension) { case 'html': case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); break; default: //Open in code view @@ -420,6 +441,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Event Detail: Contains the current ActiveDocument _onOpenDocument: { value: function(doc){ + this.webTemplate = false; this.application.ninja.currentDocument = doc; this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); -- cgit v1.2.3 From e085f15bcef9f84d9a8d39e4b2a1fe2ee73c3f29 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 19 Apr 2012 14:20:17 -0700 Subject: typo fix Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e56c3e31..1fcdf6d0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -332,7 +332,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.documentHackReference = doc; // switch (doc.extension) { - case 'html': case 'html': + case 'html': //Open in designer view Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); break; -- cgit v1.2.3 From c62273126004f057de40ce91ecda5606643f4c92 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 20 Apr 2012 16:37:47 -0700 Subject: reverting old template to current working status. New template work. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 38 +++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1fcdf6d0..a7aa0de6 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -11,6 +11,9 @@ var Montage = require("montage/core/core").Montage, Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/html-document").HTMLDocument, TextDocument = require("js/document/text-document").TextDocument; + + // New Document Objects +var Document = require("js/document/document-html").HtmlDocument; //////////////////////////////////////////////////////////////////////// // var DocumentController = exports.DocumentController = Montage.create(Component, { @@ -289,7 +292,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.isNewFilePath = false;//reset path identifier flag //Sending full response object - this.openDocument(response); + // TODO: Unify those 2 methods. Using if/else for the new template + if(this.webTemplate) { + this.openWebDocument(response); + } else { + this.openDocument(response); + } } else if (!!response && (response.status === 404)){ alert("Unable to open file.\n [Error: File does not exist]"); } else if (!!response && (response.status === 500)){ @@ -334,7 +342,31 @@ var DocumentController = exports.DocumentController = Montage.create(Component, switch (doc.extension) { case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this), this.webTemplate); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); + break; + default: + //Open in code view + var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; + textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); + code.initialize(doc, docuuid, textArea, textArea.parentNode); + //code.init(doc.name, doc.uri, doc.extension, null, docuuid); + code.textArea.value = doc.content; + this.application.ninja.stage.stageView.createTextView(code); + break; + } + } + }, + openWebDocument: { + value: function(doc) { + // TODO: HACKS to remove + this.documentHackReference = doc; + document.getElementById("iframeContainer").style.overflow = "hidden"; + // + switch (doc.extension) { + case 'html': + //Open in designer view + this._hackRootFlag = false; + Montage.create(Document).init(doc, this, this._onOpenDocument); break; default: //Open in code view @@ -453,8 +485,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this._showCurrentDocument(); NJevent("onOpenDocument", doc); -// appDelegateModule.MyAppDelegate.onSetActiveDocument(); - } }, -- cgit v1.2.3 From 3f8f224170937d498d3a03c706494408a6b4bf1d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 23 Apr 2012 13:47:35 -0700 Subject: Temporary fix for the PI and Stage when opening the new template. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a7aa0de6..4be0767a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -473,7 +473,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Event Detail: Contains the current ActiveDocument _onOpenDocument: { value: function(doc){ - this.webTemplate = false; this.application.ninja.currentDocument = doc; this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); @@ -482,7 +481,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = doc; - this._showCurrentDocument(); + if(!this.webTemplate) { + this._showCurrentDocument(); + } + + this.webTemplate = false; NJevent("onOpenDocument", doc); } @@ -578,7 +581,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.stageView.showRulers(); }else{ //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display="none"; + document.getElementById("iframeContainer").style.display = "none"; } } } -- cgit v1.2.3