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 c5e66f69b108e359b00c8fd897a4278812484c55 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 20 Apr 2012 12:09:54 -0700 Subject: Fixing translate handles to draw without zoom value. Also fixed some typos in zoom code. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/stage-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index 3ef7dacc..e9779c81 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -182,5 +182,5 @@ exports.StageController = Montage.create(ElementController, { return dist; } } - }, + } }); -- 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 From a0daa3668883c8c35ce277b60509a3a3dcf303b2 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 24 Apr 2012 11:42:42 -0700 Subject: Allow users to toggle application of stroke and border settings when using the ink bottle tool. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 16 ++++++++++++---- js/controllers/elements/shapes-controller.js | 20 +++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 35a543ac..452d09f1 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -152,16 +152,24 @@ exports.ElementController = Montage.create(Component, { 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); - this.setProperty(el, "border-style", color.borderInfo.borderStyle); + if(color.borderInfo.borderWidth) { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); + } + if(color.borderInfo.borderStyle) { + 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); - this.setProperty(el, "border-style", color.borderInfo.borderStyle); + if(color.borderInfo.borderWidth) { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); + } + if(color.borderInfo.borderStyle) { + this.setProperty(el, "border-style", color.borderInfo.borderStyle); + } } } } diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index e9dde5fc..3ada5f82 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -20,8 +20,10 @@ exports.ShapesController = Montage.create(CanvasController, { color; switch(p) { case "strokeSize": - // TODO - For now, just handling px units. this.setShapeProperty(el, "strokeSize", value); + var strokeInfo = value.split(" "); + val = this.GetValueInPixels(strokeInfo[0], strokeInfo[1]); + // TODO - For now, just handle Line, Rectangle and Oval. Eventually, move this into each class's // setStrokeWidth code like SubPath and BrushStroke do. var geomType = el.elementModel.shapeModel.GLGeomObj.geomType(); @@ -527,16 +529,6 @@ exports.ShapesController = Montage.create(CanvasController, { } else { - // Support for ink-bottle tool - if(color.strokeInfo) - { - var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize, - color.strokeInfo.strokeUnits); - el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth); - this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " - + color.strokeInfo.strokeUnits); - } - if(mode) { switch (mode) { @@ -559,6 +551,12 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); } } + + // Support for ink-bottle tool + if(color.strokeInfo) + { + this.setProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " + color.strokeInfo.strokeUnits); + } } el.elementModel.shapeModel.GLWorld.render(); this.application.ninja.documentController.activeDocument.needsSave = true; -- cgit v1.2.3 From d5510229ebd4549ce435e3947874cc37eef27ffb Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 24 Apr 2012 14:27:54 -0700 Subject: Fixed issue with setting stroke when using the PI. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 3ada5f82..8d7b74f0 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -21,7 +21,7 @@ exports.ShapesController = Montage.create(CanvasController, { switch(p) { case "strokeSize": this.setShapeProperty(el, "strokeSize", value); - var strokeInfo = value.split(" "); + var strokeInfo = njModule.NJUtils.getValueAndUnits(value); val = this.GetValueInPixels(strokeInfo[0], strokeInfo[1]); // TODO - For now, just handle Line, Rectangle and Oval. Eventually, move this into each class's -- cgit v1.2.3