aboutsummaryrefslogtreecommitdiff
path: root/js/components/combobox.reel
diff options
context:
space:
mode:
authorhwc4872012-02-07 14:42:51 -0800
committerhwc4872012-02-07 14:42:51 -0800
commit6173fe8440152b1e4c63834a6b4dc7573d532339 (patch)
treed23449204ae7f23cb9bab09836d126e90c30484b /js/components/combobox.reel
parent2d4da18a778471b02e188ad668752e331ee76127 (diff)
parentaec849d91e4b697d496b9ede28b5d89cf2283781 (diff)
downloadninja-6173fe8440152b1e4c63834a6b4dc7573d532339.tar.gz
Merge branch 'ToolFixes' of github.com:mqg734/ninja-internal into working
Conflicts: js/helper-classes/RDGE/GLRectangle.js js/helper-classes/RDGE/GLWorld.js js/helper-classes/RDGE/MaterialsLibrary.js
Diffstat (limited to 'js/components/combobox.reel')
-rw-r--r--js/components/combobox.reel/combobox.js63
1 files changed, 60 insertions, 3 deletions
diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js
index a68a7d6b..3200b01c 100644
--- a/js/components/combobox.reel/combobox.js
+++ b/js/components/combobox.reel/combobox.js
@@ -15,7 +15,7 @@ exports.Combobox = Montage.create(Component, {
15 }, 15 },
16 16
17 _wasSetByCode: { 17 _wasSetByCode: {
18 enumerable: false, 18 enumerable: true,
19 value: true 19 value: true
20 }, 20 },
21 21
@@ -27,6 +27,14 @@ exports.Combobox = Montage.create(Component, {
27 value: null 27 value: null
28 }, 28 },
29 29
30 dataField: {
31 value: null
32 },
33
34 dataFunction: {
35 value: null
36 },
37
30 _items: { 38 _items: {
31 value: [] 39 value: []
32 }, 40 },
@@ -71,7 +79,27 @@ exports.Combobox = Montage.create(Component, {
71 e.value = this._value; 79 e.value = this._value;
72 this.dispatchEvent(e); 80 this.dispatchEvent(e);
73 81
74 this._wasSetByCode = false; 82 this._wasSetByCode = true;
83 }
84 }
85 },
86
87 _enabled: {
88 enumerable: false,
89 value: true
90 },
91
92 enabled: {
93 enumerable: true,
94 serializable: true,
95 get: function() {
96 return this._enabled;
97 },
98 set: function(value) {
99 if(value !== this._enabled)
100 {
101 this._enabled = value;
102 this.needsDraw = true;
75 } 103 }
76 } 104 }
77 }, 105 },
@@ -102,7 +130,19 @@ exports.Combobox = Montage.create(Component, {
102 { 130 {
103 var current = items[i]; 131 var current = items[i];
104 optionItem = document.createElement("option"); 132 optionItem = document.createElement("option");
105 optionItem.value = current; 133 if(this.dataFunction)
134 {
135 optionItem.value = this.dataFunction(current);
136 }
137 else if(this.dataField)
138 {
139 optionItem.value = current[this.dataField];
140 }
141 else
142 {
143 optionItem.value = current;
144 }
145
106 if(this.labelFunction) 146 if(this.labelFunction)
107 { 147 {
108 optionItem.innerText = this.labelFunction(current); 148 optionItem.innerText = this.labelFunction(current);
@@ -117,6 +157,7 @@ exports.Combobox = Montage.create(Component, {
117 } 157 }
118 this.element.appendChild(optionItem); 158 this.element.appendChild(optionItem);
119 } 159 }
160 this.element.disabled = !this._enabled;
120 } 161 }
121 } 162 }
122 }, 163 },
@@ -133,6 +174,22 @@ exports.Combobox = Montage.create(Component, {
133 174
134 prepareForDraw: { 175 prepareForDraw: {
135 value: function() { 176 value: function() {
177 if( (this._value === null) && this._items.length )
178 {
179 var current = this._items[0];
180 if(this.dataFunction)
181 {
182 this.value = this.dataFunction(current);
183 }
184 else if(this.dataField)
185 {
186 this.value = current[this.dataField];
187 }
188 else
189 {
190 this.value = current;
191 }
192 }
136 this.element.addEventListener("change", this, false); 193 this.element.addEventListener("change", this, false);
137 } 194 }
138 } 195 }