aboutsummaryrefslogtreecommitdiff
path: root/js/ninja.reel/ninja.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ninja.reel/ninja.js')
-rwxr-xr-xjs/ninja.reel/ninja.js87
1 files changed, 47 insertions, 40 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index d0eb1557..a12270a0 100755
--- a/js/ninja.reel/ninja.js
+++ b/js/ninja.reel/ninja.js
@@ -18,16 +18,28 @@ exports.Ninja = Montage.create(Component, {
18 value: null 18 value: null
19 }, 19 },
20 20
21 toolsData: { value: null }, 21 toolsData: {
22 appData: { value: AppData },
23
24 currentDocument: {
25 value: null 22 value: null
26 }, 23 },
27 24
28 _isResizing: { 25 appData: {
26 value: AppData
27 },
28
29 documentList: {
29 value: null 30 value: null
30 }, 31 },
32
33 currentDocument: {
34 get: function() {
35 if(this.documentList.selectedObjects) {
36 return this.documentList.selectedObjects[0];
37 } else {
38 return null;
39 }
40 }
41 },
42
31 _resizedHeight : { 43 _resizedHeight : {
32 value: 0 44 value: 0
33 }, 45 },
@@ -55,9 +67,10 @@ exports.Ninja = Montage.create(Component, {
55 } 67 }
56 }, 68 },
57 69
58 _resizedWidth : { 70 _resizedWidth: {
59 value: 0 71 value: 0
60 }, 72 },
73
61 _width: { 74 _width: {
62 value: null 75 value: null
63 }, 76 },
@@ -129,7 +142,6 @@ exports.Ninja = Montage.create(Component, {
129 } 142 }
130 }, 143 },
131 144
132
133 selectedElements: { 145 selectedElements: {
134 value: [] 146 value: []
135 }, 147 },
@@ -174,14 +186,10 @@ exports.Ninja = Montage.create(Component, {
174 186
175 this.eventManager.addEventListener("selectTool", this, false); 187 this.eventManager.addEventListener("selectTool", this, false);
176 this.eventManager.addEventListener("selectSubTool", this, false); 188 this.eventManager.addEventListener("selectSubTool", this, false);
177 this.eventManager.addEventListener("onOpenDocument", this, false);
178 this.eventManager.addEventListener("onSwitchDocument", this, false);
179 189
180 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); 190 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false);
181 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); 191 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false);
182 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false); 192 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false);
183
184 NJevent("appLoading");
185 } 193 }
186 }, 194 },
187 195
@@ -190,7 +198,7 @@ exports.Ninja = Montage.create(Component, {
190 //TODO: Expand method to allow other browsers for preview 198 //TODO: Expand method to allow other browsers for preview
191 executeChromePreview: { 199 executeChromePreview: {
192 value: function () { 200 value: function () {
193 this.application.ninja.documentController.activeDocument.model.browserPreview('chrome'); 201 this.currentDocument.model.browserPreview('chrome');
194 } 202 }
195 }, 203 },
196 //////////////////////////////////////////////////////////////////// 204 ////////////////////////////////////////////////////////////////////
@@ -275,31 +283,40 @@ exports.Ninja = Montage.create(Component, {
275 } 283 }
276 }, 284 },
277 285
278 handleOnOpenDocument: { 286 openDocument: {
279 value: function(event) { 287 value: function(doc) {
280 this.currentDocument = event.detail; 288 this.documentList.content.push(doc);
281 289 // This is not needed with the latest 0.10 montage.
282 if(this.currentDocument.model.documentRoot) { 290 // TODO: Remove this when integrating the next montage
283 this.currentSelectedContainer = this.currentDocument.model.documentRoot; 291 this.documentList.selectedObjects = [doc];
284 } else { 292
285 alert("The current document has not loaded yet"); 293 if(doc.currentView === "design") {
286 return; 294 // TODO: Bind directly to the model of the document in components instead of this property
295 this._currentSelectedContainer = null;
296 this.currentSelectedContainer = doc.model.documentRoot;
287 } 297 }
288
289 this.appModel.show3dGrid = this.currentDocument.draw3DGrid;
290 NJevent("openDocument");
291 } 298 }
292 }, 299 },
293 300
294 handleOnSwitchDocument: { 301 closeFile: {
295 value: function() { 302 value: function(document) {
296 this.currentDocument = this.documentController.activeDocument; 303 var doc = this.documentList.content[this.documentList.content.indexOf(document)], activeDocument;
297 304
298 if(this.currentDocument.model.documentRoot) { 305 if(this.documentList.selectedObjects[0] !== doc) {
299 this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.model.documentRoot; 306 activeDocument = this.documentList.selectedObjects[0];
307 } else {
308 activeDocument = null;
300 } 309 }
301 310
302 NJevent("switchDocument"); 311 this.documentList.removeObjects(doc);
312
313 if(activeDocument) {
314 this.documentList.selectedObjects = [activeDocument];
315 } else {
316 if(this.documentList.content.length) {
317 this.documentList.selectedObjects = this.documentList.content[0];
318 }
319 }
303 } 320 }
304 }, 321 },
305 322
@@ -360,16 +377,6 @@ exports.Ninja = Montage.create(Component, {
360 } 377 }
361 }, 378 },
362 379
363 getCurrentToolInstance: {
364 value: function() {
365 if(this.toolsData.selectedTool.container) {
366 return this.toolsList[this.toolsData.selectedSubTool.action];
367 } else {
368 return this.toolsList[this.toolsData.selectedTool.action];
369 }
370 }
371 },
372
373 setupGlobalHelpers: { 380 setupGlobalHelpers: {
374 value: function() { 381 value: function() {
375 382