aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/select-input.reel/select-input.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/select-input.reel/select-input.js')
-rw-r--r--node_modules/montage/ui/select-input.reel/select-input.js53
1 files changed, 24 insertions, 29 deletions
diff --git a/node_modules/montage/ui/select-input.reel/select-input.js b/node_modules/montage/ui/select-input.reel/select-input.js
index 76de1a5a..09a064d4 100644
--- a/node_modules/montage/ui/select-input.reel/select-input.js
+++ b/node_modules/montage/ui/select-input.reel/select-input.js
@@ -7,14 +7,8 @@
7var Montage = require("montage").Montage, 7var Montage = require("montage").Montage,
8 Component = require("ui/component").Component, 8 Component = require("ui/component").Component,
9 ArrayController = require("ui/controller/array-controller").ArrayController, 9 ArrayController = require("ui/controller/array-controller").ArrayController,
10 NativeControl = require("ui/native-control").NativeControl; 10 NativeControl = require("ui/native-control").NativeControl,
11 11 PressComposer = require("ui/composer/press-composer").PressComposer;
12var STRING_CLASS = '[object String]';
13var _toString = Object.prototype.toString;
14
15var isString = function(object) {
16 return _toString.call(object) === STRING_CLASS;
17};
18 12
19var SelectInput = exports.SelectInput = Montage.create(NativeControl, { 13var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
20 14
@@ -154,9 +148,6 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
154 148
155 deserializedFromTemplate: { 149 deserializedFromTemplate: {
156 value: function() { 150 value: function() {
157 // @todo - Need a better way to do this.
158 var fn = Object.getPrototypeOf(SelectInput).deserializedFromTemplate;
159 fn.call(this);
160 151
161 /* 152 /*
162 1) If <option> is provided in the markup but contentController is not, 153 1) If <option> is provided in the markup but contentController is not,
@@ -168,18 +159,6 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
168 } 159 }
169 }, 160 },
170 161
171 /**
172 Description TODO
173 @function
174 */
175 prepareForDraw: {
176 enumerable: false,
177 value: function() {
178 var el = this.element;
179 el.addEventListener("focus", this);
180 el.addEventListener('change', this);
181 }
182 },
183 162
184 _removeAll: { 163 _removeAll: {
185 value: function(elem) { 164 value: function(elem) {
@@ -192,12 +171,11 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
192 171
193 _refreshOptions: { 172 _refreshOptions: {
194 value: function() { 173 value: function() {
195 console.log('==== refreshOptions ====');
196 var arr = this.content||[], len = arr.length, i, option; 174 var arr = this.content||[], len = arr.length, i, option;
197 var text, value; 175 var text, value;
198 for(i=0; i< len; i++) { 176 for(i=0; i< len; i++) {
199 option = document.createElement('option'); 177 option = document.createElement('option');
200 if(isString(arr[i])) { 178 if(String.isString(arr[i])) {
201 text = value = arr[i]; 179 text = value = arr[i];
202 } else { 180 } else {
203 text = arr[i][this.textPropertyPath || 'text']; 181 text = arr[i][this.textPropertyPath || 'text'];
@@ -221,6 +199,26 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
221 Description TODO 199 Description TODO
222 @function 200 @function
223 */ 201 */
202 prepareForDraw: {
203 enumerable: false,
204 value: function() {
205 this.element.addEventListener("focus", this);
206 this.element.addEventListener('change', this);
207 }
208 },
209
210 prepareForActivationEvents: {
211 value: function() {
212 // add pressComposer to handle the claimPointer related work
213 var pressComposer = PressComposer.create();
214 this.addComposer(pressComposer);
215 }
216 },
217
218 /**
219 Description TODO
220 @function
221 */
224 draw: { 222 draw: {
225 enumerable: false, 223 enumerable: false,
226 value: function() { 224 value: function() {
@@ -242,7 +240,7 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
242 var arr = this.content||[], len = arr.length, i; 240 var arr = this.content||[], len = arr.length, i;
243 var text, value; 241 var text, value;
244 for(i=0; i< len; i++) { 242 for(i=0; i< len; i++) {
245 if(isString(arr[i])) { 243 if(String.isString(arr[i])) {
246 value = arr[i]; 244 value = arr[i];
247 } else { 245 } else {
248 value = arr[i][this.valuePropertyPath || 'value']; 246 value = arr[i][this.valuePropertyPath || 'value'];
@@ -288,9 +286,6 @@ var SelectInput = exports.SelectInput = Montage.create(NativeControl, {
288 handleChange: { 286 handleChange: {
289 value: function(e) { 287 value: function(e) {
290 // get selected values and set it on the contentController 288 // get selected values and set it on the contentController
291 console.log('selection changed');
292 console.log(this.element.selectedOptions);
293
294 //var selectedOptions = this.element.selectedOptions || []; 289 //var selectedOptions = this.element.selectedOptions || [];
295 // select.selectedOptions does not work on Chrome ! 290 // select.selectedOptions does not work on Chrome !
296 291