From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 5fa06259..1307e0c0 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -65,6 +65,9 @@ exports.BaseDocumentModel = Montage.create(Component, { _selection: { value: [] }, + domContainer: { + value: null + }, //////////////////////////////////////////////////////////////////// // selection: { -- cgit v1.2.3 From 19c77d87df72a85345e527d790878fc65eca189a Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 11 Jun 2012 15:44:15 -0700 Subject: Adding temp prompt UI component Added a temp prompt component and added on before close logic to ensure user does not lose data if the file needs saving when they close. --- js/document/models/base.js | 66 +++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 5fa06259..0fd609c3 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 //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; //////////////////////////////////////////////////////////////////////// // exports.BaseDocumentModel = Montage.create(Component, { @@ -264,30 +265,59 @@ exports.BaseDocumentModel = Montage.create(Component, { if (this.callback) this.callback(result); } }, + //////////////////////////////////////////////////////////////////// + // + handleSavePrompt: { + value: function (continueToClose, callback) { + //TODO: Perhaps add logic to save the file is the user wants + if (continueToClose) { + if (callback) callback(); + } else { + //User canceled + //this.saveAll(null, callback); + } + } + }, //////////////////////////////////////////////////////////////////// //TODO: Implement better logic to include different views on single document close: { value: function (view, callback) { - //Outcome of close (pending on save logic) - var success; - // + //Checking if files needs to be saved to avoid losing data if (this.needsSave) { - //TODO: Prompt user to save or lose data + //Creating prompt to ask user to save the file + var prompt = NinjaPrompt.create(); + 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)); + //Showing the prompt, it will make callback with user input + prompt.show(); } else { - //Close file - success = true; - } - //Checking for view mode to close - if (this.views.design && (!view || view === 'design')) { - //TODO: Create a destroy method, this is messy - this.views.design.pauseAndStopVideos(); - this.parentContainer.removeChild(this.views.design.iframe); - this.views.design = null; + //TODO: Add support for other views + if (!view || view === 'design') { + this.closeView('design'); + } + //Making callback + if (callback) callback(); } - //Returning result of operation - return success; + } - } + }, + //////////////////////////////////////////////////////////////////// + // + closeView: { + value: function (view) { + //Checking for view mode to close + switch (view.toLowerCase()) { + case 'design': + //TODO: Make into clean method in the design view + this.views.design.pauseAndStopVideos(); + this.parentContainer.removeChild(this.views.design.iframe); + this.views.design = null; + break; + default: + //TODO: Error? + break; + } + } + } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3