function a11y_a11y_block in Accessibility toolkit 7
Renders the default a11y block.
2 calls to a11y_a11y_block()
- a11y_block_view in ./
a11y.module - Implements hook_block_view().
- a11y_fa_a11y in ./
a11y.module - Implements hook_fa_a11y(). Returns the accessibility block to foundation access.
File
- ./
a11y.module, line 48 - A11y accessibiliy toolkit module to help people.
Code
function a11y_a11y_block($render = TRUE) {
// apply the css / js as selected
a11y_apply_a11y();
if ($render) {
$output = '';
}
else {
$output = array();
}
// assemble the user alterations to the interface
$alters = array(
'#type' => 'fieldset',
'#title' => t('Interface'),
'#description' => t('Adjust the interface to make it easier to use for different conditions.'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#weight' => -10,
'#attributes' => array(
'class' => array(
'collapsible',
'form-wrapper',
),
),
'#materialize' => array(
'type' => 'collapsible',
'icon' => 'brightness_medium',
),
);
// textsize default state
if (variable_get('a11y_textsize', 1)) {
$icon_path = base_path() . drupal_get_path('module', 'a11y') . '/plugins/icons/';
$alters['textsize'] = array(
'#markup' => '
<div class="a11y-textsize-controls">
<div class="a11y-textsize-controls-label">' . t('Interface Size') . '</div>
<div class="a11y-textsize-controls-body row">
<div class="col s4">
<a data-voicecommand="smaller text" href="#textsizesmaller" onclick="Drupal.a11y.textsize(-1);" class="a11y-operation-icons a11y-decrease">
<span>Smaller</span>
<img alt="' . t('Decrease text size') . '" title="' . t('Decrease') . '" src="' . $icon_path . 'text-decrease.png" width="24" height="24" />
</a>
</div>
<div class="col s4">
<a data-voicecommand="larger text" href="#textsizelarger" onclick="Drupal.a11y.textsize(1);" class="a11y-operation-icons a11y-increase">
<span>Larger</span>
<img alt="' . t('Increase text size') . '" title="' . t('Increase') . '" src="' . $icon_path . 'text-increase.png" width="24" height="24" />
</a>
</div>
<div class="col s4">
<a data-voicecommand="normal text" href="#textsizereset" onclick="Drupal.a11y.textsize(0);" class="a11y-operation-icons a11y-reset">
<span>Reset</span>
<img alt="' . t('Reset text size') . '" title="' . t('Reset') . '" src="' . $icon_path . 'text-reset.png" width="24" height="24" />
</a>
</div>
</div>
</div>',
'#weight' => -10,
);
}
// support contrast settings
if (variable_get('a11y_contrast', 1)) {
$alters['contrast'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_contrast_checkbox',
'#title' => t('High contrast mode'),
'#default_value' => 0,
'#description' => t('This renders the document in high contrast mode.'),
'#weight' => -9,
'#attributes' => array(
'data-voicecommand' => 'high contrast mode (on)(off)',
),
);
$alters['invert'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_invert_checkbox',
'#title' => t('Invert colors'),
'#default_value' => 0,
'#description' => t('This renders the document as white on black'),
'#weight' => -8,
'#attributes' => array(
'data-voicecommand' => 'invert colors (again)',
),
);
}
// support animation disabling
if (variable_get('a11y_animation', 1)) {
// animation default state
$alters['animation'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_animation_checkbox',
'#title' => t('Disable interface animations'),
'#default_value' => 0,
'#description' => t('This can help those with trouble processing rapid screen movements.'),
'#weight' => -7,
'#attributes' => array(
'data-voicecommand' => 'toggle interface animations',
),
);
}
// open dyslexic font
if (variable_get('a11y_opendyslexic', 1)) {
$alters['opendyslexic'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_opendyslexic_checkbox',
'#title' => t('Optimize fonts for dyslexia'),
'#default_value' => 0,
'#description' => t('This loads a font easier to read for people with dyslexia.'),
'#weight' => -6,
'#attributes' => array(
'data-voicecommand' => 'toggle dyslexic (font)',
),
);
}
// support voicecommander disabling
if (user_access('use voice commander')) {
// voicecommander default state
$alters['voicecommander'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_voicecommander_checkbox',
'#title' => t('Continuously listen for voice commands'),
'#default_value' => 0,
'#description' => t('This allows for more natural speech with working with the system.'),
'#weight' => -5,
'#attributes' => array(
'data-voicecommand' => 'toggle always listening',
),
);
// speechSynth seting
if (variable_get('a11y_speechsynth', 1)) {
$alters['a11y_speechsynth'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_speechsynth_checkbox',
'#title' => t('Read to me'),
'#default_value' => 0,
'#description' => t('This will speak the page\'s content to you.'),
'#weight' => -4,
'#attributes' => array(
'data-voicecommand' => 'read to me',
),
);
}
}
if ($render) {
// render any aleration array items we have
$output .= drupal_render($alters);
}
else {
$output['alters'] = $alters;
}
// add in the simulations if they are allowed to see them
if (user_access('view a11y simulations')) {
$sim = array(
'#type' => 'fieldset',
'#title' => t('Simulators'),
'#description' => t('Simulate different accessibility conditions. This is useful to see how your site would possibly be viewed by people with different conditions.'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#weight' => -9,
'#attributes' => array(
'class' => array(
'collapsible',
'form-wrapper',
'collapsed',
),
),
'#materialize' => array(
'type' => 'collapsible',
'icon' => 'videogame_asset',
),
);
// support for dyslexia simulator
if (variable_get('a11y_sim_dyslexia', 1)) {
$sim['dyslexia'] = array(
'#type' => 'checkbox',
'#id' => 'a11y_sim_dyslexia_checkbox',
'#title' => t('Dyslexia'),
'#default_value' => 0,
'#description' => t('This will simulate how a dyslexic might view your material.'),
'#weight' => -10,
);
drupal_add_js(drupal_get_path('module', 'a11y') . '/simulations/dyslexia/dyslexia.js');
}
// support for field-loss simulator
if (variable_get('a11y_sim_field_loss', 1)) {
$sim['field_loss'] = array(
'#type' => 'select',
'#id' => 'a11y_sim_field_loss_select',
'#title' => t('Field loss'),
'#default_value' => '',
'#options' => array(
'' => t('No field loss'),
'central' => t('Central loss'),
'peripheral' => t('Peripheral loss'),
),
'#description' => t('This will simulate how someone with vision field loss might view your material.'),
'#weight' => -10,
);
drupal_add_js(drupal_get_path('module', 'a11y') . '/simulations/field-loss/field-loss.js');
drupal_add_css(drupal_get_path('module', 'a11y') . '/simulations/field-loss/field-loss.css');
}
// support for colorblind simulator
if (variable_get('a11y_sim_colorblind', 1)) {
$options = array(
'' => t('No color blindness'),
'achromatopsia' => t('Achromatopsia'),
'achromatomaly' => t('Achromatomaly'),
'deuteranopia' => t('Deuteranopia'),
'deuteranomaly' => t('Deuteranomaly'),
'protanopia' => t('Protanopia'),
'protanomaly' => t('Protanomaly'),
'tritanopia' => t('Tritanopia'),
'tritanomaly' => t('Tritanomaly'),
);
$sim['colorblind'] = array(
'#type' => 'select',
'#id' => 'a11y_sim_colorblind_select',
'#title' => t('Color blind'),
'#default_value' => '',
'#options' => $options,
'#description' => t('This will simulate different variations of color blindness.'),
'#weight' => -11,
);
// add in the JS
drupal_add_js(drupal_get_path('module', 'a11y') . '/simulations/colorblind/colorblind.js');
// seems weird but we need to build the CSS dynamically
$filterpath = url(drupal_get_path('module', 'a11y') . '/simulations/colorblind/filters.svg', array(
'absolute' => TRUE,
));
$colorblindcss = '';
array_shift($options);
foreach ($options as $option => $name) {
$colorblindcss .= '.' . $option . ' {
-webkit-filter: url("' . $filterpath . '#' . $option . '");
filter: url("' . $filterpath . '#' . $option . '"); }';
}
// kick it out inline
drupal_add_css($colorblindcss, array(
'type' => 'inline',
));
}
if ($render) {
// render any aleration array items we have
$output .= drupal_render($sim);
}
else {
$output['sim'] = $sim;
}
}
return $output;
}