From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/document/models/base.js | 448 ++++++++++++++++++++++----------------------- 1 file changed, 224 insertions(+), 224 deletions(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 97992324..21bb6a6f 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -30,63 +30,63 @@ POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; +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, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { value: false }, //////////////////////////////////////////////////////////////////// - // - _file: { + // + _file: { value: null }, //////////////////////////////////////////////////////////////////// - // + // file: { get: function() {return this._file;}, set: function(value) {this._file = value;} }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // _isActive: { value: true }, //////////////////////////////////////////////////////////////////// - // + // isActive: { get: function() {return this._isActive;}, set: function(value) {this._isActive = value;} }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // _needsSave: { value: null }, //////////////////////////////////////////////////////////////////// - // + // needsSave: { get: function() {return this._needsSave;}, set: function(value) {this._needsSave = value;} }, //////////////////////////////////////////////////////////////////// - // + // _currentView: { value: null }, //////////////////////////////////////////////////////////////////// - // + // currentView: { get: function() {return this._currentView;}, set: function(value) {this._currentView = value;} }, //////////////////////////////////////////////////////////////////// - // + // _selection: { value: [] }, @@ -105,18 +105,18 @@ exports.BaseDocumentModel = Montage.create(Component, { value: null }, //////////////////////////////////////////////////////////////////// - // + // parentContainer: { value: null }, //////////////////////////////////////////////////////////////////// - // - views: { + // + views: { value: null }, //////////////////////////////////////////////////////////////////// - // - libs: { + // + libs: { value: null }, @@ -133,233 +133,233 @@ exports.BaseDocumentModel = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - // - switchViewTo: { + // + switchViewTo: { value: function (view) { - // + // } }, //////////////////////////////////////////////////////////////////// - //TODO: Add API to allow other browser support - browserPreview: { + //TODO: Add API to allow other browser support + browserPreview: { value: function (browser, screen, context) { - //Making call to show feedback screen - if (screen) screen.show(context); - //Generating URL for document - var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; - //TODO: Add logic to prompt user to save (all) before preview - this.saveAll(null,function (success) { - //Making call to show feedback screen - if (screen) screen.hide(context); - //TODO: Add error handling logic - if (!success) { - console.log('Error!'); - return; - } - //Currently only supporting current browser (Chrome, obviously) - switch (this.browser) { - case 'chrome': - if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { - window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); - } else { - window.open(this.url); - } - break; - default: - if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { - window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); - } else { - window.open(this.url); - } - break; - } - }.bind({browser: browser, url: url, template: this.fileTemplate})); + //Making call to show feedback screen + if (screen) screen.show(context); + //Generating URL for document + var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; + //TODO: Add logic to prompt user to save (all) before preview + this.saveAll(null,function (success) { + //Making call to show feedback screen + if (screen) screen.hide(context); + //TODO: Add error handling logic + if (!success) { + console.log('Error!'); + return; + } + //Currently only supporting current browser (Chrome, obviously) + switch (this.browser) { + case 'chrome': + if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { + window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); + } else { + window.open(this.url); + } + break; + default: + if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { + window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); + } else { + window.open(this.url); + } + break; + } + }.bind({browser: browser, url: url, template: this.fileTemplate})); } }, //////////////////////////////////////////////////////////////////// - //Gets all stylesheets in document - getStyleSheets: { - value: function () { - //Array to store styles (style and link tags) - var styles = []; - //Looping through document sytles - for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { - //Check for styles to has proper propeties - if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { - //Check for ninja-template styles, if so, exclude - if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { - styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); - } - } - } - //Returning filtered results - return styles; - } - }, + //Gets all stylesheets in document + getStyleSheets: { + value: function () { + //Array to store styles (style and link tags) + var styles = []; + //Looping through document sytles + for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { + //Check for styles to has proper propeties + if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { + //Check for ninja-template styles, if so, exclude + if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { + styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); + } + } + } + //Returning filtered results + return styles; + } + }, //////////////////////////////////////////////////////////////////// - // - save: { + // + save: { value: function (callback, libCopyCallback) { - //TODO: Implement on demand logic - if (this.needsSave) { - //Save - } else { - //Ignore command - } - // - if (this.currentView === this.views.design) { - // - var save = this.application.ninja.ioMediator.fileSave({ - mode: 'html', - libs: this.libs, - file: this.file, - webgl: this.webGlHelper.glData, - styles: this.getStyleSheets(), - template: this.fileTemplate, - document: this.views.design.iframe.contentWindow.document, - head: this.views.design.iframe.contentWindow.document.head, - body: this.views.design.iframe.contentWindow.document.body, - mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); - //TODO: Improve detection during save routine - if (save) { - if (save.montageId) { - this.libs.montageId = save.montageId; - this.libs.montage = true; - } - if (save.canvasId) { - this.libs.canvasId = save.canvasId; - this.libs.canvas = true; - } - } - } else { - //TODO: Add logic to save code view data - } + //TODO: Implement on demand logic + if (this.needsSave) { + //Save + } else { + //Ignore command + } + // + if (this.currentView === this.views.design) { + // + var save = this.application.ninja.ioMediator.fileSave({ + mode: 'html', + libs: this.libs, + file: this.file, + webgl: this.webGlHelper.glData, + styles: this.getStyleSheets(), + template: this.fileTemplate, + document: this.views.design.iframe.contentWindow.document, + head: this.views.design.iframe.contentWindow.document.head, + body: this.views.design.iframe.contentWindow.document.body, + mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator + }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); + //TODO: Improve detection during save routine + if (save) { + if (save.montageId) { + this.libs.montageId = save.montageId; + this.libs.montage = true; + } + if (save.canvasId) { + this.libs.canvasId = save.canvasId; + this.libs.canvas = true; + } + } + } else { + //TODO: Add logic to save code view data + } } }, //////////////////////////////////////////////////////////////////// - // - saveAll: { + // + saveAll: { value: function (callback, libCopyCallback) { - //TODO: Implement on demand logic - if (this.needsSave) { - //Save - } else { - //Ignore command - } - // - if (this.currentView === this.views.design) { - // - var save = this.application.ninja.ioMediator.fileSave({ - mode: 'html', - libs: this.libs, - file: this.file, - webgl: this.webGlHelper.glData, - css: this.getStyleSheets(), - template: this.fileTemplate, - document: this.views.design.iframe.contentWindow.document, - head: this.views.design.iframe.contentWindow.document.head, - body: this.views.design.iframe.contentWindow.document.body, - mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); - //TODO: Improve detection during save routine - if (save) { - if (save.montageId) { - this.libs.montageId = save.montageId; - this.libs.montage = true; - } - if (save.canvasId) { - this.libs.canvasId = save.canvasId; - this.libs.canvas = true; - } - } - } else { - //TODO: Add logic to save code view data - } + //TODO: Implement on demand logic + if (this.needsSave) { + //Save + } else { + //Ignore command + } + // + if (this.currentView === this.views.design) { + // + var save = this.application.ninja.ioMediator.fileSave({ + mode: 'html', + libs: this.libs, + file: this.file, + webgl: this.webGlHelper.glData, + css: this.getStyleSheets(), + template: this.fileTemplate, + document: this.views.design.iframe.contentWindow.document, + head: this.views.design.iframe.contentWindow.document.head, + body: this.views.design.iframe.contentWindow.document.body, + mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator + }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback); + //TODO: Improve detection during save routine + if (save) { + if (save.montageId) { + this.libs.montageId = save.montageId; + this.libs.montage = true; + } + if (save.canvasId) { + this.libs.canvasId = save.canvasId; + this.libs.canvas = true; + } + } + } else { + //TODO: Add logic to save code view data + } } }, //////////////////////////////////////////////////////////////////// - // - saveAs: { + // + saveAs: { value: function (callback) { - //TODO: Implement on demand logic - if (this.needsSave) { - //Save current file on memory - } else { - //Copy file from disk - } - //TODO: Add functionality + //TODO: Implement on demand logic + if (this.needsSave) { + //Save current file on memory + } else { + //Copy file from disk + } + //TODO: Add functionality + } + }, + //////////////////////////////////////////////////////////////////// + // + handleSaved: { + value: function (result) { + //Checking for success code in save + if (result.status === 204) { + //Clearing flag with successful save + this.model.needsSave = false; + } + //Making callback call if specifed with results of operation + if (this.callback) this.callback(result); } }, //////////////////////////////////////////////////////////////////// - // - handleSaved: { - value: function (result) { - //Checking for success code in save - if (result.status === 204) { - //Clearing flag with successful save - this.model.needsSave = false; - } - //Making callback call if specifed with results of operation - 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); - } - } - }, + // + 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: { + //TODO: Implement better logic to include different views on single document + close: { value: function (view, callback) { - //Checking if files needs to be saved to avoid losing data - if (this.needsSave) { - //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 { - //TODO: Add support for other views - if (!view || view === 'design') { - this.closeView('design'); - } - //Making callback - if (callback) callback(); - } - + //Checking if files needs to be saved to avoid losing data + if (this.needsSave) { + //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 { + //TODO: Add support for other views + if (!view || view === 'design') { + this.closeView('design'); + } + //Making callback + if (callback) callback(); + } + } }, //////////////////////////////////////////////////////////////////// - // - 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; - } - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + // + 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 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/document/models/base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/document/models/base.js') diff --git a/js/document/models/base.js b/js/document/models/base.js index 21bb6a6f..0bc86627 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -34,7 +34,7 @@ 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, { //////////////////////////////////////////////////////////////////// // @@ -337,7 +337,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //Making callback if (callback) callback(); } - + } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3