source: Dev/trunk/src/client/dojox/mobile/RoundRectList.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 4.5 KB
Line 
1define([
2        "dojo/_base/array",
3        "dojo/_base/declare",
4        "dojo/_base/event",
5        "dojo/_base/lang",
6        "dojo/_base/window",
7        "dojo/dom-construct",
8        "dojo/dom-attr",
9        "dijit/_Contained",
10        "dijit/_Container",
11        "dijit/_WidgetBase"
12], function(array, declare, event, lang, win, domConstruct, domAttr, Contained, Container, WidgetBase){
13
14        // module:
15        //              dojox/mobile/RoundRectList
16
17        return declare("dojox.mobile.RoundRectList", [WidgetBase, Container, Contained], {
18                // summary:
19                //              A rounded rectangle list.
20                // description:
21                //              RoundRectList is a rounded rectangle list, which can be used to
22                //              display a group of items. Each item must be a dojox/mobile/ListItem.
23
24                // transition: String
25                //              The default animated transition effect for child items.
26                transition: "slide",
27
28                // iconBase: String
29                //              The default icon path for child items.
30                iconBase: "",
31
32                // iconPos: String
33                //              The default icon position for child items.
34                iconPos: "",
35
36                // select: String
37                //              Selection mode of the list. The check mark is shown for the
38                //              selected list item(s). The value can be "single", "multiple", or "".
39                //              If "single", there can be only one selected item at a time.
40                //              If "multiple", there can be multiple selected items at a time.
41                //              If "", the check mark is not shown.
42                select: "",
43
44                // stateful: Boolean
45                //              If true, the last selected item remains highlighted.
46                stateful: false,
47
48                // syncWithViews: [const] Boolean
49                //              If true, this widget listens to view transition events to be
50                //              synchronized with view's visibility.
51                //              Note that changing the value of the property after the widget
52                //              creation has no effect.
53                syncWithViews: false,
54
55                // editable: [const] Boolean
56                //              If true, the list can be reordered.
57                //              Note that changing the value of the property after the widget
58                //              creation has no effect.
59                editable: false,
60
61                // tag: String
62                //              A name of html tag to create as domNode.
63                tag: "ul",
64
65                /* internal properties */
66                // editableMixinClass: String
67                //              The name of the mixin class.
68                editableMixinClass: "dojox/mobile/_EditableListMixin",
69               
70                // baseClass: String
71                //              The name of the CSS class of this widget.
72                baseClass: "mblRoundRectList",
73               
74                // filterBoxClass: String
75                //              The name of the CSS class added to the DOM node inside which is placed the
76                //              dojox/mobile/SearchBox created when mixing dojox/mobile/FilteredListMixin.
77                //              The default value is "mblFilteredRoundRectListSearchBox". 
78                filterBoxClass: "mblFilteredRoundRectListSearchBox",
79
80                buildRendering: function(){
81                        this.domNode = this.srcNodeRef || domConstruct.create(this.tag);
82                        if(this.select){
83                                domAttr.set(this.domNode, "role", "listbox");
84                                if(this.select === "multiple"){
85                                        domAttr.set(this.domNode, "aria-multiselectable", "true");
86                                }
87                        }
88                        this.inherited(arguments);
89                },
90
91                postCreate: function(){
92                        if(this.editable){
93                                require([this.editableMixinClass], lang.hitch(this, function(module){
94                                        declare.safeMixin(this, new module());
95                                }));
96                        }
97                        this.connect(this.domNode, "onselectstart", event.stop);
98
99                        if(this.syncWithViews){ // see also TabBar#postCreate
100                                var f = function(view, moveTo, dir, transition, context, method){
101                                        var child = array.filter(this.getChildren(), function(w){
102                                                return w.moveTo === "#" + view.id || w.moveTo === view.id; })[0];
103                                        if(child){ child.set("selected", true); }
104                                };
105                                this.subscribe("/dojox/mobile/afterTransitionIn", f);
106                                this.subscribe("/dojox/mobile/startView", f);
107                        }
108                },
109
110                resize: function(){
111                        // summary:
112                        //              Calls resize() of each child widget.
113                        array.forEach(this.getChildren(), function(child){
114                                if(child.resize){ child.resize(); }
115                        });
116                },
117
118                onCheckStateChanged: function(/*Widget*//*===== listItem, =====*/ /*String*//*===== newState =====*/){
119                        // summary:
120                        //              Stub function to connect to from your application.
121                        // description:
122                        //              Called when the check state has been changed.
123                },
124
125                _setStatefulAttr: function(stateful){
126                        // tags:
127                        //              private
128                        this._set("stateful", stateful);
129                        this.selectOne = stateful;
130                        array.forEach(this.getChildren(), function(child){
131                                child.setArrow && child.setArrow();
132                        });
133                },
134
135                deselectItem: function(/*dojox/mobile/ListItem*/item){
136                        // summary:
137                        //              Deselects the given item.
138                        item.set("selected", false);
139                },
140
141                deselectAll: function(){
142                        // summary:
143                        //              Deselects all the items.
144                        array.forEach(this.getChildren(), function(child){
145                                child.set("selected", false);
146                        });
147                },
148
149                selectItem: function(/*ListItem*/item){
150                        // summary:
151                        //              Selects the given item.
152                        item.set("selected", true);
153                }
154        });
155});
Note: See TracBrowser for help on using the repository browser.