aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/document-controller.js6
-rwxr-xr-xjs/controllers/elements/element-controller.js6
-rwxr-xr-xjs/controllers/selection-controller.js9
-rwxr-xr-xjs/document/html-document.js57
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js20
-rwxr-xr-xjs/stage/stage-deps.js38
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js14
-rwxr-xr-xjs/stage/stage.reel/stage.js4
8 files changed, 124 insertions, 30 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 3a77ed5f..6f7d098f 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -335,7 +335,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
335 // Event Detail: Contains the current ActiveDocument 335 // Event Detail: Contains the current ActiveDocument
336 _onOpenDocument: { 336 _onOpenDocument: {
337 value: function(doc){ 337 value: function(doc){
338 //var data = DocumentManager.activeDocument; 338 this.application.ninja.currentDocument = doc;
339 this._hideCurrentDocument(); 339 this._hideCurrentDocument();
340 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); 340 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid);
341 341
@@ -419,7 +419,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
419 value: function() { 419 value: function() {
420 if(this.activeDocument) { 420 if(this.activeDocument) {
421 if(this.activeDocument.currentView === "design"){ 421 if(this.activeDocument.currentView === "design"){
422 this.application.ninja.stage.saveScroll(); 422 this.activeDocument.saveAppState();
423 this.activeDocument.container.parentNode.style["display"] = "none"; 423 this.activeDocument.container.parentNode.style["display"] = "none";
424 this.application.ninja.stage.hideCanvas(true); 424 this.application.ninja.stage.hideCanvas(true);
425 this.application.ninja.stage.stageView.hideRulers(); 425 this.application.ninja.stage.stageView.hideRulers();
@@ -436,7 +436,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
436 this.activeDocument.container.style["display"] = "block"; 436 this.activeDocument.container.style["display"] = "block";
437 if(this.activeDocument.currentView === "design"){ 437 if(this.activeDocument.currentView === "design"){
438 this.activeDocument.container.parentNode.style["display"] = "block"; 438 this.activeDocument.container.parentNode.style["display"] = "block";
439 this.application.ninja.stage.restoreScroll(); 439 this.activeDocument.restoreAppState();
440 this.application.ninja.stage.hideCanvas(false); 440 this.application.ninja.stage.hideCanvas(false);
441 this.application.ninja.stage.stageView.showRulers(); 441 this.application.ninja.stage.stageView.showRulers();
442 }else{ 442 }else{
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 46e82ace..ec0335b4 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -27,7 +27,11 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
27 27
28 getProperty: { 28 getProperty: {
29 value: function(el, prop, fallbackOnComputed, isStageElement) { 29 value: function(el, prop, fallbackOnComputed, isStageElement) {
30 return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); 30 if(el.nodeType !== 3){
31 return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement);
32 }else{
33 return null;
34 }
31 } 35 }
32 }, 36 },
33 37
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index d69b53e0..f50762f3 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -58,6 +58,7 @@ exports.SelectionController = Montage.create(Component, {
58 handleOpenDocument: { 58 handleOpenDocument: {
59 value: function() { 59 value: function() {
60 // Handle initializing the selection array here. 60 // Handle initializing the selection array here.
61 this.initWithDocument([]);
61 } 62 }
62 }, 63 },
63 64
@@ -70,6 +71,14 @@ exports.SelectionController = Montage.create(Component, {
70 if(currentSelectionArray.length >= 1) { 71 if(currentSelectionArray.length >= 1) {
71 this._selectedItems = currentSelectionArray; 72 this._selectedItems = currentSelectionArray;
72 this._isDocument = false; 73 this._isDocument = false;
74
75
76
77 this.application.ninja.selectedElements = currentSelectionArray;
78 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
79
80
81
73 } 82 }
74 } 83 }
75 84
diff --git a/js/document/html-document.js b/js/document/html-document.js
index eaf56146..d38709e3 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -54,6 +54,11 @@ exports.HTMLDocument = Montage.create(TextDocument, {
54 }, 54 },
55 55
56 56
57 //drawUtils state
58 _gridHorizontalSpacing: {value:0},
59 _gridVerticalSpacing: {value:0},
60 //end - drawUtils state
61
57 62
58 // GETTERS / SETTERS 63 // GETTERS / SETTERS
59 64
@@ -72,6 +77,16 @@ exports.HTMLDocument = Montage.create(TextDocument, {
72 set: function(value) { this._savedTopScroll = value} 77 set: function(value) { this._savedTopScroll = value}
73 }, 78 },
74 79
80 gridHorizontalSpacing:{
81 get: function() { return this._gridHorizontalSpacing; },
82 set: function(value) { this._gridHorizontalSpacing = value}
83 },
84
85 gridVerticalSpacing:{
86 get: function() { return this._gridVerticalSpacing; },
87 set: function(value) { this._gridVerticalSpacing = value}
88 },
89
75 selectionExclude: { 90 selectionExclude: {
76 get: function() { return this._selectionExclude; }, 91 get: function() { return this._selectionExclude; },
77 set: function(value) { this._selectionExclude = value; } 92 set: function(value) { this._selectionExclude = value; }
@@ -618,7 +633,47 @@ exports.HTMLDocument = Montage.create(TextDocument, {
618 //Error 633 //Error
619 } 634 }
620 } 635 }
621 } 636 },
622 //////////////////////////////////////////////////////////////////// 637 ////////////////////////////////////////////////////////////////////
638 saveAppState:{
639 enumerable: false,
640 value: function () {
641
642 this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft;
643 this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop;
644
645 this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
646 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
647
648 //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory
649 if(typeof this.application.ninja.selectedElements !== 'undefined'){
650 this.selectionModel = this.application.ninja.selectedElements;
651 }
652 }
653 },
654
655 ////////////////////////////////////////////////////////////////////
656 restoreAppState:{
657 enumerable: false,
658 value: function () {
659 if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){
660 this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll;
661 this.application.ninja.stage._scrollLeft = this.savedLeftScroll;
662 this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll;
663 this.application.ninja.stage._scrollTop = this.savedTopScroll;
664 }
665
666 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing;
667 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
668
669 //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate
670 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){
671 this.application.ninja.selectionController.initWithDocument(this.selectionModel);
672 }
673
674
675 }
676 }
677
623 //////////////////////////////////////////////////////////////////// 678 ////////////////////////////////////////////////////////////////////
624}); \ No newline at end of file 679}); \ No newline at end of file
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index c07391db..37fc1cfc 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -115,6 +115,26 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
115 } 115 }
116 }, 116 },
117 117
118 initializeFromDocument:{
119 value:function(){
120 var documentRootChildren = null, i;
121 //initialize with current document
122 this._eltArray = [];
123 this._planesArray = [];
124 this.setDrawingSurfaceElement(this.application.ninja.stage.canvas);
125 this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage );
126 this.setWorkingPlane( Vector.create( [0,0,1,0] ) );
127
128 //Loop through all the top-level children of the current document and call drawUtils.addElement on them
129 if(this.application.ninja.currentDocument.documentRoot.hasChildNodes()){
130 documentRootChildren = this.application.ninja.currentDocument.documentRoot.childNodes;
131 for(i=0;i<documentRootChildren.length;i++){
132 this.addElement(documentRootChildren[i]);
133 }
134 }
135 }
136 },
137
118 handleElementAdded: { 138 handleElementAdded: {
119 value: function(event) { 139 value: function(event) {
120 this.addElement(event.detail); 140 this.addElement(event.detail);
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index d46e2b81..316a5bb0 100755
--- a/js/stage/stage-deps.js
+++ b/js/stage/stage-deps.js
@@ -23,6 +23,10 @@ exports.StageDeps = Montage.create(Component, {
23 value: snapManager 23 value: snapManager
24 }, 24 },
25 25
26 drawUtils: {
27 value: drawUtils
28 },
29
26 currentStage: { 30 currentStage: {
27 value: null 31 value: null