source: Dev/trunk/src/client/dojo/hccss.js @ 501

Last change on this file since 501 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.6 KB
Line 
1define([
2        "require",                      // require, require.toUrl
3        "./_base/config", // config.blankGif
4        "./dom-class", // domClass.add
5        "./dom-style", // domStyle.getComputedStyle
6        "./has",
7        "./domReady",
8        "./_base/window" // win.body
9], function(require, config, domClass, domStyle, has, domReady, win){
10
11        // module:
12        //              dojo/hccss
13
14        /*=====
15        return function(){
16                // summary:
17                //              Test if computer is in high contrast mode (i.e. if browser is not displaying background images).
18                //              Defines `has("highcontrast")` and sets `dj_a11y` CSS class on `<body>` if machine is in high contrast mode.
19                //              Returns `has()` method;
20        };
21        =====*/
22
23        // Has() test for when background images aren't displayed.  Don't call has("highcontrast") before dojo/domReady!.
24        has.add("highcontrast", function(){
25                // note: if multiple documents, doesn't matter which one we use
26                var div = win.doc.createElement("div");
27                div.style.cssText = "border: 1px solid; border-color:red green; position: absolute; height: 5px; top: -999px;" +
28                        "background-image: url(" + (config.blankGif || require.toUrl("./resources/blank.gif")) + ");";
29                win.body().appendChild(div);
30
31                var cs = domStyle.getComputedStyle(div),
32                        bkImg = cs.backgroundImage,
33                        hc = (cs.borderTopColor == cs.borderRightColor) ||
34                                (bkImg && (bkImg == "none" || bkImg == "url(invalid-url:)" ));
35
36                if(has("ie") <= 8){
37                        div.outerHTML = "";             // prevent mixed-content warning, see http://support.microsoft.com/kb/925014
38                }else{
39                        win.body().removeChild(div);
40                }
41
42                return hc;
43        });
44
45        domReady(function(){
46                if(has("highcontrast")){
47                        domClass.add(win.body(), "dj_a11y");
48                }
49        });
50
51        return has;
52});
Note: See TracBrowser for help on using the repository browser.