aboutsummaryrefslogtreecommitdiff
path: root/js/tools/TagTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/TagTool.js')
-rwxr-xr-xjs/tools/TagTool.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js
index e3f49bbe..d946db72 100755
--- a/js/tools/TagTool.js
+++ b/js/tools/TagTool.js
@@ -90,7 +90,7 @@ exports.TagTool = Montage.create(DrawingTool, {
90 if(selectionManagerModule.selectionManager.isDocument) { 90 if(selectionManagerModule.selectionManager.isDocument) {
91 this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot; 91 this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot;
92 } else { 92 } else {
93 this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0]._element; 93 this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0];
94 } 94 }
95 */ 95 */
96 } 96 }
@@ -104,7 +104,7 @@ exports.TagTool = Montage.create(DrawingTool, {
104 if(selectionManagerModule.selectionManager.isDocument) { 104 if(selectionManagerModule.selectionManager.isDocument) {
105 this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot; 105 this.editSymbol = documentManagerModule.DocumentManager.activeDocument.documentRoot;
106 } else { 106 } else {
107 this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0]._element; 107 this.editSymbol = selectionManagerModule.selectionManager._selectedItems[0];
108 } 108 }
109 109
110 } 110 }
@@ -142,7 +142,7 @@ exports.TagTool = Montage.create(DrawingTool, {
142 element = this.makeElement(~~data.width, ~~data.height, data.planeMat, data.midPt, this.makeTag()); 142 element = this.makeElement(~~data.width, ~~data.height, data.planeMat, data.midPt, this.makeTag());
143 143
144 // Insert Element 144 // Insert Element
145 NJevent("elementAdding", element); 145 this.application.ninja.elementMediator.addElements(element.el, element.data);
146 } else { 146 } else {
147 element = this.makeStaticElement(this.makeTag()); 147 element = this.makeStaticElement(this.makeTag());
148 this._insertStatic(this.editSymbol, element.el, element.style); 148 this._insertStatic(this.editSymbol, element.el, element.style);
@@ -221,22 +221,23 @@ exports.TagTool = Montage.create(DrawingTool, {
221 }, 221 },
222 222
223 makeElement: { 223 makeElement: {
224 value: function(w, h, planeMat, midPt,tag) { 224 value: function(w, h, planeMat, midPt, tag, isShape) {
225 var styles;
226
227 var left = Math.round(midPt[0] - 0.5 * w); 225 var left = Math.round(midPt[0] - 0.5 * w);
228 var top = Math.round(midPt[1] - 0.5 * h); 226 var top = Math.round(midPt[1] - 0.5 * h);
229 227
230 var matStr = DrawingToolBase.getElementMatrix(planeMat, midPt); 228 var styles = {
231
232 styles = {
233 'position': 'absolute', 229 'position': 'absolute',
234 'top' : top + 'px', 230 'top' : top + 'px',
235 'left' : left + 'px', 231 'left' : left + 'px'
236 '-webkit-transform-style' : 'preserve-3d',
237 '-webkit-transform' : matStr
238 }; 232 };
239 233
234 if(!MathUtils.isIdentityMatrix(planeMat)) {
235 styles['-webkit-transform-style'] = 'preserve-3d';
236 styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt);
237 } else if(isShape) {
238 styles['-webkit-transform-style'] = 'preserve-3d';
239 }
240
240 // TODO - for canvas, set both as style and attribute. 241 // TODO - for canvas, set both as style and attribute.
241 // Otherwise, we need to create a separate controller for canvas elements 242 // Otherwise, we need to create a separate controller for canvas elements
242 if(tag.tagName === "CANVAS") { 243 if(tag.tagName === "CANVAS") {
@@ -255,7 +256,7 @@ exports.TagTool = Montage.create(DrawingTool, {
255 value: function(tag) { 256 value: function(tag) {
256 var styles = { 257 var styles = {
257 "-webkit-transform-style": "preserve-3d", 258 "-webkit-transform-style": "preserve-3d",
258 "-webkit-transform": "perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)" 259 "-webkit-transform": "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)"
259 }; 260 };
260 tag.innerHTML = "content"; 261 tag.innerHTML = "content";
261 262