From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..d3e4ebf9 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -165,10 +165,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); - var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; + var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes, + selectionController = this.application.ninja.selectionController; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { + if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) { selectedItems.push(item); } }); -- cgit v1.2.3 From 8f8f7f9a36fb9abadea2a9f25aef0084946bebc9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:42:00 -0700 Subject: Removed special-casing for new template workflow. Instead, we will enforce a width and height on the body in order to do 3d. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 2a9c63db..90cbe95e 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -96,12 +96,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { viewUtils.pushViewportObj( stage ); var eltCtr = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - eltCtr[0] = stage.scrollWidth/2; - eltCtr[1] = stage.scrollHeight/2; - } var curMat = viewUtils.getMatrixFromElement(stage); var curMatInv = glmat4.inverse(curMat, []); @@ -118,17 +112,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { } this._origin = viewUtils.localToGlobal(eltCtr, stage); - -// if(this.application.ninja.documentController.webTemplate) - if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") - { - this._startOriginArray = []; - this._startOriginArray.push(this._origin.slice()); - } - else - { - this._setTransformOrigin(false); - } + this._setTransformOrigin(false); this.DrawHandles(); } }, -- cgit v1.2.3 From 27935436ad8cd0675311667f70b6a285eb126a94 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 17:10:01 -0700 Subject: Fixing references to iframe's styles in new template. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateStage3DTool.js | 2 +- js/tools/ZoomTool.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'js/tools') diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 90cbe95e..c8818021 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -139,7 +139,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // let the document and stage manager know about the zoom change this.application.ninja.stage._firstDraw = true; this.application.ninja.documentBar.zoomFactor = 100; - this.application.ninja.currentDocument.iframe.style.zoom = 1.0; + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; this.application.ninja.stage._firstDraw = false; // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 93caf984..17301262 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -280,7 +280,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { this.application.ninja.documentBar.zoomFactor = zoomFactor*100; //this.application.ninja.stage.zoomFactor = zoomFactor; if (zoomFactor >= 1) - this.application.ninja.currentDocument.iframe.style.zoom = zoomFactor; + { + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = zoomFactor; + } this.application.ninja.stage._firstDraw = false; //tmp3 = viewUtils.localToGlobal( localPt, userContent ); // DEBUG - remove this line -- cgit v1.2.3 From 4baed156932f5875755532939a411953fa41c59d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 8 May 2012 09:43:32 -0700 Subject: Stage should update scroll offsets when scrolled. Note that this is not always correct because we don't get a scroll end event. Updating Pan Tool to update scroll bars. Signed-off-by: Nivesh Rajbhandari --- js/tools/PanTool.js | 66 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 19 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ce7606a1..132ac0b1 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -21,6 +21,9 @@ exports.PanTool = Montage.create(toolBase, _lastGPt :{value: [0,0], writable:true}, _lastY :{value: 0, writable:true}, + _maxHorizontalScroll: {value: 0, writable:true}, + _maxVerticalScroll: {value: 0, writable:true}, + Configure: { value: function ( doActivate ) { @@ -43,10 +46,19 @@ exports.PanTool = Montage.create(toolBase, HandleLeftButtonDown: { value : function ( event ) { - this._isDrawing = true; - this.isDrawing = true; - - this.mouseDown( event ); + // Determine the maximum horizontal and vertical scroll values + this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; + this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; + if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) + { + this._isDrawing = true; + this.isDrawing = true; + this.mouseDown( event ); + } +// else +// { +// console.log("nothing to scroll"); +// } } }, @@ -136,8 +148,8 @@ exports.PanTool = Montage.create(toolBase, delta = 10*event.wheelDelta/120; //console.log( "delta: " + delta ); - this.application.ninja.stage._iframeContainer.scrollLeft += delta; - this.application.ninja.stage._scrollLeft += delta; + this.application.ninja.currentDocument.documentRoot.scrollLeft += delta; +// this.application.ninja.stage._scrollLeft += delta; delta *= zoom; @@ -291,17 +303,19 @@ exports.PanTool = Montage.create(toolBase, if (this._isDrawing) { // get the global screen point - var gPt = [point.x, point.y, this._globalPt[2]]; + var gPt = [point.x, point.y, this._globalPt[2]], + dx, + dy; if (this._altKeyDown) { - var dy = 5*(point.y - this._lastY); + dy = 5*(point.y - this._lastY); this._globalPt[2] += dy; gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; } else if (this._shiftKeyDown) { - var dx = Math.abs( this._shiftPt[0] - gPt[0] ), - dy = Math.abs( this._shiftPt[1] - gPt[1] ); + dx = Math.abs( this._shiftPt[0] - gPt[0] ); + dy = Math.abs( this._shiftPt[1] - gPt[1] ); if (dx >= dy) gPt[1] = this._shiftPt[1]; @@ -310,16 +324,28 @@ exports.PanTool = Montage.create(toolBase, } // update the scrollbars - var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); + var deltaGPt = vecUtils.vecSubtract(2, gPt, this._lastGPt); this._lastGPt = gPt.slice(); this._lastY = point.y; - - var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, - oldTop = this.application.ninja.stage._iframeContainer.scrollTop; - this.application.ninja.stage._iframeContainer.scrollLeft -= deltaGPt[0]; - this.application.ninja.stage._iframeContainer.scrollTop -= deltaGPt[1]; - deltaGPt[0] = oldLeft - this.application.ninja.stage._iframeContainer.scrollLeft; - deltaGPt[1] = oldTop - this.application.ninja.stage._iframeContainer.scrollTop; + var limitX = false; + var limitY = false; + + var oldLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft, + oldTop = this.application.ninja.currentDocument.documentRoot.scrollTop, + newLeft = oldLeft - deltaGPt[0], + newTop = oldTop - deltaGPt[1]; + if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) + { + limitX = true; + } + if((newTop < 0) || (newTop > this._maxVerticalScroll)) + { + limitY = true; + } + this.application.ninja.currentDocument.documentRoot.scrollLeft -= deltaGPt[0]; + this.application.ninja.currentDocument.documentRoot.scrollTop -= deltaGPt[1]; + deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.documentRoot.scrollLeft; + deltaGPt[1] = oldTop - this.application.ninja.currentDocument.documentRoot.scrollTop; gPt[0] -= deltaGPt[0]; gPt[1] -= deltaGPt[1]; @@ -334,7 +360,7 @@ exports.PanTool = Montage.create(toolBase, // limit the change var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); - var tooMuch = false + var tooMuch = false; if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; @@ -349,6 +375,8 @@ exports.PanTool = Montage.create(toolBase, else this._worldPt = wPt; + if(limitX) delta[0] = 0; + if(limitY) delta[1] = 0; // update everything var transMat = Matrix.Translation( delta ); this.applyDeltaMat( transMat ); -- cgit v1.2.3 From 253b8803c71c88a6f87fb1caccd42fa081fc6eca Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 15 May 2012 14:17:41 -0700 Subject: Fixing scrollbar syncing, including pan tool, for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/tools/PanTool.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 132ac0b1..5cfeec75 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -148,8 +148,7 @@ exports.PanTool = Montage.create(toolBase, delta = 10*event.wheelDelta/120; //console.log( "delta: " + delta ); - this.application.ninja.currentDocument.documentRoot.scrollLeft += delta; -// this.application.ninja.stage._scrollLeft += delta; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; delta *= zoom; @@ -330,8 +329,8 @@ exports.PanTool = Montage.create(toolBase, var limitX = false; var limitY = false; - var oldLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft, - oldTop = this.application.ninja.currentDocument.documentRoot.scrollTop, + var oldLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft, + oldTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop, newLeft = oldLeft - deltaGPt[0], newTop = oldTop - deltaGPt[1]; if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) @@ -342,10 +341,10 @@ exports.PanTool = Montage.create(toolBase, { limitY = true; } - this.application.ninja.currentDocument.documentRoot.scrollLeft -= deltaGPt[0]; - this.application.ninja.currentDocument.documentRoot.scrollTop -= deltaGPt[1]; - deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.documentRoot.scrollLeft; - deltaGPt[1] = oldTop - this.application.ninja.currentDocument.documentRoot.scrollTop; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft -= deltaGPt[0]; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= deltaGPt[1]; + deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + deltaGPt[1] = oldTop - this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; gPt[0] -= deltaGPt[0]; gPt[1] -= deltaGPt[1]; -- cgit v1.2.3 From f9f8fdc3000042ba5b4504d91870dc9a32ef25eb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 01:00:22 -0700 Subject: Squashed master into dom-architecture Signed-off-by: Valerio Virgillito --- js/tools/LineTool.js | 3 ++- js/tools/OvalTool.js | 2 +- js/tools/RectTool.js | 2 +- js/tools/TextTool.js | 40 ++++++++++++++-------------------------- 4 files changed, 18 insertions(+), 29 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 5941b464..198d7e69 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -234,7 +234,8 @@ exports.LineTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); + var line = Object.create(Line, {}); + line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); world.addObject(line); world.render(); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 6edec811..e9dc66bb 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -68,7 +68,7 @@ exports.OvalTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); - var oval = new Circle(); //GLCircle(); + var oval = Object.create(Circle, {}); oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); world.addObject(oval); diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 0c14a559..0a3c8200 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -87,7 +87,7 @@ exports.RectTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var rect = new Rectangle(); + var rect = Object.create(Rectangle, {}); rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js index a58aacc6..024a92ce 100755 --- a/js/tools/TextTool.js +++ b/js/tools/TextTool.js @@ -5,13 +5,18 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage, - DrawingTool = require("js/tools/drawing-tool").DrawingTool; + DrawingTool = require("js/tools/drawing-tool").DrawingTool, RichTextEditor = require("node_modules/labs/rich-text-editor.reel").RichTextEditor, ElementsMediator = require("js/mediators/element-mediator").ElementMediator; exports.TextTool = Montage.create(DrawingTool, { + drawingFeedback: { + value: { mode: "Draw3D", type: "rectangle" } + }, - _selectedElement: { value : null }, + _selectedElement: { + value : null + }, selectedElement: { get: function() { @@ -35,9 +40,6 @@ exports.TextTool = Montage.create(DrawingTool, { } } }, - - - drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, HandleLeftButtonDown: { value: function(event) { @@ -81,15 +83,7 @@ exports.TextTool = Montage.create(DrawingTool, { return; } - var drawData, selectedItem; - if(this._hasDraw) { - drawData = this.getDrawingData(); - - if(drawData) { - //this.insertElement(drawData); - } - this._hasDraw = false; this.endDraw(event); } else { @@ -113,6 +107,8 @@ exports.TextTool = Montage.create(DrawingTool, { drawTextTool: { value: function() { + var self = this; + this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML; if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; } this.selectedElement.innerHTML = ""; @@ -125,35 +121,27 @@ exports.TextTool = Montage.create(DrawingTool, { this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px"; this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px"; - // Set font styling (Size, Style, Weight) - - me = this; this.application.ninja.stage.textTool.didDraw = function() { - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element, ["overflow"]); - me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element, ["overflow"]); + self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); var range = document.createRange(), sel = window.getSelection(); sel.removeAllRanges(); - range.selectNodeContents(this.application.ninja.stage.textTool.element.firstChild); + range.selectNodeContents(self.application.ninja.stage.textTool.element.firstChild); sel.addRange(range); this.didDraw = function() {}; } } }, + /* HandleDoubleClick: { value: function(e) { //this.application.ninja.selectedElements[0].setAttribute("contenteditable", true); - - //if (!this.application.ninja.textTool) { - - //} - - - } }, + */ Configure: { value: function(wasSelected) { -- cgit v1.2.3 From db749e10fdff655c2f3b8336a8cc58bf4f389e2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 17 May 2012 10:47:53 -0700 Subject: IKNinja-1628 - Can't draw shapes inside canvas after double-clicking into canvas. Signed-off-by: Nivesh Rajbhandari --- js/tools/ShapeTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 0562dbc2..367ab78d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -72,7 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(!canvas.elementModel.shapeModel) { canvas.elementModel.shapeModel = Montage.create(ShapeModel); } - this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); + this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas); } } -- cgit v1.2.3