From 2aecbd712d59734ebd749a7fb2614c4c36b1a255 Mon Sep 17 00:00:00 2001 From: aeschylus Date: Thu, 18 Feb 2016 17:41:29 -0800 Subject: [PATCH] Adds accessibility features to browse-nearby --- .../embedded-call-number-browse.js | 12 +++---- .../stylesheets/modules/browse-embed.scss | 4 +-- app/helpers/browse_helper.rb | 36 ++++++++++--------- .../record/_callnumber_browse.html.erb | 2 +- spec/helpers/browse_helper_spec.rb | 19 ++++------ .../_callnumber_browse.html.erb_spec.rb | 11 +++--- 6 files changed, 40 insertions(+), 44 deletions(-) diff --git a/app/assets/javascripts/embedded-call-number-browse.js b/app/assets/javascripts/embedded-call-number-browse.js index 3b9842306..e94a9180d 100644 --- a/app/assets/javascripts/embedded-call-number-browse.js +++ b/app/assets/javascripts/embedded-call-number-browse.js @@ -22,10 +22,9 @@ this.startDoc = item.data('start'); this.embedContainer = this.embedViewport.find('.gallery'); this.url = item.data('url'); - this.browseUrl = item.attr('href'); + this.browseUrl = item.data('index-path'); this.docs = []; this.currentDoc = this.startDoc; - this.updateHref(); }; GalleryDocs.prototype.updateDocs = function() { @@ -52,11 +51,6 @@ return $.inArray(this.currentDoc, this.docs); }; - // Updates the href to activate plugin for javascript enabled browsers - GalleryDocs.prototype.updateHref = function() { - this.item.attr("href", this.item.data('embed-viewport')); - }; - // Calculates how many docs can be viewed in the viewport GalleryDocs.prototype.calculateDocsPerView = function() { var width = $(this.embedViewport).outerWidth(); @@ -108,14 +102,18 @@ function openThisBrowser() { if ($galleryDoc.item.hasClass('collapsed')){ $galleryDoc.item.removeClass('collapsed').addClass('active'); + $galleryDoc.item.attr('aria-expanded', 'true'); + $galleryDoc.embedViewport.attr('aria-expanded', 'true'); $galleryDoc.embedViewport.slideDown(function(){ $galleryDoc.calculateDocsPerView(); showPreview(); }); }else{ $galleryDoc.item.addClass('collapsed'); + $galleryDoc.item.attr('aria-expanded', 'false'); $galleryDoc.embedViewport.slideUp(function(){ }); + $galleryDoc.embedViewport.attr('aria-expanded', 'false'); } } diff --git a/app/assets/stylesheets/modules/browse-embed.scss b/app/assets/stylesheets/modules/browse-embed.scss index e5d751606..006f12d6e 100644 --- a/app/assets/stylesheets/modules/browse-embed.scss +++ b/app/assets/stylesheets/modules/browse-embed.scss @@ -1,9 +1,9 @@ -.callnumber a.collapsed { +.callnumber button.collapsed { @extend .btn; @extend .btn-default; } -.callnumber a { +.callnumber button { @extend .btn; @extend .btn-default; } diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index c1aae6836..1bb83231f 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,23 +1,25 @@ module BrowseHelper def link_to_callnumber_browse(document, callnumber, index = 0) - link_to( + button_tag( callnumber.callnumber, - browse_index_path( - start: document[:id], - barcode: (callnumber.barcode unless callnumber.barcode == document[:preferred_barcode]), - view: :gallery - ), class: "collapsed", - id: "callnumber-browse-#{index}", - "aria-labelledby" => "callnumber-browse-#{index}", - data: { behavior: "embed-browse", - start: document[:id], - embed_viewport: "#callnumber-#{index}", - url: browse_nearby_path( - start: document[:id], - barcode: (callnumber.barcode unless callnumber.barcode == document[:preferred_barcode]), - view: :gallery - ) - } + class: "collapsed", + id: "callnumber-browse-#{index}", + "aria-labelledby" => "callnumber-browse-#{index}", + "aria-expanded" => "true", + data: { behavior: "embed-browse", + start: document[:id], + embed_viewport: "#callnumber-#{index}", + index_path: browse_index_path( + start: document[:id], + barcode: (callnumber.barcode unless callnumber.barcode == document[:preferred_barcode]), + view: :gallery + ), + url: browse_nearby_path( + start: document[:id], + barcode: (callnumber.barcode unless callnumber.barcode == document[:preferred_barcode]), + view: :gallery + ) + } ) end end diff --git a/app/views/catalog/record/_callnumber_browse.html.erb b/app/views/catalog/record/_callnumber_browse.html.erb index 6e4264a9a..5b394f114 100644 --- a/app/views/catalog/record/_callnumber_browse.html.erb +++ b/app/views/catalog/record/_callnumber_browse.html.erb @@ -20,7 +20,7 @@ <% document.holdings.browsable_callnumbers.each_with_index do |callnumber, index| %> -
+