From fb7a3aa9ce0d9b99dca79cfb89951b5c51523250 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 14:54:38 -0700 Subject: Adding partial close functionality --- js/document/models/base.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/base.js b/js/document/models/base.js index 2bbbe501..ebfb73b8 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -60,6 +60,11 @@ exports.BaseDocumentModel = Montage.create(Component, { get: function() {return this._currentView;}, set: function(value) {this._currentView = value;} }, + //////////////////////////////////////////////////////////////////// + // + parentContainer: { + value: null + }, //////////////////////////////////////////////////////////////////// // views: { @@ -114,6 +119,12 @@ exports.BaseDocumentModel = Montage.create(Component, { // save: { value: function (callback) { + // + if (this.needsSave) { + //Save + } else { + //Ignore command + } // if (this.currentView === this.views.design) { // @@ -129,18 +140,18 @@ exports.BaseDocumentModel = Montage.create(Component, { } else { //TODO: Add logic to save code view data } - // - if (this.needsSave) { - //Save - } else { - //Ignore command - } } }, //////////////////////////////////////////////////////////////////// // saveAll: { value: function (callback) { + // + if (this.needsSave) { + //Save + } else { + //Ignore command + } // if (this.currentView === this.views.design) { // @@ -156,12 +167,7 @@ exports.BaseDocumentModel = Montage.create(Component, { } else { //TODO: Add logic to save code view data } - // - if (this.needsSave) { - //Save - } else { - //Ignore command - } + } }, //////////////////////////////////////////////////////////////////// @@ -179,13 +185,24 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // close: { - value: function () { + value: function (view, callback) { + //Outcome of close (pending on save logic) + var success; // if (this.needsSave) { //Prompt user to save of lose data } else { //Close file + success = true; + } + // + if (this.views.design && (!view || view === 'design')) { + // + this.parentContainer.removeChild(this.views.design.iframe); + this.views.design = null; } + // + if (callback) callback(success); } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3