aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/element-controller.js38
-rwxr-xr-xjs/controllers/elements/element-controller.js.orig393
2 files changed, 422 insertions, 9 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index e40a646a..fcb121ee 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -15,13 +15,32 @@ exports.ElementController = Montage.create(Component, {
15 15
16 if (el.getAttribute) el.setAttribute('data-ninja-node', 'true'); 16 if (el.getAttribute) el.setAttribute('data-ninja-node', 'true');
17 17
18 // Updated to use new methods in TimelinePanel. JR.
19 var insertionIndex = this.application.ninja.timeline.getInsertionIndex();
20 if (insertionIndex === false) {
21 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
22 } else {
23 if (insertionIndex === 0) {
24 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
25 } else {
26 var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement;
27 element.parentNode.insertBefore(el, element.nextSibling);
28 }
29 }
30
31 if(styles) {
32 this.application.ninja.stylesController.setElementStyles(el, styles);
33 }
34
35 /*
36 // Old methods. Kept for reference. Delete if not needed. JR.
18 if(this.application.ninja.timeline.currentLayerSelected) { 37 if(this.application.ninja.timeline.currentLayerSelected) {
19 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); 38 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
20 39
21 if(selectedLayerIndex === 0) { 40 if(selectedLayerIndex === 0) {
22 this.application.ninja.currentDocument.model.domContainer.appendChild(el); 41 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
23 } else { 42 } else {
24 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; 43 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.stageElement;
25 element.parentNode.insertBefore(el, element.nextSibling); 44 element.parentNode.insertBefore(el, element.nextSibling);
26 } 45 }
27 } else { 46 } else {
@@ -31,6 +50,7 @@ exports.ElementController = Montage.create(Component, {
31 if(styles) { 50 if(styles) {
32 this.application.ninja.stylesController.setElementStyles(el, styles); 51 this.application.ninja.stylesController.setElementStyles(el, styles);
33 } 52 }
53 */
34 } 54 }
35 }, 55 },
36 56
@@ -83,24 +103,24 @@ exports.ElementController = Montage.create(Component, {
83 103
84 // Return cached value if one exists 104 // Return cached value if one exists
85 if(isFill) { 105 if(isFill) {
86 if(el.elementModel.fill) { 106// if(el.elementModel.fill) {
87 return el.elementModel.fill; 107// return el.elementModel.fill;
88 } 108// }
89 //TODO: Once logic for color and gradient is established, this needs to be revised 109 //TODO: Once logic for color and gradient is established, this needs to be revised
90 color = this.getProperty(el, "background-color"); 110 color = this.getProperty(el, "background-color");
91 image = this.getProperty(el, "background-image"); 111 image = this.getProperty(el, "background-image");
92 } else { 112 } else {
93 // Try getting border color from specific side first 113 // Try getting border color from specific side first
94 if(borderSide) { 114 if(borderSide) {
95 color = this.getProperty(el, "border-" + borderSide + "-color"); 115 color = this.getProperty(el, "border-" + borderSide + "-color",true);
96 image = this.getProperty(el, "border-" + borderSide + "-image"); 116 image = this.getProperty(el, "border-" + borderSide + "-image");
97 } 117 }
98 118
99 // If no color was found, look up the shared border color 119 // If no color was found, look up the shared border color
100 if(!color && !image) { 120 if(!color && !image) {
101 if(el.elementModel.stroke) { 121// if(el.elementModel.stroke) {
102 return el.elementModel.stroke; 122// return el.elementModel.stroke;
103 } 123// }
104 124
105 color = this.getProperty(el, "border-color"); 125 color = this.getProperty(el, "border-color");
106 image = this.getProperty(el, "border-image"); 126 image = this.getProperty(el, "border-image");
@@ -132,7 +152,7 @@ exports.ElementController = Montage.create(Component, {
132 }, 152 },
133 153
134 setColor: { 154 setColor: {
135 value: function(el, color, isFill) { 155 value: function(el, color, isFill,borderSide) {
136 var mode = color.mode; 156 var mode = color.mode;
137 157
138 if(isFill) { 158 if(isFill) {
diff --git a/js/controllers/elements/element-controller.js.orig b/js/controllers/elements/element-controller.js.orig
new file mode 100755
index 00000000..bf631d61
--- /dev/null
+++ b/js/controllers/elements/element-controller.js.orig
@@ -0,0 +1,393 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component,
9 njModule = require("js/lib/NJUtils");
10
11exports.ElementController = Montage.create(Component, {
12
13 addElement: {
14 value: function(el, styles) {
15
16 if (el.getAttribute) el.setAttribute('data-ninja-node', 'true');
17
18 // Updated to use new methods in TimelinePanel. JR.
19 var insertionIndex = this.application.ninja.timeline.getInsertionIndex();
20 if (insertionIndex === false) {
21 this.application.ninja.currentSelectedContainer.appendChild(el);
22 } else {
23 if (insertionIndex === 0) {
24 this.application.ninja.currentSelectedContainer.appendChild(el);
25 } else {
26 var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement;
27 element.parentNode.insertBefore(el, element.nextSibling);
28 }
29 }
30
31 if(styles) {
32 this.application.ninja.stylesController.setElementStyles(el, styles);
33 }
34
35 /*
36 // Old methods. Kept for reference. Delete if not needed. JR.
37 if(this.application.ninja.timeline.currentLayerSelected) {
38 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
39
40 if(selectedLayerIndex === 0) {
41 this.application.ninja.currentSelectedContainer.appendChild(el);
42 } else {
43 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.stageElement;
44 element.parentNode.insertBefore(el, element.nextSibling);
45 }
46 } else {
47 this.application.ninja.currentSelectedContainer.appendChild(el);
48 }
49
50 if(styles) {
51 this.application.ninja.stylesController.setElementStyles(el, styles);
52 }
53 */
54 }
55 },
56
57 // Remove the element from the DOM and clear the GLWord.
58 removeElement: {
59 value: function(el) {
60 if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) {
61 el.elementModel.shapeModel.GLWorld.clearTree();
62 }
63 el.parentNode.removeChild(el);
64 }
65 },
66
67 getProperty: {
68 value: function(el, prop, fallbackOnComputed, isStageElement) {
69 if(el.nodeType !== 3){
70 return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement);
71 }else{
72 return null;
73 }
74 }
75 },
76
77 setProperty: {
78 value: function(el, p, value) {
79 this.application.ninja.stylesController.setElementStyle(el, p, value);
80 }
81 },
82
83 setProperties: {
84 value: function(element, properties) {
85 for(var property in properties) {
86 this.application.ninja.stylesController.setElementStyle(element, property, properties[property]);
87 }
88 }
89 },
90
91 setAttribute: {
92 value: function(el, att, value) {
93 el.setAttribute(att, value);
94 }
95 },
96
97 //--------------------------------------------------------------------------------------------------------
98 // Routines to get/set color properties
99 // borderSide : "top", "right", "bottom", or "left"
100 getColor: {
101 value: function(el, isFill, borderSide) {
102 var colorObj, color, image;
103
104 // Return cached value if one exists
105 if(isFill) {
106// if(el.elementModel.fill) {
107// return el.elementModel.fill;
108// }
109 //TODO: Once logic for color and gradient is established, this needs to be revised
110 color = this.getProperty(el, "backgroun