Skip to content

Instantly share code, notes, and snippets.

@ckundo
Last active January 4, 2016 07:19
Show Gist options
  • Save ckundo/8587550 to your computer and use it in GitHub Desktop.
Save ckundo/8587550 to your computer and use it in GitHub Desktop.
// requires axs_testing.js from https://github.com/GoogleChrome/accessibility-developer-tools
accessible = {};
accessible.highContrastMode = function() {
var elementsWithText = $('body *:not(:has(*))').filter(function() {
var $this = $(this);
return $.trim($this.text()).length > 0 && $this.prop('tagName') !== 'IFRAME';
});
$(elementsWithText).each(function(i, el) {
var properties = axs.properties.getColorProperties(el);
if(properties.contrastRatio.suggestedColors && properties.contrastRatio.value < 4.5){
el.style.color = properties.contrastRatio.suggestedColors.AA.fg;
el.style.backgroundColor = properties.contrastRatio.suggestedColors.AA.bg;
};
});
};
accessible.highContrastMode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment