root / trunk / web / dojo / dijit / _base / manager.js @ 10
History | View | Annotate | Download (4.72 KB)
| 1 |
/*
|
|---|---|
| 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._base.manager"]){ |
| 9 |
dojo._hasResource["dijit._base.manager"]=true; |
| 10 |
dojo.provide("dijit._base.manager");
|
| 11 |
dojo.declare("dijit.WidgetSet",null,{constructor:function(){ |
| 12 |
this._hash={};
|
| 13 |
this.length=0; |
| 14 |
},add:function(_1){ |
| 15 |
if(this._hash[_1.id]){ |
| 16 |
throw new Error("Tried to register widget with id=="+_1.id+" but that id is already registered"); |
| 17 |
} |
| 18 |
this._hash[_1.id]=_1;
|
| 19 |
this.length++;
|
| 20 |
},remove:function(id){ |
| 21 |
if(this._hash[id]){ |
| 22 |
delete this._hash[id]; |
| 23 |
this.length--;
|
| 24 |
} |
| 25 |
},forEach:function(_2,_3){ |
| 26 |
_3=_3||dojo.global; |
| 27 |
var i=0,id; |
| 28 |
for(id in this._hash){ |
| 29 |
_2.call(_3,this._hash[id],i++,this._hash); |
| 30 |
} |
| 31 |
return this; |
| 32 |
},filter:function(_4,_5){ |
| 33 |
_5=_5||dojo.global; |
| 34 |
var _6=new dijit.WidgetSet(),i=0,id; |
| 35 |
for(id in this._hash){ |
| 36 |
var w=this._hash[id]; |
| 37 |
if(_4.call(_5,w,i++,this._hash)){ |
| 38 |
_6.add(w); |
| 39 |
} |
| 40 |
} |
| 41 |
return _6;
|
| 42 |
},byId:function(id){ |
| 43 |
return this._hash[id]; |
| 44 |
},byClass:function(_7){ |
| 45 |
var _8=new dijit.WidgetSet(),id,_9; |
| 46 |
for(id in this._hash){ |
| 47 |
_9=this._hash[id];
|
| 48 |
if(_9.declaredClass==_7){
|
| 49 |
_8.add(_9); |
| 50 |
} |
| 51 |
} |
| 52 |
return _8;
|
| 53 |
},toArray:function(){ |
| 54 |
var ar=[];
|
| 55 |
for(var id in this._hash){ |
| 56 |
ar.push(this._hash[id]);
|
| 57 |
} |
| 58 |
return ar;
|
| 59 |
},map:function(_a,_b){ |
| 60 |
return dojo.map(this.toArray(),_a,_b); |
| 61 |
},every:function(_c,_d){ |
| 62 |
_d=_d||dojo.global; |
| 63 |
var x=0,i; |
| 64 |
for(i in this._hash){ |
| 65 |
if(!_c.call(_d,this._hash[i],x++,this._hash)){ |
| 66 |
return false; |
| 67 |
} |
| 68 |
} |
| 69 |
return true; |
| 70 |
},some:function(_e,_f){ |
| 71 |
_f=_f||dojo.global; |
| 72 |
var x=0,i; |
| 73 |
for(i in this._hash){ |
| 74 |
if(_e.call(_f,this._hash[i],x++,this._hash)){ |
| 75 |
return true; |
| 76 |
} |
| 77 |
} |
| 78 |
return false; |
| 79 |
}}); |
| 80 |
(function(){
|
| 81 |
dijit.registry=new dijit.WidgetSet();
|
| 82 |
var _10=dijit.registry._hash,_11=dojo.attr,_12=dojo.hasAttr,_13=dojo.style;
|
| 83 |
dijit.byId=function(id){ |
| 84 |
return typeof id=="string"?_10[id]:id; |
| 85 |
}; |
| 86 |
var _14={};
|
| 87 |
dijit.getUniqueId=function(_15){ |
| 88 |
var id;
|
| 89 |
do{
|
| 90 |
id=_15+"_"+(_15 in _14?++_14[_15]:_14[_15]=0); |
| 91 |
}while(_10[id]);
|
| 92 |
return dijit._scopeName=="dijit"?id:dijit._scopeName+"_"+id; |
| 93 |
}; |
| 94 |
dijit.findWidgets=function(_16){ |
| 95 |
var _17=[];
|
| 96 |
function _18(_19){ |
| 97 |
for(var _1a=_19.firstChild;_1a;_1a=_1a.nextSibling){ |
| 98 |
if(_1a.nodeType==1){ |
| 99 |
var _1b=_1a.getAttribute("widgetId"); |
| 100 |
if(_1b){
|
| 101 |
_17.push(_10[_1b]); |
| 102 |
}else{
|
| 103 |
_18(_1a); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
}; |
| 108 |
_18(_16); |
| 109 |
return _17;
|
| 110 |
}; |
| 111 |
dijit._destroyAll=function(){ |
| 112 |
dijit._curFocus=null;
|
| 113 |
dijit._prevFocus=null;
|
| 114 |
dijit._activeStack=[]; |
| 115 |
dojo.forEach(dijit.findWidgets(dojo.body()),function(_1c){
|
| 116 |
if(!_1c._destroyed){
|
| 117 |
if(_1c.destroyRecursive){
|
| 118 |
_1c.destroyRecursive(); |
| 119 |
}else{
|
| 120 |
if(_1c.destroy){
|
| 121 |
_1c.destroy(); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
}); |
| 126 |
}; |
| 127 |
if(dojo.isIE){
|
| 128 |
dojo.addOnWindowUnload(function(){
|
| 129 |
dijit._destroyAll(); |
| 130 |
}); |
| 131 |
} |
| 132 |
dijit.byNode=function(_1d){ |
| 133 |
return _10[_1d.getAttribute("widgetId")]; |
| 134 |
}; |
| 135 |
dijit.getEnclosingWidget=function(_1e){ |
| 136 |
while(_1e){
|
| 137 |
var id=_1e.getAttribute&&_1e.getAttribute("widgetId"); |
| 138 |
if(id){
|
| 139 |
return _10[id];
|
| 140 |
} |
| 141 |
_1e=_1e.parentNode; |
| 142 |
} |
| 143 |
return null; |
| 144 |
}; |
| 145 |
var _1f=(dijit._isElementShown=function(_20){ |
| 146 |
var s=_13(_20);
|
| 147 |
return (s.visibility!="hidden")&&(s.visibility!="collapsed")&&(s.display!="none")&&(_11(_20,"type")!="hidden"); |
| 148 |
}); |
| 149 |
dijit.hasDefaultTabStop=function(_21){ |
| 150 |
switch(_21.nodeName.toLowerCase()){
|
| 151 |
case "a": |
| 152 |
return _12(_21,"href"); |
| 153 |
case "area": |
| 154 |
case "button": |
| 155 |
case "input": |
| 156 |
case "object": |
| 157 |
case "select": |
| 158 |
case "textarea": |
| 159 |
return true; |
| 160 |
case "iframe": |
| 161 |
if(dojo.isMoz){
|
| 162 |
try{
|
| 163 |
return _21.contentDocument.designMode=="on"; |
| 164 |
} |
| 165 |
catch(err){
|
| 166 |
return false; |
| 167 |
} |
| 168 |
}else{
|
| 169 |
if(dojo.isWebKit){
|
| 170 |
var doc=_21.contentDocument,_22=doc&&doc.body;
|
| 171 |
return _22&&_22.contentEditable=="true"; |
| 172 |
}else{
|
| 173 |
try{
|
| 174 |
doc=_21.contentWindow.document; |
| 175 |
_22=doc&&doc.body; |
| 176 |
return _22&&_22.firstChild&&_22.firstChild.contentEditable=="true"; |
| 177 |
} |
| 178 |
catch(e){
|
| 179 |
return false; |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
default:
|
| 184 |
return _21.contentEditable=="true"; |
| 185 |
} |
| 186 |
}; |
| 187 |
var _23=(dijit.isTabNavigable=function(_24){ |
| 188 |
if(_11(_24,"disabled")){ |
| 189 |
return false; |
| 190 |
}else{
|
| 191 |
if(_12(_24,"tabIndex")){ |
| 192 |
return _11(_24,"tabIndex")>=0; |
| 193 |
}else{
|
| 194 |
return dijit.hasDefaultTabStop(_24);
|
| 195 |
} |
| 196 |
} |
| 197 |
}); |
| 198 |
dijit._getTabNavigable=function(_25){ |
| 199 |
var _26,_27,_28,_29,_2a,_2b;
|
| 200 |
var _2c=function(_2d){ |
| 201 |
dojo.query("> *",_2d).forEach(function(_2e){ |
| 202 |
if((dojo.isIE&&_2e.scopeName!=="HTML")||!_1f(_2e)){ |
| 203 |
return;
|
| 204 |
} |
| 205 |
if(_23(_2e)){
|
| 206 |
var _2f=_11(_2e,"tabIndex"); |
| 207 |
if(!_12(_2e,"tabIndex")||_2f==0){ |
| 208 |
if(!_26){
|
| 209 |
_26=_2e; |
| 210 |
} |
| 211 |
_27=_2e; |
| 212 |
}else{
|
| 213 |
if(_2f>0){ |
| 214 |
if(!_28||_2f<_29){
|
| 215 |
_29=_2f; |
| 216 |
_28=_2e; |
| 217 |
} |
| 218 |
if(!_2a||_2f>=_2b){
|
| 219 |
_2b=_2f; |
| 220 |
_2a=_2e; |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
} |
| 225 |
if(_2e.nodeName.toUpperCase()!="SELECT"){ |
| 226 |
_2c(_2e); |
| 227 |
} |
| 228 |
}); |
| 229 |
}; |
| 230 |
if(_1f(_25)){
|
| 231 |
_2c(_25); |
| 232 |
} |
| 233 |
return {first:_26,last:_27,lowest:_28,highest:_2a}; |
| 234 |
}; |
| 235 |
dijit.getFirstInTabbingOrder=function(_30){ |
| 236 |
var _31=dijit._getTabNavigable(dojo.byId(_30));
|
| 237 |
return _31.lowest?_31.lowest:_31.first;
|
| 238 |
}; |
| 239 |
dijit.getLastInTabbingOrder=function(_32){ |
| 240 |
var _33=dijit._getTabNavigable(dojo.byId(_32));
|
| 241 |
return _33.last?_33.last:_33.highest;
|
| 242 |
}; |
| 243 |
dijit.defaultDuration=dojo.config["defaultDuration"]||200; |
| 244 |
})(); |
| 245 |
} |