diff options
Diffstat (limited to 'js/ninja.reel/ninja.js')
-rwxr-xr-x | js/ninja.reel/ninja.js | 126 |
1 files changed, 82 insertions, 44 deletions
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index d0eb1557..38f5efcf 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 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var 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 | ||
12 | var matrix = require("js/lib/math/matrix"); | 13 | var matrix = require("js/lib/math/matrix"); |
13 | var NjUtils = require("js/lib/NJUtils").NJUtils; | 14 | var NjUtils = require("js/lib/NJUtils").NJUtils; |
@@ -18,16 +19,28 @@ exports.Ninja = Montage.create(Component, { | |||
18 | value: null | 19 | value: null |
19 | }, | 20 | }, |
20 | 21 | ||
21 | toolsData: { value: null }, | 22 | toolsData: { |
22 | appData: { value: AppData }, | ||
23 | |||
24 | currentDocument: { | ||
25 | value: null | 23 | value: null |
26 | }, | 24 | }, |
27 | 25 | ||
28 | _isResizing: { | 26 | appData: { |
27 | value: AppData | ||
28 | }, | ||
29 | |||
30 | documentList: { | ||
29 | value: null | 31 | value: null |
30 | }, | 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 | |||
31 | _resizedHeight : { | 44 | _resizedHeight : { |
32 | value: 0 | 45 | value: 0 |
33 | }, | 46 | }, |
@@ -55,9 +68,10 @@ exports.Ninja = Montage.create(Component, { | |||
55 | } | 68 | } |
56 | }, | 69 | }, |
57 | 70 | ||
58 | _resizedWidth : { | 71 | _resizedWidth: { |
59 | value: 0 | 72 | value: 0 |
60 | }, | 73 | }, |
74 | |||
61 | _width: { | 75 | _width: { |
62 | value: null | 76 | value: null |
63 | }, | 77 | }, |
@@ -129,7 +143,6 @@ exports.Ninja = Montage.create(Component, { | |||
129 | } | 143 | } |
130 | }, | 144 | }, |
131 | 145 | ||
132 | |||
133 | selectedElements: { | 146 | selectedElements: { |
134 | value: [] | 147 | value: [] |
135 | }, | 148 | }, |
@@ -174,27 +187,53 @@ exports.Ninja = Montage.create(Component, { | |||
174 | 187 | ||
175 | this.eventManager.addEventListener("selectTool", this, false); | 188 | this.eventManager.addEventListener("selectTool", this, false); |
176 | this.eventManager.addEventListener("selectSubTool", this, false); | 189 | this.eventManager.addEventListener("selectSubTool", this, false); |
177 | this.eventManager.addEventListener("onOpenDocument", this, false); | ||
178 | this.eventManager.addEventListener("onSwitchDocument", this, false); | ||
179 | 190 | ||
180 | this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); | 191 | this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); |
181 | this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); | 192 | this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); |
182 | this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false); | 193 | this.addPropertyChangeListener("appModel.debug", this.toggleDebug, false); |
183 | |||
184 | NJevent("appLoading"); | ||
185 | } | 194 | } |
186 | }, | 195 | }, |
187 | 196 | ||
188 | 197 | ||
189 | //////////////////////////////////////////////////////////////////// | 198 | //////////////////////////////////////////////////////////////////// |
199 | //////////////////////////////////////////////////////////////////// | ||
190 | //TODO: Expand method to allow other browsers for preview | 200 | //TODO: Expand method to allow other browsers for preview |
191 | executeChromePreview: { | 201 | executeChromePreview: { |
192 | value: function () { | 202 | value: function () { |
193 | this.application.ninja.documentController.activeDocument.model.browserPreview('chrome'); | 203 | //TODO: Make into proper component |
204 | this.saveOperationScreen = {}; | ||
205 | this._saveOperationPopup = {}; | ||
206 | //Show | ||
207 | this.saveOperationScreen.show = function (ctxt) { | ||
208 | // | ||
209 | ctxt._saveOperationPopup.blackout = document.createElement('div'); | ||
210 | ctxt._saveOperationPopup.blackout.style.width = '100%'; | ||
211 | ctxt._saveOperationPopup.blackout.style.height = '100%'; | ||
212 | 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%)'; | ||
213 | ctxt.application.ninja.popupManager.addPopup(ctxt._saveOperationPopup.blackout); | ||
214 | }; | ||
215 | //Hide | ||
216 | this.saveOperationScreen.hide = function (ctxt) { | ||
217 | ctxt.application.ninja.popupManager.removePopup(ctxt._saveOperationPopup.blackout); | ||
218 | }; | ||
219 | // | ||
220 | this.currentDocument.model.browserPreview('chrome', this.saveOperationScreen, this); | ||
194 | } | 221 | } |
195 | }, | 222 | }, |
196 | //////////////////////////////////////////////////////////////////// | 223 | //////////////////////////////////////////////////////////////////// |
197 | 224 | ||
225 | //TODO: Make into proper component | ||
226 | _saveOperationPopup: { | ||
227 | value: null | ||
228 | }, | ||
229 | //TODO: Make into proper component | ||
230 | saveOperationScreen: { | ||
231 | value: null | ||
232 | }, | ||
233 | |||
234 | //////////////////////////////////////////////////////////////////// | ||
235 | //////////////////////////////////////////////////////////////////// | ||
236 | |||
198 | 237 | ||
199 | handleResize: { | 238 | handleResize: { |
200 | value: function() { | 239 | value: function() { |
@@ -275,31 +314,40 @@ exports.Ninja = Montage.create(Component, { | |||
275 | } | 314 | } |
276 | }, | 315 | }, |
277 | 316 | ||
278 | handleOnOpenDocument: { | 317 | openDocument: { |
279 | value: function(event) { | 318 | value: function(doc) { |
280 | this.currentDocument = event.detail; | 319 | this.documentList.content.push(doc); |
281 | 320 | // This is not needed with the latest 0.10 montage. | |
282 | if(this.currentDocument.model.documentRoot) { | 321 | // TODO: Remove this when integrating the next montage |
283 | this.currentSelectedContainer = this.currentDocument.model.documentRoot; | 322 | this.documentList.selectedObjects = [doc]; |
284 | } else { | 323 | |
285 | alert("The current document has not loaded yet"); | 324 | if(doc.currentView === "design") { |
286 | return; | 325 | // TODO: Bind directly to the model of the document in components instead of this property |
326 | this._currentSelectedContainer = null; | ||
327 | this.currentSelectedContainer = doc.model.documentRoot; | ||
287 | } | 328 | } |
288 | |||
289 | this.appModel.show3dGrid = this.currentDocument.draw3DGrid; | ||
290 | NJevent("openDocument"); | ||
291 | } | 329 | } |
292 | }, | 330 | }, |
293 | 331 | ||
294 | handleOnSwitchDocument: { | 332 | closeFile: { |
295 | value: function() { | 333 | value: function(document) { |
296 | this.currentDocument = this.documentController.activeDocument; | 334 | var doc = this.documentList.content[this.documentList.content.indexOf(document)], activeDocument; |
297 | 335 | ||
298 | if(this.currentDocument.model.documentRoot) { | 336 | if(this.documentList.selectedObjects[0] !== doc) { |
299 | this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.model.documentRoot; | 337 | activeDocument = this.documentList.selectedObjects[0]; |
338 | } else { | ||
339 | activeDocument = null; | ||
300 | } | 340 | } |
301 | 341 | ||
302 | NJevent("switchDocument"); | 342 | this.documentList.removeObjects(doc); |
343 | |||
344 | if(activeDocument) { | ||
345 | this.documentList.selectedObjects = [activeDocument]; | ||
346 | } else { | ||
347 | if(this.documentList.content.length) { | ||
348 | this.documentList.selectedObjects = this.documentList.content[0]; | ||
349 | } | ||
350 | } | ||
303 | } | 351 | } |
304 | }, | 352 | }, |
305 | 353 | ||
@@ -360,16 +408,6 @@ exports.Ninja = Montage.create(Component, { | |||
360 | } | 408 | } |
361 | }, | 409 | }, |
362 | 410 | ||
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: { | 411 | setupGlobalHelpers: { |
374 | value: function() { | 412 | value: function() { |
375 | 413 | ||