2
** This file contains function to enable and
3
** disable Accessibility stylesheet in ubuntu-it
6
ACCESSIBILITY_CSS_THEME_DIR = 'light-drupal-theme/styles';
7
ACCESSIBILITY_CSS_FILE_NAME = 'accessibility.css' ;
8
ACCESSIBILITY_COOKIE_VALUE_ON = 'on';
9
ACCESSIBILITY_COOKIE_VALUE_OFF = 'off';
11
// This function adds the accessibility css into the Head section
12
// and set the cookie value ON
13
function accessibility_set_on () {
14
// Get the absolute path of theme dir from other css files
15
head = document.getElementsByTagName('head')[0];
16
links = head.getElementsByTagName('link');
18
for (i = 0 ; i < links.length ; i++) {
20
if (link.hasAttribute('type') &&
21
link.getAttribute('type') == 'text/css' &&
22
link.hasAttribute('href') &&
23
link.getAttribute('href').indexOf(ACCESSIBILITY_CSS_THEME_DIR) >= 0) {
25
theme_dir = link.getAttribute('href').replace(/\\/g,'/').replace(/\/[^\/]*\/?$/, '');
31
accessibility_css_file = theme_dir + '/' + ACCESSIBILITY_CSS_FILE_NAME;
33
link = document.createElement('link');
34
link.setAttribute('type','text/css');
35
link.setAttribute('rel', 'stylesheet');
36
link.setAttribute('media', 'all');
37
link.setAttribute('href', accessibility_css_file);
39
head.appendChild(link);
40
set_cookie_accessibility( ACCESSIBILITY_COOKIE_VALUE_ON );
43
// This function removes the accessibility css from the Head section
44
// and set the cookie offset
45
function accessibility_set_off() {
46
head = document.getElementsByTagName('head')[0];
47
links = head.getElementsByTagName('link');
48
for (i = 0 ; i < links.length ; i++) {
50
if (link.hasAttribute('type') &&
51
link.getAttribute('type') == 'text/css' &&
52
link.hasAttribute('href') &&
53
link.getAttribute('href').indexOf(ACCESSIBILITY_CSS_THEME_DIR + "/" + ACCESSIBILITY_CSS_FILE_NAME) >= 0) {
54
head.removeChild(link);
58
set_cookie_accessibility( ACCESSIBILITY_COOKIE_VALUE_OFF );
62
function accessibility_toggle () {
63
value = get_cookie_accessibility();
65
// console.info('Accessibility: ' + value)
67
// If accessibility is ON, add the css stylesheet
68
if (value == ACCESSIBILITY_COOKIE_VALUE_OFF)
69
accessibility_set_on();
71
accessibility_set_off();
75
function accessibility () {
76
accessibility_toggle();