From 7bdcab084d1991361ba8d37a7435efd229648630 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Tue, 1 May 2012 10:12:40 -0700
Subject: Setting up new architecture for I/O
---
js/document/document-html.js | 102 +++++++++++++++++---------------------
js/document/helpers/url-parser.js | 24 +++++++++
js/document/models/base.js | 34 +++++++++++--
js/document/views/base.js | 53 +++++++++++++++++++-
js/document/views/design.js | 49 +++++++++++++++++-
5 files changed, 200 insertions(+), 62 deletions(-)
create mode 100755 js/document/helpers/url-parser.js
(limited to 'js/document')
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 89717dd6..28406ee8 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -18,25 +18,33 @@ exports.HtmlDocument = Montage.create(Component, {
enumerable: false,
value: false
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
model: {
+ enumerable: false,
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
loadDelegate: {
+ enumerable: false,
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
delegateContext: {
+ enumerable: false,
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
exclusionList: {
+ enumerable: false,
value: ["HTML", "BODY"]
},
-
- // Getters for the model.
- // TODO: Change how these properties are accessed through Ninja
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ //TODO: Remove these setters/getters, should call model directly
name: {
get: function() {
return this.model._name;
@@ -45,7 +53,7 @@ exports.HtmlDocument = Montage.create(Component, {
this.model._name = value;
}
},
-
+ //
isActive: {
get: function() {
return this.model._isActive;
@@ -54,7 +62,7 @@ exports.HtmlDocument = Montage.create(Component, {
this.model._isActive = value;
}
},
-
+ //
needsSave: {
get: function() {
return this.model._needsSave;
@@ -63,82 +71,62 @@ exports.HtmlDocument = Montage.create(Component, {
this.model._needsSave = value;
}
},
-
- // View Properties
- // TODO: Move those into a view object - for now dump it here
- iframe: {
- value: null
- },
-
+ //
uuid: {
get: function() {
return this._uuid;
}
},
-
+ //
currentView: {
value: "design"
},
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
- init: {
- value:function(file, context, callback) {
- this.model = Montage.create(HtmlDocumentModel, {
- file: {
- value: file
- }
- });
-
- this.name = file.name;
-
- // this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
-
-
- this.iframe = this.createView();
-
- //this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
- //this.currentView = "design";
- //
-
- this.delegateContext = context;
- this.loadDelegate = callback;
- }
+ //
+ iframe: { //MOVE TO: base.js in views
+ value: null
},
-
- // Create View
- // Move this into a base view object
- createView: {
+ //
+ createView: { //MOVE TO: design.js in views
value: function() {
var ifr = document.createElement("iframe");
+ //
ifr.id = "document_" + this._uuid;
-
-
ifr.style.border = "none";
ifr.style.background = "#FFF";
ifr.style.height = "100%";
ifr.style.width = "100%";
-
- // TODO: Reable opacity to display only when done loading
-// ifr.style.opacity = 0;
-
+ //
ifr.src = "js/document/templates/montage-web/index.html";
ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true);
-
+ //
return document.getElementById("iframeContainer").appendChild(ifr);
}
},
-
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ //
+ init: {
+ value:function(file, context, callback) {
+ this.model = Montage.create(HtmlDocumentModel, {
+ file: {
+ value: file
+ }
+ });
+ this.name = file.name;
+ this.iframe = this.createView();
+ this.delegateContext = context;
+ this.loadDelegate = callback;
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
handleWebTemplateLoad: {
value: function(event) {
//TODO: Remove, also for prototyping
this.application.ninja.documentController._hackRootFlag = true;
-
- //TODO: Clean up, using for prototyping save
-// this._templateDocument = {};
-// this._templateDocument.html = this.iframe.contentWindow.document;
-// this._templateDocument.body =
-
this._window = this.iframe.contentWindow;
this._document = this.iframe.contentWindow.document;
this.documentRoot = this.iframe.contentWindow.document.body;
diff --git a/js/document/helpers/url-parser.js b/js/document/helpers/url-parser.js
new file mode 100755
index 00000000..878c79e9
--- /dev/null
+++ b/js/document/helpers/url-parser.js
@@ -0,0 +1,24 @@
+/*
+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.UrlParser = Montage.create(Component, {
+ ////////////////////////////////////////////////////////////////////
+ //
+ hasTemplate: {
+ enumerable: false,
+ value: false
+ }
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+});
+////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/js/document/models/base.js b/js/document/models/base.js
index f237e793..f4dbbc0b 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -21,18 +21,26 @@ exports.BaseDocumentModel = Montage.create(Montage, {
file: {
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
_name: {
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
_isActive: {
value: null
},
-
+ ////////////////////////////////////////////////////////////////////
+ //
_needsSave: {
value: null
},
+ ////////////////////////////////////////////////////////////////////
+ //
+ _currentView: {
+ value: null
+ },
////////////////////////////////////////////////////////////////////
//
njdata: {
@@ -42,6 +50,26 @@ exports.BaseDocumentModel = Montage.create(Montage, {
//
views: {
value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ save: {
+ value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ saveAs: {
+ value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ saveAll: {
+ value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ close: {
+ value: null
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
diff --git a/js/document/views/base.js b/js/document/views/base.js
index 50c0a78d..fc380027 100755
--- a/js/document/views/base.js
+++ b/js/document/views/base.js
@@ -7,7 +7,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;
+ Component = require("montage/ui/component").Component,
+ UrlParser = require("js/document/helpers/url-parser").UrlParser;
////////////////////////////////////////////////////////////////////////
//
exports.BaseDocumentView = Montage.create(Component, {
@@ -16,6 +17,56 @@ exports.BaseDocumentView = Montage.create(Component, {
hasTemplate: {
enumerable: false,
value: false
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ parser: {
+ enumerable: false,
+ value: UrlParser
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ _iframe: {
+ enumerable: false,
+ value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ iframe: {
+ get: function() {
+ return this._iframe;
+ },
+ set: function(value) {
+ this._iframe= value;
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ show: {
+ enumerable: false,
+ value: function (callback) {
+ if (this.iframe) {
+ this.iframe.style.display = 'block';
+ } else {
+ console.log('Error: View has no iframe to show!');
+ }
+ //
+ if (callback) callback();
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ hide: {
+ enumerable: false,
+ value: function (callback) {
+ if (this.iframe) {
+ this.iframe.style.display = 'none';
+ } else {
+ console.log('Error: View has no iframe to hide!');
+ }
+ //
+ if (callback) callback();
+ }
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 84871257..ecd2956c 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -7,7 +7,6 @@ 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,
CodeDocumentView = require("js/document/views/code").CodeDocumentView;
////////////////////////////////////////////////////////////////////////
//
@@ -17,6 +16,54 @@ exports.DesignDocumentView = Montage.create(CodeDocumentView, {
hasTemplate: {
enumerable: false,
value: false
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ initiliaze: {
+ enumerable: false,
+ value: function () {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ render: {
+ enumerable: false,
+ value: function () {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ onTemplateLoad: {
+ enumerable: false,
+ value: function () {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ initCss: {
+ enumerable: false,
+ value: function () {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ initWebGl: {
+ enumerable: false,
+ value: function () {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ initMontage: {
+ enumerable: false,
+ value: function () {
+ //
+ }
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
--
cgit v1.2.3
From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Tue, 1 May 2012 15:26:37 -0700
Subject: Preliminary IO to new DOM view
---
js/document/document-html.js | 191 ++++++++++-----------------
js/document/helpers/url-parser.js | 23 +++-
js/document/models/base.js | 55 ++++++--
js/document/models/html.js | 1 -
js/document/templates/montage-web/index.html | 1 -
js/document/views/base.js | 15 +--
js/document/views/design.js | 72 ++++++++--
7 files changed, 198 insertions(+), 160 deletions(-)
(limited to 'js/document')
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 28406ee8..ad82c371 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -7,117 +7,108 @@ 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;
- HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel;
+ Component = require("montage/ui/component").Component,
+ HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel,
+ DesignDocumentView = require("js/document/views/design").DesignDocumentView;
////////////////////////////////////////////////////////////////////////
//
exports.HtmlDocument = Montage.create(Component, {
////////////////////////////////////////////////////////////////////
//
hasTemplate: {
- enumerable: false,
value: false
},
////////////////////////////////////////////////////////////////////
//
model: {
- enumerable: false,
value: null
},
- ////////////////////////////////////////////////////////////////////
- //
- loadDelegate: {
- enumerable: false,
- value: null
- },
- ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
//
- delegateContext: {
- enumerable: false,
- value: null
+ _document: {
+ value: null //TODO: Figure out if this will be needed, probably not
},
////////////////////////////////////////////////////////////////////
//
exclusionList: {
- enumerable: false,
- value: ["HTML", "BODY"]
+ value: [] //TODO: Update to correct list
},
////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- //TODO: Remove these setters/getters, should call model directly
- name: {
- get: function() {
- return this.model._name;
- },
- set: function(value) {
- this.model._name = value;
- }
- },
- //
- isActive: {
- get: function() {
- return this.model._isActive;
- },
- set: function(value) {
- this.model._isActive = value;
- }
- },
- //
- needsSave: {
- get: function() {
- return this.model._needsSave;
- },
- set: function(value) {
- this.model._needsSave = value;
- }
- },
- //
+ //
uuid: {
get: function() {
return this._uuid;
}
},
- //
- currentView: {
- value: "design"
- },
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- //
- iframe: { //MOVE TO: base.js in views
- value: null
- },
- //
- createView: { //MOVE TO: design.js in views
- value: function() {
- var ifr = document.createElement("iframe");
- //
- ifr.id = "document_" + this._uuid;
- ifr.style.border = "none";
- ifr.style.background = "#FFF";
- ifr.style.height = "100%";
- ifr.style.width = "100%";
- //
- ifr.src = "js/document/templates/montage-web/index.html";
- ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true);
- //
- return document.getElementById("iframeContainer").appendChild(ifr);
+ ////////////////////////////////////////////////////////////////////
+ //
+ inExclusion: {
+ value: function(element) {
+ if(this.exclusionList.indexOf(element.nodeName) === -1) {
+ return -1;
+ }
+ return 1;
}
},
- ////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//
init: {
- value:function(file, context, callback) {
- this.model = Montage.create(HtmlDocumentModel, {
- file: {
- value: file
- }
+ value:function(file, context, callback, view) {
+ //Creating instance of HTML Document Model
+ this.model = Montage.create(HtmlDocumentModel,{
+ file: {value: file},
+ views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic
});
- this.name = file.name;
- this.iframe = this.createView();
- this.delegateContext = context;
- this.loadDelegate = callback;
+ //Initiliazing views and hiding
+ if (this.model.views.design.initiliaze(document.getElementById("iframeContainer"))) {
+ //Hiding iFrame, just initiliazing
+ this.model.views.design.hide();
+ } else {
+ //ERROR: Design View not initilized
+ }
+ //
+ if (view === 'design') {
+ //Showing design iFrame
+ this.model.views.design.show();
+ this.model.views.design.iframe.style.opacity = 0;
+ this.model.views.design.content = this.model.file.content;
+ //
+ this.model.views.design.render(function () {
+ //Setting opacity to be viewable after load
+ this.model.views.design.iframe.style.opacity = 1;
+
+
+
+
+ //TODO: Identify and remove usage of '_document'
+ this._document = this.model.views.design.document;
+ //TODO: Check for needed
+ this.documentRoot = this.model.views.design.document.body;
+ //
+ this._liveNodeList = this.documentRoot.getElementsByTagName('*');
+ //
+ document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body");
+
+
+
+
+ this.hack = {callback: callback, context: context};
+
+ setTimeout(function () {
+ //Making callback after view is loaded
+ this.hack.callback.call(this.hack.context, this);
+ }.bind(this), 1000);
+
+
+
+
+
+
+
+ }.bind(this));
+ } else {
+ //TODO: Identify default view (probably code)
+ }
}
},
////////////////////////////////////////////////////////////////////
@@ -137,21 +128,9 @@ exports.HtmlDocument = Montage.create(Component, {
}
}
- // TODO: We don't need this anymore -> need to setup the main container still
- //Adding a handler for the main user document reel to finish loading
-// this.documentRoot.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false);
-
// Live node list of the current loaded document
this._liveNodeList = this.documentRoot.getElementsByTagName('*');
-
- // TODO Move this to the appropriate location
- /*
- var len = this._liveNodeList.length;
-
- for(var i = 0; i < len; i++) {
- NJUtils.makeModelFromElement(this._liveNodeList[i]);
- }
- */
+
setTimeout(function () {
@@ -322,32 +301,6 @@ exports.HtmlDocument = Montage.create(Component, {
}.bind(this), 1000);
}
- },
-
- GetElementFromPoint: {
- value: function(x, y) {
- return this._window.getElement(x,y);
- }
- },
-
- inExclusion: {
- value: function(element) {
- if(this.exclusionList.indexOf(element.nodeName) === -1) {
- return -1;
- }
-
- return 1;
-
- }
- },
-
- // 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;
- }
}
});
////////////////////////////////////////////////////////////////////////
diff --git a/js/document/helpers/url-parser.js b/js/document/helpers/url-parser.js
index 878c79e9..a1a7406a 100755
--- a/js/document/helpers/url-parser.js
+++ b/js/document/helpers/url-parser.js
@@ -14,8 +14,29 @@ exports.UrlParser = Montage.create(Component, {
////////////////////////////////////////////////////////////////////
//
hasTemplate: {
- enumerable: false,
value: false
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ parseStyles: {
+ value: function (styles) {
+ //
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ loadLocalStyleSheet: {
+ value: function (path) {
+ //
+ }
+ }
+ ,
+ ////////////////////////////////////////////////////////////////////
+ //
+ loadExternalStyleSheet: {
+ value: function (path) {
+ //
+ }
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/base.js b/js/document/models/base.js
index f4dbbc0b..3bb69f6b 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -6,36 +6,49 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
////////////////////////////////////////////////////////////////////////
//
-var Montage = require("montage/core/core").Montage;
+var Montage = require("montage/core/core").Montage,
+ Component = require("montage/ui/component").Component;
////////////////////////////////////////////////////////////////////////
//
-exports.BaseDocumentModel = Montage.create(Montage, {
+exports.BaseDocumentModel = Montage.create(Component, {
////////////////////////////////////////////////////////////////////
//
hasTemplate: {
- enumerable: false,
value: false
},
////////////////////////////////////////////////////////////////////
//
- file: {
+ _file: {
value: null
},
- ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
//
- _name: {
- value: null
+ file: {
+ get: function() {return this._file;},
+ set: function(value) {this._file = value;}
},
////////////////////////////////////////////////////////////////////
//
_isActive: {
value: null
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ 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: {
@@ -43,33 +56,49 @@ exports.BaseDocumentModel = Montage.create(Montage, {
},
////////////////////////////////////////////////////////////////////
//
- njdata: {
- value: null
+ currentView: {
+ get: function() {return this._currentView;},
+ set: function(value) {this._currentView = value;}
},
////////////////////////////////////////////////////////////////////
//
views: {
value: null
},
+ ////////////////////////////////////////////////////////////////////
+ //
+ switchViewTo: {
+ value: function () {
+ //
+ }
+ },
////////////////////////////////////////////////////////////////////
//
save: {
- value: null
+ value: function () {
+ //
+ }
},
////////////////////////////////////////////////////////////////////
//
saveAs: {
- value: null
+ value: function () {
+ //
+ }
},
////////////////////////////////////////////////////////////////////
//
saveAll: {
- value: null
+ value: function () {
+ //
+ }
},
////////////////////////////////////////////////////////////////////
//
close: {
- value: null
+ value: function () {
+ //
+ }
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/html.js b/js/document/models/html.js
index ff57454b..f45a0e21 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -14,7 +14,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
////////////////////////////////////////////////////////////////////
//
hasTemplate: {
- enumerable: false,
value: false
}
////////////////////////////////////////////////////////////////////
diff --git a/js/document/templates/montage-web/index.html b/js/document/templates/montage-web/index.html
index caebc8d0..696904b4 100755
--- a/js/document/templates/montage-web/index.html
+++ b/js/document/templates/montage-web/index.html
@@ -32,7 +32,6 @@
-