dijit/_base/wai.js

  • Provides:

    • dijit
  • dijit.wai

    • type
      Object
    • summary
  • dijit.wai.onload

    • type
      Function
    • source: [view]
      define("dijit/_base/wai", ["dojo", "dijit"], function(dojo, dijit) {


      dijit.wai = {
       onload: function(){
        // summary:
        //  Detects if we are in high-contrast mode or not


        // This must be a named function and not an anonymous
        // function, so that the widget parsing code can make sure it
        // registers its onload function after this function.
        // DO NOT USE "this" within this function.


        // create div for testing if high contrast mode is on or images are turned off
        var div = 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());


        // test it
        var cs = dojo.getComputedStyle(div);
        if(cs){
         var bkImg = cs.backgroundImage;
         var needsA11y = (cs.borderTopColor == cs.borderRightColor) || (bkImg != null && (bkImg == "none" || bkImg == "url(invalid-url:)" ));
         dojo[needsA11y ? "addClass" : "removeClass"](dojo.body(), "dijit_a11y");
         if(dojo.isIE){
          div.outerHTML = "";  // prevent mixed-content warning, see http://support.microsoft.com/kb/925014
         }else{
          dojo.body().removeChild(div);
         }
        }
    • summary
  • dijit.hasWaiRole

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • role: (typeof String)
    • source: [view]
        var waiRole = this.getWaiRole(elem);
        return role ? (waiRole.indexOf(role) > -1) : (waiRole.length > 0);
    • summary
      Determines if an element has a particular role.
    • return_summary
      True if elem has the specific role attribute and false if not.
      For backwards compatibility if role parameter not provided,
      returns true if has a role
  • dijit.getWaiRole

    • type
      Function
    • parameters:
      • elem: (typeof Element)
    • source: [view]
         return dojo.trim((dojo.attr(elem, "role") || "").replace("wairole:",""));
    • summary
      Gets the role for an element (which should be a wai role).
    • return_summary
      The role of elem or an empty string if elem
      does not have a role.
  • dijit.setWaiRole

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • role: (typeof String)
    • source: [view]
         dojo.attr(elem, "role", role);
    • summary
      Sets the role on an element.
    • description
      Replace existing role attribute with new role.
  • dijit.removeWaiRole

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • role: (typeof String)
    • source: [view]
        var roleValue = dojo.attr(elem, "role");
        if(!roleValue){ return; }
        if(role){
         var t = dojo.trim((" " + roleValue + " ").replace(" " + role + " ", " "));
         dojo.attr(elem, "role", t);
        }else{
         elem.removeAttribute("role");
        }
    • summary
      Removes the specified role from an element.
      Removes role attribute if no specific role provided (for backwards compat.)
  • dijit.hasWaiState

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • state: (typeof String)
    • source: [view]
        return elem.hasAttribute ? elem.hasAttribute("aria-"+state) : !!elem.getAttribute("aria-"+state);
    • summary
      Determines if an element has a given state.
    • description
      Checks for an attribute called "aria-"+state.
    • return_summary
      true if elem has a value for the given state and
      false if it does not.
  • dijit.getWaiState

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • state: (typeof String)
    • source: [view]
        return elem.getAttribute("aria-"+state) || "";
    • summary
      Gets the value of a state on an element.
    • description
      Checks for an attribute called "aria-"+state.
    • return_summary
      The value of the requested state on elem
      or an empty string if elem has no value for state.
  • dijit.setWaiState

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • state: (typeof String)
      • value: (typeof String)
    • source: [view]
        elem.setAttribute("aria-"+state, value);
    • summary
      Sets a state on an element.
    • description
      Sets an attribute called "aria-"+state.
  • dijit.removeWaiState

    • type
      Function
    • parameters:
      • elem: (typeof Element)
      • state: (typeof String)
    • source: [view]
        elem.removeAttribute("aria-"+state);
    • summary
      Removes a state from an element.
    • description
      Sets an attribute called "aria-"+state.
  • dijit

    • type
      Object
    • summary