diff options
author | Jon Reid | 2012-06-12 13:32:02 -0700 |
---|---|---|
committer | Jon Reid | 2012-06-12 13:32:02 -0700 |
commit | 8c55dfcb0a669eef0a3bb406b70868078ef09810 (patch) | |
tree | e4d070fe1e67fea38cc0343eda297572da717efa /js/mediators | |
parent | 8e98ce012f55576ddb979969a3a1d834301af0c7 (diff) | |
parent | 7887aafbff794e9c5f918c667e73a8386c38cf02 (diff) | |
download | ninja-8c55dfcb0a669eef0a3bb406b70868078ef09810.tar.gz |
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/drag-drop-mediator.js | 2 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 48 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 10 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 7 |
4 files changed, 22 insertions, 45 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 d166467c..e711e632 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 | }, |
@@ -315,10 +294,10 @@ exports.ElementMediator = Montage.create(Component, { | |||
315 | @param stageRedraw: *OPTIONAL*: True. If set to false the stage will not redraw the selection/outline | 294 | @param stageRedraw: *OPTIONAL*: True. If set to false the stage will not redraw the selection/outline |
316 | */ | 295 | */ |
317 | setColor: { | 296 | setColor: { |
318 | value: function(els, value, isFill, eventType, source, currentValue) { | 297 | value: function(els, value, isFill, eventType, source, currentValue,borderSide) { |
319 | 298 | ||
320 | if(eventType === "Changing") { | 299 | if(eventType === "Changing") { |
321 | this._setColor(els, value, isFill, eventType, source); | 300 | this._setColor(els, value, isFill, eventType, source,borderSide); |
322 | } else { | 301 | } else { |
323 | // Calculate currentValue if not found for each element | 302 | // Calculate currentValue if not found for each element |
324 | if(!currentValue) { | 303 | if(!currentValue) { |
@@ -337,11 +316,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
337 | _source: { value: "undo-redo"}, | 316 | _source: { value: "undo-redo"}, |
338 | description: { value: "Set Color"}, | 317 | description: { value: "Set Color"}, |
339 | receiver: { value: this}, | 318 | receiver: { value: this}, |
319 | _borderSide: { value: borderSide}, | ||
340 | 320 | ||
341 | execute: { | 321 | execute: { |
342 | value: function(senderObject) { | 322 | value: function(senderObject) { |
343 | if(senderObject) this._source = senderObject; | 323 | if(senderObject) this._source = senderObject; |
344 | this.receiver._setColor(this._els, this._value, this._isFill, this._eventType, this._source); | 324 | this.receiver._setColor(this._els, this._value, this._isFill, this._eventType, this._source,this._borderSide); |
345 | this._source = "undo-redo"; | 325 | this._source = "undo-redo"; |
346 | return ""; | 326 | return ""; |
347 | } | 327 | } |
@@ -363,12 +343,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
363 | }, | 343 | }, |
364 | 344 | ||
365 | _setColor: { | 345 | _setColor: { |
366 | value: function(els, value, isFill, eventType, source) { | 346 | value: function(els, value, isFill, eventType, source,borderSide) { |
367 | for(var i=0, item; item = els[i]; i++) { | 347 | for(var i=0, item; item = els[i]; i++) { |
368 | item.elementModel.controller["setColor"](item, value, isFill); | 348 | item.elementModel.controller["setColor"](item, value, isFill,borderSide); |
369 | } | 349 | } |
370 | 350 | ||
371 | NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill}, redraw: null}); | 351 | NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill, "borderSide":borderSide}, redraw: null}); |
372 | } | 352 | } |
373 | }, | 353 | }, |
374 | 354 | ||
@@ -450,18 +430,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
450 | // Routines to get/set 3D properties | 430 | // Routines to get/set 3D properties |
451 | get3DProperty: { | 431 | get3DProperty: { |
452 | value: function(el, prop) { | 432 | value: function(el, prop) { |
453 | if(!el.elementModel) { | ||
454 | NJUtils.makeModelFromElement(el); | ||
455 | } | ||
456 | return el.elementModel.controller["get3DProperty"](el, prop); | 433 | return el.elementModel.controller["get3DProperty"](el, prop); |
457 | } | 434 | } |
458 | }, | 435 | }, |
459 | 436 | ||
460 | get3DProperties: { | 437 | get3DProperties: { |
461 | value: function(el) { | 438 | value: function(el) { |
462 | if(!el.elementModel) { | ||
463 | NJUtils.makeModelFromElement(el); | ||
464 | } | ||
465 | // var mat = this.getMatrix(el); | 439 | // var mat = this.getMatrix(el); |
466 | // var dist = this.getPerspectiveDist(el); | 440 | // var dist = this.getPerspectiveDist(el); |
467 | var mat = el.elementModel.controller["getMatrix"](el); | 441 | var mat = el.elementModel.controller["getMatrix"](el); |
@@ -472,18 +446,12 @@ exports.ElementMediator = Montage.create(Component, { | |||
472 | 446 | ||
473 | getMatrix: { | 447 | getMatrix: { |
474 | value: function(el) { | 448 | value: function(el) { |
475 | if(!el.elementModel) { | ||
476 | NJUtils.makeModelFromElement(el); | ||
477 | } | ||
478 | return el.elementModel.controller["getMatrix"](el); | 449 | return el.elementModel.controller["getMatrix"](el); |
479 | } | 450 | } |
480 | }, | 451 | }, |
481 | 452 | ||
482 | getPerspectiveDist: { | 453 | getPerspectiveDist: { |
483 | value: function(el) { | 454 | value: function(el) { |
484 | if(!el.elementModel) { | ||
485 | NJUtils.makeModelFromElement(el); | ||
486 | } | ||
487 | return el.elementModel.controller["getPerspectiveDist"](el); | 455 | return el.elementModel.controller["getPerspectiveDist"](el); |
488 | } | 456 | } |
489 | }, | 457 | }, |
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, |