diff options
author | Kruti Shah | 2012-06-12 13:09:11 -0700 |
---|---|---|
committer | Kruti Shah | 2012-06-12 13:09:11 -0700 |
commit | d648c842905c7c53e0f89b943982493d2b79f56e (patch) | |
tree | eb5585f92061975215f6d19305a8d1b76262e2fc /js/mediators | |
parent | bedb38e14887b29eae3cdf1c8d435259c920257c (diff) | |
parent | cf3b96822665751dae7a64644db3cb3960733c3d (diff) | |
download | ninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz |
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts:
js/controllers/elements/element-controller.js
js/document/_toDelete/html-document.js
js/panels/Timeline/Layer.reel/Layer.js
Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/mediators')
-rwxr-xr-x | js/mediators/drag-drop-mediator.js | 2 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 129 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 703 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 7 |
4 files changed, 100 insertions, 741 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 67f2a562..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); |
@@ -48,7 +45,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
48 | 45 | ||
49 | document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify); | 46 | document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify); |
50 | 47 | ||
51 | this.application.ninja.documentController.activeDocument.model.needsSave = true; | 48 | this.application.ninja.currentDocument.model.needsSave = true; |
52 | 49 | ||
53 | if(notify || notify === undefined) { | 50 | if(notify || notify === undefined) { |
54 | NJevent("elementAdded", elements); | 51 | NJevent("elementAdded", elements); |
@@ -77,7 +74,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
77 | 74 | ||
78 | document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify); | 75 | document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify); |
79 | 76 | ||
80 | this.application.ninja.documentController.activeDocument.model.needsSave = true; | 77 | this.application.ninja.currentDocument.model.needsSave = true; |
81 | 78 | ||
82 | NJevent("elementsRemoved", elements); | 79 | NJevent("elementsRemoved", elements); |
83 | } | 80 | } |
@@ -92,7 +89,7 @@ exports.ElementMediator = Montage.create(Component, { | |||
92 | 89 | ||
93 | document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); | 90 | document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); |
94 | 91 | ||
95 | this.application.ninja.documentController.activeDocument.model.needsSave = true; | 92 | this.application.ninja.currentDocument.model.needsSave = true; |
96 | 93 | ||
97 | if(notify || notify === undefined) { | 94 | if(notify || notify === undefined) { |
98 | NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); | 95 | NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); |
@@ -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 | }, |
@@ -374,78 +353,76 @@ exports.ElementMediator = Montage.create(Component, { | |||
374 | }, | 353 | }, |
375 | 354 | ||
376 | getStroke: { | 355 | getStroke: { |
377 | value: function(el) { | 356 | value: function(el, strokeProperties) { |
378 | if(!el.elementModel) { | 357 | return el.elementModel.controller["getStroke"](el, strokeProperties); |
379 | NJUtils.makeElementModel(el, "Div", "block"); | ||
380 | } | ||
381 | return el.elementModel.controller["getStroke"](el); | ||
382 | } | 358 | } |
383 | }, | 359 | }, |
384 | 360 | ||
385 | |||
386 | /** | 361 | /** |
387 | Set a property change command for an element or array of elements | 362 | Set stroke/border properties on an element or array of elements |
388 | @param els: Array of elements. Can contain 1 or more elements | 363 | @param els: Array of elements. Can contain 1 or more elements |
389 | @param value: Value to be set. This is the stroke info | 364 | @param value: Value to be set. This is the stroke info |
390 | @param eventType: Change/Changing. Will be passed to the dispatched event | 365 | @param eventType: Change/Changing. Will be passed to the dispatched event |
391 | @param source: String for the source object making the call | 366 | @param source: String for the source object making the call |
392 | @param currentValue *OPTIONAL*: current value array. If not found the current value is calculated | 367 | @param currentValue *OPTIONAL*: current value array. If not found the current value is calculated |
393 | @param stageRedraw: *OPTIONAL*: True. If set to false the stage will not redraw the selection/outline | ||
394 | */ | 368 | */ |
395 | setStroke: { | 369 | setStroke: { |
396 | value: function(els, value, eventType, source, currentValue) { | 370 | value: function(els, value, eventType, source, currentValue) { |
397 | 371 | ||
398 | if(eventType === "Changing") { | 372 | if(eventType !== "Changing") { |
399 | this._setStroke(els, value, isFill, eventType, source); | ||
400 | } else { | ||
401 | // Calculate currentValue if not found for each element | 373 | // Calculate currentValue if not found for each element |
402 | if(!currentValue) { | 374 | if(!currentValue) { |
403 | var that = this; | 375 | var that = this, |
376 | val = value; | ||
404 | currentValue = els.map(function(item) { | 377 | currentValue = els.map(function(item) { |
405 | return that.getStroke(item); | 378 | return that.getStroke(item, val); |
406 | }); | 379 | }); |
407 | } | 380 | } |
381 | document.application.undoManager.add("Set stroke", this.setStroke, this, els, currentValue, eventType, source, value); | ||
382 | } | ||
408 | 383 | ||
409 | var command = Montage.create(Command, { | 384 | for(var i=0, item; item = els[i]; i++) { |
410 | _els: { value: els }, | 385 | item.elementModel.controller["setStroke"](item, (value[i] || value), eventType, source); |
411 | _value: { value: value }, | ||
412 | _previous: { value: currentValue }, | ||
413 | _eventType: { value: eventType}, | ||
414 | _source: { value: "undo-redo"}, | ||
415 | description: { value: "Set Color"}, | ||
416 | receiver: { value: this}, | ||
417 | |||
418 | execute: { | ||
419 | value: function(senderObject) { | ||
420 | if(senderObject) this._source = senderObject; | ||
421 | this.receiver._setStroke(this._els, this._value, this._eventType, this._source); | ||
422 | this._source = "undo-redo"; | ||
423 | return ""; | ||
424 | } | ||
425 | }, | ||
426 | |||
427 | unexecute: { | ||
428 | value: function() { | ||
429 | this.receiver._setStroke(this._els, this._previous, this._eventType, this._source); | ||