diff options
author | John Mayhew | 2012-04-02 16:28:39 -0700 |
---|---|---|
committer | John Mayhew | 2012-04-02 16:28:39 -0700 |
commit | b4155fb4c33675a8a7cd37473513718043fdf0ba (patch) | |
tree | 3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/controllers/document-controller.js | |
parent | 5ba9aeac94c86049423fd5d4b37b277263939c13 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/helper-classes/RDGE/rdge-compiled.js
js/helper-classes/RDGE/runtime/GLRuntime.js
js/helper-classes/RDGE/src/core/script/MeshManager.js
js/helper-classes/RDGE/src/core/script/engine.js
js/helper-classes/RDGE/src/core/script/fx/ssao.js
js/helper-classes/RDGE/src/core/script/init_state.js
js/helper-classes/RDGE/src/core/script/run_state.js
js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
js/helper-classes/RDGE/src/core/script/utilities.js
js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
js/helper-classes/RDGE/src/tools/rdge-compiled.js
js/lib/drawing/world.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/linear-gradient-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-blur-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
js/preloader/Preloader.js
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-x | js/controllers/document-controller.js | 92 |
1 files changed, 81 insertions, 11 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a8056519..a308f191 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -32,22 +32,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
32 | _iframeHolder: { value: null, enumerable: false }, | 32 | _iframeHolder: { value: null, enumerable: false }, |
33 | _textHolder: { value: null, enumerable: false }, | 33 | _textHolder: { value: null, enumerable: false }, |
34 | _codeMirrorCounter: {value: 1, enumerable: false}, | 34 | _codeMirrorCounter: {value: 1, enumerable: false}, |
35 | |||
36 | canSave:{value: false},//for Save menu state update | ||
37 | canSaveAll:{value: false},//for Save All menu state update | ||
35 | 38 | ||
36 | activeDocument: { | 39 | activeDocument: { |
37 | get: function() { | 40 | get: function() { |
38 | return this._activeDocument; | 41 | return this._activeDocument; |
39 | }, | 42 | }, |
40 | set: function(doc) { | 43 | set: function(doc) { |
41 | if(!!this._activeDocument) this._activeDocument.isActive = false; | 44 | if(!!this._activeDocument){ this._activeDocument.isActive = false;} |
42 | |||
43 | this._activeDocument = doc; | 45 | this._activeDocument = doc; |
44 | if(!!this._activeDocument){ | 46 | if(!!this._activeDocument){ |
45 | |||
46 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); | 47 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
47 | this._activeDocument.isActive = true; | 48 | this._activeDocument.isActive = true; |
49 | |||
48 | if(!!this._activeDocument.editor){ | 50 | if(!!this._activeDocument.editor){ |
49 | this._activeDocument.editor.focus(); | 51 | this._activeDocument.editor.focus(); |
50 | } | 52 | } |
53 | |||
54 | this.canSave = doc.needsSave; | ||
55 | this.canSaveAll = doc.needsSave; | ||
56 | }else{ | ||
57 | this.canSave = false; | ||
58 | this.canSaveAll = false; | ||
51 | } | 59 | } |
52 | } | 60 | } |
53 | }, | 61 | }, |
@@ -60,25 +68,34 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
60 | this.eventManager.addEventListener("executeSave", this, false); | 68 | this.eventManager.addEventListener("executeSave", this, false); |
61 | this.eventManager.addEventListener("executeSaveAs", this, false); | 69 | this.eventManager.addEventListener("executeSaveAs", this, false); |
62 | this.eventManager.addEventListener("executeSaveAll", this, false); | 70 | this.eventManager.addEventListener("executeSaveAll", this, false); |
71 | this.eventManager.addEventListener("executeFileClose", this, false); | ||
72 | this.eventManager.addEventListener("executeFileCloseAll", this, false); | ||
63 | 73 | ||
64 | this.eventManager.addEventListener("recordStyleChanged", this, false); | 74 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
65 | 75 | ||
76 | this.eventManager.addEventListener("addComponentFirstDraw", this, false); | ||
66 | } | 77 | } |
67 | }, | 78 | }, |
68 | 79 | ||
69 | 80 | handleAddComponentFirstDraw: { | |
81 | value: function (e) { | ||
82 | //TODO: Add logic to reparse the document for dynamically added styles | ||
83 | console.log(e); | ||
84 | } | ||
85 | }, | ||
70 | 86 | ||
71 | 87 | ||
72 | 88 | ||
73 | 89 | ||
74 | 90 | ||
75 | //////////////////////////////////////////////////////////////////// | 91 | //////////////////////////////////////////////////////////////////// |
76 | // | 92 | // |
77 | handleWebRequest: { | 93 | handleWebRequest: { |
78 | value: function (request) { | 94 | value: function (request) { |
79 | //TODO: Check if frameId is proper | 95 | //TODO: Check if frameId is proper |
80 | if (this._hackRootFlag && request.parentFrameId !== -1) { | 96 | if (this._hackRootFlag && request.parentFrameId !== -1) { |
81 | //TODO: Optimize creating string | 97 | //TODO: Optimize creating string |
98 | //console.log(request); | ||
82 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); | 99 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); |
83 | //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; | 100 | //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; |
84 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; | 101 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; |
@@ -102,6 +119,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
102 | }, | 119 | }, |
103 | //////////////////////////////////////////////////////////////////// | 120 | //////////////////////////////////////////////////////////////////// |
104 | 121 | ||
122 | |||
105 | 123 | ||
106 | 124 | ||
107 | 125 | ||
@@ -157,17 +175,40 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
157 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 175 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
158 | saveAsSettings.fileName = this.activeDocument.name; | 176 | saveAsSettings.fileName = this.activeDocument.name; |
159 | saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); | 177 | saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); |
160 | //add callback | 178 | saveAsSettings.callback = this.saveAsCallback.bind(this); |
161 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); | 179 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); |
162 | } | 180 | } |
163 | } | 181 | } |
164 | }, | 182 | }, |
165 | 183 | //////////////////////////////////////////////////////////////////// | |
184 | handleExecuteFileClose:{ | ||
185 | value: function(event) { | ||
186 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
187 | this.closeDocument(this.activeDocument.uuid); | ||
188 | } | ||
189 | } | ||
190 | }, | ||
191 | //////////////////////////////////////////////////////////////////// | ||
192 | handleExecuteFileCloseAll:{ | ||
193 | value: function(event) { | ||
194 | var i=0; | ||
195 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
196 | while(this._documents.length > 0){ | ||
197 | this.closeDocument(this._documents[this._documents.length -1].uuid); | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | }, | ||
202 | //////////////////////////////////////////////////////////////////// | ||
166 | // | 203 | // |
167 | fileSaveResult: { | 204 | fileSaveResult: { |
168 | value: function (result) { | 205 | value: function (result) { |
169 | if(result.status === 204){ | 206 | if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved |
170 | this.activeDocument.needsSave = false; | 207 | this.activeDocument.needsSave = false; |
208 | if(this.application.ninja.currentDocument !== null){ | ||
209 | //clear Dirty StyleSheets for the saved document | ||
210 | this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); | ||
211 | } | ||
171 | } | 212 | } |
172 | } | 213 | } |
173 | }, | 214 | }, |
@@ -249,6 +290,29 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
249 | }, | 290 | }, |
250 | //////////////////////////////////////////////////////////////////// | 291 | //////////////////////////////////////////////////////////////////// |
251 | // | 292 | // |
293 | saveAsCallback:{ | ||
294 | value:function(saveAsDetails){ | ||
295 | var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; | ||
296 | //update document metadata | ||
297 | this.activeDocument.name = ""+filename; | ||
298 | //prepare new file uri | ||
299 | if(destination && (destination.charAt(destination.length -1) !== "/")){ | ||
300 | destination = destination + "/"; | ||
301 | } | ||
302 | fileUri = destination+filename; | ||
303 | |||
304 | this.activeDocument.uri = fileUri; | ||
305 | //save a new file | ||
306 | //use the ioMediator.fileSaveAll when implemented | ||
307 | this.activeDocument._userDocument.name=filename; | ||
308 | this.activeDocument._userDocument.root=destination; | ||
309 | this.activeDocument._userDocument.uri=fileUri; | ||
310 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); | ||
311 | // | ||
312 | } | ||
313 | }, | ||
314 | |||
315 | //////////////////////////////////////////////////////////////////// | ||
252 | openDocument: { | 316 | openDocument: { |
253 | value: function(doc) { | 317 | value: function(doc) { |
254 | 318 | ||
@@ -336,7 +400,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
336 | nextDocumentIndex = closeDocumentIndex - 1; | 400 | nextDocumentIndex = closeDocumentIndex - 1; |
337 | } | 401 | } |
338 | this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); | 402 | this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); |
339 | if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} | 403 | if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} |
340 | this._removeDocumentView(doc.container); | 404 | this._removeDocumentView(doc.container); |
341 | }else if(this._documents.length === 0){ | 405 | }else if(this._documents.length === 0){ |
342 | if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ | 406 | if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ |
@@ -515,5 +579,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
515 | value: function() { | 579 | value: function() { |
516 | return "userDocument_" + (this._iframeCounter++); | 580 | return "userDocument_" + (this._iframeCounter++); |
517 | } | 581 | } |
582 | }, | ||
583 | < |