diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-08 11:46:22 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-08 11:46:22 +0000 |
commit | 8b4ac207ca1ea76dc000969314b871aa3f85d343 (patch) | |
tree | bfe278ab7fc38ba63df75e49d06cc1fc0c8543cc /misc/collapse.js | |
parent | 2bc18b615540ca4ba41cf79a27fd900835bea989 (diff) | |
download | brdo-8b4ac207ca1ea76dc000969314b871aa3f85d343.tar.gz brdo-8b4ac207ca1ea76dc000969314b871aa3f85d343.tar.bz2 |
#541568 by brandonojc, mgifford, Everett Zufelt, and sun: Fixed Link to expand / collapse fieldsets has poorly accessible link text.
Diffstat (limited to 'misc/collapse.js')
-rw-r--r-- | misc/collapse.js | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/misc/collapse.js b/misc/collapse.js index 6da082452..a976345dc 100644 --- a/misc/collapse.js +++ b/misc/collapse.js @@ -11,7 +11,10 @@ Drupal.toggleFieldset = function (fieldset) { var content = $('> div:not(.action)', fieldset); $(fieldset) .removeClass('collapsed') - .trigger({ type: 'collapsed', value: false }); + .trigger({ type: 'collapsed', value: false }) + .find('> legend > a > span.element-invisible') + .empty() + .append(Drupal.t('Hide')); content.hide(); content.slideDown({ duration: 'fast', @@ -31,7 +34,10 @@ Drupal.toggleFieldset = function (fieldset) { $('div.action', fieldset).hide(); $(fieldset).trigger({ type: 'collapsed', value: true }); var content = $('> div:not(.action)', fieldset).slideUp('fast', function () { - $(this.parentNode).addClass('collapsed'); + $(this.parentNode).addClass('collapsed') + .find('> legend > a > span.element-invisible') + .empty() + .append(Drupal.t('Show')); this.parentNode.animating = false; }); } @@ -75,15 +81,22 @@ Drupal.behaviors.collapse = { // Turn the legend into a clickable link and wrap the contents of the // fieldset in a div for easier animation. var text = this.innerHTML; - $(this).empty().append($('<a href="#">' + text + '</a>').click(function () { - var fieldset = $(this).parents('fieldset:first')[0]; - // Don't animate multiple times. - if (!fieldset.animating) { - fieldset.animating = true; - Drupal.toggleFieldset(fieldset); - } - return false; - })) + $(this).empty() + .append($('<a href="#">' + text + '</a>') + .click(function () { + var fieldset = $(this).parents('fieldset:first')[0]; + // Don't animate multiple times. + if (!fieldset.animating) { + fieldset.animating = true; + Drupal.toggleFieldset(fieldset); + } + return false; + }) + .prepend($('<span class="element-invisible"></span>') + .append(fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide')) + .after(' ') + ) + ) .append(summary) .after( $('<div class="fieldset-wrapper"></div>') |