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 ++++++++++++++++++++++----------------------- js/document/models/html.js | 46 ++--- js/document/models/text.js | 62 +++---- 3 files changed, 278 insertions(+), 278 deletions(-) (limited to 'js/document/models') 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; + } + } + } + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// diff --git a/js/document/models/html.js b/js/document/models/html.js index f1f8fd78..947c6c8b 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -30,29 +30,29 @@ POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, - webGlDocumentHelper = require("js/document/helpers/webgl-helper").webGlDocumentHelper; +var Montage = require("montage/core/core").Montage, + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, + webGlDocumentHelper = require("js/document/helpers/webgl-helper").webGlDocumentHelper; //////////////////////////////////////////////////////////////////////// -// +// exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { value: false }, //////////////////////////////////////////////////////////////////// - //Called by the document immidiately after the model is created + //Called by the document immidiately after the model is created init: { value:function() { - //Creating instance of the webGL helper for this model - this.webGlHelper = webGlDocumentHelper.create(); - // - this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; - } + //Creating instance of the webGL helper for this model + this.webGlHelper = webGlDocumentHelper.create(); + // + this.libs = {montage: false, canvas: false, montageId: null, canvasId: null}; + } }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // draw3DGrid: { value: false }, @@ -77,24 +77,24 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { value: null }, //////////////////////////////////////////////////////////////////// - //TODO: Convert to bindings + //TODO: Convert to bindings documentRoot: { get: function() {return this.views.design._documentRoot;}, set: function(value) {this.views.design._documentRoot = value;} }, //////////////////////////////////////////////////////////////////// - //TODO: Convert to bindings - baseHref: { - get: function() {return this.views.design._baseHref;}, + //TODO: Convert to bindings + baseHref: { + get: function() {return this.views.design._baseHref;}, set: function(value) {this.views.design._baseHref = value;} - }, + }, //////////////////////////////////////////////////////////////////// - // - webGlHelper: { + // + webGlHelper: { value: null } //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// diff --git a/js/document/models/text.js b/js/document/models/text.js index acb70631..1786c660 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -30,19 +30,19 @@ POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; +var Montage = require("montage/core/core").Montage, + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; //////////////////////////////////////////////////////////////////////// -// +// exports.TextDocumentModel = Montage.create(BaseDocumentModel, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { + enumerable: false, value: false }, //////////////////////////////////////////////////////////////////// - // + // save: { enumerable: false, value: function (callback) { @@ -58,37 +58,37 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { } }, //////////////////////////////////////////////////////////////////// - // + // handleSaved: { - value: function (result) { - // - if (result.status === 204) { - this.model.needsSave = false; - } - // - if (this.callback) this.callback(result); - } - }, + value: function (result) { + // + if (result.status === 204) { + this.model.needsSave = false; + } + // + if (this.callback) this.callback(result); + } + }, //////////////////////////////////////////////////////////////////// - // + // close: { 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; - } - // + //Outcome of close (pending on save logic) + var success; + // + if (this.needsSave) { + //Prompt user to save of lose data + } else { + //Close file + success = true; + } + // this.parentContainer.removeChild(this.views.code.textViewContainer); this.application.ninja.stage.restoreAllPanels(); this.views.code = null; - // - return success; + // + return success; } } }); -- cgit v1.2.3