From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- js/document/models/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/text.js b/js/document/models/text.js index d1252b7d..0135b9ba 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -22,7 +22,7 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { save: { enumerable: false, value: function (callback) { - this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea + this.application.ninja.currentDocument.model.views.code.editor.save();//save to textarea var self = this; -- cgit v1.2.3 From 5d7dff15e1e603e3b37057b9843e4b1eef1b2dca Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 15:32:47 -0700 Subject: cleanup and handling the document views in the document controller for now. Signed-off-by: Valerio Virgillito --- js/document/_toDelete/html-document.js | 874 --------------------------------- js/document/_toDelete/text-document.js | 198 -------- js/document/views/code.js | 6 - 3 files changed, 1078 deletions(-) delete mode 100755 js/document/_toDelete/html-document.js delete mode 100755 js/document/_toDelete/text-document.js (limited to 'js/document') diff --git a/js/document/_toDelete/html-document.js b/js/document/_toDelete/html-document.js deleted file mode 100755 index 447d90e3..00000000 --- a/js/document/_toDelete/html-document.js +++ /dev/null @@ -1,874 +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, - GLWorld = require("js/lib/drawing/world").World, - MaterialsModel = require("js/models/materials-model").MaterialsModel; -//////////////////////////////////////////////////////////////////////// -// -exports.HTMLDocument = Montage.create(TextDocument, { - - _selectionExclude: { value: null, enumerable: false }, - _htmlTemplateUrl: { value: "js/document/templates/montage-html/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 }, - _liveNodeList: { value: null, enumarable: 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 }, - _userComponents: { value: {}, enumarable: 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 }, - - cssLoadInterval: { value: null, enumerable: false }, - - _savedLeftScroll: {value:null}, - _savedTopScroll: {value:null}, - - _codeViewDocument:{ - writable: true, - enumerable: true, - value:null - }, - - - //drawUtils state - _gridHorizontalSpacing: {value:0}, - _gridVerticalSpacing: {value:0}, - //end - drawUtils state - - _undoStack: { value: [] }, - undoStack: { - get: function() { - return this._undoStack; - }, - set:function(value){ - this._undoStack = value; - } - }, - - _redoStack: { value: [], enumerable: false }, - - redoStack: { - get: function() { - return this._redoStack; - }, - set:function(value){ - this._redoStack = value; - } - }, - - - // 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} - }, - - gridHorizontalSpacing:{ - get: function() { return this._gridHorizontalSpacing; }, - set: function(value) { this._gridHorizontalSpacing = value} - }, - - gridVerticalSpacing:{ - get: function() { return this._gridVerticalSpacing; }, - set: function(value) { this._gridVerticalSpacing = 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; - } - } - }, - - userComponents: { - get: function() { - return this._userComponents; - } - }, -// _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.contentWindow.document.getElementById("UserContent"); - // - if (elt) { - var matLib = MaterialsModel.exportMaterials(); - this._glData = [matLib]; - this.collectGLData(elt, this._glData ); - } else { - this._glData = null - } - // - return this._glData; - }, - set: function(value) { - var elt = this.documentRoot; - if (elt) - { - /* - // Use this code to test the runtime version of WebGL - var cvsDataMngr = Object.create(NinjaCvsRt.CanvasDataManager, {}); - cvsDataMngr.loadGLData(elt, value); - */ - - // /* - var nWorlds= value.length; - for (var i=0; i= 0) { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - id = importStr.substring( startIndex+4, endIndex ); - } - } - } - - if (id != null) - { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - if (jObj) - { - var useWebGL = jObj.webGL; - var world = new GLWorld( canvas, useWebGL ); - world.importJSON( jObj ); - } - - this.buildShapeModel( canvas.elementModel, world ); - } - } - } - } - // */ - } - } - }, - - buildShapeModel: - { - value: function( elementModel, world ) - { - var shapeModel = elementModel.shapeModel; - shapeModel.shapeCount = 1; // for now... - shapeModel.useWebGl = world._useWebGL; - shapeModel.GLWorld = world; - var root = world.getGeomRoot(); - if (root) - { - shapeModel.GLGeomObj = root; - shapeModel.strokeSize = root._strokeWidth; - shapeModel.strokeStyle = "solid"; - //shapeModel.strokeStyleIndex - switch (root.geomType()) - { - case root.GEOM_TYPE_RECTANGLE: - elementModel.selection = "Rectangle"; - elementModel.pi = "RectanglePi"; - shapeModel.tlRadius = root._tlRadius; - shapeModel.trRadius = root._trRadius; - shapeModel.blRadius = root._blRadius; - shapeModel.brRadius = root._brRadius; - break; - - case root.GEOM_TYPE_CIRCLE: - elementModel.selection = "Oval"; - elementModel.pi = "OvalPi"; - shapeModel.innerRadius = root._innerRadius; - break; - - case root.GEOM_TYPE_LINE: - elementModel.selection = "Line"; - elementModel.pi = "LinePi"; - shapeModel.slope = root._slope; - break; - - case root.GEOM_TYPE_BRUSH_STROKE: - elementModel.selection = "BrushStroke"; - elementModel.pi = "BrushStrokePi"; - break; - - case root.GEOM_TYPE_CUBIC_BEZIER: - elementModel.selection = "Subpath"; - elementModel.pi = "SubpathPi"; - break; - - default: - console.log( "geometry type not supported for file I/O, " + root.geomType()); - break; - } - } - } - }, - - zoomFactor: { - get: function() { return this._zoomFactor; }, - set: function(value) { this._zoomFactor = value; } - }, - - /** - * Add a reference to a component instance to the userComponents hash using the - * element UUID - */ - setComponentInstance: { - value: function(instance, el) { - this.userComponents[el.uuid] = instance; - } - }, - - /** - * Returns the component instance obj from the element - */ - getComponentFromElement: { - value: function(el) { - if(el) { - if(el.uuid) return this.userComponents[el.uuid]; - } else { - return null; - } - } - }, - - /** - * search the DOM tree to find a canvas with the given id - */ - findCanvasWithID: { - value: function( id, elt ) { - var cid = elt.getAttribute( "data-RDGE-id" ); - if (cid == id) return elt; - - if (elt.children) - { - var nKids = elt.children.length; - for (var i=0; i 1) { - //Checking all styleSheets in document - for (var i in this._document.styleSheets) { - //If rules are null, assuming cross-origin issue - if(this._document.styleSheets[i].rules === null) { - //TODO: Revisit URLs and URI creation logic, very hack right now - var fileUri, cssUrl, cssData, query, prefixUrl, fileCouldDirUrl, docRootUrl; - // - docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); - //TODO: Parse out relative URLs and map them to absolute - if (this._document.styleSheets[i].href.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) { - // - cssUrl = this._document.styleSheets[i].href.split(this.application.ninja.coreIoApi.rootUrl)[1]; - fileUri = this.application.ninja.coreIoApi.cloudData.root+cssUrl; - //TODO: Add error handling for reading file - cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); - // - var tag = this.iframe.contentWindow.document.createElement('style'); - tag.setAttribute('type', 'text/css'); - tag.setAttribute('data-ninja-uri', fileUri); - tag.setAttribute('data-ninja-file-url', cssUrl); - tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); - tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); - //Copying attributes to maintain same properties as the - for (var n in this._document.styleSheets[i].ownerNode.attributes) { - if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled' && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { - if (this._document.styleSheets[i].ownerNode.attributes[n].value.indexOf(docRootUrl) !== -1) { - tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value.split(docRootUrl)[1]); - } else { - tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); - } - } - } - // - fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; - - //TODO: Make public version of this.application.ninja.ioMediator.getNinjaPropUrlRedirect with dynamic ROOT - tag.innerHTML = cssData.content.replace(/url\(()(.+?)\1\)/g, detectUrl); - - function detectUrl (prop) { - return prop.replace(/[^()\\""\\'']+/g, prefixUrl);; - } - - function prefixUrl (url) { - if (url !== 'url') { - if (!url.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { - url = fileCouldDirUrl+url; - } - } - return url; - } - - //Looping through DOM to insert style tag at location of link element - query = this._templateDocument.html.querySelectorAll(['link']); - for (var j in query) { - if (query[j].href === this._document.styleSheets[i].href) { - //Disabling style sheet to reload via inserting in style tag - query[j].setAttribute('disabled', 'true'); - //Inserting tag - this._templateDocument.head.insertBefore(tag, query[j]); - } - } - } else { - console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); - //None local stylesheet, probably on a CDN (locked) - var tag = this.iframe.contentWindow.document.createElement('style'); - tag.setAttribute('type', 'text/css'); - tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href); - tag.setAttribute('data-ninja-file-read-only', "true"); - tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]); - //Copying attributes to maintain same properties as the - for (var n in this._document.styleSheets[i].ownerNode.attributes) { - if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled' && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { - if (this._document.styleSheets[i].ownerNode.attributes[n].value.indexOf(docRootUrl) !== -1) { - tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value.split(docRootUrl)[1]); - } else { - tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); - } - } - } - /* - - //TODO: Figure out cross-domain XHR issue, might need cloud to handle - var xhr = new XMLHttpRequest(); - xhr.open("GET", this._document.styleSheets[i].href, true); - xhr.send(); - // - if (xhr.readyState === 4) { - console.log(xhr); - } - //tag.innerHTML = xhr.responseText //xhr.response; - */ - //Temp rule so it's registered in the array - tag.innerHTML = 'noRULEjustHACK{background: #000}'; - //Disabling external style sheets - query = this._templateDocument.html.querySelectorAll(['link']); - for (var k in query) { - if (query[k].href === this._document.styleSheets[i].href) { - - //TODO: Removed the temp insertion of the stylesheet - //because it wasn't the proper way to do it - //need to be handled via XHR with proxy in Cloud Sim - - //Disabling style sheet to reload via inserting in style tag - //var tempCSS = query[k].cloneNode(true); - //tempCSS.setAttribute('data-ninja-template', 'true'); - query[k].setAttribute('disabled', 'true'); - //this.iframe.contentWindow.document.head.appendChild(tempCSS); - //Inserting tag - this._templateDocument.head.insertBefore(tag, query[k]); - } - } - } - } - } - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - - //TODO: Check if this is needed - this._stylesheets = this._document.styleSheets; - - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - - //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"); - NJUtils.makeElementModel(this.stageBG, "Stage", "stage"); - NJUtils.makeElementModel(this.iframe.contentWindow.document.getElementById("Viewport"), "Stage", "stage"); - - // Initialize the 3D properties - this.documentRoot.elementModel.props3D.init(this.documentRoot, true); - this.stageBG.elementModel.props3D.init(this.stageBG, true); - this.iframe.contentWindow.document.getElementById("Viewport").elementModel.props3D.init(this.iframe.contentWindow.document.getElementById("Viewport"), true); - - 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); - - //Setting webGL data - if (this._templateDocument.webgl) { - this.glData = this._templateDocument.webgl; - } - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - - }.bind(this), 1000); - - - - - } - }, - - //////////////////////////////////////////////////////////////////// - - // Handler for user content main reel. Gets called once the main reel of the template - // gets deserialized. - // Setting up the currentSelectedContainer to the document body. - userTemplateDidLoad: { - value: function(){ - //this.application.ninja.currentSelectedContainer = this.documentRoot; - } - }, - - - //////////////////////////////////////////////////////////////////// - _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; - */ - } - } - }, - - - - - - //////////////////////////////////////////////////////////////////// - // - livePreview: { - enumerable: false, - value: function () { - //TODO: Add logic to handle save before preview - this.application.ninja.documentController.handleExecuteSaveAll(null); - //Temp check for webGL Hack - window.open(this.application.ninja.coreIoApi.rootUrl + this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); - //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); - } - }, - //////////////////////////////////////////////////////////////////// - // - save: { - enumerable: false, - value: function () { - //TODO: Add code view logic and also styles for HTML - if (this.currentView === 'design') { - var styles = []; - for (var k in this._document.styleSheets) { - if (this._document.styleSheets[k].ownerNode && this._document.styleSheets[k].ownerNode.getAttribute) { - if (this._document.styleSheets[k].ownerNode.getAttribute('ninjatemplate') === null) { - styles.push(this._document.styleSheets[k]); - } - } - } - //return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: 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 - } - } - }, - //////////////////////////////////////////////////////////////////// - // - saveAll: { - enumerable: false, - value: function () { - //TODO: Add code view logic and also styles for HTML - if (this.currentView === 'design') { - var css = []; - for (var k in this._document.styleSheets) { - if (this._document.styleSheets[k].ownerNode && this._document.styleSheets[k].ownerNode.getAttribute) { - if (this._document.styleSheets[k].ownerNode.getAttribute('ninjatemplate') === null) { - css.push(this._document.styleSheets[k]); - } - } - } - //return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, 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/_toDelete/text-document.js b/js/document/_toDelete/text-document.js deleted file mode 100755 index 2574b67c..00000000 --- a/js/document/_toDelete/text-document.js +++ /dev/null @@ -1,198 +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, - Component = require("montage/ui/component").Component; - -var TextDocument = exports.TextDocument = Montage.create(Component, { - - - //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 }, - _needsSave: { value: false, enumarable: 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; } - }, - - needsSave: { - get: function() { return this._needsSave; }, - set: function(value) { - this._needsSave = 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? - } - } -}); \ No newline at end of file diff --git a/js/document/views/code.js b/js/document/views/code.js index 0a0ff5c1..c8b2a23e 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js @@ -82,12 +82,6 @@ exports.CodeDocumentView = Montage.create(BaseDocumentView, { // var type; // - if(this.activeDocument) { - //need to hide only if another document was open before - //this.application.ninja.documentController._hideCurrentDocument(); - //this.hideOtherDocuments(doc.uuid); - } - // switch(file.extension) { case "css" : type = "css"; -- cgit v1.2.3 From 66632a6e0de0998ff6d36abdaa8c3a546eada0f5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 23:02:46 -0700 Subject: fixing the closing of documents Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index c60a12a2..377c305a 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -99,6 +99,8 @@ exports.HtmlDocument = Montage.create(Component, { //Removing observer, only needed on initial load this._observer.disconnect(); this._observer = null; + //Show the view + this.model.currentView.show(); //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); } -- cgit v1.2.3 From f51718fc39f1311a13cc6c998eb63160dc25218d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 00:31:22 -0700 Subject: cleanup items Signed-off-by: Valerio Virgillito --- js/document/views/design.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index c7313708..dd8754ed 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -62,11 +62,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { get: function() {return this._document;}, set: function(value) {this._document = value;} }, - //////////////////////////////////////////////////////////////////// - // - propertiesPanel: { - value: null - }, //////////////////////////////////////////////////////////////////// // _liveNodeList: { -- cgit v1.2.3 From 5b982abcfe51278062c06fde5fa7e5371f6aef54 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 00:52:49 -0700 Subject: cleanup item Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 377c305a..c60a12a2 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -99,8 +99,6 @@ exports.HtmlDocument = Montage.create(Component, { //Removing observer, only needed on initial load this._observer.disconnect(); this._observer = null; - //Show the view - this.model.currentView.show(); //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); } -- cgit v1.2.3 From e1fe603a7c002073f8ac13623f8cc8dc43efb59d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 10:27:46 -0700 Subject: fixing selection when switching documents Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 5 +++++ js/document/models/html.js | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index 6d9d2e89..886a4ef0 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -62,6 +62,11 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // + selection: { + value: [] + }, + //////////////////////////////////////////////////////////////////// + // fileTemplate: { value: null }, diff --git a/js/document/models/html.js b/js/document/models/html.js index fd42d4de..9f5599a2 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -19,11 +19,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { }, //////////////////////////////////////////////////////////////////// // - selection: { - value: [] - }, - //////////////////////////////////////////////////////////////////// - // selectionContainer: { value: [] }, -- cgit v1.2.3 From 6079ceedb5b340c78ecd02f27dfa734eedccf512 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:39:14 -0700 Subject: making the document bar handle the current document to hide/show itself Signed-off-by: Valerio Virgillito --- js/document/models/text.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/text.js b/js/document/models/text.js index 0135b9ba..6cb61d48 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js @@ -60,7 +60,6 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { } // this.parentContainer.removeChild(this.views.code.textViewContainer); - this.application.ninja.stage.showCodeViewBar(false); this.application.ninja.stage.restoreAllPanels(); this.views.code = null; -- cgit v1.2.3 From 7fcb10270f9e19415f8452c261c2d0c86916a29a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 00:54:02 -0700 Subject: fixed the 3d grid when switching documents and some cleanup Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index c60a12a2..8cc61026 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -117,10 +117,6 @@ exports.HtmlDocument = Montage.create(Component, { // serializeDocument: { value: function () { - // There are not needed for now since we cannot change them - //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; - //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; - // Serialize the current scroll position //TODO: Move these properties to the design view class this.model.scrollLeft = this.application.ninja.stage._scrollLeft; @@ -132,11 +128,6 @@ exports.HtmlDocument = Montage.create(Component, { // Serialize the selection, the container and grid //TODO: Move this property to the design view class this.model.selection = this.application.ninja.selectedElements.slice(0); - this.model.selectionContainer = this.application.ninja.currentSelectedContainer; - this.draw3DGrid = this.application.ninja.appModel.show3dGrid; - - // Serialize the undo - // TODO: Save the montage undo queue // Pause the videos //TODO: Move these to be handled on the show/hide methods in the view @@ -147,27 +138,15 @@ exports.HtmlDocument = Montage.create(Component, { // deserializeDocument: { value: function () { - // There are not needed for now since we cannot change them - //this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; - //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - // Deserialize the current scroll position //TODO: Move these properties to the design view class this.application.ninja.stage._scrollLeft = this.model.scrollLeft; this.application.ninja.stage._scrollTop = this.model.scrollTop; this.application.ninja.stage._userContentLeft = this.model.userContentLeft; this.application.ninja.stage._userContentTop = this.model.userContentTop; - - //TODO: Move this property to the design view class - this.application.ninja.selectedElements = this.model.selection.slice(0); -// this.application.ninja.currentSelectedContainer = this.model.selectionContainer; - this.application.ninja.appModel.show3dGrid = this.draw3DGrid; // Serialize the undo // TODO: Save the montage undo queue - - //TODO: Move this to the document controller - this.model.isActive = true; } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 75fc82ce49d6f1eb05dc950b46292d42b5856005 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 16:19:04 -0700 Subject: fixing some selection container changes and the breadcrumb not drawing initially Signed-off-by: Valerio Virgillito --- js/document/models/base.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index 886a4ef0..76a5e62b 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -62,9 +62,18 @@ exports.BaseDocumentModel = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - selection: { + _selection: { value: [] }, + + selection: { + get: function() { + return this._selection; + }, + set: function(value) { + this._selection = value; + } + }, //////////////////////////////////////////////////////////////////// // fileTemplate: { -- cgit v1.2.3