Skip to content

Instantly share code, notes, and snippets.

@jonlow
Last active August 29, 2015 14:06
Show Gist options
  • Save jonlow/13c0aabc84f511b47afa to your computer and use it in GitHub Desktop.
Save jonlow/13c0aabc84f511b47afa to your computer and use it in GitHub Desktop.
Show completed text for screen readers on explore pages. When a an explore button is clicked, this appends some text to the explore button. The text should instruct screen reader users that they have already interacted with the button/popup.
<script>
$(document).ready(function () {
T2.CreateButton.prototype.run = (function(_super) {
return function() {
// This adds some visually hidden text for screen readers.
// Change the text so it makes sense in context with your explore page
if(!this.completed)
this.elements.link[0].innerHTML += ' <span class="visuallyhidden">completed</span>';
return _super.apply(this);
};
})(T2.CreateButton.prototype.run);
});
</script>
@jonlow
Copy link
Author

jonlow commented Aug 14, 2015

If the function has an argument, then you need to pass it to apply() in an array:

T2.page.popup.open = (function(_super) {
    return function(popupNumber) {

      debugger;
        return _super.apply(this,[popupNumber]);
    };

  })(T2.page.popup.open);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment