diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /js/document/html-document.js | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'js/document/html-document.js')
-rwxr-xr-x | js/document/html-document.js | 538 |
1 files changed, 538 insertions, 0 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js new file mode 100755 index 00000000..9a7755e6 --- /dev/null +++ b/js/document/html-document.js | |||
@@ -0,0 +1,538 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | TextDocument = require("js/document/text-document").TextDocument, | ||
11 | NJUtils = require("js/lib/NJUtils").NJUtils; | ||
12 | //////////////////////////////////////////////////////////////////////// | ||
13 | // | ||
14 | exports.HTMLDocument = Montage.create(TextDocument, { | ||
15 | |||
16 | _selectionExclude: { value: null, enumerable: false }, | ||
17 | _htmlTemplateUrl: { value: "js/document/templates/montage-html/index.html", enumerable: false}, | ||
18 | _iframe: { value: null, enumerable: false }, | ||
19 | _server: { value: null, enumerable: false }, | ||
20 | _templateDocument: { value: null, enumerable: false }, | ||
21 | _selectionModel: { value: [], enumerable: false }, | ||
22 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, | ||
23 | |||
24 | _document: { value: null, enumerable: false }, | ||
25 | _documentRoot: { value: null, enumerable: false }, | ||
26 | _stageBG: { value: null, enumerable: false }, | ||
27 | _window: { value: null, enumerable: false }, | ||
28 | _styles: { value: null, enumerable: false }, | ||
29 | _stylesheets: { value: null, enumerable: false }, | ||
30 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, | ||
31 | _userDocument: { value: null, enumerable: false }, | ||
32 | _htmlSource: {value: "<html></html>", enumerable: false}, | ||
33 | _glData: {value: null, enumerable: false }, | ||
34 | _userComponents: { value: {}, enumarable: false}, | ||
35 | |||
36 | _elementCounter: { value: 1, enumerable: false }, | ||
37 | _snapping : { value: true, enumerable: false }, | ||
38 | _layoutMode: { value: "all", enumerable: false }, | ||
39 | _draw3DGrid: { value: false, writable: true }, | ||
40 | _swfObject: { value: false, enumerable: false }, | ||
41 | |||
42 | _zoomFactor: { value: 100, enumerable: false }, | ||
43 | |||
44 | cssLoadInterval: { value: null, enumerable: false }, | ||
45 | |||
46 | _savedLeftScroll: {value:null}, | ||
47 | _savedTopScroll: {value:null}, | ||
48 | |||
49 | _codeViewDocument:{ | ||
50 | writable: true, | ||
51 | enumerable: true, | ||
52 | value:null | ||
53 | }, | ||
54 | |||
55 | |||
56 | |||
57 | // GETTERS / SETTERS | ||
58 | |||
59 | codeViewDocument:{ | ||
60 | get: function() { return this._codeViewDocument; }, | ||
61 | set: function(value) { this._codeViewDocument = value} | ||
62 | }, | ||
63 | |||
64 | savedLeftScroll:{ | ||
65 | get: function() { return this._savedLeftScroll; }, | ||
66 | set: function(value) { this._savedLeftScroll = value} | ||
67 | }, | ||
68 | |||
69 | savedTopScroll:{ | ||
70 | get: function() { return this._savedTopScroll; }, | ||
71 | set: function(value) { this._savedTopScroll = value} | ||
72 | }, | ||
73 | |||
74 | selectionExclude: { | ||
75 | get: function() { return this._selectionExclude; }, | ||
76 | set: function(value) { this._selectionExclude = value; } | ||
77 | }, | ||
78 | |||
79 | iframe: { | ||
80 | get: function() { return this._iframe; }, | ||
81 | set: function(value) { this._iframe = value; } | ||
82 | }, | ||
83 | |||
84 | server: { | ||
85 | get: function() { return this._server; }, | ||
86 | set: function(value) { this._server = value; } | ||
87 | }, | ||
88 | |||
89 | selectionModel: { | ||
90 | get: function() { return this._selectionModel; }, | ||
91 | set: function(value) { this._selectionModel = value; } | ||
92 | }, | ||
93 | |||
94 | undoModel: { | ||
95 | get: function() { return this._undoModel; }, | ||
96 | set: function(value) { this._undoModel.queue = value.queue; this._undoModel.position = value.position; } | ||
97 | }, | ||
98 | |||
99 | documentRoot: { | ||
100 | get: function() { return this._documentRoot; }, | ||
101 | set: function(value) { this._documentRoot = value; } | ||
102 | }, | ||
103 | |||
104 | stageBG: { | ||
105 | get: function() { return this._stageBG; }, | ||
106 | set: function(value) { this._stageBG = value; } | ||
107 | }, | ||
108 | |||
109 | elementCounter: { | ||
110 | set: function(value) { this._elementCounter = value; }, | ||
111 | get: function() { return this._elementCounter; } | ||
112 | }, | ||
113 | |||
114 | snapping: { | ||
115 | get: function() { return this._snapping; }, | ||
116 | set: function(value) { | ||
117 | if(this._snapping !== value) { | ||
118 | this._snapping = value; | ||
119 | } | ||
120 | } | ||
121 | }, | ||
122 | |||
123 | // TODO SEND THE EVENT --> Redraw the desired layout | ||
124 | layoutMode: { | ||
125 | get: function() { return this._layoutMode; }, | ||
126 | set: function(mode) { this._layoutMode = mode; } | ||
127 | }, | ||
128 | |||
129 | draw3DGrid: { | ||
130 | get: function() { return this._draw3DGrid; }, | ||
131 | set: function(value) { | ||
132 | if(this._draw3DGrid !== value) { | ||
133 | this._draw3DGrid = value; | ||
134 | } | ||
135 | } | ||
136 | }, | ||
137 | |||
138 | userComponents: { | ||
139 | get: function() { | ||
140 | return this._userComponents; | ||
141 | } | ||
142 | }, | ||
143 | // _drawUserComponentsOnOpen:{ | ||
144 | // value:function(){ | ||
145 | // for(var i in this._userComponentSet){ | ||
146 | // console.log(this._userComponentSet[i].control) | ||
147 | // this._userComponentSet[i].control.needsDraw = true; | ||
148 | // } | ||
149 | // } | ||
150 | // }, | ||
151 | |||
152 | glData: { | ||
153 | get: function() | ||
154 | { | ||
155 | var elt = this.iframe; | ||
156 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); | ||
157 | this._glData = null; | ||
158 | if (elt) | ||
159 | { | ||
160 | this._glData = new Array(); | ||
161 | this.collectGLData( elt, this._glData ); | ||
162 | } | ||
163 | |||
164 | return this._glData | ||
165 | }, | ||
166 | |||
167 | set: function(value) | ||
168 | { | ||
169 | var nWorlds = value.length; | ||
170 | for (var i=0; i<nWorlds; i++) | ||
171 | { | ||
172 | var importStr = value[i]; | ||
173 | var startIndex = importStr.indexOf( "id: " ); | ||
174 | if (startIndex >= 0) | ||
175 | { | ||
176 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
177 | if (endIndex > 0) | ||
178 | { | ||
179 | var id = importStr.substring( startIndex+4, endIndex ); | ||
180 | var canvas = this.iframe.contentWindow.document.getElementById( id ); | ||
181 | if (canvas) | ||
182 | { | ||
183 | if (!canvas.elementModel) | ||
184 | { | ||
185 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
186 | } | ||
187 | |||
188 | if (canvas.elementModel) | ||
189 | { | ||
190 | if (canvas.elementModel.shapeModel.GLWorld) | ||
191 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
192 | |||
193 | var world = new GLWorld( canvas ); | ||
194 | canvas.elementModel.shapeModel.GLWorld = world; | ||
195 | world.import( importStr ); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | }, | ||
203 | |||
204 | zoomFactor: { | ||
205 | get: function() { return this._zoomFactor; }, | ||
206 | set: function(value) { this._zoomFactor = value; } | ||
207 | }, | ||
208 | |||
209 | /** | ||
210 | * Add a reference to a component instance to the userComponents hash using the | ||
211 | * element UUID | ||
212 | */ | ||
213 | setComponentInstance: { | ||
214 | value: function(instance, el) { | ||
215 | this.userComponents[el.uuid] = instance; | ||
216 | } | ||
217 | }, | ||
218 | |||
219 | /** | ||
220 | * Returns the component instance obj from the element | ||
221 | */ | ||
222 | getComponentFromElement: { | ||
223 | value: function(el) { | ||
224 | if(el) { | ||
225 | if(el.uuid) return this.userComponents[el.uuid]; | ||
226 | } else { | ||
227 | return null; | ||
228 | } | ||
229 | } | ||
230 | }, | ||
231 | |||
232 | |||
233 | |||