diff --git a/common/static/common/js/components/views/paginated_view.js b/common/static/common/js/components/views/paginated_view.js index 405128b3b3..0507d52cbd 100644 --- a/common/static/common/js/components/views/paginated_view.js +++ b/common/static/common/js/components/views/paginated_view.js @@ -1,3 +1,19 @@ +/** + * A base class for a view which renders and paginates a collection, + * along with a header and footer displaying controls for + * pagination. + * + * Subclasses should define a `type` property which will be used to + * create class names for the different subcomponents, as well as an + * `itemViewClass` which will be used to display each individual + * element of the collection. + * + * If provided, the `srInfo` property will be used to provide + * information for screen readers on each item. The `srInfo.text` + * property will be shown in the header, and the `srInfo.id` property + * will be used to connect each card's title with the header text via + * the ARIA describedby attribute. + */ ;(function(define) { 'use strict'; define([ @@ -24,7 +40,7 @@ }, createHeaderView: function() { - return new PagingHeader({collection: this.options.collection}); + return new PagingHeader({collection: this.options.collection, srInfo: this.srInfo}); }, createFooterView: function() { diff --git a/common/static/common/js/components/views/paging_header.js b/common/static/common/js/components/views/paging_header.js index 3bed5147b1..bd5e741778 100644 --- a/common/static/common/js/components/views/paging_header.js +++ b/common/static/common/js/components/views/paging_header.js @@ -8,6 +8,7 @@ ], function (Backbone, _, gettext, headerTemplate) { var PagingHeader = Backbone.View.extend({ initialize: function (options) { + this.srInfo = options.srInfo; this.collections = options.collection; this.collection.bind('add', _.bind(this.render, this)); this.collection.bind('remove', _.bind(this.render, this)); @@ -28,7 +29,10 @@ context, true ); } - this.$el.html(_.template(headerTemplate, {message: message})); + this.$el.html(_.template(headerTemplate, { + message: message, + srInfo: this.srInfo + })); return this; } }); diff --git a/common/static/common/templates/components/paginated-view.underscore b/common/static/common/templates/components/paginated-view.underscore index 09ea0a13b4..7a01eff6a5 100644 --- a/common/static/common/templates/components/paginated-view.underscore +++ b/common/static/common/templates/components/paginated-view.underscore @@ -1,4 +1,4 @@
- +<%- description %>