| 1 |
define([ |
| 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 |
|
| 15 |
|
| 16 |
|
| 17 |
return declare("dojox.mobile.RoundRectList", [WidgetBase, Container, Contained], { |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
transition: "slide", |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
iconBase: "", |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
iconPos: "", |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
select: "", |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
stateful: false, |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
syncWithViews: false, |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
editable: false, |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
tag: "ul", |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
editableMixinClass: "dojox/mobile/_EditableListMixin", |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
baseClass: "mblRoundRectList", |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 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){ |
| 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 |
|
| 112 |
|
| 113 |
array.forEach(this.getChildren(), function(child){ |
| 114 |
if(child.resize){ child.resize(); } |
| 115 |
}); |
| 116 |
}, |
| 117 |
|
| 118 |
onCheckStateChanged: function( ){ |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
}, |
| 124 |
|
| 125 |
_setStatefulAttr: function(stateful){ |
| 126 |
|
| 127 |
|
| 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(item){ |
| 136 |
|
| 137 |
|
| 138 |
item.set("selected", false); |
| 139 |
}, |
| 140 |
|
| 141 |
deselectAll: function(){ |
| 142 |
|
| 143 |
|
| 144 |
array.forEach(this.getChildren(), function(child){ |
| 145 |
child.set("selected", false); |
| 146 |
}); |
| 147 |
}, |
| 148 |
|
| 149 |
selectItem: function(item){ |
| 150 |
|
| 151 |
|
| 152 |
item.set("selected", true); |
| 153 |
} |
| 154 |
}); |
| 155 |
}); |