diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/document/mediators/template.js | 14 | ||||
-rwxr-xr-x | js/document/models/base.js | 13 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 27 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 41 |
4 files changed, 74 insertions, 21 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 17fa553c..c3e8033b 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js | |||
@@ -334,7 +334,9 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
334 | var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [], | 334 | var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [], |
335 | scripts = template.file.content.document.getElementsByTagName('script'), | 335 | scripts = template.file.content.document.getElementsByTagName('script'), |
336 | libsobserver = {montage: false, canvas: false, montageCopied: null, canvasCopied: null, callback: libCopyCallback, dispatched: false}; | 336 | libsobserver = {montage: false, canvas: false, montageCopied: null, canvasCopied: null, callback: libCopyCallback, dispatched: false}; |
337 | 337 | //TODO: Clean up, this is messy | |
338 | if (mJsSerialization) libsobserver.montage = true; | ||
339 | if (template.webgl && template.webgl.length > 1) libsobserver.canvas = true; | ||
338 | // | 340 | // |
339 | for (var i in scripts) { | 341 | for (var i in scripts) { |
340 | if (scripts[i].getAttribute) { | 342 | if (scripts[i].getAttribute) { |
@@ -378,7 +380,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
378 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { | 380 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { |
379 | rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); | 381 | rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); |
380 | rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; | 382 | rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; |
381 | libsobserver.canvas = true; | ||
382 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); | 383 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); |
383 | } else { | 384 | } else { |
384 | //TODO: Error handle no available library to copy | 385 | //TODO: Error handle no available library to copy |
@@ -505,7 +506,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
505 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { | 506 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { |
506 | mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); | 507 | mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); |
507 | mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; | 508 | mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; |
508 | libsobserver.montage = true; | ||
509 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); | 509 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); |
510 | 510 | ||
511 | 511 | ||
@@ -589,7 +589,11 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
589 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); | 589 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); |
590 | } | 590 | } |
591 | // | 591 | // |
592 | return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); | 592 | if (libsobserver.montage || libsobserver.canvas) { |
593 | return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: true}; | ||
594 | } else { | ||
595 | return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: false}; | ||
596 | } | ||
593 | } | 597 | } |
594 | }, | 598 | }, |
595 | //////////////////////////////////////////////////////////////////// | 599 | //////////////////////////////////////////////////////////////////// |
@@ -614,7 +618,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
614 | if (observer.callback && !observer.dispatched) observer.callback(false); | 618 | if (observer.callback && !observer.dispatched) observer.callback(false); |
615 | observer.dispatched = true; | 619 | observer.dispatched = true; |
616 | } | 620 | } |
617 | } else if (observer.canvas && observer.canvasCopied) { | 621 | } else if (observer.canvas) { |
618 | // | 622 | // |
619 | if (observer.canvasCopied) { | 623 | if (observer.canvasCopied) { |
620 | if (observer.callback && !observer.dispatched) observer.callback(true); | 624 | if (observer.callback && !observer.dispatched) observer.callback(true); |
diff --git a/js/document/models/base.js b/js/document/models/base.js index 27f7d43f..0957145a 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -99,11 +99,20 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
99 | //////////////////////////////////////////////////////////////////// | 99 | //////////////////////////////////////////////////////////////////// |
100 | //TODO: Add API to allow other browser support | 100 | //TODO: Add API to allow other browser support |
101 | browserPreview: { | 101 | browserPreview: { |
102 | value: function (browser) { | 102 | value: function (browser, screen, context) { |
103 | //Making call to show feedback screen | ||
104 | if (screen) screen.show(context); | ||
103 | //Generating URL for document | 105 | //Generating URL for document |
104 | var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; | 106 | var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; |
105 | //TODO: Add logic to prompt user to save (all) before preview | 107 | //TODO: Add logic to prompt user to save (all) before preview |
106 | this.saveAll(null,function (result) { | 108 | this.saveAll(null,function (success) { |
109 | //Making call to show feedback screen | ||
110 | if (screen) screen.hide(context); | ||
111 | //TODO: Add error handling logic | ||
112 | if (!success) { | ||
113 | console.log('Error!'); | ||
114 | return; | ||
115 | } | ||
107 | //Currently only supporting current browser (Chrome, obviously) | 116 | //Currently only supporting current browser (Chrome, obviously) |
108 | switch (this.browser) { | 117 | switch (this.browser) { |
109 | case 'chrome': | 118 | case 'chrome': |
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c5ec951e..c9e10896 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -152,29 +152,38 @@ exports.IoMediator = Montage.create(Component, { | |||
152 | } | 152 | } |
153 | }, | 153 | }, |
154 | //////////////////////////////////////////////////////////////////// | 154 | //////////////////////////////////////////////////////////////////// |
155 | // | 155 | //TODO: Optimize |
156 | fileSave: { | 156 | fileSave: { |
157 | value: function (doc, callback, libCopyCallback) { | 157 | value: function (doc, callback, libCopyCallback) { |
158 | // | 158 | // |
159 | var contents, save; | 159 | var content, parsedDoc, save; |
160 | // | 160 | // |
161 | switch (doc.mode) { | 161 | switch (doc.mode) { |
162 | case 'html': | 162 | case 'html': |
163 | //Getting content from function to properly handle saving assets (as in external if flagged) | 163 | //Getting content from function to properly handle saving assets (as in external if flagged) |
164 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { | 164 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { |
165 | contents = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); | 165 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); |
166 | } else { | 166 | } else { |
167 | contents = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); | 167 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); |
168 | } | 168 | } |
169 | break; | 169 | break; |
170 | default: | 170 | default: |
171 | contents = doc.content; | 171 | content = doc.content; |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | //Making call to save file | 174 | if (parsedDoc) { |
175 | save = this.fio.saveFile({ uri: doc.file.uri, contents: contents }); | 175 | //Making call to save file |
176 | //Checking for callback | 176 | save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); |
177 | if (callback) callback(save); | 177 | //Checking for callback |
178 | if (callback) callback(save); | ||
179 | // | ||
180 | if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); | ||
181 | } else { | ||
182 | //Making call to save file | ||
183 | save = this.fio.saveFile({uri: doc.file.uri, contents: content}); | ||
184 | //Checking for callback | ||
185 | if (callback) callback(save); | ||
186 | } | ||
178 | } | 187 | } |
179 | }, | 188 | }, |
180 | //////////////////////////////////////////////////////////////////// | 189 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index a12270a0..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; |
@@ -195,14 +196,44 @@ exports.Ninja = Montage.create(Component, { | |||
195 | 196 | ||
196 | 197 | ||
197 | //////////////////////////////////////////////////////////////////// | 198 | //////////////////////////////////////////////////////////////////// |
199 | //////////////////////////////////////////////////////////////////// | ||
198 | //TODO: Expand method to allow other browsers for preview | 200 | //TODO: Expand method to allow other browsers for preview |
199 | executeChromePreview: { | 201 | executeChromePreview: { |
200 | value: function () { | 202 | value: function () { |
201 | this.currentDocument.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); | ||
202 | } | 221 | } |
203 | }, | 222 | }, |
204 | //////////////////////////////////////////////////////////////////// | 223 | //////////////////////////////////////////////////////////////////// |
205 | 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 | //////////////////////////////////////////////////////////////////// | ||