Skip to content

Instantly share code, notes, and snippets.

View joelhsmith's full-sized avatar

Joel joelhsmith

View GitHub Profile
@joelhsmith
joelhsmith / a11y-custog-config-limited.js
Last active May 18, 2018 18:02
a11y custom config example
/**
* Custom config file for running A11y audits in Lighthouse.
* Work in progress
*/
module.exports = {
passes: [{
recordTrace: true,
pauseAfterLoadMs: 5000,
useThrottling: true,
gatherers: [
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3434.0 Safari/537.36",
"lighthouseVersion": "2.9.4",
"generatedTime": "2018-05-18T18:01:56.973Z",
"initialUrl": "https://cats.com",
"url": "https://cats.com/",
"runWarnings": [],
"audits": {
"errors-in-console": {
"score": false,
<button class="menu-toggle fa fa-bars" type="button" value="toggle mobile nav"> &nbsp;</button>
@joelhsmith
joelhsmith / gist:ab8a02cf3fb32651d756b7de736a4391
Last active May 29, 2018 19:29
online-d-nav-missing-role
<ul role="navigation" id="menu-primary-header-menu" class="navbar-nav mr-auto justify-content-end top-items align-items-center d-none d-lg-flex">
<li id="menu-item-4780" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-4780 nav-item">
<a href="https://online.duke.edu/our-work/">Our Work</a>
</li>
<li id="menu-item-4833" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-4833 nav-item">
<a href="https://online.duke.edu/news/">News</a></li>
</li>
...
</ul>
@joelhsmith
joelhsmith / a11y-drupal-flexslider.js
Created June 18, 2018 16:47
Accessibility Drupal Flexslider Fix.
// # Info about Flexslider in Drupal:
// Requires jquery_update to 1.7
// Requires latest verion of Flexslider in your /libraries folder
// # Tips
// If you are using the module flexslider, this might be helpful: drupal.org/project/flexslider/issues/1580902#comment-12363103
// If you are using the module flexslider_view_slideshow, you might need this patch: drupal.org/project/flexslider/issues/1580902#comment-12363103
// If the module gives you the option to turn of aria-live, do it. Even using aria-live="polite" on a slideshow is like flipping someone off.
Drupal.behaviors.flexslider_a11y_fixes = {
@joelhsmith
joelhsmith / basic-a11y-menu.html
Last active June 19, 2018 16:48
basic-a11y-menu
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic nav</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
body {
font-size: 30px;
}
@joelhsmith
joelhsmith / a11y-simple-contrast-only.js
Created June 27, 2018 15:13
LIghthouse onlyAudits test
/**
* Config file for running just color-contrast.
*/
'use strict';
module.exports = {
extends: 'lighthouse:default',
settings: {
onlyAudits: ['color-contrast'],
@joelhsmith
joelhsmith / interactive-element-affordance.js
Last active July 13, 2018 19:23
Interactive element manual audit for Lighthouse
/**
* Interactive Element Affordance
*/
'use strict';
import ManualAudit from 'lighthouse-core'
const ManualAudit = require('../node_modules/lighthouse/lighthouse-core/audits/manual/manual-audit');
@joelhsmith
joelhsmith / gist:62e39463840aa91e7cc632b986f1e432
Created July 24, 2018 17:32
Flexslider initialization that adds aria attributes and improves it's accessibility
$(document).ready(function() {
// NOTE: I suggest using this in addition to my Fork of the Flexslider library:
// https://github.com/jhc36-duke-edu/FlexSlider (This Fork fixes empty link problems that cannot be fixed through the api.)
$('.flexslider').flexslider({
slideshow: false,
prevText: "Previous slide",
nextText: "Next slide",
animation: "fade",
@joelhsmith
joelhsmith / dedupchoice.js
Created August 3, 2018 18:05
Deduplicate the labels in choice questions in Qualtrics
const labelCheckboxeChoices = Array.from(document.querySelectorAll('.q-checkbox'));
const labelRadioChoices = Array.from(document.querySelectorAll('.q-radio'));
var labelAllChoices = labelCheckboxeChoices.concat(labelRadioChoices);
labelAllChoices.forEach(function(e) {
if (e.innerText === '') {
e.remove();
}
});