root / trunk / web / dojo / dijit / form / MultiSelect.js @ 10
History | View | Annotate | Download (1.7 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dijit.form.MultiSelect"]){ |
||
9 | dojo._hasResource["dijit.form.MultiSelect"]=true; |
||
10 | dojo.provide("dijit.form.MultiSelect");
|
||
11 | dojo.require("dijit.form._FormWidget");
|
||
12 | dojo.declare("dijit.form.MultiSelect",dijit.form._FormValueWidget,{size:7,templateString:"<select multiple='true' ${!nameAttrSetting} dojoAttachPoint='containerNode,focusNode' dojoAttachEvent='onchange: _onChange'></select>",attributeMap:dojo.delegate(dijit.form._FormWidget.prototype.attributeMap,{size:"focusNode"}),reset:function(){ |
||
13 | this._hasBeenBlurred=false; |
||
14 | this._setValueAttr(this._resetValue,true); |
||
15 | },addSelected:function(_1){ |
||
16 | _1.getSelected().forEach(function(n){
|
||
17 | this.containerNode.appendChild(n);
|
||
18 | this.domNode.scrollTop=this.domNode.offsetHeight; |
||
19 | var _2=_1.domNode.scrollTop;
|
||
20 | _1.domNode.scrollTop=0;
|
||
21 | _1.domNode.scrollTop=_2; |
||
22 | },this);
|
||
23 | },getSelected:function(){ |
||
24 | return dojo.query("option",this.containerNode).filter(function(n){ |
||
25 | return n.selected;
|
||
26 | }); |
||
27 | },_getValueAttr:function(){ |
||
28 | return this.getSelected().map(function(n){ |
||
29 | return n.value;
|
||
30 | }); |
||
31 | },multiple:true,_setValueAttr:function(_3){ |
||
32 | dojo.query("option",this.containerNode).forEach(function(n){ |
||
33 | n.selected=(dojo.indexOf(_3,n.value)!=-1);
|
||
34 | }); |
||
35 | },invertSelection:function(_4){ |
||
36 | dojo.query("option",this.containerNode).forEach(function(n){ |
||
37 | n.selected=!n.selected; |
||
38 | }); |
||
39 | this._handleOnChange(this.get("value"),_4==true); |
||
40 | },_onChange:function(e){ |
||
41 | this._handleOnChange(this.get("value"),true); |
||
42 | },resize:function(_5){ |
||
43 | if(_5){
|
||
44 | dojo.marginBox(this.domNode,_5);
|
||
45 | } |
||
46 | },postCreate:function(){ |
||
47 | this._onChange();
|
||
48 | }}); |
||
49 | } |