diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 6 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 6 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 9 | ||||
-rwxr-xr-x | js/document/html-document.js | 59 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 20 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 1 | ||||
-rwxr-xr-x | js/stage/stage-deps.js | 38 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 14 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 4 |
9 files changed, 126 insertions, 31 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 48e33267..f323ed99 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -321,7 +321,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
321 | // Event Detail: Contains the current ActiveDocument | 321 | // Event Detail: Contains the current ActiveDocument |
322 | _onOpenDocument: { | 322 | _onOpenDocument: { |
323 | value: function(doc){ | 323 | value: function(doc){ |
324 | //var data = DocumentManager.activeDocument; | 324 | this.application.ninja.currentDocument = doc; |
325 | this._hideCurrentDocument(); | 325 | this._hideCurrentDocument(); |
326 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); | 326 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); |
327 | 327 | ||
@@ -405,7 +405,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
405 | value: function() { | 405 | value: function() { |
406 | if(this.activeDocument) { | 406 | if(this.activeDocument) { |
407 | if(this.activeDocument.currentView === "design"){ | 407 | if(this.activeDocument.currentView === "design"){ |
408 | this.application.ninja.stage.saveScroll(); | 408 | this.activeDocument.saveAppState(); |
409 | this.activeDocument.container.parentNode.style["display"] = "none"; | 409 | this.activeDocument.container.parentNode.style["display"] = "none"; |
410 | this.application.ninja.stage.hideCanvas(true); | 410 | this.application.ninja.stage.hideCanvas(true); |
411 | this.application.ninja.stage.stageView.hideRulers(); | 411 | this.application.ninja.stage.stageView.hideRulers(); |
@@ -422,7 +422,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
422 | this.activeDocument.container.style["display"] = "block"; | 422 | this.activeDocument.container.style["display"] = "block"; |
423 | if(this.activeDocument.currentView === "design"){ | 423 | if(this.activeDocument.currentView === "design"){ |
424 | this.activeDocument.container.parentNode.style["display"] = "block"; | 424 | this.activeDocument.container.parentNode.style["display"] = "block"; |
425 | this.application.ninja.stage.restoreScroll(); | 425 | this.activeDocument.restoreAppState(); |
426 | this.application.ninja.stage.hideCanvas(false); | 426 | this.application.ninja.stage.hideCanvas(false); |
427 | this.application.ninja.stage.stageView.showRulers(); | 427 | this.application.ninja.stage.stageView.showRulers(); |
428 | }else{ | 428 | }else{ |
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index ac14def4..d6f2bc56 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 02e9918f..f260b665 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -53,6 +53,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
53 | }, | 53 | }, |
54 | 54 | ||
55 | 55 | ||
56 | //drawUtils state | ||
57 | _gridHorizontalSpacing: {value:0}, | ||
58 | _gridVerticalSpacing: {value:0}, | ||
59 | //end - drawUtils state | ||
60 | |||
56 | 61 | ||
57 | // GETTERS / SETTERS | 62 | // GETTERS / SETTERS |
58 | 63 | ||
@@ -71,6 +76,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
71 | set: function(value) { this._savedTopScroll = value} | 76 | set: function(value) { this._savedTopScroll = value} |
72 | }, | 77 | }, |
73 | 78 | ||
79 | gridHorizontalSpacing:{ | ||
80 | get: function() { return this._gridHorizontalSpacing; }, | ||
81 | set: function(value) { this._gridHorizontalSpacing = value} | ||
82 | }, | ||
83 | |||
84 | gridVerticalSpacing:{ | ||
85 | get: function() { return this._gridVerticalSpacing; }, | ||
86 | set: function(value) { this._gridVerticalSpacing = value} | ||
87 | }, | ||
88 | |||
74 | selectionExclude: { | 89 | selectionExclude: { |
75 | get: function() { return this._selectionExclude; }, | 90 | get: function() { return this._selectionExclude; }, |
76 | set: function(value) { this._selectionExclude = value; } | 91 | set: function(value) { this._selectionExclude = value; } |
@@ -444,7 +459,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
444 | this._styles = this._document.styleSheets[1]; | 459 | this._styles = this._document.styleSheets[1]; |
445 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array | 460 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array |
446 | 461 | ||
447 | console.log(this._document.styleSheets); | 462 | //console.log(this._document.styleSheets); |
448 | 463 | ||
449 | //////////////////////////////////////////////////////////////////////////// | 464 | //////////////////////////////////////////////////////////////////////////// |
450 | //////////////////////////////////////////////////////////////////////////// | 465 | //////////////////////////////////////////////////////////////////////////// |
@@ -570,7 +585,47 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
570 | //Error | 585 | //Error |
571 | } | 586 | } |
572 | } | 587 | } |
573 | } | 588 | }, |
574 | //////////////////////////////////////////////////////////////////// | 589 | //////////////////////////////////////////////////////////////////// |
590 | saveAppState:{ | ||
591 | enumerable: false, | ||
592 | value: function () { | ||
593 | |||
594 | this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; | ||
595 | this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; | ||
596 | |||
597 | this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; | ||
598 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | ||
599 | |||
600 | //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory | ||
601 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ | ||
602 | this.selectionModel = this.application.ninja.selectedElements; | ||
603 | } | ||
604 | } | ||
605 | }, | ||
606 | |||
607 | //////////////////////////////////////////////////////////////////// | ||
608 | restoreAppState:{ | ||
609 | enumerable: false, | ||
610 | value: function () { | ||
611 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ | ||
612 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; | ||
613 | this.application.ninja.stage._scrollLeft = this.savedLeftScroll; | ||
614 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; | ||
615 | this.application.ninja.stage._scrollTop = this.savedTopScroll; | ||
616 | } | ||
617 | |||
618 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | ||
619 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | ||
620 | |||
621 | //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate | ||
622 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ | ||
623 | this.application.ninja.selectionController.initWithDocument(this.selectionModel); | ||
624 | } | ||
625 | |||
626 | |||
627 | } | ||
628 | } | ||
629 | |||
575 | //////////////////////////////////////////////////////////////////// | 630 | //////////////////////////////////////////////////////////////////// |
576 | }); \ No newline at end of file | 631 | }); \ 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/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-ma |