From 2e308be9bec5e06d81b2905b65005a232f0a190d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 09:50:20 -0800 Subject: Revert "Creating NinjaTemplate to HTML function" This reverts commit e327eccb93e2bc513fcbb7ab302783d6bce83884. Signed-off-by: Ananya Sen --- js/document/text-document.js | 9 +++++++++ js/mediators/io-mediator.js | 22 ++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/js/document/text-document.js b/js/document/text-document.js index 6f8efaad..f2b7b0d8 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -191,5 +191,14 @@ var TextDocument = exports.TextDocument = Montage.create(Montage, { value: function() { // Have the XHR here? } + }/* +, + + save:{ + value:function(){ + //base function - to be overridden + } } +*/ + }); \ No newline at end of file diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 2008e40f..599b7d84 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -142,7 +142,12 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': - contents = this.parseNinjaTemplateToHtml(file); + file.document.content.document.body.innerHTML = file.body; + file.document.content.document.head.innerHTML = file.head; + if (file.style) { + file.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(file.style.cssRules); + } + contents = file.document.content.document.documentElement.outerHTML; break; default: contents = file.content; @@ -184,21 +189,6 @@ exports.IoMediator = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - //TODO: Expand to allow more templates - parseNinjaTemplateToHtml: { - enumerable: false, - value: function (template) { - // - template.document.content.document.body.innerHTML = template.body; - template.document.content.document.head.innerHTML = template.head; - //TODO: Remove temp fix for styles - if (template.style) { - template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); - } - return template.document.content.document.documentElement.outerHTML; - } - }, - //////////////////////////////////////////////////////////////////// //Method to return a string from CSS rules (to be saved to a file) getCssFromRules: { enumerable: false, -- cgit v1.2.3 From 9048cd50bf5e0a418d1d95498bb593961f72db36 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 09:51:12 -0800 Subject: Revert "Reverting text/html document classes and setting up MVC folder structure" This reverts commit 68ce64a5a2f4a71b54d33916aaf1d57161302425. Signed-off-by: Ananya Sen --- css/ninja.css | 2 - .../pickerNavigator.reel/pickerNavigator.css | 3 +- .../ui/icon-list-basic/icon.reel/icon.css | 16 +- js/controllers/document-controller.js | 25 +- js/document/controllers/base-controller.js | 32 -- js/document/html-document.js | 492 --------------------- js/document/mediators/base-mediator.js | 32 -- js/document/models/base-document.js | 204 +++++++++ js/document/models/base-model.js | 32 -- js/document/models/html-document.js | 492 +++++++++++++++++++++ js/document/text-document.js | 204 --------- js/document/views/base-view.js | 32 -- js/io/system/coreioapi.js | 4 +- scss/imports/scss/_MainWindow.scss | 6 - 14 files changed, 726 insertions(+), 850 deletions(-) delete mode 100755 js/document/controllers/base-controller.js delete mode 100755 js/document/html-document.js delete mode 100755 js/document/mediators/base-mediator.js create mode 100755 js/document/models/base-document.js delete mode 100755 js/document/models/base-model.js create mode 100755 js/document/models/html-document.js delete mode 100755 js/document/text-document.js delete mode 100755 js/document/views/base-view.js diff --git a/css/ninja.css b/css/ninja.css index 0be30434..d22cfc22 100755 --- a/css/ninja.css +++ b/css/ninja.css @@ -174,8 +174,6 @@ body { position: absolute; margin: 0px; width: 100%; height: 100%; background-co #documentBar { height: 25px; width: 1000px; position: relative; overflow: hidden; color: white; } -.montage-popup-modal-mask { opacity: 1; background: -webkit-radial-gradient(center, ellipse cover, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.8) 80%); } - #middleDocArea { -webkit-box-orient: horizontal; -moz-box-orient: horizontal; box-orient: horizontal; -moz-box-flex: 1; -webkit-box-flex: 1; box-flex: 1; margin: 1px; margin-bottom: 3px; border-style: solid; border-width: 1px; } #mainStageIFrame { border: none; margin: 4px; } diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.css b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.css index 796c283f..9c85c6b5 100644 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.css +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.css @@ -6,7 +6,7 @@ .picker{ font-size:12px; - width:523px; + width:510px; height:500px; padding-top:15px; padding-left:15px; @@ -53,7 +53,6 @@ height:75%; width:auto; border-right: none; - margin: 8px 0px 0px 8px; } .picker .right-bottom{ diff --git a/js/components/ui/icon-list-basic/icon.reel/icon.css b/js/components/ui/icon-list-basic/icon.reel/icon.css index 9fb180d2..4d71f6b8 100644 --- a/js/components/ui/icon-list-basic/icon.reel/icon.css +++ b/js/components/ui/icon-list-basic/icon.reel/icon.css @@ -5,14 +5,14 @@ */ .icon{ - width:88px; - height:78px; + width:90px; + height:80px; display: inline; float: left; -moz-border-radius: 8px; border-radius: 8px; - margin-bottom: 8px; - margin-right: 8px; + margin-bottom: 5px; + margin-right: 5px; background-color: #5f5f5f; } @@ -29,17 +29,17 @@ .icon .iconImg{ width:35px; height:35px; - margin-left: 26px; + margin-left: 20px; margin-top: 10px; } .icon .iconLabel{ margin-top:8px; white-space: nowrap; - text-overflow: ellipsis; + text-overflow:ellipsis; line-height:15px; overflow: hidden; - width: 72px; - padding: 0px 8px; + max-width:80%; text-align: center; + padding-left: 2px; } \ No newline at end of file diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f397ace7..25f60cc5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -9,8 +9,8 @@ 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, Uuid = require("montage/core/uuid").Uuid, - HTMLDocument = require("js/document/html-document").HTMLDocument, - TextDocument = require("js/document/text-document").TextDocument, + HTMLDocument = require("js/document/models/html-document").HTMLDocument, + BaseDocument = require("js/document/models/base-document").BaseDocument, DocumentController; //////////////////////////////////////////////////////////////////////// // @@ -28,7 +28,13 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _iframeHolder: { value: null, enumerable: false }, _textHolder: { value: null, enumerable: false }, _codeMirrorCounter: {value: 1, enumerable: false}, - + + tmpSourceForTesting: { + value: "function CodeMirror(place, givenOptions) {" + + "// Determine effective options based on given values and defaults." + + "var options = {}, defaults = CodeMirror.defaults; }" + }, + activeDocument: { get: function() { return this._activeDocument; @@ -56,12 +62,21 @@ DocumentController = exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("recordStyleChanged", this, false); + + // Temporary testing opening a new file after Ninja has loaded + this.eventManager.addEventListener("executeNewProject", this, false); } }, handleAppLoaded: { value: function() { - // + //this.openDocument({"type": "html"}); + } + }, + + handleExecuteNewProject: { + value: function() { + this.openDocument({"type": "html"}); } }, @@ -188,7 +203,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { break; default: //Open in code view - var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; + var code = Montage.create(BaseDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); code.initialize(doc, docuuid, textArea, textArea.parentNode); //code.init(doc.name, doc.uri, doc.extension, null, docuuid); diff --git a/js/document/controllers/base-controller.js b/js/document/controllers/base-controller.js deleted file mode 100755 index be441da2..00000000 --- a/js/document/controllers/base-controller.js +++ /dev/null @@ -1,32 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; -//////////////////////////////////////////////////////////////////////// -// -exports.ENTERNAME = Montage.create(Montage, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, - value: false - }, - //////////////////////////////////////////////////////////////////// - // - deserializedFromTemplate: { - enumerable: false, - value: function () { - // - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// -}); -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/html-document.js b/js/document/html-document.js deleted file mode 100755 index d0b63dcc..00000000 --- a/js/document/html-document.js +++ /dev/null @@ -1,492 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - TextDocument = require("js/document/text-document").TextDocument, - NJUtils = require("js/lib/NJUtils").NJUtils; -//////////////////////////////////////////////////////////////////////// -// -exports.HTMLDocument = Montage.create(TextDocument, { - // PRIVATE MEMBERS - _selectionExclude: { value: null, enumerable: false }, - _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, - _iframe: { value: null, enumerable: false }, - _server: { value: null, enumerable: false }, - _templateDocument: { value: null, enumerable: false }, - _selectionModel: { value: [], enumerable: false }, - _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, - - _document: { value: null, enumerable: false }, - _documentRoot: { value: null, enumerable: false }, - _stageBG: { value: null, enumerable: false }, - _window: { value: null, enumerable: false }, - _styles: { value: null, enumerable: false }, - _stylesheets: { value: null, enumerable: false }, - _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, - _userDocument: { value: null, enumerable: false }, - _htmlSource: {value: "", enumerable: false}, - _glData: {value: null, enumerable: false }, - - _elementCounter: { value: 1, enumerable: false }, - _snapping : { value: true, enumerable: false }, - _layoutMode: { value: "all", enumerable: false }, - _draw3DGrid: { value: false, writable: true }, - _swfObject: { value: false, enumerable: false }, - - _zoomFactor: { value: 100, enumerable: false }, - - // PUBLIC MEMBERS - cssLoadInterval: { value: null, enumerable: false }, - - _savedLeftScroll: {value:null}, - _savedTopScroll: {value:null}, - - _codeViewDocument:{ - writable: true, - enumerable: true, - value:null - }, - - /* - * PUBLIC API - */ - - // GETTERS / SETTERS - - codeViewDocument:{ - get: function() { return this._codeViewDocument; }, - set: function(value) { this._codeViewDocument = value} - }, - - savedLeftScroll:{ - get: function() { return this._savedLeftScroll; }, - set: function(value) { this._savedLeftScroll = value} - }, - - savedTopScroll:{ - get: function() { return this._savedTopScroll; }, - set: function(value) { this._savedTopScroll = value} - }, - - selectionExclude: { - get: function() { return this._selectionExclude; }, - set: function(value) { this._selectionExclude = value; } - }, - - iframe: { - get: function() { return this._iframe; }, - set: function(value) { this._iframe = value; } - }, - - server: { - get: function() { return this._server; }, - set: function(value) { this._server = value; } - }, - - selectionModel: { - get: function() { return this._selectionModel; }, - set: function(value) { this._selectionModel = value; } - }, - - undoModel: { - get: function() { return this._undoModel; }, - set: function(value) { this._undoModel.queue = value.queue; this._undoModel.position = value.position; } - }, - - documentRoot: { - get: function() { return this._documentRoot; }, - set: function(value) { this._documentRoot = value; } - }, - - stageBG: { - get: function() { return this._stageBG; }, - set: function(value) { this._stageBG = value; } - }, - - elementCounter: { - set: function(value) { this._elementCounter = value; }, - get: function() { return this._elementCounter; } - }, - - snapping: { - get: function() { return this._snapping; }, - set: function(value) { - if(this._snapping !== value) { - this._snapping = value; - } - } - }, - - // TODO SEND THE EVENT --> Redraw the desired layout - layoutMode: { - get: function() { return this._layoutMode; }, - set: function(mode) { this._layoutMode = mode; } - }, - - draw3DGrid: { - get: function() { return this._draw3DGrid; }, - set: function(value) { - if(this._draw3DGrid !== value) { - this._draw3DGrid = value; - } - } - }, - - _userComponentSet: { - value: {}, - writable: true, - enumerable:true - }, - -// userComponentSet:{ -// enumerable: true, -// get: function() { -// return this._userComponentSet; -// }, -// set: function(value) { -// this._userComponentSet = value; -// this._drawUserComponentsOnOpen(); -// } -// }, -// -// _drawUserComponentsOnOpen:{ -// value:function(){ -// for(var i in this._userComponentSet){ -// console.log(this._userComponentSet[i].control) -// this._userComponentSet[i].control.needsDraw = true; -// } -// } -// }, - - glData: { - get: function() - { - var elt = this.iframe; - var elt = this.iframe.contentWindow.document.getElementById("UserContent"); - this._glData = null; - if (elt) - { - this._glData = new Array(); - this.collectGLData( elt, this._glData ); - } - - return this._glData - }, - - set: function(value) - { - var nWorlds = value.length; - for (var i=0; i= 0) - { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - { - var id = importStr.substring( startIndex+4, endIndex ); - var canvas = this.iframe.contentWindow.document.getElementById( id ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - var world = new GLWorld( canvas ); - canvas.elementModel.shapeModel.GLWorld = world; - world.import( importStr ); - } - } - } - } - } - } - }, - - zoomFactor: { - get: function() { return this._zoomFactor; }, - set: function(value) { this._zoomFactor = value; } - }, - - //****************************************// - // PUBLIC METHODS - - - //////////////////////////////////////////////////////////////////// - // - initialize: { - value: function(file, uuid, iframe, callback) { - // - this._userDocument = file; - // - this.init(file.name, file.uri, file.extension, iframe, uuid, callback); - // - this.iframe = iframe; - this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; - this.currentView = "design"; - // - this.iframe.src = this._htmlTemplateUrl; - this.iframe.addEventListener("load", this, true); - } - }, - //////////////////////////////////////////////////////////////////// - - - collectGLData: { - value: function( elt, dataArray ) - { - if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) - { - var data = elt.elementModel.shapeModel.GLWorld.export(); - dataArray.push( data ); - } - - if (elt.children) - { - var nKids = elt.children.length; - for (var i=0; i 1) { - clearInterval(this.cssLoadInterval); - this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; - this._stylesheets = this._document.styleSheets; // Entire stlyesheets array - - this.callback(this); - } - }.bind(this), 50); - - // TODO - Not sure where this goes - this._userComponentSet = {}; - - - this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; - this._stylesheets = this._document.styleSheets; // Entire stlyesheets array - - /* TODO Finish this implementation once we start caching Core Elements */ - // Assign a model to the UserContent and add the ViewPort reference to it. - NJUtils.makeElementModel(this.documentRoot, "Stage", "stage"); - //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport"); - NJUtils.makeElementModel(this.stageBG, "Stage", "stage"); - NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage"); - - for(i = 0; i < this._stylesheets.length; i++) { - if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) { - this.documentRoot.elementModel.defaultRule = this._stylesheets[i]; - break; - } - } - - // Temporary create properties for each rule we need to save the index of the rule. - var len = this.documentRoot.elementModel.defaultRule.cssRules.length; - for(var j = 0; j < len; j++) { -// console.log(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText); - if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "*") { - - this.documentRoot.elementModel.transitionStopRule = this.documentRoot.elementModel.defaultRule.cssRules[j]; - - } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "body") { - - this.documentRoot.elementModel.body = this.documentRoot.elementModel.defaultRule.cssRules[j]; - - } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#Viewport") { - - this.documentRoot.elementModel.viewPort = this.documentRoot.elementModel.defaultRule.cssRules[j]; - - } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageDimension") { - - this.documentRoot.elementModel.stageDimension = this.documentRoot.elementModel.defaultRule.cssRules[j]; - - } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageView") { - - this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j]; - - } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") { - - this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j]; - } - } - - this.callback(this); - - } - }, - - _setSWFObjectScript: { - value: function() { - if(!this._swfObject) { - /* - var swfObj = document.createElement("script"); - swfObj.type = "text/javascript"; - swfObj.src = "../../user-document-templates/external-libs/swf-object/swfobject.js"; - swfObj.id = "swfObject"; - var head= this._document.getElementsByTagName('head')[0]; - head.appendChild(swfObj); - this._swfObject = true; - */ - } - } - }, - - /** - * public method - * - */ - //////////////////////////////////////////////////////////////////// - // - save: { - enumerable: false, - value: function () { - //TODO: Add code view logic and also styles for HTML - if (this.currentView === 'design') { - return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - } else if (this.currentView === "code"){ - //TODO: Would this get call when we are in code of HTML? - } else { - //Error - } - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// -}); \ No newline at end of file diff --git a/js/document/mediators/base-mediator.js b/js/document/mediators/base-mediator.js deleted file mode 100755 index be441da2..00000000 --- a/js/document/mediators/base-mediator.js +++ /dev/null @@ -1,32 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; -//////////////////////////////////////////////////////////////////////// -// -exports.ENTERNAME = Montage.create(Montage, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, - value: false - }, - //////////////////////////////////////////////////////////////////// - // - deserializedFromTemplate: { - enumerable: false, - value: function () { - // - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// -}); -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/models/base-document.js b/js/document/models/base-document.js new file mode 100755 index 00000000..45c340ce --- /dev/null +++ b/js/document/models/base-document.js @@ -0,0 +1,204 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +//BaseDocument Object for all files types and base class for HTML documents. + +var Montage = require("montage/core/core").Montage; + +var BaseDocument = exports.BaseDocument = Montage.create(Montage, { + + + //TODO: Clean up, test + + + + + + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //Taken from text-document, which shouldn't be needed + + // PRIVATE MEMBERS + _codeEditor: { + value: { + "editor": { value: null, enumerable: false }, + + } + }, + + _editor: { value: null, enumerable: false }, + _hline: { value: null, enumerable: false }, + + _textArea: {value: null, enumerable: false }, + + _userDocument: {value: null, enumerable: false }, + + _source: { value: null, enumerable: false}, + + source: { + get: function() { return this._source;}, + set: function(value) { this._source = value;} + }, + + // PUBLIC MEMBERS + + _savedLeftScroll: {value:null}, + _savedTopScroll: {value:null}, + + //****************************************// + //PUBLIC API + + + // GETTERS / SETTERS + + savedLeftScroll:{ + get: function() { return this._savedLeftScroll; }, + set: function(value) { this._savedLeftScroll = value} + }, + + savedTopScroll:{ + get: function() { return this._savedTopScroll; }, + set: function(value) { this._savedTopScroll = value} + }, + + textArea: { + get: function() { return this._textArea; }, + set: function(value) { this._textArea = value; } + }, + editor: { + get: function() { return this._editor; }, + set: function(value) { this._editor = value} + }, + + hline: { + get: function() { return this._hline; }, + set: function(value) {this._hline = value; } + }, + + + //////////////////////////////////////////////////////////////////// + // + initialize: { + value: function(file, uuid, textArea, container, callback) { + // + this._userDocument = file; + // + this.init(file.name, file.uri, file.extension, container, uuid, callback); + // + this.currentView = "code"; + this.textArea = textArea; + } + }, + //////////////////////////////////////////////////////////////////// + // + save: { + enumerable: false, + value: function () { + //TODO: Improve sequence + this.editor.save(); + return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value}; + } + }, + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + + + + + + + + + + + /** Private Members **/ + _name: { value: null, enumerable: false }, + _uri: { value: null, enumerable: false }, + _documentType: { value: null, enumerable: false }, + _container: {value: null, enumerable: false }, + _uuid: { value: null, enumerable: false }, + _isActive: { value: true, enumerable: false }, + _dirtyFlag: { value: false, enumerable: false }, + _callback: { value: null, enumerable: false }, + _currentView: { value: null, enumerable: false}, + + /** Getters/Setters **/ + name: { + get: function() { return this._name; }, + set: function(value) { this._name = value; } + }, + + uri: { + get: function() { return this._uri; }, + set: function(value) { this._uri = value; } + }, + + documentType: { + get: function() { return this._documentType; }, + set: function(value) { this._documentType = value; } + }, + + container: { + get: function() { return this._container; }, + set: function(value) { this._container = value; } + }, + + uuid: { + get: function() { return this._uuid; }, + set: function(value) { this._uuid = value; } + }, + + isActive: { + get: function() { return this._isActive; }, + set: function(value) { this._isActive = value; } + }, + + dirtyFlag: { + get: function() { return this._dirtyFlag; }, + set: function(value) { this._dirtyFlag = value; } + }, + + callback: { + get: function() { return this._callback; }, + set: function(value) { this._callback = value; } + }, + + currentView: { + get: function() { return this._currentView; }, + set: function(value) { this._currentView = value } + }, + + /** Base Methods **/ + init: { + value: function(name, uri, type, container, uuid, callback) { + this.name = name; + this.uri = uri; + this.documentType = type; + this.container = container; + this.uuid = uuid; + this.callback = callback; + } + }, + + loadDocument: { + value: function() { + // Have the XHR here? + } + }/* +, + + save:{ + value:function(){ + //base function - to be overridden + } + } +*/ + +}); \ No newline at end of file diff --git a/js/document/models/base-model.js b/js/document/models/base-model.js deleted file mode 100755 index be441da2..00000000 --- a/js/document/models/base-model.js +++ /dev/null @@ -1,32 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; -//////////////////////////////////////////////////////////////////////// -// -exports.ENTERNAME = Montage.create(Montage, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, - value: false - }, - //////////////////////////////////////////////////////////////////// - // - deserializedFromTemplate: { - enumerable: false, - value: function () { - // - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// -}); -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/models/html-document.js b/js/document/models/html-document.js new file mode 100755 index 00000000..cb399f04 --- /dev/null +++ b/js/document/models/html-document.js @@ -0,0 +1,492 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + BaseDocument = require("js/document/models/base-document").BaseDocument, + NJUtils = require("js/lib/NJUtils").NJUtils; +//////////////////////////////////////////////////////////////////////// +// +exports.HTMLDocument = Montage.create(BaseDocument, { + // PRIVATE MEMBERS + _selectionExclude: { value: null, enumerable: false }, + _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, + _iframe: { value: null, enumerable: false }, + _server: { value: null, enumerable: false }, + _templateDocument: { value: null, enumerable: false }, + _selectionModel: { value: [], enumerable: false }, + _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, + + _document: { value: null, enumerable: false }, + _documentRoot: { value: null, enumerable: false }, + _stageBG: { value: null, enumerable: false }, + _window: { value: null, enumerable: false }, + _styles: { value: null, enumerable: false }, + _stylesheets: { value: null, enumerable: false }, + _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, + _userDocument: { value: null, enumerable: false }, + _htmlSource: {value: "", enumerable: false}, + _glData: {value: null, enumerable: false }, + + _elementCounter: { value: 1, enumerable: false }, + _snapping : { value: true, enumerable: false }, + _layoutMode: { value: "all", enumerable: false }, + _draw3DGrid: { value: false, writable: true }, + _swfObject: { value: false, enumerable: false }, + + _zoomFactor: { value: 100, enumerable: false }, + + // PUBLIC MEMBERS + cssLoadInterval: { value: null, enumerable: false }, + + _savedLeftScroll: {value:null}, + _savedTopScroll: {value:null}, + + _codeViewDocument:{ + writable: true, + enumerable: true, + value:null + }, + + /* + * PUBLIC API + */ + + // GETTERS / SETTERS + + codeViewDocument:{ + get: function() { return this._codeViewDocument; }, + set: function(value) { this._codeViewDocument = value} + }, + + savedLeftScroll:{ + get: function() { return this._savedLeftScroll; }, + set: function(value) { this._savedLeftScroll = value} + }, + + savedTopScroll:{ + get: function() { return this._savedTopScroll; }, + set: function(value) { this._savedTopScroll = value} + }, + + selectionExclude: { + get: function() { return this._selectionExclude; }, + set: function(value) { this._selectionExclude = value; } + }, + + iframe: { + get: function() { return this._iframe; }, + set: function(value) { this._iframe = value; } + }, + + server: { + get: function() { return this._server; }, + set: function(value) { this._server = value; } + }, + + selectionModel: { + get: function() { return this._selectionModel; }, + set: function(value) { this._selectionModel = value; } + }, + + undoModel: { + get: function() { return this._undoModel; }, + set: function(value) { this._undoModel.queue = value.queue; this._undoModel.position = value.position; } + }, + + documentRoot: { + get: function() { return this._documentRoot; }, + set: function(value) { this._documentRoot = value; } + }, + + stageBG: { + get: function() { return this._stageBG; }, + set: function(value) { this._stageBG = value; } + }, + + elementCounter: { + set: function(value) { this._elementCounter = value; }, + get: function() { return this._elementCounter; } + }, + + snapping: { + get: function() { return this._snapping; }, + set: function(value) { + if(this._snapping !== value) { + this._snapping = value; + } + } + }, + + // TODO SEND THE EVENT --> Redraw the desired layout + layoutMode: { + get: function() { return this._layoutMode; }, + set: function(mode) { this._layoutMode = mode; } + }, + + draw3DGrid: { + get: function() { return this._draw3DGrid; }, + set: function(value) { + if(this._draw3DGrid !== value) { + this._draw3DGrid = value; + } + } + }, + + _userComponentSet: { + value: {}, + writable: true, + enumerable:true + }, + +// userComponentSet:{ +// enumerable: true, +// get: function() { +// return this._userComponentSet; +// }, +// set: function(value) { +// this._userComponentSet = value; +// this._drawUserComponentsOnOpen(); +// } +// }, +// +// _drawUserComponentsOnOpen:{ +// value:function(){ +// for(var i in this._userComponentSet){ +// console.log(this._userComponentSet[i].control) +// this._userComponentSet[i].control.needsDraw = true; +// } +// } +// }, + + glData: { + get: function() + { + var elt = this.iframe; + var elt = this.iframe.contentWindow.document.getElementById("UserContent"); + this._glData = null; + if (elt) + { + this._glData = new Array(); + this.collectGLData( elt, this._glData ); + } + + return this._glData + }, + + set: function(value) + { + var nWorlds = value.length; + for (var i=0; i= 0) + { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) + { + var id = importStr.substring( startIndex+4, endIndex ); + var canvas = this.iframe.contentWindow.document.getElementById( id ); + if (canvas) + { + if (!canvas.elementModel) + { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + + if (canvas.elementModel) + { + if (canvas.elementModel.shapeModel.GLWorld) + canvas.elementModel.shapeModel.GLWorld.clearTree(); + + var world = new GLWorld( canvas ); + canvas.elementModel.shapeModel.GLWorld = world; + world.import( importStr ); + } + } + } + } + } + } + }, + + zoomFactor: { + get: function() { return this._zoomFactor; }, + set: function(value) { this._zoomFactor = value; } + }, + + //****************************************// + // PUBLIC METHODS + + + //////////////////////////////////////////////////////////////////// + // + initialize: { + value: function(file, uuid, iframe, callback) { + // + this._userDocument = file; + // + this.init(file.name, file.uri, file.extension, iframe, uuid, callback); + // + this.iframe = iframe; + this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; + this.currentView = "design"; + // + this.iframe.src = this._htmlTemplateUrl; + this.iframe.addEventListener("load", this, true); + } + }, + //////////////////////////////////////////////////////////////////// + + + collectGLData: { + value: function( elt, dataArray ) + { + if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) + { + var data = elt.elementModel.shapeModel.GLWorld.export(); + dataArray.push( data ); + } + + if (elt.children) + { + var nKids = elt.children.length; + for (var i=0; i 1) { + clearInterval(this.cssLoadInterval); + this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; + this._stylesheets = this._document.styleSheets; // Entire stlyesheets array + + this.callback(this); + } + }.bind(this), 50); + + // TODO - Not sure where this goes + this._userComponentSet = {}; + + + this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; + this._stylesheets = this._document.styleSheets; // Entire stlyesheets array + + /* TODO Finish this implementation once we start caching Core Elements */ + // Assign a model to the UserContent and add the ViewPort reference to it. + NJUtils.makeElementModel(this.documentRoot, "Stage", "stage"); + //this.documentRoot.elementModel.viewPort = this.iframe.contentWindow.document.getElementById("Viewport"); + NJUtils.makeElementModel(this.stageBG, "Stage", "stage"); + NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage"); + + for(i = 0; i < this._stylesheets.length; i++) { + if(this._stylesheets[i].ownerNode.id === this._stageStyleSheetId) { + this.documentRoot.elementModel.defaultRule = this._stylesheets[i]; + break; + } + } + + // Temporary create properties for each rule we need to save the index of the rule. + var len = this.documentRoot.elementModel.defaultRule.cssRules.length; + for(var j = 0; j < len; j++) { +// console.log(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText); + if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "*") { + + this.documentRoot.elementModel.transitionStopRule = this.documentRoot.elementModel.defaultRule.cssRules[j]; + + } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "body") { + + this.documentRoot.elementModel.body = this.documentRoot.elementModel.defaultRule.cssRules[j]; + + } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#Viewport") { + + this.documentRoot.elementModel.viewPort = this.documentRoot.elementModel.defaultRule.cssRules[j]; + + } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageDimension") { + + this.documentRoot.elementModel.stageDimension = this.documentRoot.elementModel.defaultRule.cssRules[j]; + + } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === ".stageView") { + + this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j]; + + } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") { + + this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j]; + } + } + + this.callback(this); + + } + }, + + _setSWFObjectScript: { + value: function() { + if(!this._swfObject) { + /* + var swfObj = document.createElement("script"); + swfObj.type = "text/javascript"; + swfObj.src = "../../user-document-templates/external-libs/swf-object/swfobject.js"; + swfObj.id = "swfObject"; + var head= this._document.getElementsByTagName('head')[0]; + head.appendChild(swfObj); + this._swfObject = true; + */ + } + } + }, + + /** + * public method + * + */ + //////////////////////////////////////////////////////////////////// + // + save: { + enumerable: false, + value: function () { + //TODO: Add code view logic and also styles for HTML + if (this.currentView === 'design') { + return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + } else if (this.currentView === "code"){ + //TODO: Would this get call when we are in code of HTML? + } else { + //Error + } + } + } + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// +}); \ No newline at end of file diff --git a/js/document/text-document.js b/js/document/text-document.js deleted file mode 100755 index f2b7b0d8..00000000 --- a/js/document/text-document.js +++ /dev/null @@ -1,204 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//BaseDocument Object for all files types and base class for HTML documents. - -var Montage = require("montage/core/core").Montage; - -var TextDocument = exports.TextDocument = Montage.create(Montage, { - - - //TODO: Clean up, test - - - - - - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - //Taken from text-document, which shouldn't be needed - - // PRIVATE MEMBERS - _codeEditor: { - value: { - "editor": { value: null, enumerable: false }, - - } - }, - - _editor: { value: null, enumerable: false }, - _hline: { value: null, enumerable: false }, - - _textArea: {value: null, enumerable: false }, - - _userDocument: {value: null, enumerable: false }, - - _source: { value: null, enumerable: false}, - - source: { - get: function() { return this._source;}, - set: function(value) { this._source = value;} - }, - - // PUBLIC MEMBERS - - _savedLeftScroll: {value:null}, - _savedTopScroll: {value:null}, - - //****************************************// - //PUBLIC API - - - // GETTERS / SETTERS - - savedLeftScroll:{ - get: function() { return this._savedLeftScroll; }, - set: function(value) { this._savedLeftScroll = value} - }, - - savedTopScroll:{ - get: function() { return this._savedTopScroll; }, - set: function(value) { this._savedTopScroll = value} - }, - - textArea: { - get: function() { return this._textArea; }, - set: function(value) { this._textArea = value; } - }, - editor: { - get: function() { return this._editor; }, - set: function(value) { this._editor = value} - }, - - hline: { - get: function() { return this._hline; }, - set: function(value) {this._hline = value; } - }, - - - //////////////////////////////////////////////////////////////////// - // - initialize: { - value: function(file, uuid, textArea, container, callback) { - // - this._userDocument = file; - // - this.init(file.name, file.uri, file.extension, container, uuid, callback); - // - this.currentView = "code"; - this.textArea = textArea; - } - }, - //////////////////////////////////////////////////////////////////// - // - save: { - enumerable: false, - value: function () { - //TODO: Improve sequence - this.editor.save(); - return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value}; - } - }, - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// - - - - - - - - - - - /** Private Members **/ - _name: { value: null, enumerable: false }, - _uri: { value: null, enumerable: false }, - _documentType: { value: null, enumerable: false }, - _container: {value: null, enumerable: false }, - _uuid: { value: null, enumerable: false }, - _isActive: { value: true, enumerable: false }, - _dirtyFlag: { value: false, enumerable: false }, - _callback: { value: null, enumerable: false }, - _currentView: { value: null, enumerable: false}, - - /** Getters/Setters **/ - name: { - get: function() { return this._name; }, - set: function(value) { this._name = value; } - }, - - uri: { - get: function() { return this._uri; }, - set: function(value) { this._uri = value; } - }, - - documentType: { - get: function() { return this._documentType; }, - set: function(value) { this._documentType = value; } - }, - - container: { - get: function() { return this._container; }, - set: function(value) { this._container = value; } - }, - - uuid: { - get: function() { return this._uuid; }, - set: function(value) { this._uuid = value; } - }, - - isActive: { - get: function() { return this._isActive; }, - set: function(value) { this._isActive = value; } - }, - - dirtyFlag: { - get: function() { return this._dirtyFlag; }, - set: function(value) { this._dirtyFlag = value; } - }, - - callback: { - get: function() { return this._callback; }, - set: function(value) { this._callback = value; } - }, - - currentView: { - get: function() { return this._currentView; }, - set: function(value) { this._currentView = value } - }, - - /** Base Methods **/ - init: { - value: function(name, uri, type, container, uuid, callback) { - this.name = name; - this.uri = uri; - this.documentType = type; - this.container = container; - this.uuid = uuid; - this.callback = callback; - } - }, - - loadDocument: { - value: function() { - // Have the XHR here? - } - }/* -, - - save:{ - value:function(){ - //base function - to be overridden - } - } -*/ - -}); \ No newline at end of file diff --git a/js/document/views/base-view.js b/js/document/views/base-view.js deleted file mode 100755 index be441da2..00000000 --- a/js/document/views/base-view.js +++ /dev/null @@ -1,32 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -//////////////////////////////////////////////////////////////////////// -// -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; -//////////////////////////////////////////////////////////////////////// -// -exports.ENTERNAME = Montage.create(Montage, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, - value: false - }, - //////////////////////////////////////////////////////////////////// - // - deserializedFromTemplate: { - enumerable: false, - value: function () { - // - } - } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// -}); -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 507804fd..ea9627cc 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -97,12 +97,10 @@ window.hack = function (name, type) { this.application.ninja.ioMediator.fileNew('Users/kgq387/Desktop/Ninja Cloud/Disk/'+name+'.'+type, '/js/io/templates/files/'+type+'.txt', function (status) {console.log(status)}); }.bind(this); */ - /* -window.hack = function (path) { + window.hack = function (path) { // this.application.ninja.ioMediator.fileOpen('Users/kgq387/Desktop/Ninja Cloud/Disk/'+path, function (result) {console.log(result)}); }.bind(this); -*/ } }, //////////////////////////////////////////////////////////////////// diff --git a/scss/imports/scss/_MainWindow.scss b/scss/imports/scss/_MainWindow.scss index b5ff42bc..b7c7f4b7 100755 --- a/scss/imports/scss/_MainWindow.scss +++ b/scss/imports/scss/_MainWindow.scss @@ -331,9 +331,3 @@ overflow: hidden; color: white; } - -.montage-popup-modal-mask -{ - opacity: 1; - background: -webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%); -} \ No newline at end of file -- cgit v1.2.3 From a90e3be8850b64e8e370aa8ff8cadaa448dd0c82 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 09:58:37 -0800 Subject: Revert "Cleaning up" This reverts commit a7952c5a16e2cae3fd1a459b03b9f16bba1004da. Conflicts: js/controllers/document-controller.js js/io/document/text-document.js Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 4 +- js/document/models/base-document.js | 204 -------------- js/document/models/html-document.js | 492 ---------------------------------- js/io/document/base-document.js | 204 ++++++++++++++ js/io/document/html-document.js | 492 ++++++++++++++++++++++++++++++++++ js/io/document/text-document.js | 156 +++++++++++ 6 files changed, 854 insertions(+), 698 deletions(-) delete mode 100755 js/document/models/base-document.js delete mode 100755 js/document/models/html-document.js create mode 100755 js/io/document/base-document.js create mode 100755 js/io/document/html-document.js create mode 100755 js/io/document/text-document.js diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 25f60cc5..9ece27f9 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -9,8 +9,8 @@ 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, Uuid = require("montage/core/uuid").Uuid, - HTMLDocument = require("js/document/models/html-document").HTMLDocument, - BaseDocument = require("js/document/models/base-document").BaseDocument, + HTMLDocument = require("js/io/document/html-document").HTMLDocument, + TextDocument = require("js/io/document/text-document").TextDocument, DocumentController; //////////////////////////////////////////////////////////////////////// // diff --git a/js/document/models/base-document.js b/js/document/models/base-document.js deleted file mode 100755 index 45c340ce..00000000 --- a/js/document/models/base-document.js +++ /dev/null @@ -1,204 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright