aboutsummaryrefslogtreecommitdiff
path: root/js/document/models
diff options
context:
space:
mode:
authorKruti Shah2012-06-12 13:09:11 -0700
committerKruti Shah2012-06-12 13:09:11 -0700
commitd648c842905c7c53e0f89b943982493d2b79f56e (patch)
treeeb5585f92061975215f6d19305a8d1b76262e2fc /js/document/models
parentbedb38e14887b29eae3cdf1c8d435259c920257c (diff)
parentcf3b96822665751dae7a64644db3cb3960733c3d (diff)
downloadninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/controllers/elements/element-controller.js js/document/_toDelete/html-document.js js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/document/models')
-rwxr-xr-xjs/document/models/base.js99
-rwxr-xr-xjs/document/models/html.js59
-rwxr-xr-xjs/document/models/text.js3
3 files changed, 100 insertions, 61 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 6d9d2e89..5fa06259 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -62,6 +62,17 @@ exports.BaseDocumentModel = Montage.create(Component, {
62 }, 62 },
63 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
64 // 64 //
65 _selection: {
66 value: []
67 },
68 ////////////////////////////////////////////////////////////////////
69 //
70 selection: {
71 get: function() {return this._selection;},
72 set: function(value) {this._selection = value;}
73 },
74 ////////////////////////////////////////////////////////////////////
75 //
65 fileTemplate: { 76 fileTemplate: {
66 value: null 77 value: null
67 }, 78 },
@@ -77,6 +88,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
77 }, 88 },
78 //////////////////////////////////////////////////////////////////// 89 ////////////////////////////////////////////////////////////////////
79 // 90 //
91 libs: {
92 value: null
93 },
94 ////////////////////////////////////////////////////////////////////
95 //
80 switchViewTo: { 96 switchViewTo: {
81 value: function (view) { 97 value: function (view) {
82 // 98 //
@@ -85,11 +101,20 @@ exports.BaseDocumentModel = Montage.create(Component, {
85 //////////////////////////////////////////////////////////////////// 101 ////////////////////////////////////////////////////////////////////
86 //TODO: Add API to allow other browser support 102 //TODO: Add API to allow other browser support
87 browserPreview: { 103 browserPreview: {
88 value: function (browser) { 104 value: function (browser, screen, context) {
105 //Making call to show feedback screen
106 if (screen) screen.show(context);
89 //Generating URL for document 107 //Generating URL for document
90 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; 108 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1];
91 //TODO: Add logic to prompt user to save (all) before preview 109 //TODO: Add logic to prompt user to save (all) before preview
92 this.saveAll(function (result) { 110 this.saveAll(null,function (success) {
111 //Making call to show feedback screen
112 if (screen) screen.hide(context);
113 //TODO: Add error handling logic
114 if (!success) {
115 console.log('Error!');
116 return;
117 }
93 //Currently only supporting current browser (Chrome, obviously) 118 //Currently only supporting current browser (Chrome, obviously)
94 switch (this.browser) { 119 switch (this.browser) {
95 case 'chrome': 120 case 'chrome':
@@ -111,28 +136,30 @@ exports.BaseDocumentModel = Montage.create(Component, {
111 } 136 }
112 }, 137 },
113 //////////////////////////////////////////////////////////////////// 138 ////////////////////////////////////////////////////////////////////
114 // 139 //Gets all stylesheets in document
115 getStyleSheets: { 140 getStyleSheets: {
116 value: function () { 141 value: function () {
117 // 142 //Array to store styles (style and link tags)
118 var styles = []; 143 var styles = [];
119 // 144 //Looping through document sytles
120 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { 145 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) {
146 //Check for styles to has proper propeties
121 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { 147 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) {
148 //Check for ninja-template styles, if so, exclude
122 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { 149 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) {
123 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); 150 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]);
124 } 151 }
125 } 152 }
126 } 153 }
127 // 154 //Returning filtered results
128 return styles; 155 return styles;
129 } 156 }
130 }, 157 },
131 //////////////////////////////////////////////////////////////////// 158 ////////////////////////////////////////////////////////////////////
132 // 159 //
133 save: { 160 save: {
134 value: function (callback) { 161 value: function (callback, libCopyCallback) {
135 // 162 //TODO: Implement on demand logic
136 if (this.needsSave) { 163 if (this.needsSave) {
137 //Save 164 //Save
138 } else { 165 } else {
@@ -141,8 +168,9 @@ exports.BaseDocumentModel = Montage.create(Component, {
141 // 168 //
142 if (this.currentView === this.views.design) { 169 if (this.currentView === this.views.design) {
143 // 170 //
144 this.application.ninja.ioMediator.fileSave({ 171 var save = this.application.ninja.ioMediator.fileSave({
145 mode: 'html', 172 mode: 'html',
173 libs: this.libs,
146 file: this.file, 174 file: this.file,
147 webgl: this.webGlHelper.glData, 175 webgl: this.webGlHelper.glData,
148 styles: this.getStyleSheets(), 176 styles: this.getStyleSheets(),
@@ -151,7 +179,18 @@ exports.BaseDocumentModel = Montage.create(Component, {
151 head: this.views.design.iframe.contentWindow.document.head, 179 head: this.views.design.iframe.contentWindow.document.head,
152 body: this.views.design.iframe.contentWindow.document.body, 180 body: this.views.design.iframe.contentWindow.document.body,
153 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 181 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
154 }, this.handleSaved.bind({callback: callback, model: this})); 182 }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback);
183 //TODO: Improve detection during save routine
184 if (save) {
185 if (save.montageId) {
186 this.libs.montageId = save.montageId;
187 this.libs.montage = true;
188 }
189 if (save.canvasId) {
190 this.libs.canvasId = save.canvasId;
191 this.libs.canvas = true;
192 }
193 }
155 } else { 194 } else {
156 //TODO: Add logic to save code view data 195 //TODO: Add logic to save code view data
157 } 196 }
@@ -160,8 +199,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
160 //////////////////////////////////////////////////////////////////// 199 ////////////////////////////////////////////////////////////////////
161 // 200 //
162 saveAll: { 201 saveAll: {
163 value: function (callback) { 202 value: function (callback, libCopyCallback) {
164 // 203 //TODO: Implement on demand logic
165 if (this.needsSave) { 204 if (this.needsSave) {
166 //Save 205 //Save
167 } else { 206 } else {
@@ -170,8 +209,9 @@ exports.BaseDocumentModel = Montage.create(Component, {
170 // 209 //
171 if (this.currentView === this.views.design) { 210 if (this.currentView === this.views.design) {
172 // 211 //
173 this.application.ninja.ioMediator.fileSave({ 212 var save = this.application.ninja.ioMediator.fileSave({
174 mode: 'html', 213 mode: 'html',
214 libs: this.libs,
175 file: this.file, 215 file: this.file,
176 webgl: this.webGlHelper.glData, 216 webgl: this.webGlHelper.glData,
177 css: this.getStyleSheets(), 217 css: this.getStyleSheets(),
@@ -180,7 +220,18 @@ exports.BaseDocumentModel = Montage.create(Component, {
180 head: this.views.design.iframe.contentWindow.document.head, 220 head: this.views.design.iframe.contentWindow.document.head,
181 body: this.views.design.iframe.contentWindow.document.body, 221 body: this.views.design.iframe.contentWindow.document.body,
182 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 222 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
183 }, this.handleSaved.bind({callback: callback, model: this})); 223 }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback);
224 //TODO: Improve detection during save routine
225 if (save) {
226 if (save.montageId) {
227 this.libs.montageId = save.montageId;
228 this.libs.montage = true;
229 }
230 if (save.canvasId) {
231 this.libs.canvasId = save.canvasId;
232 this.libs.canvas = true;
233 }
234 }
184 } else { 235 } else {
185 //TODO: Add logic to save code view data 236 //TODO: Add logic to save code view data
186 } 237 }
@@ -191,47 +242,49 @@ exports.BaseDocumentModel = Montage.create(Component, {
191 // 242 //
192 saveAs: { 243 saveAs: {
193 value: function (callback) { 244 value: function (callback) {
194 // 245 //TODO: Implement on demand logic
195 if (this.needsSave) { 246 if (this.needsSave) {
196 //Save current file on memory 247 //Save current file on memory
197 } else { 248 } else {
198 //Copy file from disk 249 //Copy file from disk
199 } 250 }
251 //TODO: Add functionality
200 } 252 }
201 }, 253 },
202 //////////////////////////////////////////////////////////////////// 254 ////////////////////////////////////////////////////////////////////
203 // 255 //
204 handleSaved: { 256 handleSaved: {
205 value: function (result) { 257 value: function (result) {
206