aboutsummaryrefslogtreecommitdiff
path: root/js/tools/TagTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/TagTool.js')
-rwxr-xr-xjs/tools/TagTool.js129
1 files changed, 1 insertions, 128 deletions
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js
index 6c999df9..5e9c792b 100755
--- a/js/tools/TagTool.js
+++ b/js/tools/TagTool.js
@@ -89,139 +89,12 @@ exports.TagTool = Montage.create(DrawingTool, {
89 // Create the model 89 // Create the model
90 document.application.njUtils.createModel(element); 90 document.application.njUtils.createModel(element);
91 91
92
93 // Create the styles 92 // Create the styles
94 styles = this.makeStylesFromDraw(drawData); 93 styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData);
95 if(element.nodeName === "CANVAS") {
96 element.width = parseInt(styles.width);
97 element.height = parseInt(styles.height);
98 delete styles['width'];
99 delete styles['height'];
100 }
101 94
102 // Add the element and styles 95 // Add the element and styles
103 this.application.ninja.elementMediator.addElements(element, styles); 96 this.application.ninja.elementMediator.addElements(element, styles);
104 } 97 }
105 },
106
107 makeStylesFromDraw: {
108 value: function(drawData) {
109 var styles = {};
110
111 styles['position'] = "absolute";
112 styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * ~~drawData.width)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px';
113 styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * ~~drawData.height)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px';
114 styles['width'] = ~~drawData.width + 'px';
115 styles['height'] = ~~drawData.height + 'px';
116
117 if(!MathUtils.isIdentityMatrix(drawData.planeMat)) {
118 styles['-webkit-transform-style'] = 'preserve-3d';
119 styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(drawData.planeMat, drawData.midPt);
120 }
121
122 return styles;
123 }
124 },
125
126 makeTag: {
127 value: function() {
128 var selectedTag, newTag;
129
130 selectedTag = this.options.selectedElement;
131
132 if(selectedTag === "div") {
133 newTag = NJUtils.makeNJElement("div", "div", "block");
134 } else if(selectedTag === "image") {
135 newTag = NJUtils.makeNJElement("image", "image", "image");
136 } else if(selectedTag === "video") {
137 newTag = NJUtils.makeNJElement("video", "video", "video", {
138 innerHTML: "Your browser does not support the VIDEO element."
139 });
140 } else if(selectedTag === "canvas") {
141 newTag = NJUtils.makeNJElement("canvas", "canvas", "canvas");
142 } else if(selectedTag === "custom") {
143 newTag = NJUtils.makeNJElement(this.options.customName.value, this.options.customName.value, "block");
144 }
145 /* SWF Tag tool - Not used for now. Will revisit this at a later time.
146 else if(selectedTag === "flashTool") {
147 // Generate the swfobject script tag if not found in the user document
148// documentControllerModule.DocumentController.SetSWFObjectScript();
149
150 newTag = NJUtils.makeNJElement("object", "Object", "block", {
151 classId: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
152 });
153
154 var param = NJUtils.makeNJElement("param", "Object", "block", {
155 name: "movie",
156 value: ""
157 });
158
159 var param2 = NJUtils.makeNJElement("param", "Object","block", {
160 name: "wmode",
161 value: "transparent"
162 });
163
164 var param3 = NJUtils.makeNJElement("param", "Object","block", {
165 name: "play",
166 value: "false"
167 });
168
169
170 newTag.appendChild(param);
171 newTag.appendChild(param2);
172 newTag.appendChild(param3);
173 // TODO Alternative Content
174
175 }
176 */
177 else {
178 console.log("Invalid Tool is selected.");
179 }
180
181 try {
182// newTag.className = this.options.classField.value;
183 // TODO: Fix this one
184
185 }
186
187 catch(err) {
188 console.log("Could not set Tag ID/Class " + err.description);
189 }
190
191 return newTag;
192 }
193 },
194
195 makeElement: {
196 value: function(w, h, planeMat, midPt, tag, isShape) {
197 var left = (Math.round(midPt[0] - 0.5 * w)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px';
198 var top = (Math.round(midPt[1] - 0.5 * h)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px';
199
200 var styles = {
201 'position': 'absolute',
202 'top' : top,
203 'left' : left
204 };
205
206 if(!MathUtils.isIdentityMatrix(planeMat)) {
207 styles['-webkit-transform-style'] = 'preserve-3d';
208 styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt);
209 } else if(isShape) {
210 styles['-webkit-transform-style'] = 'preserve-3d';
211 }
212
213 // TODO - for canvas, set both as style and attribute.
214 // Otherwise, we need to create a separate controller for canvas elements
215 if(tag.tagName === "CANVAS") {
216 tag.width = w;
217 tag.height = h;
218 } else {
219 styles['width'] = w + 'px';
220 styles['height'] = h + 'px';
221 }
222
223 return {el: tag, data:styles};
224 }
225 } 98 }
226}); 99});
227 100