aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/document-controller.js29
-rwxr-xr-xjs/document/models/base.js102
-rwxr-xr-xjs/document/templates/montage-web/index.html17
-rwxr-xr-xjs/document/views/design.js7
-rwxr-xr-xjs/io/templates/files/html.txt1
-rw-r--r--js/mediators/io-mediator.js89
6 files changed, 178 insertions, 67 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index cf96208f..17ae8cc3 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -166,23 +166,34 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
166 } 166 }
167 }, 167 },
168 //////////////////////////////////////////////////////////////////// 168 ////////////////////////////////////////////////////////////////////
169 //TODO: Check for appropiate structures 169 //
170 handleExecuteSave: { 170 handleExecuteSave: {
171 value: function(event) { 171 value: function(event) {
172 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 172 //
173 //Text and HTML document classes should return the same save object for fileSave 173 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
174 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); 174 //
175 } 175 this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this)
176 } else {
177 //Error:
178 }
176 } 179 }
177 }, 180 },
181 testCallback: {
182 value: function (value) {
183 console.log(value);
184 }
185 },
178 //////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////
179 //TODO: Check for appropiate structures 187 //TODO: Check for appropiate structures
180 handleExecuteSaveAll: { 188 handleExecuteSaveAll: {
181 value: function(event) { 189 value: function(event) {
182 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 190 //
183 //Text and HTML document classes should return the same save object for fileSave 191 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
184 this.application.ninja.ioMediator.fileSave(this.activeDocument.saveAll(), this.fileSaveResult.bind(this)); 192 //
185 } 193 this.activeDocument.model.saveAll(this.testCallback.bind(this)); //this.fileSaveResult.bind(this)
194 } else {
195 //Error:
196 }
186 } 197 }
187 }, 198 },
188 //////////////////////////////////////////////////////////////////// 199 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 5667fb24..2bbbe501 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -76,39 +76,104 @@ exports.BaseDocumentModel = Montage.create(Component, {
76 //TODO: Add API to allow other browser support 76 //TODO: Add API to allow other browser support
77 browserPreview: { 77 browserPreview: {
78 value: function (browser) { 78 value: function (browser) {
79 79 //Generating URL for document
80 //TODO: Add file save before previewing 80 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1];
81 81 //TODO: Add logic to prompt user to save (all) before preview
82 //Currently only supporting current browser (Chrome, obviously) 82 this.saveAll(function (result) {
83 switch (browser) { 83 //Currently only supporting current browser (Chrome, obviously)
84 case 'chrome': 84 switch (this.browser) {
85 window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); 85 case 'chrome':
86 break; 86 window.open(this.url);
87 default: 87 break;
88 window.open(this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); 88 default:
89 break; 89 window.open(this.url);
90 } 90 break;
91 }
92 }.bind({browser: browser, url: url}));
91 } 93 }
92 }, 94 },
93 //////////////////////////////////////////////////////////////////// 95 ////////////////////////////////////////////////////////////////////
94 // 96 //
97 getStyleSheets: {
98 value: function () {
99 //
100 var styles = [];
101 //
102 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) {
103 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) {
104 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) {
105 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]);
106 }
107 }
108 }
109 //
110 return styles;
111 }
112 },
113 ////////////////////////////////////////////////////////////////////
114 //
95 save: { 115 save: {
96 value: function () { 116 value: function (callback) {
97 // 117 //
118 if (this.currentView === this.views.design) {
119 //
120 this.application.ninja.ioMediator.fileSave({
121 mode: 'html',
122 file: this.file,
123 webgl: this.webGlHelper.glData,
124 styles: this.getStyleSheets(),
125 document: this.views.design.iframe.contentWindow.document,
126 head: this.views.design.iframe.contentWindow.document.head,
127 body: this.views.design.iframe.contentWindow.document.body
128 }, callback.bind(this));
129 } else {
130 //TODO: Add logic to save code view data
131 }
132 //
133 if (this.needsSave) {
134 //Save
135 } else {
136 //Ignore command
137 }
98 } 138 }
99 }, 139 },
100 //////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////
101 // 141 //
102 saveAs: { 142 saveAll: {
103 value: function () { 143 value: function (callback) {
144 //
145 if (this.currentView === this.views.design) {
146 //
147 this.application.ninja.ioMediator.fileSave({
148 mode: 'html',
149 file: this.file,
150 webgl: this.webGlHelper.glData,
151 css: this.getStyleSheets(),
152 document: this.views.design.iframe.contentWindow.document,
153 head: this.views.design.iframe.contentWindow.document.head,
154 body: this.views.design.iframe.contentWindow.document.body
155 }, callback.bind(this));
156 } else {
157 //TODO: Add logic to save code view data
158 }
104 // 159 //
160 if (this.needsSave) {
161 //Save
162 } else {
163 //Ignore command
164 }
105 } 165 }
106 }, 166 },
107 //////////////////////////////////////////////////////////////////// 167 ////////////////////////////////////////////////////////////////////
108 // 168 //
109 saveAll: { 169 saveAs: {
110 value: function () { 170 value: function () {
111 // 171 //
172 if (this.needsSave) {
173 //Save current file on memory
174 } else {
175 //Copy file from disk
176 }
112 } 177 }
113 }, 178 },
114 //////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////
@@ -116,6 +181,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
116 close: { 181 close: {
117 value: function () { 182 value: function () {
118 // 183 //
184 if (this.needsSave) {
185 //Prompt user to save of lose data
186 } else {
187 //Close file
188 }
119 } 189 }
120 } 190 }
121 //////////////////////////////////////////////////////////////////// 191 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/templates/montage-web/index.html b/js/document/templates/montage-web/index.html
index 6bd5ce7a..e02d8d8e 100755
--- a/js/document/templates/montage-web/index.html
+++ b/js/document/templates/montage-web/index.html
@@ -5,13 +5,20 @@
5 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 5 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
6 </copyright> --> 6 </copyright> -->
7 7
8
9<!--
10 NOTE(s):
11 All elements in the head of the document to be exclude from I/O
12 must set the 'data-ninja-template'
13 data-ninja-template="true"
14-->
8<html> 15<html>
9 16
10 <head> 17 <head>
11 18
12 <title>Ninja Prototype</title> 19 <title data-ninja-template="true">Ninja Prototype</title>
13 20
14 <style type="text/css" id="nj-stage-stylesheet"> 21 <style type="text/css" id="nj-stage-stylesheet" data-ninja-template="true">
15 * { 22 * {
16 -webkit-transition-duration: 0s !important; 23 -webkit-transition-duration: 0s !important;
17 -webkit-animation-duration: 0s !important; 24 -webkit-animation-duration: 0s !important;
@@ -49,15 +56,15 @@
49 } 56 }
50