aboutsummaryrefslogtreecommitdiff
path: root/js/ninja.reel/ninja.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-06-11 11:17:41 -0700
committerArmen Kesablyan2012-06-11 11:17:41 -0700
commit278769df00ced8620fd73371e38fe2e43f07ca3b (patch)
treedeb505c8a66b660eee1f17a2c6c4c575c7939f6f /js/ninja.reel/ninja.js
parent555fd6efa605b937800b3979a4c68fa7eb8666ae (diff)
parent0f040acabfb7a4bf3138debec5aff869487ceb11 (diff)
downloadninja-278769df00ced8620fd73371e38fe2e43f07ca3b.tar.gz
Merge branch 'refs/heads/master' into binding
Conflicts: js/document/models/html.js js/document/views/design.js js/ninja.reel/ninja.js Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/ninja.reel/ninja.js')
-rwxr-xr-xjs/ninja.reel/ninja.js133
1 files changed, 84 insertions, 49 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index 9f5a65bd..5f753bd3 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,26 @@ 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
27 documentList: {
28 value: null
29 },
30
31 currentDocument: {
32 get: function() {
33 if(this.documentList.selectedObjects) {
34 return this.documentList.selectedObjects[0];
35 } else {
36 return null;
37 }
38 }
39 },
40
41 _workspaceMode: {
22 value: null 42 value: null
23 }, 43 },
24 44
@@ -37,16 +57,6 @@ exports.Ninja = Montage.create(Component, {
37 } 57 }
38 }, 58 },
39 59
40 toolsData: { value: null },
41 appData: { value: AppData },
42
43 currentDocument: {
44 value: null
45 },
46
47 _isResizing: {
48 value: null
49 },
50 _resizedHeight : { 60 _resizedHeight : {
51 value: 0 61 value: 0
52 }, 62 },
@@ -74,9 +84,10 @@ exports.Ninja = Montage.create(Component, {
74 } 84 }
75 }, 85 },
76 86
77 _resizedWidth : { 87 _resizedWidth: {
78 value: 0 88 value: 0
79 }, 89 },
90
80 _width: { 91 _width: {
81 value: null 92 value: null
82 }, 93 },
@@ -148,7 +159,6 @@ exports.Ninja = Montage.create(Component, {
148 } 159 }
149 }, 160 },
150 161
151
152 selectedElements: { 162 selectedElements: {
153 value: [] 163 value: []
154 }, 164 },
@@ -194,27 +204,53 @@ exports.Ninja = Montage.create(Component, {
194 204
195 this.eventManager.addEventListener("selectTool", this, false); 205 this.eventManager.addEventListener("selectTool", this, false);
196 this.eventManager.addEventListener("selectSubTool", this, false); 206 this.eventManager.addEventListener("selectSubTool", this, false);
197 this.eventManager.addEventListener("onOpenDocument", this, false);
198 this.eventManager.addEventListener("onSwitchDocument", this, false);
199 207
200 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); 208 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false);
201 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); 209 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false);
202 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false); 210 this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false);
203
204 NJevent("appLoading");
205 } 211 }
206 }, 212 },
207 213
208 214
209 //////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////
216 ////////////////////////////////////////////////////////////////////
210 //TODO: Expand method to allow other browsers for preview 217 //TODO: Expand method to allow other browsers for preview
211 executeChromePreview: { 218 executeChromePreview: {
212 value: function () { 219 value: function () {
213 this.application.ninja.documentController.activeDocument.model.browserPreview('chrome'); 220 //TODO: Make into proper component
221 this.saveOperationScreen = {};
222 this._saveOperationPopup = {};
223 //Show
224 this.saveOperationScreen.show = function (ctxt) {
225 //
226 ctxt._saveOperationPopup.blackout = document.createElement('div');
227 ctxt._saveOperationPopup.blackout.style.width = '100%';
228 ctxt._saveOperationPopup.blackout.style.height = '100%';
229 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%)';
230 ctxt.application.ninja.popupManager.addPopup(ctxt._saveOperationPopup.blackout);
231 };
232 //Hide
233 this.saveOperationScreen.hide = function (ctxt) {
234 ctxt.application.ninja.popupManager.removePopup(ctxt._saveOperationPopup.blackout);
235 };
236 //
237 this.currentDocument.model.browserPreview('chrome', this.saveOperationScreen, this);
214 } 238 }
215 }, 239 },
216 //////////////////////////////////////////////////////////////////// 240 ////////////////////////////////////////////////////////////////////
217 241
242 //TODO: Make into proper component
243 _saveOperationPopup: {
244 value: null
245 },
246 //TODO: Make into proper component
247 saveOperationScreen: {
248 value: null
249 },
250
251 ////////////////////////////////////////////////////////////////////
252 ////////////////////////////////////////////////////////////////////
253
218 254
219 handleResize: { 255 handleResize: {
220 value: function() { 256 value: function() {
@@ -295,31 +331,40 @@ exports.Ninja = Montage.create(Component, {
295 } 331 }
296 }, 332 },
297 333
298 handleOnOpenDocument: { 334 openDocument: {
299 value: function(event) { 335 value: function(doc) {
300 this.currentDocument = event.detail; 336 this.documentList.content.push(doc);
337 // This is not needed with the latest 0.10 montage.
338 // TODO: Remove this when integrating the next montage
339 this.documentList.selectedObjects = [doc];
301 340
302 if(this.currentDocument.model.documentRoot) { 341 if(doc.currentView === "design") {
303 this.currentSelectedContainer = this.currentDocument.model.documentRoot; 342 // TODO: Bind directly to the model of the document in components instead of this property
304 } else { 343 this._currentSelectedContainer = null;
305 alert("The current document has not loaded yet"); 344 this.currentSelectedContainer = doc.model.documentRoot;
306 return;
307 } 345 }
308
309 this.appModel.show3dGrid = this.currentDocument.draw3DGrid;
310 NJevent("openDocument");
311 } 346 }
312 }, 347 },
313 348
314 handleOnSwitchDocument: { 349 closeFile: {
315 value: function() { 350 value: function(document) {
316 this.currentDocument = this.documentController.activeDocument; 351 var doc = this.documentList.content[this.documentList.content.indexOf(document)], activeDocument;
317 352
318 if(this.currentDocument.model.documentRoot) { 353 if(this.documentList.selectedObjects[0] !== doc) {
319 this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.model.documentRoot; 354 activeDocument = this.documentList.selectedObjects[0];
355 } else {
356 activeDocument = null;
320 } 357 }
321 358
322 NJevent("switchDocument"); 359 this.documentList.removeObjects(doc);
360
361 if(activeDocument) {
362 this.documentList.selectedObjects = [activeDocument];
363 } else {
364 if(this.documentList.content.length) {
365 this.documentList.selectedObjects = this.documentList.content[0];
366 }
367 }
323 } 368 }
324 }, 369 },
325 370
@@ -380,16 +425,6 @@ exports.Ninja = Montage.create(Component, {
380 } 425 }
381 }, 426 },
382 427
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: { 428 setupGlobalHelpers: {
394 value: function() { 429 value: function() {
395 430