aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/controllers/document.js45
-rwxr-xr-xjs/document/document-html.js322
-rwxr-xr-xjs/document/document-text.js (renamed from js/document/controllers/base-controller.js)14
-rwxr-xr-xjs/document/html-document.js7
-rwxr-xr-xjs/document/mediators/io.js (renamed from js/document/mediators/base-mediator.js)14
-rwxr-xr-xjs/document/mediators/template.js (renamed from js/document/models/base-model.js)14
-rwxr-xr-xjs/document/models/base.js42
-rwxr-xr-xjs/document/models/html.js24
-rwxr-xr-xjs/document/models/text.js24
-rwxr-xr-xjs/document/templates/montage-web/default_html.css19
-rwxr-xr-xjs/document/templates/montage-web/index.html49
-rw-r--r--js/document/templates/montage-web/main.reel/main.js49
-rwxr-xr-xjs/document/templates/montage-web/package.json8
-rwxr-xr-xjs/document/views/base.js (renamed from js/document/views/base-view.js)14
-rwxr-xr-xjs/document/views/code.js25
-rwxr-xr-xjs/document/views/design.js25
16 files changed, 647 insertions, 48 deletions
diff --git a/js/document/controllers/document.js b/js/document/controllers/document.js
new file mode 100755
index 00000000..feba3e0e
--- /dev/null
+++ b/js/document/controllers/document.js
@@ -0,0 +1,45 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7////////////////////////////////////////////////////////////////////////
8//
9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component;
11////////////////////////////////////////////////////////////////////////
12//
13exports.DocumentController = Montage.create(Component, {
14 ////////////////////////////////////////////////////////////////////
15 //
16 hasTemplate: {
17 enumerable: false,
18 value: false
19 },
20 ////////////////////////////////////////////////////////////////////
21 //
22 save: {
23 value: function () {
24 //
25 }
26 },
27 ////////////////////////////////////////////////////////////////////
28 //
29 saveAs: {
30 value: function () {
31 //
32 }
33 },
34 ////////////////////////////////////////////////////////////////////
35 //
36 close: {
37 value: function () {
38 //
39 }
40 }
41 ////////////////////////////////////////////////////////////////////
42 ////////////////////////////////////////////////////////////////////
43});
44////////////////////////////////////////////////////////////////////////
45//////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/js/document/document-html.js b/js/document/document-html.js
new file mode 100755
index 00000000..8cb88516
--- /dev/null
+++ b/js/document/document-html.js
@@ -0,0 +1,322 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7////////////////////////////////////////////////////////////////////////
8//
9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component;
11 HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel;
12////////////////////////////////////////////////////////////////////////
13//
14exports.HtmlDocument = Montage.create(Component, {
15 ////////////////////////////////////////////////////////////////////
16 //
17 hasTemplate: {
18 enumerable: false,
19 value: false
20 },
21
22 model: {
23 value: null
24 },
25
26 loadDelegate: {
27 value: null
28 },
29
30 delegateContext: {
31 value: null
32 },
33
34 // Getters for the model.
35 // TODO: Change how these properties are accessed through Ninja
36 name: {
37 get: function() {
38 return this.model._name;
39 },
40 set: function(value) {
41 this.model._name = value;
42 }
43 },
44
45 // View Properties
46 // TODO: Move those into a view object - for now dump it here
47 iframe: {
48 value: null
49 },
50
51 uuid: {
52 get: function() {
53 return this._uuid;
54 }
55 },
56 ////////////////////////////////////////////////////////////////////
57 ////////////////////////////////////////////////////////////////////
58 init: {
59 value:function(file, context, callback) {
60 this.model = Montage.create(HtmlDocumentModel, {
61 file: {
62 value: file
63 }
64 });
65
66 this.name = file.name;
67
68 // this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
69
70
71 this.iframe = this.createView();
72
73 //this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
74 //this.currentView = "design";
75 //
76
77 this.delegateContext = context;
78 this.loadDelegate = callback;
79 }
80 },
81
82 // Create View
83 // Move this into a base view object
84 createView: {
85 value: function() {
86 var ifr = document.createElement("iframe");
87 ifr.id = "document_" + this._uuid;
88
89
90 ifr.style.border = "none";
91 ifr.style.background = "#FFF";
92 ifr.style.height = "100%";
93 ifr.style.width = "100%";
94
95 // TODO: Reable opacity to display only when done loading
96// ifr.style.opacity = 0;
97
98 ifr.src = "js/document/templates/montage-web/index.html";
99 ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true);
100
101 return document.getElementById("iframeContainer").appendChild(ifr);
102 }
103 },
104
105 handleWebTemplateLoad: {
106 value: function(event) {
107 //TODO: Remove, also for prototyping
108 this.application.ninja.documentController._hackRootFlag = true;
109
110
111 //TODO: Clean up, using for prototyping save
112// this._templateDocument = {};
113// this._templateDocument.html = this.iframe.contentWindow.document;
114// this._templateDocument.body =
115
116 this._window = this.iframe.contentWindow;
117 this._document = this.iframe.contentWindow.document;
118 this.documentRoot = this.iframe.contentWindow.document.body;
119
120 for (var k in this._document.styleSheets) {
121 if (this._document.styleSheets[k].ownerNode && this._document.styleSheets[k].ownerNode.setAttribute) {
122 this._document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true');
123 }
124 }
125
126 // TODO: We don't need this anymore -> need to setup the main container still
127 //Adding a handler for the main user document reel to finish loading
128// this.documentRoot.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false);
129
130 // Live node list of the current loaded document
131 this._liveNodeList = this.documentRoot.getElementsByTagName('*');
132
133 // TODO Move this to the appropriate location
134 /*
135 var len = this._liveNodeList.length;
136
137 for(var i = 0; i < len; i++) {
138 NJUtils.makeModelFromElement(this._liveNodeList[i]);
139 }
140 */
141
142 setTimeout(function () {
143
144 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
145 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
146 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
147 if(this._document.styleSheets.length) {
148 //Checking all styleSheets in document
149 for (var i in this._document.styleSheets) {
150 //If rules are null, assuming cross-origin issue
151 if(this._document.styleSheets[i].rules === null) {
152 //TODO: Revisit URLs and URI creation logic, very hack right now
153 var fileUri, cssUrl, cssData, query, prefixUrl, fileCouldDirUrl, docRootUrl;
154 //
155 docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
156 //TODO: Parse out relative URLs and map them to absolute
157 if (this._document.styleSheets[i].href.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) {
158 //
159 cssUrl = this._document.styleSheets[i].href.split(this.application.ninja.coreIoApi.rootUrl)[1];
160<