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 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 10 |
3 files changed, 8 insertions, 39 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 | }, |
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c9e10896..c487fef5 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -162,9 +162,9 @@ exports.IoMediator = Montage.create(Component, { | |||
162 | case 'html': | 162 | case 'html': |
163 | //Getting content from function to properly handle saving assets (as in external if flagged) | 163 | //Getting content from function to properly handle saving assets (as in external if flagged) |
164 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { | 164 | if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { |
165 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); | 165 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, true, libCopyCallback); |
166 | } else { | 166 | } else { |
167 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); | 167 | parsedDoc = this.tmplt.parseNinjaTemplateToHtml(true, doc, false, libCopyCallback); |
168 | } | 168 | } |
169 | break; | 169 | break; |
170 | default: | 170 | default: |
@@ -176,13 +176,17 @@ exports.IoMediator = Montage.create(Component, { | |||
176 | save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); | 176 | save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); |
177 | //Checking for callback | 177 | //Checking for callback |
178 | if (callback) callback(save); | 178 | if (callback) callback(save); |
179 | //Checking for libraries, making callback if specified | ||
180 | if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); | ||
179 | // | 181 | // |
180 | if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); | 182 | return {montageId: parsedDoc.montageId, canvasId: parsedDoc.canvasId}; |
181 | } else { | 183 | } else { |
182 | //Making call to save file | 184 | //Making call to save file |
183 | save = this.fio.saveFile({uri: doc.file.uri, contents: content}); | 185 | save = this.fio.saveFile({uri: doc.file.uri, contents: content}); |
184 | //Checking for callback | 186 | //Checking for callback |
185 | if (callback) callback(save); | 187 | if (callback) callback(save); |
188 | // | ||
189 | return null; | ||
186 | } | 190 | } |
187 | } | 191 | } |
188 | }, | 192 | }, |