root / trunk / web / dojo / dijit / _base / wai.js @ 12
History | View | Annotate | Download (2.13 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.wai"]){ |
9 |
dojo._hasResource["dijit._base.wai"]=true; |
10 |
dojo.provide("dijit._base.wai");
|
11 |
dijit.wai={onload:function(){ |
12 |
var _1=dojo.create("div",{id:"a11yTestNode",style:{cssText:"border: 1px solid;"+"border-color:red green;"+"position: absolute;"+"height: 5px;"+"top: -999px;"+"background-image: url(\""+(dojo.config.blankGif||dojo.moduleUrl("dojo","resources/blank.gif"))+"\");"}},dojo.body()); |
13 |
var cs=dojo.getComputedStyle(_1);
|
14 |
if(cs){
|
15 |
var _2=cs.backgroundImage;
|
16 |
var _3=(cs.borderTopColor==cs.borderRightColor)||(_2!=null&&(_2=="none"||_2=="url(invalid-url:)")); |
17 |
dojo[_3?"addClass":"removeClass"](dojo.body(),"dijit_a11y"); |
18 |
if(dojo.isIE){
|
19 |
_1.outerHTML="";
|
20 |
}else{
|
21 |
dojo.body().removeChild(_1); |
22 |
} |
23 |
} |
24 |
}}; |
25 |
if(dojo.isIE||dojo.isMoz){
|
26 |
dojo._loaders.unshift(dijit.wai.onload); |
27 |
} |
28 |
dojo.mixin(dijit,{_XhtmlRoles:/banner|contentinfo|definition|main|navigation|search|note|secondary|seealso/,hasWaiRole:function(_4,_5){ |
29 |
var _6=this.getWaiRole(_4); |
30 |
return _5?(_6.indexOf(_5)>-1):(_6.length>0); |
31 |
},getWaiRole:function(_7){ |
32 |
return dojo.trim((dojo.attr(_7,"role")||"").replace(this._XhtmlRoles,"").replace("wairole:","")); |
33 |
},setWaiRole:function(_8,_9){ |
34 |
var _a=dojo.attr(_8,"role")||""; |
35 |
if(!this._XhtmlRoles.test(_a)){ |
36 |
dojo.attr(_8,"role",_9);
|
37 |
}else{
|
38 |
if((" "+_a+" ").indexOf(" "+_9+" ")<0){ |
39 |
var _b=dojo.trim(_a.replace(this._XhtmlRoles,"")); |
40 |
var _c=dojo.trim(_a.replace(_b,"")); |
41 |
dojo.attr(_8,"role",_c+(_c?" ":"")+_9); |
42 |
} |
43 |
} |
44 |
},removeWaiRole:function(_d,_e){ |
45 |
var _f=dojo.attr(_d,"role"); |
46 |
if(!_f){
|
47 |
return;
|
48 |
} |
49 |
if(_e){
|
50 |
var t=dojo.trim((" "+_f+" ").replace(" "+_e+" "," ")); |
51 |
dojo.attr(_d,"role",t);
|
52 |
}else{
|
53 |
_d.removeAttribute("role");
|
54 |
} |
55 |
},hasWaiState:function(_10,_11){ |
56 |
return _10.hasAttribute?_10.hasAttribute("aria-"+_11):!!_10.getAttribute("aria-"+_11); |
57 |
},getWaiState:function(_12,_13){ |
58 |
return _12.getAttribute("aria-"+_13)||""; |
59 |
},setWaiState:function(_14,_15,_16){ |
60 |
_14.setAttribute("aria-"+_15,_16);
|
61 |
},removeWaiState:function(_17,_18){ |
62 |
_17.removeAttribute("aria-"+_18);
|
63 |
}}); |
64 |
} |