diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 26 | ||||
-rwxr-xr-x | js/controllers/elements/component-controller.js | 4 | ||||
-rwxr-xr-x | js/document/mediators/template.js | 756 | ||||
-rwxr-xr-x | js/document/models/base.js | 21 | ||||
-rw-r--r-- | js/document/templates/app/main.js | 51 | ||||
-rwxr-xr-x | js/document/views/design.js | 14 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 2 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.js | 42 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 712 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 41 | ||||
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 96 | ||||
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 56 |
12 files changed, 1034 insertions, 787 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index a90375af..a3ebac24 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -174,9 +174,9 @@ exports.DocumentController = Montage.create(Component, { | |||
174 | handleExecuteSaveAll: { | 174 | handleExecuteSaveAll: { |
175 | value: function(event) { | 175 | value: function(event) { |
176 | // | 176 | // |
177 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 177 | if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
178 | // | 178 | // |
179 | this.activeDocument.model.saveAll(); | 179 | this.currentDocument.model.saveAll(); |
180 | } else { | 180 | } else { |
181 | //TODO: Add error handling | 181 | //TODO: Add error handling |
182 | } | 182 | } |
@@ -186,9 +186,9 @@ exports.DocumentController = Montage.create(Component, { | |||
186 | handleExecuteSaveAs: { | 186 | handleExecuteSaveAs: { |
187 | value: function(event) { | 187 | value: function(event) { |
188 | var saveAsSettings = event._event.settings || {}; | 188 | var saveAsSettings = event._event.settings || {}; |
189 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 189 | if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
190 | saveAsSettings.fileName = this.activeDocument.model.file.name; | 190 | saveAsSettings.fileName = this.currentDocument.model.file.name; |
191 | saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); | 191 | saveAsSettings.folderUri = this.currentDocument.model.file.uri.substring(0, this.currentDocument.model.file.uri.lastIndexOf("/")); |
192 | saveAsSettings.callback = this.saveAsCallback.bind(this); | 192 | saveAsSettings.callback = this.saveAsCallback.bind(this); |
193 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); | 193 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); |
194 | } | 194 | } |
@@ -204,9 +204,9 @@ exports.DocumentController = Montage.create(Component, { | |||
204 | //TODO: Is this used, should be cleaned up | 204 | //TODO: Is this used, should be cleaned up |
205 | handleExecuteFileCloseAll:{ | 205 | handleExecuteFileCloseAll:{ |
206 | value: function(event) { | 206 | value: function(event) { |
207 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | 207 | if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ |
208 | while(this._documents.length > 0){ | 208 | while(this.currentDocument.length > 0){ |
209 | this.closeDocument(this._documents[this._documents.length -1].uuid); | 209 | this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
@@ -291,19 +291,19 @@ exports.DocumentController = Montage.create(Component, { | |||
291 | value:function(saveAsDetails){ | 291 | value:function(saveAsDetails){ |
292 | var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; | 292 | var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; |
293 | //update document metadata | 293 | //update document metadata |
294 | this.activeDocument.name = ""+filename; | 294 | this.currentDocument.model.file.name = ""+filename; |
295 | //prepare new file uri | 295 | //prepare new file uri |
296 | if(destination && (destination.charAt(destination.length -1) !== "/")){ | 296 | if(destination && (destination.charAt(destination.length -1) !== "/")){ |
297 | destination = destination + "/"; | 297 | destination = destination + "/"; |
298 | } | 298 | } |
299 | fileUri = destination+filename; | 299 | fileUri = destination+filename; |
300 | 300 | ||
301 | this.activeDocument.uri = fileUri; | 301 | this.currentDocument.model.file.uri = fileUri; |
302 | //save a new file | 302 | //save a new file |
303 | //use the ioMediator.fileSaveAll when implemented | 303 | //use the ioMediator.fileSaveAll when implemented |
304 | this.activeDocument.model.file.name = filename; | 304 | this.currentDocument.model.file.name = filename; |
305 | this.activeDocument.model.file.uri = fileUri; | 305 | this.currentDocument.model.file.uri = fileUri; |
306 | this.activeDocument.model.save(); | 306 | this.currentDocument.model.save(); |
307 | } | 307 | } |
308 | }, | 308 | }, |
309 | 309 | ||
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 5b0aaeac..dd0766df 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
11 | 11 | ||
12 | getProperty: { | 12 | getProperty: { |
13 | value: function(el, prop) { | 13 | value: function(el, prop) { |
14 | var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); | 14 | var component = el.controller; |
15 | 15 | ||
16 | switch(prop) { | 16 | switch(prop) { |
17 | case "id": | 17 | case "id": |
@@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, { | |||
34 | 34 | ||
35 | setProperty: { | 35 | setProperty: { |
36 | value: function(el, p, value) { | 36 | value: function(el, p, value) { |
37 | var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); | 37 | var component = el.controller; |
38 | 38 | ||
39 | switch(p) { | 39 | switch(p) { |
40 | case "id": | 40 | case "id": |
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index c5b45ba1..068a1f48 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js | |||
@@ -6,16 +6,766 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component, |
11 | TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator; | ||
11 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
12 | // | 13 | // |
13 | exports.TemplateDocumentMediator = Montage.create(Component, { | 14 | exports.TemplateDocumentMediator = Montage.create(Component, { |
14 | //////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////// |
15 | // | 16 | // |
16 | hasTemplate: { | 17 | hasTemplate: { |
17 | enumerable: false, | ||
18 | value: false | 18 | value: false |
19 | }, | ||
20 | //////////////////////////////////////////////////////////////////// | ||
21 | // | ||
22 | getAppTemplatesUrlRegEx: { | ||
23 | value: function () { | ||
24 | var regex = new RegExp(chrome.extension.getURL(this.application.ninja.currentDocument.model.views.design.iframe.src.split(chrome.extension.getURL('/'))[1]).replace(/\//gi, '\\\/'), 'gi'); | ||
25 | return regex; | ||
26 | } | ||
27 | }, | ||
28 | //////////////////////////////////////////////////////////////////// | ||
29 | // | ||
30 | getDataDirectory: { | ||
31 | value: function (path) { | ||
32 | //TODO: Implement user overwrite | ||
33 | return this._getUserDirectory(path+'data/'); | ||
34 | } | ||
35 | }, | ||
36 | //////////////////////////////////////////////////////////////////// | ||
37 | // | ||
38 | getNinjaDirectory: { | ||
39 | value: function (path) { | ||
40 | //TODO: Implement user overwrite | ||
41 | return this._getUserDirectory(this.getDataDirectory(path)+'ninja/'); | ||
42 | } | ||
43 | }, | ||
44 | //////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | getCanvasDirectory: { | ||
47 | value: function (path) { | ||
48 | //TODO: Implement user overwrite | ||
49 | return this._getUserDirectory(this.getNinjaDirectory(path)+'canvas/'); | ||
50 | } | ||
51 | }, | ||
52 | //////////////////////////////////////////////////////////////////// | ||
53 | // | ||
54 | _getUserDirectory: { | ||
55 | value: function (path) { | ||
56 | //Checking for data directory | ||
57 | var check = this.application.ninja.coreIoApi.fileExists({uri: path}), directory; | ||
58 | //Creating directory if doesn't exists | ||
59 | switch (check.status) { | ||
60 | case 204: //Exists | ||
61 | directory = path; | ||
62 | break; | ||
63 | case 404: //Doesn't exists | ||
64 | directory = this.application.ninja.coreIoApi.createDirectory({uri: path}); | ||
65 | //Checking for success | ||
66 | if (directory.status === 201) { | ||
67 | directory = path; | ||
68 | } else { | ||
69 | //Error | ||
70 | directory = null; | ||
71 | } | ||
72 | break; | ||
73 | default: //Error | ||
74 | directory = null; | ||
75 | break; | ||
76 | } | ||
77 | //Returning the path to the directory on disk (null for any error) | ||
78 | return directory; | ||
79 | } | ||
80 | }, | ||
81 | //////////////////////////////////////////////////////////////////// | ||
82 | // | ||
83 | parseHtmlToNinjaTemplate: { | ||
84 | value: function (html) { | ||
85 | //Creating temp object to mimic HTML | ||
86 | var doc = window.document.implementation.createHTMLDocument(), template; | ||
87 | //Setting content to temp | ||
88 | doc.getElementsByTagName('html')[0].innerHTML = html; | ||
89 | //Creating return object | ||
90 | return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; | ||
91 | } | ||
92 | }, | ||
93 | //////////////////////////////////////////////////////////////////// | ||
94 | //TODO: Expand to allow more templates, clean up variables | ||
95 | parseNinjaTemplateToHtml: { | ||