-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Khan/magic-wand
Add magic wand feature.
- Loading branch information
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Allows users to see what screen readers would see. | ||
*/ | ||
|
||
let $ = require("jquery"); | ||
let Plugin = require("../base"); | ||
|
||
require("./style.less"); | ||
|
||
class A11yTextWand extends Plugin { | ||
getTitle() { | ||
return "Screen Reader Wand"; | ||
} | ||
|
||
getDescription() { | ||
return "Hover over elements to view them as a screen reader would"; | ||
} | ||
|
||
run() { | ||
// HACK(jordan): We provide a fake summary to force the info panel to | ||
// render. | ||
this.summary(" "); | ||
this.panel.render(); | ||
|
||
$(document).on("mousemove.wand", function(e) { | ||
let element = document.elementFromPoint(e.clientX, e.clientY); | ||
|
||
let textAlternative = $.axs.properties.findTextAlternatives( | ||
element, {}); | ||
|
||
$(".tota11y-outlined").removeClass("tota11y-outlined"); | ||
$(element).addClass("tota11y-outlined"); | ||
|
||
if (!textAlternative) { | ||
$(".tota11y-info-section.active").html( | ||
<i className="tota11y-nothingness"> | ||
No text visible to a screen reader | ||
</i> | ||
); | ||
} else { | ||
$(".tota11y-info-section.active").text(textAlternative); | ||
} | ||
}); | ||
} | ||
|
||
cleanup() { | ||
$(document).off("mousemove.wand"); | ||
} | ||
} | ||
|
||
module.exports = A11yTextWand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import "../../less/variables.less"; | ||
|
||
.tota11y-outlined { | ||
outline: 2px solid fadein(@highlightColor, 100%); | ||
} | ||
|
||
.tota11y-nothingness { | ||
color: #888; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ | |
&-section { | ||
.position(absolute, 0, 0, 0, 0); | ||
|
||
& * { | ||
&, * { | ||
color: @darkGray; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters