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.js135
1 files changed, 89 insertions, 46 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index 9f5a65bd..fe20447a 100755
--- a/js/ninja.reel/ninja.js
+++ b/js/ninja.reel/ninja.js
@@ -4,10 +4,11 @@
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5 </copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component,
9 UndoManager = require("montage/core/undo-manager").UndoManager, 9 UndoManager = require("montage/core/undo-manager").UndoManager,
10 AppData = require("js/data/appdata").AppData; 10 AppData = require("js/data/appdata").AppData,
11 Popup = require("js/components/popup.reel").Popup;
11 12
12var matrix = require("js/lib/math/matrix"); 13var matrix = require("js/lib/math/matrix");
13var NjUtils = require("js/lib/NJUtils").NJUtils; 14var NjUtils = require("js/lib/NJUtils").NJUtils;
@@ -18,7 +19,29 @@ exports.Ninja = Montage.create(Component, {
18 value: null 19 value: null
19 }, 20 },
20 21
21 _workspaceMode: { 22 toolsData: {
23 value: null
24 },
25
26 appData: {
27 value: AppData
28 },
29
30 documentList: {
31 value: null
32 },
33
34 currentDocument: {
35 get: function() {
36 if(this.documentList.selectedObjects) {
37 return this.documentList.selectedObjects[0];
38 } else {
39 return null;
40 }
41 }
42 },
43
44 _workspaceMode: {
22 value: null 45 value: null
23 }, 46 },
24 47
@@ -37,19 +60,14 @@ exports.Ninja = Montage.create(Component, {
37 } 60 }
38 }, 61 },
39 62
40 toolsData: { value: null },
41 appData: { value: AppData },
42
43 currentDocument: {
44 value: null
45 },
46
47 _isResizing: { 63 _isResizing: {
48 value: null 64 value: null
49 }, 65 },
66
50 _resizedHeight : { 67 _resizedHeight : {
51 value: 0 68 value: 0
52 }, 69 },
70
53 _height: { 71 _height: {
54 value: null 72 value: null
55 }, 73 },
@@ -74,9 +92,10 @@ exports.Ninja = Montage.create(Component, {
74 } 92 }
75 }, 93 },
76 94
77 _resizedWidth : { 95 _resizedWidth: {
78 value: 0 96 value: 0
79 }, 97 },
98
80 _width: { 99 _width: {
81 value: null 100 value: null
82 }, 101 },
@@ -148,7 +167,6 @@ exports.Ninja = Montage.create(Component, {
148 } 167 }
149 }, 168 },
150 169
151
152 selectedElements: { 170 selectedElements: {
153 value: [] 171 value: []
154 }, 172 },
@@ -194,27 +212,53 @@ exports.Ninja = Montage.create(Component, {
194 212
195 this.eventManager.addEventListener("selectTool", this, false); 213 this.eventManager.addEventListener("selectTool", this, false);
196 this.eventManager.addEventListener("selectSubTool", this, false); 214 this.eventManager.addEventListener("selectSubTool", this, false);
197 this.eventManager.addEventListener("onOpenDocument", this, false);
198 this.eventManager.addEventListener("onSwitchDocument", this, false);
199 215
200 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); 216 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false);
201 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); 217 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false);
202 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false); 218 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false);
203
204 NJevent("appLoading");
205 } 219 }
206 }, 220 },
207 221
208 222
209 //////////////////////////////////////////////////////////////////// 223 ////////////////////////////////////////////////////////////////////
224 ////////////////////////////////////////////////////////////////////
210 //TODO: Expand method to allow other browsers for preview 225 //TODO: Expand method to allow other browsers for preview
211 executeChromePreview: { 226 executeChromePreview: {
212 value: function () { 227 value: function () {
213 this.application.ninja.documentController.activeDocument.model.browserPreview('chrome'); 228 //TODO: Make into proper component
229 this.saveOperationScreen = {};
230 this._saveOperationPopup = {};
231 //Show
232 this.saveOperationScreen.show = function (ctxt) {
233 //
234 ctxt._saveOperationPopup.blackout = document.createElement('div');
235 ctxt._saveOperationPopup.blackout.style.width = '100%';
236 ctxt._saveOperationPopup.blackout.style.height = '100%';
237 ctxt._saveOperationPopup.blackout.style.background = 'rgba(0,0,0,0.8)'; //'-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)';
238 ctxt.application.ninja.popupManager.addPopup(ctxt._saveOperationPopup.blackout);
239 };
240 //Hide
241 this.saveOperationScreen.hide = function (ctxt) {
242 ctxt.application.ninja.popupManager.removePopup(ctxt._saveOperationPopup.blackout);
243 };
244 //
245 this.currentDocument.model.browserPreview('chrome', this.saveOperationScreen, this);
214 } 246 }
215 }, 247 },
216 //////////////////////////////////////////////////////////////////// 248 ////////////////////////////////////////////////////////////////////
217 249
250 //TODO: Make into proper component
251 _saveOperationPopup: {
252 value: null
253 },
254 //TODO: Make into proper component
255 saveOperationScreen: {
256 value: null
257 },
258
259 ////////////////////////////////////////////////////////////////////
260 ////////////////////////////////////////////////////////////////////
261
218 262
219 handleResize: { 263 handleResize: {
220 value: function() { 264 value: function() {
@@ -295,31 +339,40 @@ exports.Ninja = Montage.create(Component, {
295 } 339 }
296 }, 340 },
297 341
298 handleOnOpenDocument: { 342 openDocument: {
299 value: function(event) { 343 value: function(doc) {
300 this.currentDocument = event.detail; 344 this.documentList.content.push(doc);
345 // This is not needed with the latest 0.10 montage.
346 // TODO: Remove this when integrating the next montage
347 this.documentList.selectedObjects = [doc];
301 348
302 if(this.currentDocument.model.documentRoot) { 349 if(doc.currentView === "design") {
303 this.currentSelectedContainer = this.currentDocument.model.documentRoot; 350 // TODO: Bind directly to the model of the document in components instead of this property
304 } else { 351 this._currentSelectedContainer = null;
305 alert("The current document has not loaded yet"); 352 this.currentSelectedContainer = doc.model.documentRoot;
306 return;
307 } 353 }
308
309 this.appModel.show3dGrid = this.currentDocument.draw3DGrid;
310 NJevent("openDocument");
311 } 354 }
312 }, 355 },
313 356
314 handleOnSwitchDocument: { 357 closeFile: {
315 value: function() { 358 value: function(document) {
316 this.currentDocument = this.documentController.activeDocument; 359 var doc = this.documentList.content[this.documentList.content.indexOf(document)], activeDocument;
317 360
318 if(this.currentDocument.model.documentRoot) { 361 if(this.documentList.selectedObjects[0] !== doc) {
319 this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.model.documentRoot; 362 activeDocument = this.documentList.selectedObjects[0];
363 } else {
364 activeDocument = null;
320 } 365 }
321 366
322 NJevent("switchDocument"); 367 this.documentList.removeObjects(doc);
368
369 if(activeDocument) {
370 this.documentList.selectedObjects = [activeDocument];
371 } else {
372 if(this.documentList.content.length) {
373 this.documentList.selectedObjects = this.documentList.content[0];
374 }
375 }
323 } 376 }
324 }, 377 },
325 378
@@ -380,16 +433,6 @@ exports.Ninja = Montage.create(Component, {
380 } 433 }
381 }, 434 },
382 435
383 getCurrentToolInstance: {
384 value: function() {
385 if(this.toolsData.selectedTool.container) {
386 return this.toolsList[this.toolsData.selectedSubTool.action];
387 } else {
388 return this.toolsList[this.toolsData.selectedTool.action];
389 }
390 }
391 },
392
393 setupGlobalHelpers: { <