Skip to content

Commit

Permalink
Bug #8, Add accessibility_fixes() Javascript function [iet:10308781]
Browse files Browse the repository at this point in the history
* Plus, minor re-factor Javascript
  • Loading branch information
nfreear committed Mar 8, 2018
1 parent dafbb18 commit f7ca637
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 19 deletions.
11 changes: 7 additions & 4 deletions .pa11yci.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
var config = {
defaults: {
screenCapture: './_pa11y-screen-capture.png',
standard: 'WCAG2AA',
standard: 'WCAG2AA', // Or, 'WCAG2AAA'
hideElements: '.coursesearchbox', // 'Fieldset does not contain a legend element.' GitHub:squizlabs/HTML_CodeSniffer--Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js#L644
ignore: [ 'notice' ],
timeout: 5000,
wait: 1500
timeout: 8000,
wait: 1500, // 2000,
'X-verifyPage': null
},
urls: [
'${TEST_SRV}/course/?_ua=pa11y',
Expand All @@ -29,7 +31,8 @@ var config = {

function myPa11yCiConfiguration (urls, defaults) {

console.error('Env:', process.env.TEST_SRV);
console.error('Standard:', defaults.standard);
// console.error('Env:', process.env.TEST_SRV);

for (var idx = 0; idx < urls.length; idx++) {
urls[ idx ] = urls[ idx ].replace('${TEST_SRV}', process.env.TEST_SRV); // substitute(urls[ idx ]);
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ script:
- composer build
- composer test
- composer ci-test
- npm run pa11y-ci
- composer validate

after_script:
- ls -al
- npm run pa11y-ci

# End.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iet-ou/moodle-auth-ouopenid",
"description": "This plugin is a wrapper around the OpenID authentication plugin for Moodle. © The Open University.",
"description": "This plugin is a wrapper around the OpenID authentication plugin for Moodle. © The Open University (IET)",
"homepage": "https://github.com/IET-OU",
"type": "moodle-auth",
"license": "proprietary",
Expand All @@ -10,6 +10,7 @@
},
"authors": [ { "name": "Nick Freear" } ],
"autoload": {
"classmap": [ "classes/local/" ],
"psr-4": {
"IET_OU\\Moodle\\Auth\\Ouopenid\\Db\\": "db/"
}
Expand Down Expand Up @@ -85,6 +86,7 @@
"composer cn",
"# npm run semi",
"npm run eslint",
"# npm run pa11y-ci",
"php -r 'simplexml_load_file(\"db/install.xml\");' && echo install.xml OK!"
],
"mcs": "phpcs --standard=./moodle-core.xml --ignore=vendor --ignore=.git --extensions=php .",
Expand Down
15 changes: 6 additions & 9 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@ var userJsonUrl = '/auth/ouopenid/user/ajax.php?r=' + util.rand();
require('./src/when-call')(
function () {
console.debug('>> when');
return window.jQuery;
return util.set_jQuery();
},
function ($) {
var W = window;
var L = W.location;

function ($, W) {
console.debug('>> call');

if (L.pathname.match(/^\/admin\//)) {
if (util.is_admin_page()) {
return console.warn('ouopenid: admin page, exiting.');
}

var $body = $('body');
var is_enrollment_page = $('#page-local-tesla-views-enrollment').length;

$body.addClass(L.href.match(/debug=1/) ? 'debug-param' : '');
$body.addClass(util.is_debug_param() ? 'debug-param' : '');

userJsonUrl += ( is_enrollment_page ? '&longtexts=true' : '' );
userJsonUrl += ( util.is_tesla_enrol_page() ? '&longtexts=true' : '' );

console.warn('ouopenid $:', $.fn.jquery, BUILD_TIME, W.M.cfg); // W.Y.version

Expand All @@ -41,6 +37,7 @@ require('./src/when-call')(
util.set_strings(data);
util.set_course_name($, data);
util.site_message($, data);
util.accessibility_fixes();

data.util = util;
data.$ = $;
Expand Down
35 changes: 35 additions & 0 deletions js/src/ouop-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
// Javascript translation/localisation [i18n].
var trans = {};

var L = window.location;
var $;

module.exports = {

set_jQuery: function () {
$ = window.jQuery;
return $;
},

is_debug_param: function () {
return L.href.match(/debug=1/);
},

is_admin_page: function () {
return L.pathname.match(/^\/admin\//);
},

is_tesla_enrol_page: function () {
return $('#page-local-tesla-views-enrollment').length;
},

rand: function () {
var min = 11;
var max = 9999;
Expand Down Expand Up @@ -45,6 +65,21 @@ module.exports = {
}
},

accessibility_fixes: function () {
var a11y_fixes = {
'fieldset.coursesearchbox': {
title: 'Search courses',
'aria-label': 'Search'
}
};

$.each(a11y_fixes, function (sel, attrs) {
$(sel).attr(attrs);
});

console.warn('A11y fixes:', a11y_fixes);
},

replace: replace_object,
less_test: ouop_less_test
};
Expand Down
8 changes: 5 additions & 3 deletions js/src/when-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
module.exports = function (whenTrueFN, callbackFN, interval) {
'use strict';

var intId = window.setInterval(function () {
var WIN = window;

var intId = WIN.setInterval(function () {
var result = whenTrueFN();
if (result) {
window.clearInterval(intId);
callbackFN(result);
WIN.clearInterval(intId);
callbackFN(result, WIN);
}
}, interval || 300); // Milliseconds.
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"replace": "^0.3.0",
"semistandard": "^11.0.0",
"uglify-js": "^3.3.12",
"uncomment-cli": "https://github.com/nfreear/uncomment-cli.git#0.9.0"
"uncomment-cli": "git+https://github.com/nfreear/uncomment-cli.git#0.9.0"
},
"x-deps": {
"envify": "^4.1.0",
Expand Down
3 changes: 3 additions & 0 deletions style/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ body {
li {
margin-top: 0.6em;
}
a {
color: #0080a7;
}
abbr {
border-bottom: 1px dotted #aaa;
cursor: help;
Expand Down

0 comments on commit f7ca637

Please sign in to comment.