Skip to content

Commit

Permalink
Changed share widget popup link to heading. Preventing closing of pop…
Browse files Browse the repository at this point in the history
…up when tabbing back to the hide link. Moved title from span to link to avoid screen readers reading the information twice.
  • Loading branch information
Paul Jackson authored and Paul Jackson committed Jul 30, 2012
1 parent e844413 commit ef9ce3a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build/js/css/pe-ap-ie-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/css/pe-ap-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions src/js/dependencies/bookmark.js
Expand Up @@ -413,10 +413,6 @@ $('div selector').bookmark({sites: ['delicious', 'digg']});
});
$(document).click(function (event) { // Close on external click
target.find('.bookmark_popup').hide();
/*var $popup = target.find('.bookmark_popup');
if (!$(event.target).is($popup) && !$(event.target).is($popupText) && $(event.target).closest($popup).length === 0) { // WET-BOEW Change
target.find($popup).hide();
}*/
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/js/i18n/formvalid/messages_fr.js
@@ -1,5 +1,5 @@
/*
* Translated default and additional messages for the jQuery validation plugin.
* Translated default messages for the jQuery validation plugin.
* Locale: FR
*/
jQuery.extend(jQuery.validator.messages, {
Expand Down
10 changes: 10 additions & 0 deletions src/js/sass/share.scss
Expand Up @@ -14,6 +14,16 @@ div.wet-boew-share {
float:right;
}

#wb-main {
.wet-boew-share {
h2, h3 {
font-size: 1em;
margin: 0;
font-weight: normal;
}
}
}

.wet-boew-share {
text-align:right;
.bookmark_popup_text{
Expand Down
44 changes: 27 additions & 17 deletions src/js/workers/share.js
Expand Up @@ -28,6 +28,7 @@
compact: false, // True if a compact presentation should be used, false for full
hint: pe.dic.get('%share-text') + pe.dic.get('%share-hint'), // Popup hint for links, {s} is replaced by display name
popup: true, // True to have it popup on demand, false to show always
popupTag: 'h2', // Parent tag for the popup link (should be either h2 or h3)
popupText: pe.dic.get('%share-text'), // Text for the popup trigger
hideText: (pe.dic.get('%hide') + " - "), // Text to prepend to the popup trigger when popup is open
addFavorite: false, // True to add a 'add to favourites' link, false for none
Expand Down Expand Up @@ -70,8 +71,19 @@
elm.bookmark(opts);
if (opts.popup && pe.cssenabled) {
elm.attr('role', 'application');
if (opts.popupTag.substring(0, 1) === 'h') { // If a heading element is used for the popup tag, then wrap the contents in a section element
elm.wrapInner('<section />');
}
$popup = elm.find('.bookmark_popup').attr('id', 'bookmark_popup').attr('aria-hidden', 'true').attr('role', 'menu').prepend('<p class="popup_title">' + opts.popupText + '</p>');
$popupLinks = $popup.find('li').attr('role', 'presentation').find('a').attr('role', 'menuitem');
$popupLinks = $popup.find('li').attr('role', 'presentation').find('a').attr('role', 'menuitem').each(function () {
// TODO: Should work with authot to fix in bookmark.js rather than maintain this workaround (fix needed otherwise some screen readers read the link twice)
var $this = $(this),
$span = $this.children('span');
if ($span.length > 0) {
$this.attr('title', $span.attr('title'));
$span.removeAttr('title');
}
});

$popup.on("click vclick", function (e) {
if (e.stopPropagation) {
Expand All @@ -80,22 +92,21 @@
e.cancelBubble = true;
}
});
$popupText = elm.find('.bookmark_popup_text').off('click vclick keydown');
$popupText = elm.find('.bookmark_popup_text').off('click vclick keydown').wrap('<' + opts.popupTag + ' />');
$popupText.attr('role', 'button').attr('aria-controls', 'bookmark_popup').attr('aria-pressed', 'false').on("click vclick keydown", function (e) {
if (e.type === "keydown" && (!(e.ctrlKey || e.altKey || e.metaKey))) {
switch (e.keyCode) {
case 13: // enter key
$popup.trigger("open");
return false;
case 32: // spacebar
$popup.trigger("open");
return false;
case 38: // up arrow
$popup.trigger("open");
return false;
case 40: // down arrow
$popup.trigger("open");
return false;
if (e.type === "keydown") {
if (!(e.ctrlKey || e.altKey || e.metaKey)) {
if (e.keyCode === 13 || e.keyCode === 32) { // enter or space
e.preventDefault();
if ($popup.attr('aria-hidden') === 'true') {
$popup.trigger("open");
} else {
$popup.trigger("close");
}
} else if (e.keyCode === 38 || e.keyCode === 40) { // up or down arrow
e.preventDefault();
$popup.trigger("open");
}
}
} else {
if ($popup.attr('aria-hidden') === 'true') {
Expand Down Expand Up @@ -218,7 +229,6 @@
});

$(document).on("click vclick touchstart", function (e) {
var target = $(e.target);
if ($popup.attr('aria-hidden') === 'false') {
$popup.trigger("close");
}
Expand Down

0 comments on commit ef9ce3a

Please sign in to comment.