1 | define([ |
---|
2 | "require", // require.toUrl |
---|
3 | "dojo/_base/config", // config.blankGif |
---|
4 | "dojo/dom-class", // domClass.add domConstruct.create domStyle.getComputedStyle |
---|
5 | "dojo/dom-construct", // domClass.add domConstruct.create domStyle.getComputedStyle |
---|
6 | "dojo/dom-style", // domClass.add domConstruct.create domStyle.getComputedStyle |
---|
7 | "dojo/ready", // ready |
---|
8 | "dojo/_base/sniff", // has("ie") has("mozilla") |
---|
9 | "dojo/_base/window" // win.body |
---|
10 | ], function(require, config, domClass, domConstruct, domStyle, ready, has, win){ |
---|
11 | |
---|
12 | // module: |
---|
13 | // dijit/hccss |
---|
14 | // summary: |
---|
15 | // Test if computer is in high contrast mode, and sets dijit_a11y flag on <body> if it is. |
---|
16 | |
---|
17 | if(has("ie") || has("mozilla")){ // NOTE: checking in Safari messes things up |
---|
18 | // priority is 90 to run ahead of parser priority of 100 |
---|
19 | ready(90, function(){ |
---|
20 | // summary: |
---|
21 | // Detects if we are in high-contrast mode or not |
---|
22 | |
---|
23 | // create div for testing if high contrast mode is on or images are turned off |
---|
24 | var div = domConstruct.create("div",{ |
---|
25 | id: "a11yTestNode", |
---|
26 | style:{ |
---|
27 | cssText:'border: 1px solid;' |
---|
28 | + 'border-color:red green;' |
---|
29 | + 'position: absolute;' |
---|
30 | + 'height: 5px;' |
---|
31 | + 'top: -999px;' |
---|
32 | + 'background-image: url("' + (config.blankGif || require.toUrl("dojo/resources/blank.gif")) + '");' |
---|
33 | } |
---|
34 | }, win.body()); |
---|
35 | |
---|
36 | // test it |
---|
37 | var cs = domStyle.getComputedStyle(div); |
---|
38 | if(cs){ |
---|
39 | var bkImg = cs.backgroundImage; |
---|
40 | var needsA11y = (cs.borderTopColor == cs.borderRightColor) || (bkImg != null && (bkImg == "none" || bkImg == "url(invalid-url:)" )); |
---|
41 | if(needsA11y){ |
---|
42 | domClass.add(win.body(), "dijit_a11y"); |
---|
43 | } |
---|
44 | if(has("ie")){ |
---|
45 | div.outerHTML = ""; // prevent mixed-content warning, see http://support.microsoft.com/kb/925014 |
---|
46 | }else{ |
---|
47 | win.body().removeChild(div); |
---|
48 | } |
---|
49 | } |
---|
50 | }); |
---|
51 | } |
---|
52 | }); |
---|