aboutsummaryrefslogtreecommitdiff
path: root/js/document/models/base.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-13 13:38:09 -0700
committerValerio Virgillito2012-06-13 13:38:09 -0700
commita827f2769d75848c0ba0bff03a927c1f2706322b (patch)
treedbd9ec47cd2828bfa43c6b6a69ff9e82d5e03377 /js/document/models/base.js
parenta75947d69f571d723552f926f94d195514a01cbd (diff)
parent5a7774f6769a7a682e21bafe0e57007668f16153 (diff)
downloadninja-a827f2769d75848c0ba0bff03a927c1f2706322b.tar.gz
Merge branch 'refs/heads/master' into montage-v10-integration
Diffstat (limited to 'js/document/models/base.js')
-rwxr-xr-xjs/document/models/base.js66
1 files changed, 48 insertions, 18 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 1307e0c0..8ff52132 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//
9var Montage = require("montage/core/core").Montage, 9var 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//
13exports.BaseDocumentModel = Montage.create(Component, { 14exports.BaseDocumentModel = Montage.create(Component, {
@@ -267,30 +268,59 @@ exports.BaseDocumentModel = Montage.create(Component, {
267 if (this.callback) this.callback(result); 268 if (this.callback) this.callback(result);
268 } 269 }
269 }, 270 },
271 ////////////////////////////////////////////////////////////////////
272 //
273 handleSavePrompt: {
274 value: function (continueToClose, callback) {
275 //TODO: Perhaps add logic to save the file is the user wants
276 if (continueToClose) {
277 if (callback) callback();
278 } else {
279 //User canceled
280 //this.saveAll(null, callback);
281 }
282 }
283 },
270 //////////////////////////////////////////////////////////////////// 284 ////////////////////////////////////////////////////////////////////
271 //TODO: Implement better logic to include different views on single document 285 //TODO: Implement better logic to include different views on single document
272 close: { 286 close: {
273 value: function (view, callback) { 287 value: function (view, callback) {
274 //Outcome of close (pending on save logic) 288 //Checking if files needs to be saved to avoid losing data
275 var success;
276 //
277 if (this.needsSave) { 289 if (this.needsSave) {
278 //TODO: Prompt user to save or lose data 290 //Creating prompt to ask user to save the file
291 var prompt = NinjaPrompt.create();
292 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));
293 //Showing the prompt, it will make callback with user input
294 prompt.show();
279 } else { 295 } else {
280 //Close file 296 //TODO: Add support for other views
281 success = true; 297 if (!view || view === 'design') {
282 } 298 this.closeView('design');
283 //Checking for view mode to close 299 }
284 if (this.views.design && (!view || view === 'design')) { 300 //Making callback
285 //TODO: Create a destroy method, this is messy 301 if (callback) callback();
286 this.views.design.pauseAndStopVideos();
287 this.parentContainer.removeChild(this.views.design.iframe);
288 this.views.design = null;
289 } 302 }
290 //Returning result of operation 303
291 return success;
292 } 304 }
293 } 305 },
306 ////////////////////////////////////////////////////////////////////
307 //
308 closeView: {
309 value: function (view) {
310 //Checking for view mode to close
311 switch (view.toLowerCase()) {
312 case 'design':
313 //TODO: Make into clean method in the design view
314 this.views.design.pauseAndStopVideos();
315 this.parentContainer.removeChild(this.views.design.iframe);
316 this.views.design = null;
317 break;
318 default:
319 //TODO: Error?
320 break;
321 }
322 }
323 }
294 //////////////////////////////////////////////////////////////////// 324 ////////////////////////////////////////////////////////////////////
295 //////////////////////////////////////////////////////////////////// 325 ////////////////////////////////////////////////////////////////////
296}); 326});