diff options
Diffstat (limited to 'js/document/models')
-rwxr-xr-x | js/document/models/base.js | 69 | ||||
-rwxr-xr-x | js/document/models/html.js | 5 |
2 files changed, 51 insertions, 23 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js index 9c26bd2a..1daec5c0 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -6,8 +6,9 @@ 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 | NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; | ||
11 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
12 | // | 13 | // |
13 | exports.BaseDocumentModel = Montage.create(Component, { | 14 | exports.BaseDocumentModel = Montage.create(Component, { |
@@ -65,6 +66,9 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
65 | _selection: { | 66 | _selection: { |
66 | value: [] | 67 | value: [] |
67 | }, | 68 | }, |
69 | domContainer: { | ||
70 | value: null | ||
71 | }, | ||
68 | //////////////////////////////////////////////////////////////////// | 72 | //////////////////////////////////////////////////////////////////// |
69 | // | 73 | // |
70 | selection: { | 74 | selection: { |
@@ -277,30 +281,59 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
277 | if (this.callback) this.callback(result); | 281 | if (this.callback) this.callback(result); |
278 | } | 282 | } |
279 | }, | 283 | }, |
284 | //////////////////////////////////////////////////////////////////// | ||
285 | // | ||
286 | handleSavePrompt: { | ||
287 | value: function (continueToClose, callback) { | ||
288 | //TODO: Perhaps add logic to save the file is the user wants | ||
289 | if (continueToClose) { | ||
290 | if (callback) callback(); | ||
291 | } else { | ||
292 | //User canceled | ||
293 | //this.saveAll(null, callback); | ||
294 | } | ||
295 | } | ||
296 | }, | ||
280 | //////////////////////////////////////////////////////////////////// | 297 | //////////////////////////////////////////////////////////////////// |
281 | //TODO: Implement better logic to include different views on single document | 298 | //TODO: Implement better logic to include different views on single document |
282 | close: { | 299 | close: { |
283 | value: function (view, callback) { | 300 | value: function (view, callback) { |
284 | //Outcome of close (pending on save logic) | 301 | //Checking if files needs to be saved to avoid losing data |
285 | var success; | ||
286 | // | ||
287 | if (this.needsSave) { | 302 | if (this.needsSave) { |
288 | //TODO: Prompt user to save or lose data | 303 | //Creating prompt to ask user to save the file |
304 | var prompt = NinjaPrompt.create(); | ||
305 | prompt.initialize('confirm', {message: 'Do you want to save the changes you made in the document '+this.file.name+'?\n\nYour changes will be lost if you do not save them.'}, function (result){this.handleSavePrompt(result, callback);}.bind(this)); | ||
306 | //Showing the prompt, it will make callback with user input | ||
307 | prompt.show(); | ||
289 | } else { | 308 | } else { |
290 | //Close file | 309 | //TODO: Add support for other views |
291 | success = true; | 310 | if (!view || view === 'design') { |
292 | } | 311 | this.closeView('design'); |
293 | //Checking for view mode to close | 312 | } |
294 | if (this.views.design && (!view || view === 'design')) { | 313 | //Making callback |
295 | //TODO: Create a destroy method, this is messy | 314 | if (callback) callback(); |
296 | this.views.design.pauseAndStopVideos(); | ||
297 | this.parentContainer.removeChild(this.views.design.iframe); | ||
298 | this.views.design = null; | ||
299 | } | 315 | } |
300 | //Returning result of operation | 316 | |
301 | return success; | ||
302 | } | 317 | } |
303 | } | 318 | }, |
319 | //////////////////////////////////////////////////////////////////// | ||
320 | // | ||
321 | closeView: { | ||
322 | value: function (view) { | ||
323 | //Checking for view mode to close | ||
324 | switch (view.toLowerCase()) { | ||
325 | case 'design': | ||
326 | //TODO: Make into clean method in the design view | ||
327 | this.views.design.pauseAndStopVideos(); | ||
328 | this.parentContainer.removeChild(this.views.design.iframe); | ||
329 | this.views.design = null; | ||
330 | break; | ||
331 | default: | ||
332 | //TODO: Error? | ||
333 | break; | ||
334 | } | ||
335 | } | ||
336 | } | ||
304 | //////////////////////////////////////////////////////////////////// | 337 | //////////////////////////////////////////////////////////////////// |
305 | //////////////////////////////////////////////////////////////////// | 338 | //////////////////////////////////////////////////////////////////// |
306 | }); | 339 | }); |
diff --git a/js/document/models/html.js b/js/document/models/html.js index f65cd8c3..d9002b4e 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -27,11 +27,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
27 | this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; | 27 | this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; |
28 | } | 28 | } |
29 | }, | 29 | }, |
30 | //////////////////////////////////////////////////////////////////// | ||
31 | // | ||
32 | selectionContainer: { | ||
33 | value: [] | ||
34 | }, | ||
35 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
36 | // | 31 | // |
37 | draw3DGrid: { | 32 | draw3DGrid: { |