diff options
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/drag-drop-mediator.js | 2 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 35 |
2 files changed, 1 insertions, 36 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index 59086ef6..14bdb0eb 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
@@ -115,12 +115,10 @@ exports.DragDropMediator = Montage.create(Component, { | |||
115 | // | 115 | // |
116 | if (e.currentTarget.fileType.indexOf('svg') !== -1) { | 116 | if (e.currentTarget.fileType.indexOf('svg') !== -1) { |
117 | element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper | 117 | element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper |
118 | NJUtils.createModelWithSelection(element, "SVG"); | ||
119 | element.type = 'image/svg+xml'; | 118 | element.type = 'image/svg+xml'; |
120 | element.src = url+'/'+fileName; | 119 | element.src = url+'/'+fileName; |
121 | } else { | 120 | } else { |
122 | element = NJUtils.make('image', null, this.application.ninja.currentDocument); | 121 | element = NJUtils.make('image', null, this.application.ninja.currentDocument); |
123 | NJUtils.createModel(element); | ||
124 | element.src = url+'/'+fileName; | 122 | element.src = url+'/'+fileName; |
125 | } | 123 | } |
126 | //Adding element once it is loaded | 124 | //Adding element once it is loaded |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index da8cbb76..40e94cca 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -29,16 +29,13 @@ exports.ElementMediator = Montage.create(Component, { | |||
29 | if(Array.isArray(elements)) { | 29 | if(Array.isArray(elements)) { |
30 | elements.forEach(function(element) { | 30 | elements.forEach(function(element) { |
31 | ElementController.addElement(element, rules); | 31 | ElementController.addElement(element, rules); |
32 | if(element.elementModel && element.elementModel.props3D) { | ||
33 | element.elementModel.props3D.init(element, false); | 32 | element.elementModel.props3D.init(element, false); |
34 | } | ||
35 | }); | 33 | }); |
36 | } else { | 34 | } else { |
37 | ElementController.addElement(elements, rules); | 35 | ElementController.addElement(elements, rules); |
38 | if(elements.elementModel && elements.elementModel.props3D) { | ||
39 | elements.elementModel.props3D.init(elements, false); | 36 | elements.elementModel.props3D.init(elements, false); |
37 | |||
40 | } | 38 | } |
41 | } | ||
42 | 39 | ||
43 | if(this.addDelegate && typeof (this.addDelegate['onAddElements']) === "function") { | 40 | if(this.addDelegate && typeof (this.addDelegate['onAddElements']) === "function") { |
44 | this.addDelegate['onAddElements'].call(this.addDelegate, elements); | 41 | this.addDelegate['onAddElements'].call(this.addDelegate, elements); |
@@ -102,11 +99,6 @@ exports.ElementMediator = Montage.create(Component, { | |||
102 | 99 | ||
103 | getProperty: { | 100 | getProperty: { |
104 | value: function(el, prop, valueMutator) { | 101 | value: function(el, prop, valueMutator) { |
105 | if(!el.elementModel) { | ||
106 | console.log("Element has no Model -> One should have been created"); | ||
107 | NJUtils.makeElementModel(el, "Div", "block"); | ||
108 | } | ||
109 | |||
110 | if(valueMutator && typeof valueMutator === "function") { | 102 | if(valueMutator && typeof valueMutator === "function") { |
111 | return valueMutator(el.elementModel.controller["getProperty"](el, prop)); | 103 | return valueMutator(el.elementModel.controller["getProperty"](el, prop)); |
112 | } else { | 104 | } else { |
@@ -117,22 +109,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
117 | 109 | ||
118 | getShapeProperty: { | 110 | getShapeProperty: { |
119 | value: function(el, prop) { | 111 | value: function(el, prop) { |
120 | if(!el.elementModel) { | ||
121 | console.log("Element has no Model -> One should have been created"); | ||
122 | NJUtils.makeElementModel(el, "Canvas", "block", true); | ||
123 | } | ||
124 | |||
125 | return el.elementModel.controller["getShapeProperty"](el, prop); | 112 | return el.elementModel.controller["getShapeProperty"](el, prop); |
126 | } | 113 | } |
127 | }, | 114 | }, |
128 | 115 | ||
129 | setShapeProperty: { | 116 | setShapeProperty: { |
130 | value: function(el, prop, value) { | 117 | value: function(el, prop, value) { |
131 | if(!el.elementModel) { | ||
132 | console.log("Element has no Model -> One should have been created"); | ||
133 | NJUtils.makeElementModel(el, "Canvas", "block", true); | ||
134 | } | ||
135 | |||
136 | return el.elementModel.controller["setShapeProperty"](el, prop, value); | 118 | return el.elementModel.controller["setShapeProperty"](el, prop, value); |
137 | } | 119 | } |
138 | }, | 120 | }, |
@@ -297,9 +279,6 @@ exports.ElementMediator = Montage.create(Component, { | |||
297 | // Routines to get/set color | 279 | // Routines to get/set color |
298 | getColor: { | 280 | getColor: { |
299 | value: function(el, isFill, borderSide) { | 281 | value: function(el, isFill, borderSide) { |
300 | if(!el.elementModel) { | ||
301 | NJUtils.makeModelFromElement(el); | ||
302 | } | ||
303 | return el.elementModel.controller["getColor"](el, isFill, borderSide); | 282 | return el.elementModel.controller["getColor"](el, isFill, borderSide); |
304 | } | 283 | } |
305 | }, | 284 | }, |
@@ -450,18 +429,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
450 | // Routines to get/set 3D properties | 429 | // Routines to get/set 3D properties |
451 | get3DProperty: { | 430 | get3DProperty: { |
452 | value: function(el, prop) { | 431 | value: function(el, prop) { |
453 | if(!el.elementModel) { | ||
454 | NJUtils.makeModelFromElement(el); | ||
455 | } | ||
456 | return el.elementModel.controller["get3DProperty"](el, prop); | 432 | return el.elementModel.controller["get3DProperty"](el, prop); |
457 | } | 433 | } |
458 | }, | 434 | }, |
459 | 435 | ||
460 | get3DProperties: { | 436 | get3DProperties: { |
461 | value: function(el) { | 437 | value: function(el) { |
462 | if(!el.elementModel) { | ||
463 | NJUtils.makeModelFromElement(el); | ||
464 | } | ||
465 | // var mat = this.getMatrix(el); | 438 | // var mat = this.getMatrix(el); |
466 | // var dist = this.getPerspectiveDist(el); | 439 | // var dist = this.getPerspectiveDist(el); |
467 | var mat = el.elementModel.controller["getMatrix"](el); | 440 | var mat = el.elementModel.controller["getMatrix"](el); |
@@ -472,18 +445,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
472 | 445 | ||
473 | getMatrix: { | 446 | getMatrix: { |
474 | value: function(el) { | 447 | value: function(el) { |
475 | if(!el.elementModel) { | ||
476 | NJUtils.makeModelFromElement(el); | ||
477 | } | ||
478 | return el.elementModel.controller["getMatrix"](el); | 448 | return el.elementModel.controller["getMatrix"](el); |
479 | } | 449 | } |
480 | }, | 450 | }, |
481 | 451 | ||
482 | getPerspectiveDist: { | 452 | getPerspectiveDist: { |
483 | value: function(el) { | 453 | value: function(el) { |
484 | if(!el.elementModel) { | ||
485 | NJUtils.makeModelFromElement(el); | ||
486 | } | ||
487 | return el.elementModel.controller["getPerspectiveDist"](el); | 454 | return el.elementModel.controller["getPerspectiveDist"](el); |
488 | } | 455 | } |
489 | }, | 456 | }, |