]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/Select.js
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
8 if(!dojo
._hasResource
["dijit.form.Select"]){
9 dojo
._hasResource
["dijit.form.Select"]=true;
10 dojo
.provide("dijit.form.Select");
11 dojo
.require("dijit.form._FormSelectWidget");
12 dojo
.require("dijit._HasDropDown");
13 dojo
.require("dijit.Menu");
14 dojo
.require("dijit.Tooltip");
15 dojo
.requireLocalization("dijit.form","validate",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
16 dojo
.declare("dijit.form._SelectMenu",dijit
.Menu
,{buildRendering:function(){
17 this.inherited(arguments
);
18 var o
=(this.menuTableNode
=this.domNode
);
19 var n
=(this.domNode
=dojo
.create("div",{style
:{overflowX
:"hidden",overflowY
:"scroll"}}));
21 o
.parentNode
.replaceChild(n
,o
);
23 dojo
.removeClass(o
,"dijitMenuTable");
24 n
.className
=o
.className
+" dijitSelectMenu";
25 o
.className
="dijitReset dijitMenuTable";
26 dijit
.setWaiRole(o
,"listbox");
27 dijit
.setWaiRole(n
,"presentation");
29 },resize:function(mb
){
31 dojo
.marginBox(this.domNode
,mb
);
33 this.menuTableNode
.style
.width
="100%";
37 dojo
.declare("dijit.form.Select",[dijit
.form
._FormSelectWidget
,dijit
._HasDropDown
],{baseClass
:"dijitSelect",templateString
:dojo
.cache("dijit.form","templates/Select.html","<table class=\"dijit dijitReset dijitInline dijitLeft\"\n\tdojoAttachPoint=\"_buttonNode,tableNode,focusNode\" cellspacing='0' cellpadding='0'\n\twaiRole=\"combobox\" waiState=\"haspopup-true\"\n\t><tbody waiRole=\"presentation\"><tr waiRole=\"presentation\"\n\t\t><td class=\"dijitReset dijitStretch dijitButtonContents dijitButtonNode\" waiRole=\"presentation\"\n\t\t\t><span class=\"dijitReset dijitInline dijitButtonText\" dojoAttachPoint=\"containerNode,_popupStateNode\"></span\n\t\t\t><input type=\"hidden\" ${!nameAttrSetting} dojoAttachPoint=\"valueNode\" value=\"${value}\" waiState=\"hidden-true\"\n\t\t/></td><td class=\"dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton\"\n\t\t\t\tdojoAttachPoint=\"titleNode\" waiRole=\"presentation\"\n\t\t\t><div class=\"dijitReset dijitArrowButtonInner\" waiRole=\"presentation\"></div\n\t\t\t><div class=\"dijitReset dijitArrowButtonChar\" waiRole=\"presentation\">▼</div\n\t\t></td\n\t></tr></tbody\n></table>\n"),attributeMap
:dojo
.mixin(dojo
.clone(dijit
.form
._FormSelectWidget
.prototype.attributeMap
),{style
:"tableNode"}),required
:false,state
:"",tooltipPosition
:[],emptyLabel
:"",_isLoaded
:false,_childrenLoaded
:false,_fillContent:function(){
38 this.inherited(arguments
);
39 if(this.options
.length
&&!this.value
&&this.srcNodeRef
){
40 var si
=this.srcNodeRef
.selectedIndex
;
41 this.value
=this.options
[si
!=-1?si
:0].value
;
43 this.dropDown
=new dijit
.form
._SelectMenu({id
:this.id
+"_menu"});
44 dojo
.addClass(this.dropDown
.domNode
,this.baseClass
+"Menu");
45 },_getMenuItemForOption:function(_1
){
47 return new dijit
.MenuSeparator();
49 var _2
=dojo
.hitch(this,"_setValueAttr",_1
);
50 var _3
=new dijit
.MenuItem({option
:_1
,label
:_1
.label
,onClick
:_2
,disabled
:_1
.disabled
||false});
51 dijit
.setWaiRole(_3
.focusNode
,"listitem");
54 },_addOptionItem:function(_4
){
56 this.dropDown
.addChild(this._getMenuItemForOption(_4
));
58 },_getChildren:function(){
62 return this.dropDown
.getChildren();
63 },_loadChildren:function(_5
){
66 delete this.dropDown
.focusedChild
;
68 if(this.options
.length
){
69 this.inherited(arguments
);
71 dojo
.forEach(this._getChildren(),function(_6
){
72 _6
.destroyRecursive();
74 var _7
=new dijit
.MenuItem({label
:" "});
75 this.dropDown
.addChild(_7
);
78 this._updateSelection();
80 var _8
=this.options
.length
;
82 this._childrenLoaded
=true;
83 if(!this._loadingStore
){
84 this._setValueAttr(this.value
);
86 },_setValueAttr:function(_9
){
87 this.inherited(arguments
);
88 dojo
.attr(this.valueNode
,"value",this.get("value"));
89 },_setDisplay:function(_a
){
90 this.containerNode
.innerHTML
="<span class=\"dijitReset dijitInline "+this.baseClass
+"Label\">"+(_a
||this.emptyLabel
||" ")+"</span>";
91 dijit
.setWaiState(this.focusNode
,"valuetext",(_a
||this.emptyLabel
||" "));
92 },validate:function(_b
){
93 var _c
=this.isValid(_b
);
94 this.state
=_c
?"":"Error";
95 this._setStateClass();
96 dijit
.setWaiState(this.focusNode
,"invalid",_c
?"false":"true");
97 var _d
=_c
?"":this._missingMsg
;
98 if(this._message
!==_d
){
100 dijit
.hideTooltip(this.domNode
);
102 dijit
.showTooltip(_d
,this.domNode
,this.tooltipPosition
,!this.isLeftToRight());
106 },isValid:function(_e
){
107 return (!this.required
||!(/^\s*$/.test(this.value
)));
109 this.inherited(arguments
);
110 dijit
.hideTooltip(this.domNode
);
112 this._setStateClass();
113 delete this._message
;
114 },postMixInProperties:function(){
115 this.inherited(arguments
);
116 this._missingMsg
=dojo
.i18n
.getLocalization("dijit.form","validate",this.lang
).missingMessage
;
117 },postCreate:function(){
118 this.inherited(arguments
);
119 if(this.tableNode
.style
.width
){
120 dojo
.addClass(this.domNode
,this.baseClass
+"FixedWidth");
122 },isLoaded:function(){
123 return this._isLoaded
;
124 },loadDropDown:function(_f
){
125 this._loadChildren(true);
128 },closeDropDown:function(){
129 this.inherited(arguments
);
130 if(this.dropDown
&&this.dropDown
.menuTableNode
){
131 this.dropDown
.menuTableNode
.style
.width
="";
133 },uninitialize:function(_10
){
134 if(this.dropDown
&&!this.dropDown
._destroyed
){
135 this.dropDown
.destroyRecursive(_10
);
136 delete this.dropDown
;
138 this.inherited(arguments
);