Debian Codegraph @

dijit/form/_FormSelectWidget.js

raw symbols SCIP
1 define([
2 "dojo/_base/array", // array.filter array.forEach array.map array.some
3 "dojo/_base/Deferred",
4 "dojo/aspect", // aspect.after
5 "dojo/data/util/sorter", // util.sorter.createSortFunction
6 "dojo/_base/declare", // declare
7 "dojo/dom", // dom.setSelectable
8 "dojo/dom-class", // domClass.toggle
9 "dojo/_base/kernel", // _scopeName
10 "dojo/_base/lang", // lang.delegate lang.isArray lang.isObject lang.hitch
11 "dojo/query", // query
12 "dojo/when",
13 "dojo/store/util/QueryResults",
14 "./_FormValueWidget"
15 ], function(array, Deferred, aspect, sorter, declare, dom, domClass, kernel, lang, query, when,
16 QueryResults, _FormValueWidget){
17
18 // module:
19 // dijit/form/_FormSelectWidget
20
21 /*=====
22 var __SelectOption = {
23 // value: String
24 // The value of the option. Setting to empty (or missing) will
25 // place a separator at that location
26 // label: String
27 // The label for our option. It can contain html tags.
28 // selected: Boolean
29 // Whether or not we are a selected option
30 // disabled: Boolean
31 // Whether or not this specific option is disabled
32 };
33 =====*/
34
35 var _FormSelectWidget = declare("dijit.form._FormSelectWidget", _FormValueWidget, {
36 // summary:
37 // Extends _FormValueWidget in order to provide "select-specific"
38 // values - i.e., those values that are unique to `<select>` elements.
39 // This also provides the mechanism for reading the elements from
40 // a store, if desired.
41
42 // multiple: [const] Boolean
43 // Whether or not we are multi-valued
44 multiple: false,
45
46 // options: __SelectOption[]
47 // The set of options for our select item. Roughly corresponds to
48 // the html `<option>` tag.
49 options: null,
50
51 // store: dojo/store/api/Store
52 // A store to use for getting our list of options - rather than reading them
53 // from the `<option>` html tags. Should support getIdentity().
54 // For back-compat store can also be a dojo/data/api/Identity.
55 store: null,
56 _setStoreAttr: function(val){
57 if(this._created){ // don't repeat work that will happen in postCreate()
58 this._deprecatedSetStore(val);
59 }
60 },
61
62 // query: object
63 // A query to use when fetching items from our store
64 query: null,
65 _setQueryAttr: function(query){
66 if(this._created){ // don't repeat work that will happen in postCreate()
67 this._deprecatedSetStore(this.store, this.selectedValue, {query: query});
68 }
69 },
70
71 // queryOptions: object
72 // Query options to use when fetching from the store
73 queryOptions: null,
74 _setQueryOptionsAttr: function(queryOptions){
75 if(this._created){ // don't repeat work that will happen in postCreate()
76 this._deprecatedSetStore(this.store, this.selectedValue, {queryOptions: queryOptions});
77 }
78 },
79
80 // labelAttr: String?
81 // The entries in the drop down list come from this attribute in the dojo.store items.
82 // If ``store`` is set, labelAttr must be set too, unless store is an old-style
83 // dojo.data store rather than a new dojo/store.
84 labelAttr: "",
85
86 // onFetch: Function
87 // A callback to do with an onFetch - but before any items are actually
88 // iterated over (i.e. to filter even further what you want to add)
89 onFetch: null,
90
91 // sortByLabel: Boolean
92 // Flag to sort the options returned from a store by the label of
93 // the store.
94 sortByLabel: true,
95
96
97 // loadChildrenOnOpen: Boolean
98 // By default loadChildren is called when the items are fetched from the
99 // store. This property allows delaying loadChildren (and the creation
100 // of the options/menuitems) until the user clicks the button to open the
101 // dropdown.
102 loadChildrenOnOpen: false,
103
104 // onLoadDeferred: [readonly] dojo.Deferred
105 // This is the `dojo.Deferred` returned by setStore().
106 // Calling onLoadDeferred.then() registers your
107 // callback to be called only once, when the prior setStore completes.
108 onLoadDeferred: null,
109
110 getOptions: function(/*anything*/ valueOrIdx){
111 // summary:
112 // Returns a given option (or options).
113 // valueOrIdx:
114 // If passed in as a string, that string is used to look up the option
115 // in the array of options - based on the value property.
116 // (See dijit/form/_FormSelectWidget.__SelectOption).
117 //
118 // If passed in a number, then the option with the given index (0-based)
119 // within this select will be returned.
120 //
121 // If passed in a dijit/form/_FormSelectWidget.__SelectOption, the same option will be
122 // returned if and only if it exists within this select.
123 //
124 // If passed an array, then an array will be returned with each element
125 // in the array being looked up.
126 //
127 // If not passed a value, then all options will be returned
128 //
129 // returns:
130 // The option corresponding with the given value or index.
131 // null is returned if any of the following are true:
132 //
133 // - A string value is passed in which doesn't exist
134 // - An index is passed in which is outside the bounds of the array of options
135 // - A dijit/form/_FormSelectWidget.__SelectOption is passed in which is not a part of the select
136
137 // NOTE: the compare for passing in a dijit/form/_FormSelectWidget.__SelectOption checks
138 // if the value property matches - NOT if the exact option exists
139 // NOTE: if passing in an array, null elements will be placed in the returned
140 // array when a value is not found.
141 var opts = this.options || [];
142
143 if(valueOrIdx == null){
144 return opts; // __SelectOption[]
145 }
146 if(lang.isArrayLike(valueOrIdx)){
147 return array.map(valueOrIdx, function(item){
148 return this.getOptions(item);
149 }, this); // __SelectOption[]
150 }
151 if(lang.isString(valueOrIdx)){
152 valueOrIdx = { value: valueOrIdx };
153 }
154 if(lang.isObject(valueOrIdx)){
155 // We were passed an option - so see if it's in our array (directly),
156 // and if it's not, try and find it by value.
157
158 if(!array.some(opts, function(option, idx){
159 for(var a in valueOrIdx){
160 if(!(a in option) || option[a] != valueOrIdx[a]){ // == and not === so that 100 matches '100'
161 return false;
162 }
163 }
164 valueOrIdx = idx;
165 return true; // stops iteration through opts
166 })){
167 valueOrIdx = -1;
168 }
169 }
170 if(valueOrIdx >= 0 && valueOrIdx < opts.length){
171 return opts[valueOrIdx]; // __SelectOption
172 }
173 return null; // null
174 },
175
176 addOption: function(/*__SelectOption|__SelectOption[]*/ option){
177 // summary:
178 // Adds an option or options to the end of the select. If value
179 // of the option is empty or missing, a separator is created instead.
180 // Passing in an array of options will yield slightly better performance
181 // since the children are only loaded once.
182 array.forEach(lang.isArrayLike(option) ? option : [option], function(i){
183 if(i && lang.isObject(i)){
184 this.options.push(i);
185 }
186 }, this);
187 this._loadChildren();
188 },
189
190 removeOption: function(/*String|__SelectOption|Number|Array*/ valueOrIdx){
191 // summary:
192 // Removes the given option or options. You can remove by string
193 // (in which case the value is removed), number (in which case the
194 // index in the options array is removed), or select option (in
195 // which case, the select option with a matching value is removed).
196 // You can also pass in an array of those values for a slightly
197 // better performance since the children are only loaded once.
198 // For numeric option values, specify {value: number} as the argument.
199 var oldOpts = this.getOptions(lang.isArrayLike(valueOrIdx) ? valueOrIdx : [valueOrIdx]);
200 array.forEach(oldOpts, function(option){
201 // We can get null back in our array - if our option was not found. In
202 // that case, we don't want to blow up...
203 if(option){
204 this.options = array.filter(this.options, function(node){
205 return (node.value !== option.value || node.label !== option.label);
206 });
207 this._removeOptionItem(option);
208 }
209 }, this);
210 this._loadChildren();
211 },
212
213 updateOption: function(/*__SelectOption|__SelectOption[]*/ newOption){
214 // summary:
215 // Updates the values of the given option. The option to update
216 // is matched based on the value of the entered option. Passing
217 // in an array of new options will yield better performance since
218 // the children will only be loaded once.
219 array.forEach(lang.isArrayLike(newOption) ? newOption : [newOption], function(i){
220 var oldOpt = this.getOptions({ value: i.value }), k;
221 if(oldOpt){
222 for(k in i){
223 oldOpt[k] = i[k];
224 }
225 }
226 }, this);
227 this._loadChildren();
228 },
229
230 setStore: function(store, selectedValue, fetchArgs){
231 kernel.deprecated(this.declaredClass+"::setStore(store, selectedValue, fetchArgs) is deprecated. Use set('query', fetchArgs.query), set('queryOptions', fetchArgs.queryOptions), set('store', store), or set('value', selectedValue) instead.", "", "2.0");
232 this._deprecatedSetStore(store, selectedValue, fetchArgs);
233 },
234
235 _deprecatedSetStore: function(store, selectedValue, fetchArgs){
236 // summary:
237 // Sets the store you would like to use with this select widget.
238 // The selected value is the value of the new store to set. This
239 // function returns the original store, in case you want to reuse
240 // it or something.
241 // store: dojo/store/api/Store
242 // The dojo.store you would like to use - it MUST implement getIdentity()
243 // and MAY implement observe().
244 // For backwards-compatibility this can also be a data.data store, in which case
245 // it MUST implement dojo/data/api/Identity,
246 // and MAY implement dojo/data/api/Notification.
247 // selectedValue: anything?
248 // The value that this widget should set itself to *after* the store
249 // has been loaded
250 // fetchArgs: Object?
251 // Hash of parameters to set filter on store, etc.
252 //
253 // - query: new value for Select.query,
254 // - queryOptions: new value for Select.queryOptions,
255 // - onFetch: callback function for each item in data (Deprecated)
256 var oStore = this.store;
257 fetchArgs = fetchArgs || {};
258
259 if(oStore !== store){
260 // Our store has changed, so cancel any listeners on old store (remove for 2.0)
261 var h;
262 while((h = this._notifyConnections.pop())){
263 h.remove();
264 }
265
266 // For backwards-compatibility, accept dojo.data store in addition to dojo.store.store. Remove in 2.0.
267 if(!store.get){
268 lang.mixin(store, {
269 _oldAPI: true,
270 get: function(id){
271 // summary:
272 // Retrieves an object by it's identity. This will trigger a fetchItemByIdentity.
273 // Like dojo.store.DataStore.get() except returns native item.
274 var deferred = new Deferred();
275 this.fetchItemByIdentity({
276 identity: id,
277 onItem: function(object){
278 deferred.resolve(object);
279 },
280 onError: function(error){
281 deferred.reject(error);
282 }
283 });
284 return deferred.promise;
285 },
286 query: function(query, options){
287 // summary:
288 // Queries the store for objects. Like dojo/store/DataStore.query()
289 // except returned Deferred contains array of native items.
290 var deferred = new Deferred(function(){
291 if(fetchHandle.abort){
292 fetchHandle.abort();
293 }
294 });
295 deferred.total = new Deferred();
296 var fetchHandle = this.fetch(lang.mixin({
297 query: query,
298 onBegin: function(count){
299 deferred.total.resolve(count);
300 },
301 onComplete: function(results){
302 deferred.resolve(results);
303 },
304 onError: function(error){
305 deferred.reject(error);
306 }
307 }, options));
308 return new QueryResults(deferred);
309 }
310 });
311
312 if(store.getFeatures()["dojo.data.api.Notification"]){
313 this._notifyConnections = [
314 aspect.after(store, "onNew", lang.hitch(this, "_onNewItem"), true),
315 aspect.after(store, "onDelete", lang.hitch(this, "_onDeleteItem"), true),
316 aspect.after(store, "onSet", lang.hitch(this, "_onSetItem"), true)
317 ];
318 }
319 }
320 this._set("store", store); // Our store has changed, so update our notifications
321 }
322
323 // Remove existing options (if there are any)
324 if(this.options && this.options.length){
325 this.removeOption(this.options);
326 }
327
328 // Cancel listener for updates to old (dojo.data) store
329 if(this._queryRes && this._queryRes.close){
330 this._queryRes.close();
331 }
332
333 // Cancel listener for updates to new (dojo.store) store
334 if(this._observeHandle && this._observeHandle.remove){
335 this._observeHandle.remove();
336 this._observeHandle = null;
337 }
338
339 // If user has specified new query and query options along with this new store, then use them.
340 if(fetchArgs.query){
341 this._set("query", fetchArgs.query);
342 }
343 if(fetchArgs.queryOptions){
344 this._set("queryOptions", fetchArgs.queryOptions);
345 }
346
347 // Add our new options
348 if(store && store.query){
349 this._loadingStore = true;
350 this.onLoadDeferred = new Deferred();
351
352 // Run query
353 // Save result in this._queryRes so we can cancel the listeners we register below
354 this._queryRes = store.query(this.query, this.queryOptions);
355 when(this._queryRes, lang.hitch(this, function(items){
356
357 if(this.sortByLabel && !fetchArgs.sort && items.length){
358 if(store.getValue){
359 // Old dojo.data API to access items, remove for 2.0
360 items.sort(sorter.createSortFunction([
361 {
362 attribute: store.getLabelAttributes(items[0])[0]
363 }
364 ], store));
365 }else{
366 // TODO: remove sortByLabel completely for 2.0? It can be handled by queryOptions: {sort: ... }.
367 var labelAttr = this.labelAttr;
368 items.sort(function(a, b){
369 return a[labelAttr] > b[labelAttr] ? 1 : b[labelAttr] > a[labelAttr] ? -1 : 0;
370 });
371 }
372 }
373
374 if(fetchArgs.onFetch){
375 items = fetchArgs.onFetch.call(this, items, fetchArgs);
376 }
377
378 // TODO: Add these guys as a batch, instead of separately
379 array.forEach(items, function(i){
380 this._addOptionForItem(i);
381 }, this);
382
383 // Register listener for store updates
384 if(this._queryRes.observe){
385 // observe returns yet another handle that needs its own explicit gc
386 this._observeHandle = this._queryRes.observe(lang.hitch(this, function(object, deletedFrom, insertedInto){
387 if(deletedFrom == insertedInto){
388 this._onSetItem(object);
389 }else{
390 if(deletedFrom != -1){
391 this._onDeleteItem(object);
392 }
393 if(insertedInto != -1){
394 this._onNewItem(object);
395 }
396 }
397 }), true);
398 }
399
400 // Set our value (which might be undefined), and then tweak
401 // it to send a change event with the real value
402 this._loadingStore = false;
403 this.set("value", "_pendingValue" in this ? this._pendingValue : selectedValue);
404 delete this._pendingValue;
405
406 if(!this.loadChildrenOnOpen){
407 this._loadChildren();
408 }else{
409 this._pseudoLoadChildren(items);
410 }
411 this.onLoadDeferred.resolve(true);
412 this.onSetStore();
413 }), lang.hitch(this, function(err){
414 console.error('dijit.form.Select: ' + err.toString());
415 this.onLoadDeferred.reject(err);
416 }));
417 }
418 return oStore; // dojo/data/api/Identity
419 },
420
421 _setValueAttr: function(/*anything*/ newValue, /*Boolean?*/ priorityChange){
422 // summary:
423 // set the value of the widget.
424 // If a string is passed, then we set our value from looking it up.
425 if(!this._onChangeActive){
426 priorityChange = null;
427 }
428 if(this._loadingStore){
429 // Our store is loading - so save our value, and we'll set it when
430 // we're done
431 this._pendingValue = newValue;
432 return;
433 }
434 if(newValue == null){
435 return;
436 }
437 if(lang.isArrayLike(newValue)){
438 newValue = array.map(newValue, function(value){
439 return lang.isObject(value) ? value : { value: value };
440 }); // __SelectOption[]
441 }else if(lang.isObject(newValue)){
442 newValue = [newValue];
443 }else{
444 newValue = [
445 { value: newValue }
446 ];
447 }
448 newValue = array.filter(this.getOptions(newValue), function(i){
449 return i && i.value;
450 });
451 var opts = this.getOptions() || [];
452 if(!this.multiple && (!newValue[0] || !newValue[0].value) && !!opts.length){
453 newValue[0] = opts[0];
454 }
455 array.forEach(opts, function(opt){
456 opt.selected = array.some(newValue, function(v){
457 return v.value === opt.value;
458 });
459 });
460 var val = array.map(newValue, function(opt){
461 return opt.value;
462 });
463
464 if(typeof val == "undefined" || typeof val[0] == "undefined"){
465 return;
466 } // not fully initialized yet or a failed value lookup
467 var disp = array.map(newValue, function(opt){
468 return opt.label;
469 });
470 this._setDisplay(this.multiple ? disp : disp[0]);
471 this.inherited(arguments, [ this.multiple ? val : val[0], priorityChange ]);
472 this._updateSelection();
473 },
474
475 _getDisplayedValueAttr: function(){
476 // summary:
477 // returns the displayed value of the widget
478 var ret = array.map([].concat(this.get('selectedOptions')), function(v){
479 if(v && "label" in v){
480 return v.label;
481 }else if(v){
482 return v.value;
483 }
484 return null;
485 }, this);
486 return this.multiple ? ret : ret[0];
487 },
488
489 _setDisplayedValueAttr: function(label){
490 // summary:
491 // Sets the displayed value of the widget
492 this.set('value', this.getOptions(typeof label == "string" ? { label: label } : label));
493 },
494
495 _loadChildren: function(){
496 // summary:
497 // Loads the children represented by this widget's options.
498 // reset the menu to make it populatable on the next click
499 if(this._loadingStore){
500 return;
501 }
502 array.forEach(this._getChildren(), function(child){
503 child.destroyRecursive();
504 });
505 // Add each menu item
506 array.forEach(this.options, this._addOptionItem, this);
507
508 // Update states
509 this._updateSelection();
510 },
511
512 _updateSelection: function(){
513 // summary:
514 // Sets the "selected" class on the item for styling purposes
515 this.focusedChild = null;
516 this._set("value", this._getValueFromOpts());
517 var val = [].concat(this.value);
518 if(val && val[0]){
519 var self = this;
520 array.forEach(this._getChildren(), function(child){
521 var isSelected = array.some(val, function(v){
522 return child.option && (v === child.option.value);
523 });
524 if(isSelected && !self.multiple){
525 self.focusedChild = child;
526 }
527 domClass.toggle(child.domNode, this.baseClass.replace(/\s+|$/g, "SelectedOption "), isSelected);
528 child.domNode.setAttribute("aria-selected", isSelected ? "true" : "false");
529 }, this);
530 }
531 },
532
533 _getValueFromOpts: function(){
534 // summary:
535 // Returns the value of the widget by reading the options for
536 // the selected flag
537 var opts = this.getOptions() || [];
538 if(!this.multiple && opts.length){
539 // Mirror what a select does - choose the first one
540 var opt = array.filter(opts, function(i){
541 return i.selected;
542 })[0];
543 if(opt && opt.value){
544 return opt.value;
545 }else{
546 opts[0].selected = true;
547 return opts[0].value;
548 }
549 }else if(this.multiple){
550 // Set value to be the sum of all selected
551 return array.map(array.filter(opts, function(i){
552 return i.selected;
553 }), function(i){
554 return i.value;
555 }) || [];
556 }
557 return "";
558 },
559
560 // Internal functions to call when we have store notifications come in
561 _onNewItem: function(/*item*/ item, /*Object?*/ parentInfo){
562 if(!parentInfo || !parentInfo.parent){
563 // Only add it if we are top-level
564 this._addOptionForItem(item);
565 }
566 },
567 _onDeleteItem: function(/*item*/ item){
568 var store = this.store;
569 this.removeOption({value: store.getIdentity(item) });
570 },
571 _onSetItem: function(/*item*/ item){
572 this.updateOption(this._getOptionObjForItem(item));
573 },
574
575 _getOptionObjForItem: function(item){
576 // summary:
577 // Returns an option object based off the given item. The "value"
578 // of the option item will be the identity of the item, the "label"
579 // of the option will be the label of the item.
580
581 // remove getLabel() call for 2.0 (it's to support the old dojo.data API)
582 var store = this.store,
583 label = (this.labelAttr && this.labelAttr in item) ? item[this.labelAttr] : store.getLabel(item),
584 value = (label ? store.getIdentity(item) : null);
585 return {value: value, label: label, item: item}; // __SelectOption
586 },
587
588 _addOptionForItem: function(/*item*/ item){
589 // summary:
590 // Creates (and adds) the option for the given item
591 var store = this.store;
592 if(store.isItemLoaded && !store.isItemLoaded(item)){
593 // We are not loaded - so let's load it and add later.
594 // Remove for 2.0 (it's the old dojo.data API)
595 store.loadItem({item: item, onItem: function(i){
596 this._addOptionForItem(i);
597 },
598 scope: this});
599 return;
600 }
601 var newOpt = this._getOptionObjForItem(item);
602 this.addOption(newOpt);
603 },
604
605 constructor: function(params /*===== , srcNodeRef =====*/){
606 // summary:
607 // Create the widget.
608 // params: Object|null
609 // Hash of initialization parameters for widget, including scalar values (like title, duration etc.)
610 // and functions, typically callbacks like onClick.
611 // The hash can contain any of the widget's properties, excluding read-only properties.
612 // srcNodeRef: DOMNode|String?
613 // If a srcNodeRef (DOM node) is specified, replace srcNodeRef with my generated DOM tree
614
615 // Saves off our value, if we have an initial one set so we
616 // can use it if we have a store as well (see startup())
617 this._oValue = (params || {}).value || null;
618 this._notifyConnections = []; // remove for 2.0
619 },
620
621 buildRendering: function(){
622 this.inherited(arguments);
623 dom.setSelectable(this.focusNode, false);
624 },
625
626 _fillContent: function(){
627 // summary:
628 // Loads our options and sets up our dropdown correctly. We
629 // don't want any content, so we don't call any inherit chain
630 // function.
631 if(!this.options){
632 this.options =
633 this.srcNodeRef
634 ? query("> *", this.srcNodeRef).map(
635 function(node){
636 if(node.getAttribute("type") === "separator"){
637 return { value: "", label: "", selected: false, disabled: false };
638 }
639 return {
640 value: (node.getAttribute("data-" + kernel._scopeName + "-value") || node.getAttribute("value")),
641 label: String(node.innerHTML),
642 // FIXME: disabled and selected are not valid on complex markup children (which is why we're
643 // looking for data-dojo-value above. perhaps we should data-dojo-props="" this whole thing?)
644 // decide before 1.6
645 selected: node.getAttribute("selected") || false,
646 disabled: node.getAttribute("disabled") || false
647 };
648 },
649 this)
650 : [];
651 }
652 if(!this.value){
653 this._set("value", this._getValueFromOpts());
654 }else if(this.multiple && typeof this.value == "string"){
655 this._set("value", this.value.split(","));
656 }
657 },
658
659 postCreate: function(){
660 // summary:
661 // sets up our event handling that we need for functioning
662 // as a select
663 this.inherited(arguments);
664
665 // Make our event connections for updating state
666 aspect.after(this, "onChange", lang.hitch(this, "_updateSelection"));
667
668 // Connects in our store, if we have one defined
669 var store = this.store;
670 if(store && (store.getIdentity || store.getFeatures()["dojo.data.api.Identity"])){
671 // Temporarily set our store to null so that it will get set
672 // and connected appropriately
673 this.store = null;
674 this._deprecatedSetStore(store, this._oValue, {query: this.query, queryOptions: this.queryOptions});
675 }
676
677 this._storeInitialized = true;
678 },
679
680 startup: function(){
681 // summary:
682 this._loadChildren();
683 this.inherited(arguments);
684 },
685
686 destroy: function(){
687 // summary:
688 // Clean up our connections
689
690 var h;
691 while((h = this._notifyConnections.pop())){
692 h.remove();
693 }
694
695 // Cancel listener for store updates
696 if(this._queryRes && this._queryRes.close){
697 this._queryRes.close();
698 }
699
700 // Cancel listener for updates to new (dojo.store) store
701 if(this._observeHandle && this._observeHandle.remove){
702 this._observeHandle.remove();
703 this._observeHandle = null;
704 }
705
706 this.inherited(arguments);
707 },
708
709 _addOptionItem: function(/*__SelectOption*/ /*===== option =====*/){
710 // summary:
711 // User-overridable function which, for the given option, adds an
712 // item to the select. If the option doesn't have a value, then a
713 // separator is added in that place. Make sure to store the option
714 // in the created option widget.
715 },
716
717 _removeOptionItem: function(/*__SelectOption*/ /*===== option =====*/){
718 // summary:
719 // User-overridable function which, for the given option, removes
720 // its item from the select.
721 },
722
723 _setDisplay: function(/*String or String[]*/ /*===== newDisplay =====*/){
724 // summary:
725 // Overridable function which will set the display for the
726 // widget. newDisplay is either a string (in the case of
727 // single selects) or array of strings (in the case of multi-selects)
728 },
729
730 _getChildren: function(){
731 // summary:
732 // Overridable function to return the children that this widget contains.
733 return [];
734 },
735
736 _getSelectedOptionsAttr: function(){
737 // summary:
738 // hooks into this.attr to provide a mechanism for getting the
739 // option items for the current value of the widget.
740 return this.getOptions({ selected: true });
741 },
742
743 _pseudoLoadChildren: function(/*item[]*/ /*===== items =====*/){
744 // summary:
745 // a function that will "fake" loading children, if needed, and
746 // if we have set to not load children until the widget opens.
747 // items:
748 // An array of items that will be loaded, when needed
749 },
750
751 onSetStore: function(){
752 // summary:
753 // a function that can be connected to in order to receive a
754 // notification that the store has finished loading and all options
755 // from that store are available
756 }
757 });
758
759 /*=====
760 _FormSelectWidget.__SelectOption = __SelectOption;
761 =====*/
762
763 return _FormSelectWidget;
764 });