diff options
Diffstat (limited to 'js/document/models')
-rwxr-xr-x | js/document/models/base.js | 58 | ||||
-rwxr-xr-x | js/document/models/html.js | 48 |
2 files changed, 51 insertions, 55 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js index 76a5e62b..a3644815 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -65,7 +65,8 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
65 | _selection: { | 65 | _selection: { |
66 | value: [] | 66 | value: [] |
67 | }, | 67 | }, |
68 | 68 | //////////////////////////////////////////////////////////////////// | |
69 | // | ||
69 | selection: { | 70 | selection: { |
70 | get: function() { | 71 | get: function() { |
71 | return this._selection; | 72 | return this._selection; |
@@ -99,11 +100,20 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
99 | //////////////////////////////////////////////////////////////////// | 100 | //////////////////////////////////////////////////////////////////// |
100 | //TODO: Add API to allow other browser support | 101 | //TODO: Add API to allow other browser support |
101 | browserPreview: { | 102 | browserPreview: { |
102 | value: function (browser) { | 103 | value: function (browser, screen, context) { |
104 | //Making call to show feedback screen | ||
105 | if (screen) screen.show(context); | ||
103 | //Generating URL for document | 106 | //Generating URL for document |
104 | var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; | 107 | 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 | 108 | //TODO: Add logic to prompt user to save (all) before preview |
106 | this.saveAll(function (result) { | 109 | this.saveAll(null,function (success) { |
110 | //Making call to show feedback screen | ||
111 | if (screen) screen.hide(context); | ||
112 | //TODO: Add error handling logic | ||
113 | if (!success) { | ||
114 | console.log('Error!'); | ||
115 | return; | ||
116 | } | ||
107 | //Currently only supporting current browser (Chrome, obviously) | 117 | //Currently only supporting current browser (Chrome, obviously) |
108 | switch (this.browser) { | 118 | switch (this.browser) { |
109 | case 'chrome': | 119 | case 'chrome': |
@@ -125,28 +135,30 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
125 | } | 135 | } |
126 | }, | 136 | }, |
127 | //////////////////////////////////////////////////////////////////// | 137 | //////////////////////////////////////////////////////////////////// |
128 | // | 138 | //Gets all stylesheets in document |
129 | getStyleSheets: { | 139 | getStyleSheets: { |
130 | value: function () { | 140 | value: function () { |
131 | // | 141 | //Array to store styles (style and link tags) |
132 | var styles = []; | 142 | var styles = []; |
133 | // | 143 | //Looping through document sytles |
134 | for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { | 144 | for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { |
145 | //Check for styles to has proper propeties | ||
135 | if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { | 146 | if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { |
147 | //Check for ninja-template styles, if so, exclude | ||
136 | if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { | 148 | if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { |
137 | styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); | 149 | styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); |
138 | } | 150 | } |
139 | } | 151 | } |
140 | } | 152 | } |
141 | // | 153 | //Returning filtered results |
142 | return styles; | 154 | return styles; |
143 | } | 155 | } |
144 | }, | 156 | }, |
145 | //////////////////////////////////////////////////////////////////// | 157 | //////////////////////////////////////////////////////////////////// |
146 | // | 158 | // |
147 | save: { | 159 | save: { |
148 | value: function (callback) { | 160 | value: function (callback, libCopyCallback) { |
149 | // | 161 | //TODO: Implement on demand logic |
150 | if (this.needsSave) { | 162 | if (this.needsSave) { |
151 | //Save | 163 | //Save |
152 | } else { | 164 | } else { |
@@ -165,7 +177,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
165 | head: this.views.design.iframe.contentWindow.document.head, | 177 | head: this.views.design.iframe.contentWindow.document.head, |
166 | body: this.views.design.iframe.contentWindow.document.body, | 178 | body: this.views.design.iframe.contentWindow.document.body, |
167 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator | 179 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator |
168 | }, this.handleSaved.bind({callback: callback, model: this})); | 180 | }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); |
169 | } else { | 181 | } else { |
170 | //TODO: Add logic to save code view data | 182 | //TODO: Add logic to save code view data |
171 | } | 183 | } |
@@ -174,8 +186,8 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
174 | //////////////////////////////////////////////////////////////////// | 186 | //////////////////////////////////////////////////////////////////// |
175 | // | 187 | // |
176 | saveAll: { | 188 | saveAll: { |
177 | value: function (callback) { | 189 | value: function (callback, libCopyCallback) { |
178 | // | 190 | //TODO: Implement on demand logic |
179 | if (this.needsSave) { | 191 | if (this.needsSave) { |
180 | //Save | 192 | //Save |
181 | } else { | 193 | } else { |
@@ -194,7 +206,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
194 | head: this.views.design.iframe.contentWindow.document.head, | 206 | head: this.views.design.iframe.contentWindow.document.head, |
195 | body: this.views.design.iframe.contentWindow.document.body, | 207 | body: this.views.design.iframe.contentWindow.document.body, |
196 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator | 208 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator |
197 | }, this.handleSaved.bind({callback: callback, model: this})); | 209 | }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); |
198 | } else { | 210 | } else { |
199 | //TODO: Add logic to save code view data | 211 | //TODO: Add logic to save code view data |
200 | } | 212 | } |
@@ -205,47 +217,49 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
205 | // | 217 | // |
206 | saveAs: { | 218 | saveAs: { |
207 | value: function (callback) { | 219 | value: function (callback) { |
208 | // | 220 | //TODO: Implement on demand logic |
209 | if (this.needsSave) { | 221 | if (this.needsSave) { |
210 | //Save current file on memory | 222 | //Save current file on memory |
211 | } else { | 223 | } else { |
212 | //Copy file from disk | 224 | //Copy file from disk |
213 | } | 225 | } |
226 | //TODO: Add functionality | ||
214 | } | 227 | } |
215 | }, | 228 | }, |
216 | //////////////////////////////////////////////////////////////////// | 229 | //////////////////////////////////////////////////////////////////// |
217 | // | 230 | // |
218 | handleSaved: { | 231 | handleSaved: { |
219 | value: function (result) { | 232 | value: function (result) { |
220 | // | 233 | //Checking for success code in save |
221 | if (result.status === 204) { | 234 | if (result.status === 204) { |
235 | //Clearing flag with successful save | ||
222 | this.model.needsSave = false; | 236 | this.model.needsSave = false; |
223 | } | 237 | } |
224 | // | 238 | //Making callback call if specifed with results of operation |
225 | if (this.callback) this.callback(result); | 239 | if (this.callback) this.callback(result); |
226 | } | 240 | } |
227 | }, | 241 | }, |
228 | //////////////////////////////////////////////////////////////////// | 242 | //////////////////////////////////////////////////////////////////// |
229 | // | 243 | //TODO: Implement better logic to include different views on single document |
230 | close: { | 244 | close: { |
231 | value: function (view, callback) { | 245 | value: function (view, callback) { |
232 | //Outcome of close (pending on save logic) | 246 | //Outcome of close (pending on save logic) |
233 | var success; | 247 | var success; |
234 | // | 248 | // |
235 | if (this.needsSave) { | 249 | if (this.needsSave) { |
236 | //Prompt user to save of lose data | 250 | //TODO: Prompt user to save or lose data |
237 | } else { | 251 | } else { |
238 | //Close file | 252 | //Close file |
239 | success = true; | 253 | success = true; |
240 | } | 254 | } |
241 | // | 255 | //Checking for view mode to close |
242 | if (this.views.design && (!view || view === 'design')) { | 256 | if (this.views.design && (!view || view === 'design')) { |
243 | // | 257 | //TODO: Create a destroy method, this is messy |
258 | this.views.design.pauseAndStopVideos(); | ||
244 | this.parentContainer.removeChild(this.views.design.iframe); | 259 | this.parentContainer.removeChild(this.views.design.iframe); |
245 | this.views.design.pauseAndStopVideos(); | ||
246 | this.views.design = null; | 260 | this.views.design = null; |
247 | } | 261 | } |
248 | // | 262 | //Returning result of operation |
249 | return success; | 263 | return success; |
250 | } | 264 | } |
251 | } | 265 | } |
diff --git a/js/document/models/html.js b/js/document/models/html.js index 9aa0d27e..6bdc6546 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -40,22 +40,32 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
40 | scrollLeft: { | 40 | scrollLeft: { |
41 | value: null | 41 | value: null |
42 | }, | 42 | }, |
43 | 43 | //////////////////////////////////////////////////////////////////// | |
44 | // | ||
44 | scrollTop: { | 45 | scrollTop: { |
45 | value: null | 46 | value: null |
46 | }, | 47 | }, |
47 | 48 | //////////////////////////////////////////////////////////////////// | |
49 | // | ||
48 | userContentLeft: { | 50 | userContentLeft: { |
49 | value: null | 51 | value: null |
50 | }, | 52 | }, |
51 | 53 | //////////////////////////////////////////////////////////////////// | |
54 | // | ||
52 | userContentTop: { | 55 | userContentTop: { |
53 | value: null | 56 | value: null |
54 | }, | 57 | }, |
55 | //////////////////////////////////////////////////////////////////// | 58 | //////////////////////////////////////////////////////////////////// |
56 | // | 59 | //TODO: Convert to bindings |
60 | documentRoot: { |