Debian Codegraph @

dojox/mobile/_PickerBase.js

raw symbols SCIP
1 define([
2 "dojo/_base/array",
3 "dojo/_base/declare",
4 "dijit/_Contained",
5 "dijit/_Container",
6 "dijit/_WidgetBase",
7 "dojo/has",
8 "dojo/has!dojo-bidi?dojox/mobile/bidi/_PickerBase"
9 ], function(array, declare, Contained, Container, WidgetBase, has, _BidiPickerBase){
10
11 // module:
12 // dojox/mobile/_PickerBase
13
14 var _PickerBase = declare(has("dojo-bidi") ? "dojox.mobile.NonBidi_PickerBase" : "dojox.mobile._PickerBase", [WidgetBase, Container, Contained],{
15 // summary:
16 // A base class for picker classes (e.g. SpinWheel, ValuePicker).
17
18 /*=====
19 // values: Array
20 // An array of slot values.
21 // Warning: Do not use this property directly, make sure to call set() or get() methods.
22 values: "",
23 =====*/
24
25 /*=====
26 // colors: Array
27 // An array of slot colors.
28 // Warning: Do not use this property directly, make sure to call set() or get() methods.
29 colors: "",
30 =====*/
31
32 /* internal properties */
33
34 // slotClasses: [protected] Array
35 // An array of slot classes. This property is intended to be used
36 // when you create a subclass of this widget that has specific slots.
37 slotClasses: [],
38
39 // slotProps: [protected] Array
40 // An array of property objects for each slot class specified in
41 // slotClasses. This property is intended to be used when you
42 // create a subclass of this widget that has specific slots.
43 slotProps: [],
44
45 // slotOrder: [protected] Array
46 // An array of index of slotClasses and slotProps.
47 // If there are three slots and slotOrder=[2,1,0], the slots are
48 // displayed in reversed order. This property is intended to be used
49 // when you create a subclass of this widget that has specific slots.
50 slotOrder: [],
51
52 buildRendering: function(){
53 this.inherited(arguments);
54 this.slots = [];
55 for(var i = 0; i < this.slotClasses.length; i++){
56 var idx = this.slotOrder.length ? this.slotOrder[i] : i;
57 var slot = new this.slotClasses[idx](this.slotProps[idx]);
58 this.addChild(slot);
59 this.slots[idx] = slot;
60 }
61 },
62
63 startup: function(){
64 if(this._started){ return; }
65 this._duringStartup = true;
66 this.inherited(arguments);
67 this.reset();
68 delete this._duringStartup;
69 },
70
71 getSlots: function(){
72 // summary:
73 // Returns an array of child slot widgets.
74 return this.slots.length ? this.slots :
75 array.filter(this.getChildren(), function(c){
76 return c.declaredClass.indexOf("Slot") !== -1;
77 });
78 },
79
80 _getValuesAttr: function(){
81 // summary:
82 // Returns an array of slot values.
83 // tags:
84 // private
85 return array.map(this.getSlots(), function(w){
86 return w.get("value");
87 });
88 },
89
90 _setValuesAttr: function(/*Array*/a){
91 // summary:
92 // Sets the slot values.
93 // tags:
94 // private
95 array.forEach(this.getSlots(), function(w, i){
96 w.set("value", a[i]);
97 });
98 },
99
100 _setColorsAttr: function(/*Array*/a){
101 // summary:
102 // Sets the slot colors.
103 // tags:
104 // private
105 array.forEach(this.getSlots(), function(w, i){
106 w.setColor && w.setColor(a[i]);
107 });
108 },
109
110 reset: function(){
111 // summary:
112 // Resets the picker to show the initial values.
113 array.forEach(this.getSlots(), function(w){
114 w.setInitialValue();
115 });
116 }
117 });
118 return has("dojo-bidi") ? declare("dojox.mobile._PickerBase", [_PickerBase, _BidiPickerBase]) : _PickerBase;
119 });