Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit ce38b3c

Browse files
author
Andrew Garrett
committed
Initial commit
0 parents  commit ce38b3c

File tree

5 files changed

+185
-0
lines changed

5 files changed

+185
-0
lines changed

AccessibilitySimulation.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* MediaWiki Extension: AccessibilitySimulation
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* This program is distributed WITHOUT ANY WARRANTY.
16+
*/
17+
18+
/**
19+
*
20+
* @file
21+
* @ingroup Extensions
22+
* @author Andrew Garrett
23+
*/
24+
25+
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
26+
if ( !defined( 'MEDIAWIKI' ) ) {
27+
echo <<<EOT
28+
To install this extension, put the following line in LocalSettings.php:
29+
require_once( "$IP/extensions/AccessibilitySimulation/AccessibilitySimulation.php" );
30+
EOT;
31+
exit( 1 );
32+
}
33+
34+
// Extension credits that will show up on Special:Version
35+
$wgExtensionCredits['specialpage'][] = array(
36+
'path' => __FILE__,
37+
'name' => 'AccessibilitySimulation',
38+
'url' => 'URL to extension information',
39+
'author' => array(
40+
'Andrew Garrett',
41+
),
42+
'descriptionmsg' => 'accessibilitysimulation-desc',
43+
);
44+
45+
$dir = dirname( __FILE__ ) . '/';
46+
47+
$wgMessagesDirs['AccessibilitySimulation'] = $dir . 'i18n';
48+
49+
$wgResourceModules['ext.accessibility-simulation'] = array(
50+
'remoteExtPath' => 'AccessibilitySimulation',
51+
'localBasePath' => __DIR__,
52+
'group' => 'ext.accessibility-simulation',
53+
'styles' => 'filters.css',
54+
'scripts' => 'accessibility-switch.js',
55+
'dependencies' => 'oojs-ui',
56+
);
57+
58+
$wgHooks['BeforePageDisplay'][] = function( $out ) {
59+
$out->addModules( 'ext.accessibility-simulation' );
60+
};

accessibility-switch.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
( function( $, mw ) {
2+
$( function() {
3+
var $navBar = $( 'ul.navbar-right' ),
4+
$selectorPopup = $( '<div>My popup</div>' );
5+
selector = new OO.ui.DropdownWidget( {
6+
"label": "Vision simulation",
7+
"menu" : { 'items' : [
8+
new OO.ui.MenuOptionWidget( {
9+
'data' : '',
10+
'label' : 'No simulation',
11+
'selected' : true
12+
} ),
13+
new OO.ui.MenuOptionWidget( {
14+
'data' : 'protanopia',
15+
'label' : 'Protanopia',
16+
} ),
17+
new OO.ui.MenuOptionWidget( {
18+
'data' : 'deuteranopia',
19+
'label' : 'Deuteranopia',
20+
} ),
21+
new OO.ui.MenuOptionWidget( {
22+
'data' : 'tritanopia',
23+
'label' : 'Tritanopia',
24+
} ),
25+
new OO.ui.MenuOptionWidget( {
26+
'data' : 'monochromacy',
27+
'label' : 'Monochromacy',
28+
} ),
29+
] }
30+
} ),
31+
menu = selector.getMenu();
32+
33+
$newItem = $( '<li/>' ).append( selector.$element );
34+
35+
$newItem.prependTo( $navBar );
36+
37+
menu.selectItem( menu.getItemFromData( '' ) );
38+
39+
menu.on( 'select', function( item ) {
40+
var type = item.getData();
41+
42+
$.each(
43+
['protanopia', 'deuteranopia', 'tritanopia', 'monochromacy'],
44+
function( i, type ) {
45+
$( '.container' ).removeClass( 'as-' + type );
46+
}
47+
);
48+
49+
if ( type ) {
50+
$( '.container' ).addClass( 'as-' + type );
51+
}
52+
} );
53+
} );
54+
} )( jQuery, mediaWiki );

filters.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.as-protanopia {
2+
-webkit-filter: url(filters.svg#protanopia);
3+
-moz-filter: url(filters.svg#protanopia);
4+
-ms-filter: url(filters.svg#protanopia);
5+
-o-filter: url(filters.svg#protanopia);
6+
filter: url(filters.svg#protanopia); /* Firefox 3.5+ */
7+
8+
}
9+
.as-deuteranopia {
10+
-webkit-filter: url(filters.svg#deuteranopia);
11+
-moz-filter: url(filters.svg#deuteranopia);
12+
-ms-filter: url(filters.svg#deuteranopia);
13+
-o-filter: url(filters.svg#deuteranopia);
14+
filter: url(filters.svg#deuteranopia); /* Firefox 3.5+ */
15+
16+
}
17+
.as-tritanopia {
18+
-webkit-filter: url(filters.svg#tritanopia);
19+
-moz-filter: url(filters.svg#tritanopia);
20+
-ms-filter: url(filters.svg#tritanopia);
21+
-o-filter: url(filters.svg#tritanopia);
22+
filter: url(filters.svg#tritanopia); /* Firefox 3.5+ */
23+
24+
}
25+
.as-monochromacy {
26+
-webkit-filter: url(filters.svg#monochromacy);
27+
-moz-filter: url(filters.svg#monochromacy);
28+
-ms-filter: url(filters.svg#monochromacy);
29+
-o-filter: url(filters.svg#monochromacy);
30+
filter: url(filters.svg#monochromacy); /* Firefox 3.5+ */
31+
32+
}
33+
.as-enhance-r {
34+
-webkit-filter: url(filters.svg#enhance-r);
35+
-moz-filter: url(filters.svg#enhance-r);
36+
-ms-filter: url(filters.svg#enhance-r);
37+
-o-filter: url(filters.svg#enhance-r);
38+
filter: url(filters.svg#enhance-r); /* Firefox 3.5+ */
39+
40+
}
41+
.as-enhance-g {
42+
-webkit-filter: url(filters.svg#enhance-g);
43+
-moz-filter: url(filters.svg#enhance-g);
44+
-ms-filter: url(filters.svg#enhance-g);
45+
-o-filter: url(filters.svg#enhance-g);
46+
filter: url(filters.svg#enhance-g); /* Firefox 3.5+ */
47+
48+
}

filters.svg

Lines changed: 20 additions & 0 deletions
Loading

i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"accessibility-simulation" : "Provides simulation of various types of colour blindness"
3+
}

0 commit comments

Comments
 (0)