]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_FormMixin.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._FormMixin"]){
9 dojo
._hasResource
["dijit.form._FormMixin"]=true;
10 dojo
.provide("dijit.form._FormMixin");
11 dojo
.require("dojo.window");
12 dojo
.declare("dijit.form._FormMixin",null,{reset:function(){
13 dojo
.forEach(this.getDescendants(),function(_1
){
18 },validate:function(){
20 return dojo
.every(dojo
.map(this.getDescendants(),function(_3
){
21 _3
._hasBeenBlurred
=true;
22 var _4
=_3
.disabled
||!_3
.validate
||_3
.validate();
24 dojo
.window
.scrollIntoView(_3
.containerNode
||_3
.domNode
);
32 },setValues:function(_6
){
33 dojo
.deprecated(this.declaredClass
+"::setValues() is deprecated. Use set('value', val) instead.","","2.0");
34 return this.set("value",_6
);
35 },_setValueAttr:function(_7
){
37 dojo
.forEach(this.getDescendants(),function(_9
){
41 var _a
=_8
[_9
.name
]||(_8
[_9
.name
]=[]);
45 if(!_8
.hasOwnProperty(_b
)){
48 var _c
=_8
[_b
],_d
=dojo
.getObject(_b
,false,_7
);
52 if(!dojo
.isArray(_d
)){
55 if(typeof _c
[0].checked
=="boolean"){
56 dojo
.forEach(_c
,function(w
,i
){
57 w
.set("value",dojo
.indexOf(_d
,w
.value
)!=-1);
61 _c
[0].set("value",_d
);
63 dojo
.forEach(_c
,function(w
,i
){
69 },getValues:function(){
70 dojo
.deprecated(this.declaredClass
+"::getValues() is deprecated. Use get('value') instead.","","2.0");
71 return this.get("value");
72 },_getValueAttr:function(){
74 dojo
.forEach(this.getDescendants(),function(_f
){
76 if(!_10
||_f
.disabled
){
79 var _11
=_f
.get("value");
80 if(typeof _f
.checked
=="boolean"){
81 if(/Radio/.test(_f
.declaredClass
)){
83 dojo
.setObject(_10
,_11
,_e
);
85 _11
=dojo
.getObject(_10
,false,_e
);
87 dojo
.setObject(_10
,null,_e
);
91 var ary
=dojo
.getObject(_10
,false,_e
);
94 dojo
.setObject(_10
,ary
,_e
);
101 var _12
=dojo
.getObject(_10
,false,_e
);
102 if(typeof _12
!="undefined"){
103 if(dojo
.isArray(_12
)){
106 dojo
.setObject(_10
,[_12
,_11
],_e
);
109 dojo
.setObject(_10
,_11
,_e
);
114 },isValid:function(){
115 this._invalidWidgets
=dojo
.filter(this.getDescendants(),function(_13
){
116 return !_13
.disabled
&&_13
.isValid
&&!_13
.isValid();
118 return !this._invalidWidgets
.length
;
119 },onValidStateChange:function(_14
){
120 },_widgetChange:function(_15
){
121 var _16
=this._lastValidState
;
122 if(!_15
||this._lastValidState
===undefined){
124 if(this._lastValidState
===undefined){
125 this._lastValidState
=_16
;
129 this._invalidWidgets
=dojo
.filter(this._invalidWidgets
||[],function(w
){
132 if(!_15
.isValid()&&!_15
.get("disabled")){
133 this._invalidWidgets
.push(_15
);
135 _16
=(this._invalidWidgets
.length
===0);
138 if(_16
!==this._lastValidState
){
139 this._lastValidState
=_16
;
140 this.onValidStateChange(_16
);
142 },connectChildren:function(){
143 dojo
.forEach(this._changeConnections
,dojo
.hitch(this,"disconnect"));
145 var _18
=(this._changeConnections
=[]);
146 dojo
.forEach(dojo
.filter(this.getDescendants(),function(_19
){
149 _18
.push(_17
.connect(_1a
,"validate",dojo
.hitch(_17
,"_widgetChange",_1a
)));
150 _18
.push(_17
.connect(_1a
,"_setDisabledAttr",dojo
.hitch(_17
,"_widgetChange",_1a
)));
152 this._widgetChange(null);
153 },startup:function(){
154 this.inherited(arguments
);
155 this._changeConnections
=[];
156 this.connectChildren();