diff options
author | Valerio Virgillito | 2012-05-24 11:28:27 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-24 11:28:27 -0700 |
commit | a8eb5c65a21af3bf8d8b8eb3e65b494b8bd9bc01 (patch) | |
tree | f6f2e044c646ea2749fafc29f1a1c3fabd2825ea /js | |
parent | 0ca1910df1c78116139664bf39a95cf0ec7c8dc8 (diff) | |
parent | f801708f83aadfc688e69a244eb7cbaeca5d5e8d (diff) | |
download | ninja-a8eb5c65a21af3bf8d8b8eb3e65b494b8bd9bc01.tar.gz |
Merge pull request #254 from mqg734/Dom-Architecture
Updates to stage code for handling multiple document workflow.
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/selection-controller.js | 5 | ||||
-rwxr-xr-x | js/document/document-html.js | 2 | ||||
-rwxr-xr-x | js/document/views/design.js | 29 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 19 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 7 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 13 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 4 | ||||
-rwxr-xr-x | js/stage/layout.js | 6 | ||||
-rwxr-xr-x | js/stage/stage-deps.js | 46 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 95 |
10 files changed, 103 insertions, 123 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 1092615a..214b9032 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -67,10 +67,9 @@ exports.SelectionController = Montage.create(Component, { | |||
67 | this._isDocument = true; | 67 | this._isDocument = true; |
68 | 68 | ||
69 | if(currentSelectionArray) { | 69 | if(currentSelectionArray) { |
70 | if(currentSelectionArray.length >= 1) { | 70 | this.application.ninja.selectedElements = currentSelectionArray; |
71 | if(currentSelectionArray.length) { | ||
71 | this._isDocument = false; | 72 | this._isDocument = false; |
72 | |||
73 | this.application.ninja.selectedElements = currentSelectionArray; | ||
74 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); | 73 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); |
75 | } | 74 | } |
76 | } | 75 | } |
diff --git a/js/document/document-html.js b/js/document/document-html.js index f92a425c..2fc32791 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -98,7 +98,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
98 | this.documentRoot = this.model.views.design.document.body; | 98 | this.documentRoot = this.model.views.design.document.body; |
99 | } | 99 | } |
100 | //TODO: Why is this needed? | 100 | //TODO: Why is this needed? |
101 | this._liveNodeList = this.documentRoot.getElementsByTagName('*'); | 101 | this.model.views.design._liveNodeList = this.documentRoot.getElementsByTagName('*'); |
102 | //Initiliazing document model | 102 | //Initiliazing document model |
103 | document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); | 103 | document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); |
104 | //Adding observer to know when template is ready | 104 | //Adding observer to know when template is ready |
diff --git a/js/document/views/design.js b/js/document/views/design.js index b3887fdf..13f89692 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -67,8 +67,34 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
67 | propertiesPanel: { | 67 | propertiesPanel: { |
68 | value: null | 68 | value: null |
69 | }, | 69 | }, |
70 | |||
70 | //////////////////////////////////////////////////////////////////// | 71 | //////////////////////////////////////////////////////////////////// |
71 | // | 72 | // |
73 | _liveNodeList: { | ||
74 | value: null | ||
75 | }, | ||
76 | |||
77 | getLiveNodeList: { | ||
78 | value: function(useFilter) { | ||
79 | if(useFilter) { | ||
80 | var filteredNodes = [], | ||
81 | childNodes = Array.prototype.slice.call(this._liveNodeList, 0); | ||
82 | |||
83 | childNodes.forEach(function(item) { | ||
84 | if( (item.nodeType === 1) && (item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT")) { | ||
85 | filteredNodes.push(item); | ||
86 | } | ||
87 | }); | ||
88 | return filteredNodes; | ||
89 | } else { | ||
90 | return Array.prototype.slice.call(this._liveNodeList, 0); | ||
91 | } | ||
92 | } | ||
93 | }, | ||
94 | //////////////////////////////////////////////////////////////////// | ||
95 | // | ||
96 | |||
97 | // | ||
72 | initialize: { | 98 | initialize: { |
73 | value: function (parent) { | 99 | value: function (parent) { |
74 | //Creating iFrame for view | 100 | //Creating iFrame for view |
@@ -189,9 +215,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
189 | this._bodyFragment = null; | 215 | this._bodyFragment = null; |
190 | //Calling standard method to finish opening document | 216 | //Calling standard method to finish opening document |
191 | this.bodyContentLoaded(null); | 217 | this.bodyContentLoaded(null); |
192 | //TODO: Move this to be set via the controller | ||
193 | this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); | ||
194 | this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); | ||
195 | } | 218 | } |
196 | }, | 219 | }, |
197 | //////////////////////////////////////////////////////////////////// | 220 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index bf48a723..79be5c14 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -119,7 +119,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
119 | 119 | ||
120 | initializeFromDocument:{ | 120 | initializeFromDocument:{ |
121 | value:function(){ | 121 | value:function(){ |
122 | var documentRootChildren = null, i, stage = this.application.ninja.stage; | 122 | var i, |
123 | documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), | ||
124 | stage = this.application.ninja.stage, | ||
125 | len = documentRootChildren.length; | ||
123 | //initialize with current document | 126 | //initialize with current document |
124 | this._eltArray = []; | 127 | this._eltArray = []; |
125 | this._planesArray = []; | 128 | this._planesArray = []; |
@@ -128,11 +131,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
128 | this.setWorkingPlane( [0,0,1,0] ); | 131 | this.setWorkingPlane( [0,0,1,0] ); |
129 | 132 | ||
130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them | 133 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them |
131 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ | 134 | if(len > 0) { |
132 | documentRootChildren = this.application.ninja.currentDocument._liveNodeList; | 135 | var initL = 0, |
133 | var len = documentRootChildren.length, | 136 | initT = 0, |
134 | minLeft = stage.userPaddingLeft, | 137 | minLeft = 0, |
135 | minTop = stage.userPaddingTop, | 138 | minTop = 0, |
136 | docLeft = stage.documentOffsetLeft, | 139 | docLeft = stage.documentOffsetLeft, |
137 | docTop = stage.documentOffsetTop, | 140 | docTop = stage.documentOffsetTop, |
138 | l, | 141 | l, |
@@ -151,10 +154,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
151 | minTop = t; | 154 | minTop = t; |
152 | } | 155 | } |
153 | } | 156 | } |
154 | if(minLeft !== stage.userPaddingLeft) { | 157 | if(minLeft !== initL) { |
155 | stage.userPaddingLeft = minLeft; | 158 | stage.userPaddingLeft = minLeft; |
156 | } | 159 | } |
157 | if(minTop !== stage.userPaddingTop) { | 160 | if(minTop !== initT) { |
158 | stage.userPaddingTop = minTop; | 161 | stage.userPaddingTop = minTop; |
159 | } | 162 | } |
160 | } | 163 | } |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 0f456e1e..f0f8dbe4 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -470,13 +470,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
470 | } | 470 | } |
471 | }, | 471 | }, |
472 | 472 | ||
473 | reload2DCache: { | ||
474 | value: function() { | ||
475 | this.clear2DCache(); | ||
476 | this.load2DCache(workingPlane); | ||
477 | } | ||
478 | }, | ||
479 | |||
480 | clear2DCache : { | 473 | clear2DCache : { |
481 | value : function() { | 474 | value : function() { |
482 | // clear the 2D cache flags in the objects | 475 | // clear the 2D cache flags in the objects |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 0080bf90..24b30298 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -24,9 +24,6 @@ exports.ViewUtils = Montage.create(Component, { | |||
24 | // keep a stack of viewport objects | 24 | // keep a stack of viewport objects |
25 | _viewportObjStack: { value: []}, | 25 | _viewportObjStack: { value: []}, |
26 | 26 | ||
27 | _userContentLeft: { value: null}, | ||
28 | _userContentTop: { value: null}, | ||
29 | |||
30 | /////////////////////////////////////////////////////////////////////// | 27 | /////////////////////////////////////////////////////////////////////// |
31 | // Property accessors | 28 | // Property accessors |
32 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
@@ -39,9 +36,6 @@ exports.ViewUtils = Montage.create(Component, { | |||
39 | }, | 36 | }, |
40 | getViewportObj: { value: function() { return this.m_viewportObj; } }, | 37 | getViewportObj: { value: function() { return this.m_viewportObj; } }, |
41 | 38 | ||
42 | setUserContentLeft: { value: function(value) { this._userContentLeft = value; }}, | ||
43 | setUserContentTop: { value: function(value) { this._userContentTop = value; }}, | ||
44 | |||
45 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, | 39 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, |
46 | 40 | ||
47 | /////////////////////////////////////////////////////////////////////// | 41 | /////////////////////////////////////////////////////////////////////// |
@@ -385,7 +379,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
385 | // transform the bounds up the tree | 379 | // transform the bounds up the tree |
386 | var parent = child.offsetParent; | 380 | var parent = child.offsetParent; |
387 | // TODO - Should have a different way to check for new template mode | 381 | // TODO - Should have a different way to check for new template mode |
388 | if ( parent || ((child === this.application.ninja.currentDocument.documentRoot) && (child.id !== "UserContent")) ) | 382 | if ( parent || (child === this.application.ninja.currentDocument.documentRoot) ) |
389 | { | 383 | { |
390 | this.setViewportObj( child ); | 384 | this.setViewportObj( child ); |
391 | 385 | ||
@@ -703,8 +697,8 @@ exports.ViewUtils = Montage.create(Component, { | |||
703 | { | 697 | { |
704 | // TODO - Call a routine from the user document controller to get the offsets/margins | 698 | // TODO - Call a routine from the user document controller to get the offsets/margins |
705 | // Once we expose the document controller to ViewUtils | 699 | // Once we expose the document controller to ViewUtils |
706 | offset[0] += this._userContentLeft; | 700 | offset[0] += this.application.ninja.stage._userContentLeft; |
707 | offset[1] += this._userContentTop; | 701 | offset[1] += this.application.ninja.stage._userContentTop; |
708 | } | 702 | } |
709 | 703 | ||
710 | return offset; | 704 | return offset; |
@@ -1282,7 +1276,6 @@ expo |