From 9d17dc8dab12aa661ab321567f024406f4972abb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 15:34:14 -0800 Subject: cleanup of the breadcrumb Signed-off-by: Valerio Virgillito --- .../bread-crumb-button.reel/bread-crumb-button.js | 35 +++---- .../layout/bread-crumb.reel/bread-crumb.js | 112 ++++++--------------- 2 files changed, 44 insertions(+), 103 deletions(-) (limited to 'js') diff --git a/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js b/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js index 65e5b7c8..3f5b87e1 100755 --- a/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js +++ b/js/components/layout/bread-crumb-button.reel/bread-crumb-button.js @@ -7,45 +7,38 @@ var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; - exports.BreadcrumbButton = Montage.create(Component, { - button: { value: null }, + button: { + value: null + }, - data: { value: null }, + data: { + value: null + }, prepareForDraw: { - enumerable: false, value: function() { this.element.addEventListener("mousedown", this, false); } }, draw: { - enumerable: false, value: function() { - - if(this.data.element.id==="UserContent"){ - - this.button.innerHTML = "Body"; - } - - else{ - this.button.innerHTML=this.data.element.nodeName; - } - + if(this.data.element.id === "UserContent") { + this.button.innerHTML = "Body"; + } else { + this.button.innerHTML = this.data.element.nodeName; + } } }, handleMousedown: { value: function(event) { - if(event.which===1){ - - this.data.selected=true; - NJevent('breadCrumbTrail',this.data); - this.data.selected=false; - } + //this.data.selected=true; + NJevent('breadCrumbTrail',this.data); + //this.data.selected=false; } } diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index ead7c764..1290aaac 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -1,6 +1,6 @@ -var Montage = require("montage/core/core").Montage -var Component = require("montage/ui/component").Component +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { @@ -8,15 +8,12 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { value:null }, - container: { set: function(value) { - if(this._container !== value) { - this._container = value; - this.createContainerElements(); - } - - + if(this._container !== value) { + this._container = value; + this.createContainerElements(); + } }, get: function() { return this._container; @@ -25,7 +22,6 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { containerElements: { value: [] - }, @@ -33,14 +29,12 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { value: function() { this.eventManager.addEventListener( "appLoaded", this, false); this.eventManager.addEventListener( "breadCrumbTrail", this, false); - }, - enumerable : false + } }, handleAppLoaded : { value: function() { - Object.defineBinding(this, "container", { boundObject: this.application.ninja, boundObjectPropertyPath: "currentSelectedContainer", @@ -50,107 +44,61 @@ var Breadcrumb = exports.Breadcrumb = Montage.create(Component, { } }, - prepareForDraw: { - value: function() { - - } - }, - - draw: { - value: function() { - - } - }, - - didDraw:{ - value:function(){ - } - }, - createContainerElements: { value: function() { - var parentNode; - while(this.containerElements.pop()){ - // To empty the array to get the new parentNode of the new currentLevel - } - - if(this.container.id === "UserContent"){ - - this.containerElements.push({selected:false,element:this.container}); - + this.containerElements.length = 0 - } - else{ - - parentNode= this.container; - - while(parentNode.id!=="UserContent"){ - - this.containerElements.unshift ({selected:false,element:parentNode}); - parentNode=parentNode.parentNode; + if(this.container.id === "UserContent") { + this.containerElements.push({selected:false, element:this.container}); + } else { + parentNode = this.container; - } - - this.containerElements.unshift({selected:false,element:parentNode}); + while(parentNode.id!=="UserContent") { + this.containerElements.unshift({selected:false,element:parentNode}); + parentNode = parentNode.parentNode; + } + this.containerElements.unshift({selected:false,element:parentNode}); } NJevent('layerBinding',{selected:false ,element:this.container}) - - } }, - - handleBreadCrumbTrail: { + handleBreadCrumbTrail: { value: function(event) { + var newLength,revaluatedLength,tmpvalue; + var i=0; - var newLength,revaluatedLength,tmpvalue - var i=0; - if(event.detail.setFlag){ - this.application.ninja.currentSelectedContainer = event.detail.element; - return; + if(event.detail.setFlag ){ + this.application.ninja.currentSelectedContainer = event.detail.element; + return; } newLength = this.containerElements.length; while(i < newLength ){ - - if(this.containerElements[i].selected){ - - tmpvalue = i ; - break; - - } - + if(this.containerElements[i].selected){ + tmpvalue = i; + break; + } i++; } - - - for(i = newLength -1 ; i >= 1 ; i--){ - - if(tmpvalue!==i){ - + for(i = newLength -1 ; i >= 1 ; i--) { + if(tmpvalue !== i) { this.containerElements.pop(); - } - - else{ - + } else { break; } - } revaluatedLength = this.containerElements.length; this.application.ninja.currentSelectedContainer = this.containerElements[revaluatedLength-1].element; - } } - - }); -- cgit v1.2.3 From 31781742ad40854a48ede88cf3c7a6d700b35cbb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 15:35:09 -0800 Subject: formatting cleanup Signed-off-by: Valerio Virgillito --- js/tools/SelectionTool.js | 13 +------------ js/tools/modifier-tool-base.js | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 48548271..f76a6d85 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -115,8 +115,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { HandleLeftButtonUp: { value: function(event) { var selectedItems, - point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); + point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.isDrawing = false; this.application.ninja.stage.showSelectionBounds = true; @@ -186,21 +185,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { HandleDoubleClick: { value: function(event) { - /* - var selectedObject = stageManagerModule.stageManager.GetObjectFromPoint(event.layerX, event.layerY, this._canOperateOnStage); - - if(selectedObject) { - if(selectionManagerModule.selectionManager.findSelectedElement(selectedObject) === -1) { - selectionManagerModule.selectionManager.setSingleSelection(selectedObject); - } - } - */ // Temporary Code for Breadcrumb if(this.application.ninja.selectedElements.length > 0) { this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]._element; } else { - console.log(this.application.ninja.currentDocument.documentRoot.uuid); this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; } diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 67b217c4..54bc06be 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -791,8 +791,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { HandleLeftButtonDown: { value: function(event) { - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; this.downPoint.y = point.y; -- cgit v1.2.3 From 736956ebba6db338127caeadb429d16bdf6bc375 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 21:52:57 -0800 Subject: Removing the timeline selection code. Timeline selection code is now handled by the selection controller and current container change Signed-off-by: Valerio Virgillito --- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 44129743..07fee19d 100755 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -429,9 +429,13 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._LayerUndoIndex = thingToPush.layerID; this._LayerUndoStatus = true; this._TrackUndoObject = newTrack; + + // Removing clearing the selection - Handled by the selection-controller + /* if(_firstLayerDraw){ - this.application.ninja.selectionController.executeSelectElement(); + this.application.ninja.selectionController.executeSelectElement(); } + */ } } @@ -753,9 +757,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.trackRepetition.selectedIndexes = [layerIndex]; this.currentLayerSelected = this.arrLayers[layerIndex]; this.currentTrackSelected = this.arrTracks[layerIndex]; + // Selection is being handled by the selection controller + /* if(this._captureSelection){ - this.application.ninja.selectionController.selectElements(this.currentLayerSelected.element) + this.application.ninja.selectionController.selectElements(this.currentLayerSelected.element) } + */ this._captureSelection = true; } else { this.layerRepetition.selectedIndexes = null; -- cgit v1.2.3 From d03a7d460b8998fdee8ebac10397f0c014adeef6 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 21:53:21 -0800 Subject: Removing the log of the url requests Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1f339fe7..c2aa1b6b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -70,7 +70,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (request) { if (request.url.indexOf('js/document/templates/montage-html') !== -1) { - console.log(request); + //console.log(request); //TODO: Figure out why active document is not available here -- cgit v1.2.3 From 1b1a51370feffc1abbd1ad558cbf4d5d8163ef6f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 22:23:28 -0800 Subject: cleanup Signed-off-by: Valerio Virgillito --- js/mediators/element-mediator.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'js') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 95aec2a3..8481f557 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -28,13 +28,7 @@ exports.ElementMediator = Montage.create(NJComponent, { // TODO use the specific controller to be able to subclass the functionality handleElementAdding: { value: function(event) { - /* - var cmd = ElementControllerCommands.addElementCommand(event.detail.el, event.detail.data); - NJevent("sendToUndo", cmd); - cmd.execute(); - */ this.addElement(event.detail.el, event.detail.data); - } }, @@ -97,8 +91,7 @@ exports.ElementMediator = Montage.create(NJComponent, { value: function(el, rules, noEvent) { ElementController.addElement(el, rules); var p3d = this.get3DProperties(el); - if(p3d) - { + if(p3d) { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) NJevent("elementAdded", el); -- cgit v1.2.3 From 9e566515f7e3a4ae26b39a2581008a15cf662c95 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 22:35:28 -0800 Subject: formatting and removing un-used code from the stage Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 48 +++++++++++++------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 37b1df35..44e14827 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -19,8 +19,6 @@ exports.Stage = Montage.create(Component, { zoomFactor: {value : 1 }, _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, - _editSymbolPrefs: { value: { "thickness" : 2.0, "color" : "#C61F00" } }, - _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, drawingContextPreferences: { get: function() { return this._canvasDrawingPrefs; } }, @@ -260,7 +258,6 @@ exports.Stage = Montage.create(Component, { this.application.ninja.toolsData.selectedToolInstance._configure(true); this.addEventListener("change@appModel.show3dGrid", this, false); - } }, @@ -533,8 +530,7 @@ exports.Stage = Montage.create(Component, { drawUtils.updatePlanes(); //TODO Set this variable in the needs draw so that it does not have to be calculated again for each draw for selection change - if(this.application.ninja.selectedElements.length) - { + if(this.application.ninja.selectedElements.length) { // drawUtils.drawSelectionBounds handles the single selection case as well, // so we don't have to special-case the single selection case. // TODO drawUtils.drawSelectionBounds expects an array of elements. @@ -542,8 +538,7 @@ exports.Stage = Montage.create(Component, { // TODO to work on _element instead of re-creating a new Array here. var selArray = new Array(); - for(var i = 0; this.application.ninja.selectedElements[i];i++) - { + for(var i = 0; this.application.ninja.selectedElements[i];i++) { var curElement = this.application.ninja.selectedElements[i]._element; // Add element to array that is used to calculate 3d-bounding box of all elements @@ -576,7 +571,7 @@ exports.Stage = Montage.create(Component, { * @params: x, y, w, h */ draw3DSelectionRectangle: { - value:function(x0,y0, x1,y1, x2,y2, x3,y3){ + value:function(x0,y0, x1,y1, x2,y2, x3,y3) { // this.clearCanvas(); this.clearDrawingCanvas(); this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; @@ -621,7 +616,7 @@ exports.Stage = Montage.create(Component, { * Draws selection highlight and reg. point for a given element */ drawElementBoundingBox: { - value: function(elt, editMode) { + value: function(elt) { this.stageDeps.viewUtils.setViewportObj( elt ); var bounds3D = this.stageDeps.viewUtils.getElementViewBounds3D( elt ); @@ -632,18 +627,16 @@ exports.Stage = Montage.create(Component, { // } var zoomFactor = 1; - if (this._viewport.style && this._viewport.style.zoom) - { + if (this._viewport.style && this._viewport.style.zoom) { zoomFactor = Number(this._viewport.style.zoom); } + var tmpMat = this.stageDeps.viewUtils.getLocalToGlobalMatrix( elt ); - for (var j=0; j<4; j++) - { + for (var j=0; j<4; j++) { var localPt = bounds3D[j]; var tmpPt = this.stageDeps.viewUtils.localToGlobal2(localPt, tmpMat); - if(zoomFactor !== 1) - { + if(zoomFactor !== 1) { tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); tmpPt[0] += this._scrollLeft*(zoomFactor - 1); @@ -653,13 +646,9 @@ exports.Stage = Montage.create(Component, { } // draw it - if(editMode) { - this.context.strokeStyle = this._editSymbolPrefs.color; - this.context.lineWidth = this._editSymbolPrefs.thickness; - } else { - this.context.strokeStyle = this._canvasSelectionPrefs.color; - this.context.lineWidth = this._canvasSelectionPrefs.thickness; - } + this.context.strokeStyle = this._canvasSelectionPrefs.color; + this.context.lineWidth = this._canvasSelectionPrefs.thickness; + this.context.beginPath(); @@ -673,13 +662,6 @@ exports.Stage = Montage.create(Component, { this.context.closePath(); this.context.stroke(); - - /** Bug #25 - Do Not Draw the Registration point anymore on the top left since it's assumed there. - this.context.beginPath(); - this.context.arc(bounds3D[0][0], bounds3D[0][1] , 5, 0, Math.PI*2, false); - this.context.stroke(); - */ - } }, @@ -691,10 +673,8 @@ exports.Stage = Montage.create(Component, { * * @params: x, y, w, h */ - draw3DProjectedAndUnprojectedRectangles: - { - value:function(unProjPts, projPts) - { + draw3DProjectedAndUnprojectedRectangles: { + value:function(unProjPts, projPts) { this.clearDrawingCanvas(); this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; this._drawingContext.lineWidth = this._canvasDrawingPrefs.thickness; @@ -748,7 +728,7 @@ exports.Stage = Montage.create(Component, { * @params: x0, y0, x1, y1 */ drawLine: { - value:function(x0, y0, x1, y1, strokeSize, strokeColor){ + value:function(x0, y0, x1, y1, strokeSize, strokeColor) { this.clearDrawingCanvas(); this._drawingContext.strokeStyle = strokeColor; this._drawingContext.lineWidth = strokeSize; -- cgit v1.2.3 From f9d34a54baf61ccdf77732b1aaedb29d296b8c2e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 23:03:48 -0800 Subject: enabling nested selection Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 3 +++ js/controllers/selection-controller.js | 37 ++++++++++++++++++++++----- js/ninja.reel/ninja.html | 10 +++++++- js/stage/layout.js | 29 +++++++++++++++++---- js/tools/SelectionTool.js | 23 +++++++++-------- 5 files changed, 80 insertions(+), 22 deletions(-) (limited to 'js') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 65d26bdd..ac14def4 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -12,6 +12,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, addElement: { value: function(el, styles) { this.application.ninja.currentDocument.documentRoot.appendChild(el); + // Nested elements - + // TODO make sure the CSS is correct before nesting elements + // this.application.ninja.currentSelectedContainer.appendChild(el); this.application.ninja.stylesController.setElementStyles(el, styles); } }, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 833e6f04..fed9affd 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -20,6 +20,27 @@ exports.SelectionController = Montage.create(Component, { } }, + /* + * Bound property to the ninja currentSelectedContainer + */ + _selectionContainer: { + value: null + }, + + selectionContainer: { + get: function() { + return this._selectionContainer + }, + set: function(value) { + if(this._selectionContainer && this._selectionContainer !== value) { + console.log("setting container in the selection tool"); + this.executeSelectElement(); + } + + this._selectionContainer = value; + } + }, + deserializedFromTemplate: { value: function() { this.eventManager.addEventListener("openDocument", this, false); @@ -53,7 +74,9 @@ exports.SelectionController = Montage.create(Component, { } } - this.dispatchEvent(selectionEvent.event); + // + this._selectionContainer = this.application.ninja.currentSelectedContainer; + } }, @@ -66,13 +89,10 @@ exports.SelectionController = Montage.create(Component, { handleElementDeleted: { value: function(event) { if(!this._isDocument) { - if(this.findSelectedElement(event.detail) !== -1) { this.executeSelectElement(); } - } - } }, @@ -130,12 +150,17 @@ exports.SelectionController = Montage.create(Component, { this.executeSelectElement(); // Else execute selection with no item } else { - if(item.parentNode.id == "UserContent") { +// if(item.parentNode.id === "UserContent") { + if(item.parentNode.uuid === this.selectionContainer.uuid) { this.executeSelectElement(item); } else { var outerElement = item.parentNode; - while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { + while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { + //while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { + // If element is higher up than current container then return + if(outerElement.id === "UserContent") return; + // else keep going up the chain outerElement = outerElement.parentNode; } diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index c9f17e3b..65cbfc28 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -228,7 +228,15 @@ "selectionController1": { "module": "js/controllers/selection-controller", - "name": "SelectionController" + "name": "SelectionController", + "bindings" : { + "selectionContainer": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "currentSelectedContainer", + "oneway": true + } + } + }, "documentController1": { diff --git a/js/stage/layout.js b/js/stage/layout.js index 1a491210..56bb70bf 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -195,11 +195,30 @@ exports.Layout = Montage.create(Component, { bounds3D[j] = tmpPt; } - // Draw the Item ouline - this._dashedLine(bounds3D[3][0] - 0.5,bounds3D[3][1]- 0.5,bounds3D[0][0] + 2.5, bounds3D[0][1] - 0.5,[5,5]); - this._dashedLine(bounds3D[0][0] - 0.5, bounds3D[0][1] - 0.5, bounds3D[1][0]- 0.5, bounds3D[1][1] + 0.5, [5,5] ); - this._dashedLine(bounds3D[1][0] - 0.5 , bounds3D[1][1] + 0.5, bounds3D[2][0]+ 0.5, bounds3D[2][1] + 0.5, [5,5] ); - this._dashedLine(bounds3D[2][0] + 0.5, bounds3D[2][1] + 0.5, bounds3D[3][0] + 0.5, bounds3D[3][1] - 0.5, [5,5] ); + if(item.uuid === this.application.ninja.currentSelectedContainer.uuid) { + this.ctx.save(); + this.ctx.strokeStyle = "#C61F00"; + + this.ctx.beginPath(); + + this.ctx.moveTo( bounds3D[3][0] + 0.5 , bounds3D[3][1] - 0.5 ); + + this.ctx.lineTo( bounds3D[0][0] - 0.5 , bounds3D[0][1] - 0.5 ); + this.ctx.lineTo( bounds3D[1][0] - 0.5 , bounds3D[1][1] + 0.5 ); + this.ctx.lineTo( bounds3D[2][0] + 0.5 , bounds3D[2][1] + 0.5 ); + this.ctx.lineTo( bounds3D[3][0] + 0.5 , bounds3D[3][1] + 0.5 ); + + this.ctx.closePath(); + this.ctx.stroke(); + + this.ctx.restore(); + } else { + // Draw the Item ouline + this._dashedLine(bounds3D[3][0] - 0.5,bounds3D[3][1]- 0.5,bounds3D[0][0] + 2.5, bounds3D[0][1] - 0.5,[5,5]); + this._dashedLine(bounds3D[0][0] - 0.5, bounds3D[0][1] - 0.5, bounds3D[1][0]- 0.5, bounds3D[1][1] + 0.5, [5,5] ); + this._dashedLine(bounds3D[1][0] - 0.5 , bounds3D[1][1] + 0.5, bounds3D[2][0]+ 0.5, bounds3D[2][1] + 0.5, [5,5] ); + this._dashedLine(bounds3D[2][0] + 0.5, bounds3D[2][1] + 0.5, bounds3D[3][0] + 0.5, bounds3D[3][1] - 0.5, [5,5] ); + } // Draw the Label is all mode if(this.layoutView === "layoutAll") { diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f76a6d85..37029e8c 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -183,18 +183,21 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } }, + /** + * Double click handler + * + * Sets the currentSelectionContainer to the current selected element. If no elements are selected set the + * currentSelectionContainer to the userDocument div. + */ HandleDoubleClick: { - value: function(event) { - - // Temporary Code for Breadcrumb - if(this.application.ninja.selectedElements.length > 0) { - this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]._element; - } else { - this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; - } - + value: function(event) { + if(this.application.ninja.selectedElements.length > 0) { + this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]._element; + } else { + this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; } - }, + } + }, HandleKeyPress: { value: function(event){ -- cgit v1.2.3 From b1daf0b285a4a96bfd0086709c20e3682d75551a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 14:32:17 -0800 Subject: fixing the dirty flag and removing sass changes Signed-off-by: Valerio Virgillito --- .../layout/document-entry.reel/document-entry.html | 1 - .../layout/document-entry.reel/document-entry.js | 24 +++++++-------- .../layout/documents-tab.reel/documents-tab.html | 4 +-- js/controllers/document-controller.js | 15 ++------- js/document/html-document.js | 9 ------ js/document/text-document.js | 36 ++++++++-------------- js/mediators/element-mediator.js | 4 +-- js/stage/stage-view.reel/stage-view.js | 4 +-- 8 files changed, 32 insertions(+), 65 deletions(-) (limited to 'js') diff --git a/js/components/layout/document-entry.reel/document-entry.html b/js/components/layout/document-entry.reel/document-entry.html index ba17449a..1cf01737 100755 --- a/js/components/layout/document-entry.reel/document-entry.html +++ b/js/components/layout/document-entry.reel/document-entry.html @@ -26,7 +26,6 @@
  • -
  • diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index a1bed79b..9e4110e2 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js @@ -77,19 +77,17 @@ exports.DocumentEntry = Montage.create(Component, { } }, - _dirtyFlag:{ - enumerable:false, - value:false + _saveFlag: { + value: false }, - dirtyFlag:{ + + saveFlag: { get: function() { - return this._dirtyFlag; + return this._saveFlag; }, set: function(value) { - var previousValue = this._dirtyFlag; - this._dirtyFlag = value; - - if (previousValue !== this._dirtyFlag) { + if(this._saveFlag !== value) { + this._saveFlag = value; this.needsDraw = true; } } @@ -110,10 +108,10 @@ exports.DocumentEntry = Montage.create(Component, { this._active ? this.element.classList.add("activeTab") : this.element.classList.remove("activeTab"); - if(this.dirtyFlag === true){ - if(!this.label.classList.contains("dirty")){this.label.classList.add("dirty");} - }else{ - if(this.label.classList.contains("dirty")){this.label.classList.remove("dirty");} + if(this.saveFlag) { + this.label.classList.add("dirty"); + } else { + this.label.classList.remove("dirty"); } } }, diff --git a/js/components/layout/documents-tab.reel/documents-tab.html b/js/components/layout/documents-tab.reel/documents-tab.html index 82ba8782..737dfbcb 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.html +++ b/js/components/layout/documents-tab.reel/documents-tab.html @@ -38,9 +38,9 @@ "boundObjectPropertyPath": "objectAtCurrentIteration.name", "oneway": true }, - "dirtyFlag": { + "saveFlag": { "boundObject": {"@": "repetition1"}, - "boundObjectPropertyPath": "objectAtCurrentIteration.dirtyFlag", + "boundObjectPropertyPath": "objectAtCurrentIteration.needsSave", "oneway": true }, "active": { diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 9a063280..e0402219 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -131,20 +131,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, fileSaveResult: { value: function (result) { if(result.status === 204){ - this.clearDocumentDirtyFlag(); + this.activeDocument.needsSave = false; } } }, - //////////////////////////////////////////////////////////////////// - - - clearDocumentDirtyFlag:{ - value: function(){ - this.activeDocument.dirtyFlag = false; - } - }, - - + createNewFile:{ value:function(newFileObj){ //console.log(newFileObj);//contains the template uri and the new file uri @@ -282,7 +273,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, closeDocument: { value: function(id) { - if(this.activeDocument.dirtyFlag === true){ + if(this.activeDocument.needsSave === true){ //if file dirty then alert user to save } diff --git a/js/document/html-document.js b/js/document/html-document.js index 28818774..01d042d6 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -290,15 +290,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, - - - AppendElement: { - value: function(element, parent) { - this.dirtyFlag = true; - } - }, - - /** * Return the specified inline attribute from the element. */ diff --git a/js/document/text-document.js b/js/document/text-document.js index 1132ba65..88464d87 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -120,15 +120,15 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { /** Private Members **/ - _name: { value: null, enumerable: false }, - _uri: { value: null, enumerable: false }, - _documentType: { value: null, enumerable: false }, - _container: {value: null, enumerable: false }, - _uuid: { value: null, enumerable: false }, - _isActive: { value: true, enumerable: false }, - _dirtyFlag: { value: false, enumerable: false }, - _callback: { value: null, enumerable: false }, - _currentView: { value: null, enumerable: false}, + _name: { value: null, enumerable: false }, + _uri: { value: null, enumerable: false }, + _documentType: { value: null, enumerable: false }, + _container: { value: null, enumerable: false }, + _uuid: { value: null, enumerable: false }, + _isActive: { value: true, enumerable: false }, + _needsSave: { value: false, enumarable: false }, + _callback: { value: null, enumerable: false }, + _currentView: { value: null, enumerable: false}, /** Getters/Setters **/ name: { @@ -161,9 +161,9 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { set: function(value) { this._isActive = value; } }, - dirtyFlag: { - get: function() { return this._dirtyFlag; }, - set: function(value) { this._dirtyFlag = value; } + needsSave: { + get: function() { return this._needsSave; }, + set: function(value) { this._needsSave = value } }, callback: { @@ -192,17 +192,5 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { value: function() { // Have the XHR here? } - }, - - markEdited:{ - value: function() { - this.dirtyFlag = true; - } - }, - - markUnedited:{ - value: function() { - this.dirtyFlag = false; - } } }); \ No newline at end of file diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 6088aeab..95a72c89 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -102,7 +102,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) { - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementAdded", el); } } @@ -130,7 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementDeleted", el); } }, diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 31f40d09..dc9980f0 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -98,9 +98,9 @@ exports.StageView = Montage.create(Component, { onChange: function(){ var historySize = doc.editor.historySize(); if(historySize.undo>0){ - doc.markEdited(); + doc.needsSave = true; }else if(historySize.undo===0 && historySize.redo>0){ - doc.markUnedited(); + doc.needsSave = false; } }, onCursorActivity: function() { -- cgit v1.2.3 From 2f24dafec79583547fe663d5a387d8ef15aae3bf Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 17:33:11 -0800 Subject: user document main reel listener moved to the html-document class. Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 1 - js/document/html-document.js | 21 +++++++++++++++------ js/ninja.reel/ninja.js | 9 --------- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index fed9affd..d69b53e0 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -33,7 +33,6 @@ exports.SelectionController = Montage.create(Component, { }, set: function(value) { if(this._selectionContainer && this._selectionContainer !== value) { - console.log("setting container in the selection tool"); this.executeSelectElement(); } diff --git a/js/document/html-document.js b/js/document/html-document.js index 01d042d6..9a7755e6 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -392,9 +392,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { // this._templateDocument.head.innerHTML = this._userDocument.content.head; this._templateDocument.body.innerHTML = this._userDocument.content.body; - - - + + // Adding a handler for the main user document reel to finish loading. + this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); + /* this.iframe.contentWindow.document.addEventListener('DOMSubtreeModified', function (e) { */ //TODO: Remove events upon loading once @@ -472,12 +473,20 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, + //////////////////////////////////////////////////////////////////// + + // 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. + userTemplateDidLoad: { + value: function(){ + this.application.ninja.currentSelectedContainer = this.documentRoot; + } + }, - - - + //////////////////////////////////////////////////////////////////// _setSWFObjectScript: { value: function() { if(!this._swfObject) { diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 399d7b4d..6efeef8a 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -168,19 +168,10 @@ exports.Ninja = Montage.create(Component, { this.appModel.show3dGrid = this.currentDocument.draw3DGrid; - this.currentDocument._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); - - NJevent("openDocument"); } }, - userTemplateDidLoad: { - value: function(){ - this.currentSelectedContainer = this.currentDocument.documentRoot; - } - }, - executeLivePreview: { value: function() { var background, overflow, transitionStopRule; -- cgit v1.2.3 From f86577d5083aeed2de7a932fe4147e9002e91554 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 21:11:54 -0800 Subject: cleanup - Removing temporary div to render the popups We don't need to render the popup before opening them. Removing that hack. Signed-off-by: Valerio Virgillito --- js/io/ui/file-picker/file-picker-controller.js | 14 -------------- js/io/ui/new-file-dialog/new-file-workflow-controller.js | 12 ------------ 2 files changed, 26 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 129bebad..5e4d0be8 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -33,7 +33,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require }, filePickerPopupType:{ - writable: true, enumerable: false, value: "filePicker" }, @@ -152,15 +151,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(callback, aModel){ - //render modal dialog - var pickerNavContent = document.createElement("div"); - pickerNavContent.id = "filePicker"; - - pickerNavContent.style.color = "#fff"; - - //hack (elements needs to be on DOM to be drawn) - document.getElementById('modalContainer').appendChild(pickerNavContent); - var pickerNavChoices = Montage.create(pickerNavigatorReel); var initUri = aModel.currentRoot; @@ -171,10 +161,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require pickerNavChoices.mainContentData = this.prepareContentList(initUri, aModel); pickerNavChoices.pickerModel = aModel; - pickerNavChoices.element = pickerNavContent; - - //hack - remove after rendering and add in modal dialog - document.getElementById('modalContainer').removeChild(pickerNavContent); var popup = Popup.create(); popup.content = pickerNavChoices; diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js index 7b7f4572..c2be687a 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -29,7 +29,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre }, model:{ - writable: true, enumerable:true, value: null }, @@ -56,19 +55,8 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.defaultProjectType = lastSelectedProjectType; } - //render modal dialog - var newFileNavContent = document.createElement("div"); - newFileNavContent.id = "newFileDialog"; - - //elements needs to be on DOM to be drawn - document.getElementById('modalContainer').appendChild(newFileNavContent); - var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); newFileOptionsNav.newFileModel = this.model; - newFileOptionsNav.element = newFileNavContent; - - //remove after rendering and add in modal dialog - document.getElementById('modalContainer').removeChild(newFileNavContent); var popup = Popup.create(); popup.content = newFileOptionsNav; -- cgit v1.2.3 From 067ebae166ff82ae113a91517dfa59e7de5ae3d3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:36:54 -0800 Subject: cleanup - using montage functions handlers and using the NJevent Signed-off-by: Valerio Virgillito --- .../file-input-field.reel/file-input-field.js | 21 ++++----------------- js/io/ui/file-picker/file-picker-controller.js | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 29 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 235be8ad..651fd7fa 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js @@ -9,24 +9,13 @@ var Montage = require("montage/core/core").Montage, var FileInputField = exports.FileInputField = Montage.create(Component, { - hasReel: { - value: true - }, - - willDraw: { - enumerable: false, - value: function() {} - }, - draw: { - enumerable: false, - value: function() {} - }, didDraw: { enumerable: false, value: function() { var that = this; this.findDirectory.identifier = "findDirectory"; - this.findDirectory.addEventListener("click", function(evt){that.handleFindDirectoryClick(evt);}, false); + + this.findDirectory.addEventListener("click", this, false); this.eventManager.addEventListener("pickerSelectionsDone", function(evt){that.handleFileInputPickerSelectionsDone(evt);}, false); @@ -60,8 +49,6 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { handleFindDirectoryClick: { value: function(evt){ - var openFilePicker = document.createEvent("Events"); - openFilePicker.initEvent("openFilePicker", false, false); var settings = {}; if(this.selectDirectory === true){ settings.inFileMode = false; @@ -71,8 +58,8 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { settings.pickerName = this.pickerName || "fileSelector"; } settings.callback = this.filePickerCallback.bind(this); - openFilePicker.settings = settings; - this.eventManager.dispatchEvent(openFilePicker); + + NJevent("openFilePicker", settings); } }, diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 5e4d0be8..3b19de83 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -19,16 +19,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(){ - var that = this; - - this.eventManager.addEventListener("openFilePicker", function(evt){ - var settings; - if(typeof evt._event.settings !== "undefined"){ - settings = evt._event.settings; - } - that.showFilePicker(settings); - }, false); - + this.eventManager.addEventListener("openFilePicker", this, false); } }, @@ -37,6 +28,12 @@ var FilePickerController = exports.FilePickerController = Montage.create(require value: "filePicker" }, + handleOpenFilePicker: { + value: function(evt) { + this.showFilePicker(evt.detail); + } + }, + /** *this function is used to create an instance of a file picker * @@ -128,7 +125,9 @@ var FilePickerController = exports.FilePickerController = Montage.create(require } if(!!storedUri){ - aModel.currentRoot = unescape(storedUri); + // This is depracated -- use decodeURI instead + //aModel.currentRoot = unescape(storedUri); + aModel.currentRoot = decodeURI(storedUri); } if(!!allFileFilters){aModel.fileFilters = allFileFilters;} @@ -137,7 +136,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require if(typeof pickerMode !== "undefined"){aModel.pickerMode = pickerMode;} - //logic: get file content data onDemand from the REST api for the default or last opened root. Cache the data in page [in local cache ? dirty fs? ]. Filter on client side to reduce network calls. this.openFilePickerAsModal(callback, aModel); -- cgit v1.2.3 From a8f5dcd8e85af6600f2e2b6a4536f05fd0c9916d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:37:36 -0800 Subject: Adding the default folder by default when opening a new file dialog. Adding the default folder name in the new file dialog input field. Also some more cleanup. Signed-off-by: Valerio Virgillito --- .../new-file-location.reel/new-file-location.js | 57 +++++++++++++--------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'js') diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index fae8f9c7..ee2847ca 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -11,46 +11,55 @@ var newFileWorkflowControllerModule = require("js/io/ui/new-file-dialog/new-file var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { templateHeight:{ - enumerable: true, value:"25 px" }, templateWidth:{ - enumerable: true, value:"25 px" }, - willDraw: { - enumerable: false, - value: function() {} - }, + prepareForDraw: { + value: function() { + // Populate the file input field by using the session storage or the default user folder + var defaultSaveDirectory; + + if(window.sessionStorage) { + var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); + if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); + } + + if(!defaultSaveDirectory) { + var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); + if(driveData.success){ + var topLevelDirectories = (JSON.parse(driveData.content)).children; + defaultSaveDirectory = topLevelDirectories[0].uri; + } else { + console.log("** Error ** Cannot get directory listing"); + defaultSaveDirectory = ""; + } + } - draw: { - enumerable: false, - value: function() {} + this.fileInputField.newFileDirectory.value = defaultSaveDirectory; + } }, didDraw: { - enumerable: false, value: function() { - var that=this; - this.fileInputField.selectDirectory = true; - this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); - } - + this.newFileName.addEventListener("keyup", this, false); + } }, - handleNewFileNameOnkeyup:{ - value:function(evt){ - if(this.newFileName.value !== ""){ - var newFileNameSetEvent = document.createEvent("Events"); - newFileNameSetEvent.initEvent("newFileNameSet", false, false); - newFileNameSetEvent.newFileName = this.newFileName.value; - this.eventManager.dispatchEvent(newFileNameSetEvent); - } - } + handleKeyup:{ + value:function(evt){ + if(this.newFileName.value !== "") { + var newFileNameSetEvent = document.createEvent("Events"); + newFileNameSetEvent.initEvent("newFileNameSet", false, false); + newFileNameSetEvent.newFileName = this.newFileName.value; + this.eventManager.dispatchEvent(newFileNameSetEvent); + } + } } }); \ No newline at end of file -- cgit v1.2.3 From 69983b800d0179fcccd5b61b64ed22c02e22b93a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:43:45 -0800 Subject: Adding some comments. Signed-off-by: Valerio Virgillito --- js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index ee2847ca..849c665c 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -18,16 +18,18 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { value:"25 px" }, + // Populating the directory input field with the default save location or the last stored location. prepareForDraw: { value: function() { - // Populate the file input field by using the session storage or the default user folder var defaultSaveDirectory; + // Using session storage location if(window.sessionStorage) { var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); } + // Use default if none found in session storage if(!defaultSaveDirectory) { var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); if(driveData.success){ @@ -39,6 +41,7 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { } } + // Set the input field to the correct directory this.fileInputField.newFileDirectory.value = defaultSaveDirectory; } }, -- cgit v1.2.3 From e17fb41feca768d746f89d90cef28192fa60c621 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 21 Feb 2012 23:30:01 -0800 Subject: Temp CSS fix (for file open) Implemented temporary work-around to the css-cross-origin issue on files loaded into Ninja. Fix is for open file, need to implement save functionality and integrate with CSS panel. --- js/document/html-document.js | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9a7755e6..bd41bc46 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -382,24 +382,23 @@ exports.HTMLDocument = Montage.create(TextDocument, { //TODO: Remove, also for prototyping this.application.ninja.documentController._hackRootFlag = true; // - //this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); this.stageBG.onclick = null; this._document = this.iframe.contentWindow.document; this._window = this.iframe.contentWindow; // if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; - // + //Inserting user's document into template this._templateDocument.head.innerHTML = this._userDocument.content.head; - this._templateDocument.body.innerHTML = this._userDocument.content.body; - - // Adding a handler for the main user document reel to finish loading. + //this._templateDocument.body.innerHTML = this._userDocument.content.body; + + //Adding a handler for the main user document reel to finish loading this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); /* this.iframe.contentWindow.document.addEventListener('DOMSubtreeModified', function (e) { */ //TODO: Remove events upon loading once - //TODO: When written, the best way to initialize the document is to listen for the DOM tree being modified + //TODO: When re-written, the best way to initialize the document is to listen for the DOM tree being modified setTimeout(function () { @@ -408,9 +407,41 @@ exports.HTMLDocument = Montage.create(TextDocument, { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(this._document.styleSheets.length > 1) { + //Checking all styleSheets in document + for (var i in this._document.styleSheets) { + //If rules are null, assuming cross-origin issue + if(this._document.styleSheets[i].rules === null) { + //Disabling style sheet to reload via inserting in style tag + this._document.styleSheets[i].disabled = 'true'; + //TODO: Revisit URLs and URI creation logic, very hack right now + var fileUri, cssUrl, cssData, tag; + if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { + //Getting the url of the CSS file + cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; + //Creating the URI of the file + fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl.split('/')[1]; + //Loading the data from the file + cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); + //Creating tag with file content + tag = document.createElement('style'); + tag.ninjauri = fileUri; + tag.innerHTML = cssData.content; + this._templateDocument.head.appendChild(tag); + } + } + } + + //TODO: Revisit this logic this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; this._stylesheets = this._document.styleSheets; // Entire stlyesheets array + + this._templateDocument.body.innerHTML = this._userDocument.content.body; + + + + + //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"); -- cgit v1.2.3 From 27589634d3e8ea52abe8623f8f2cc48ce0aa04c9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 22 Feb 2012 12:05:13 -0800 Subject: Improving temp CSS loading fix Adding logic to parse the entire DOM and insert the style tag loading the link element content directly above. --- js/document/html-document.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index bd41bc46..02e9918f 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -377,6 +377,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { value: function(event){ //TODO: Clean up, using for prototyping save this._templateDocument = {}; + this._templateDocument.html = this.iframe.contentWindow.document; this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead"); this._templateDocument.body = this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); //TODO: Remove, also for prototyping @@ -390,7 +391,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; //Inserting user's document into template this._templateDocument.head.innerHTML = this._userDocument.content.head; - //this._templateDocument.body.innerHTML = this._userDocument.content.body; + this._templateDocument.body.innerHTML = this._userDocument.content.body; //Adding a handler for the main user document reel to finish loading this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); @@ -411,36 +412,42 @@ exports.HTMLDocument = Montage.create(TextDocument, { for (var i in this._document.styleSheets) { //If rules are null, assuming cross-origin issue if(this._document.styleSheets[i].rules === null) { - //Disabling style sheet to reload via inserting in style tag - this._document.styleSheets[i].disabled = 'true'; //TODO: Revisit URLs and URI creation logic, very hack right now - var fileUri, cssUrl, cssData, tag; + var fileUri, cssUrl, cssData, tag, query; if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { //Getting the url of the CSS file cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; - //Creating the URI of the file + //Creating