Skip to content

Commit

Permalink
Make category filters form wcag 2.0 Accessibility compliant. Fixes jo…
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Nov 4, 2016
1 parent 4ebf7c0 commit 40defc9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 42 deletions.
78 changes: 36 additions & 42 deletions components/com_content/views/category/tmpl/default_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@
}
}
}
?>

// For B/C we also add the css classes inline. This will be removed in 4.0.
JFactory::getDocument()->addStyleDeclaration("
.hide { display: none; }
.table-noheader { border-collapse: collapse; }
.table-noheader thead { display: none; }
");

$tableClass = $this->params->get('show_headings') != 1 ? ' table-noheader' : '';
?>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
<?php if ($this->params->get('show_headings') || $this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) : ?>
<fieldset class="filters btn-toolbar clearfix">
<legend class="hide"><?php echo JText::_('COM_CONTENT_FORM_FILTER_LEGEND'); ?></legend>
<?php if ($this->params->get('filter_field') != 'hide') :?>
<div class="btn-group">
<?php if ($this->params->get('filter_field') != 'tag') :?>
Expand Down Expand Up @@ -65,43 +74,29 @@
<input type="hidden" name="limitstart" value="" />
<input type="hidden" name="task" value="" />
</fieldset>

<div class="control-group hide pull-right">
<div class="controls">
<button type="submit" name="filter_submit" class="btn btn-primary"><?php echo JText::_('COM_CONTENT_FORM_FILTER_SUBMIT'); ?></button>
</div>
</div>

<?php endif; ?>

<?php if (empty($this->items)) : ?>

<?php if ($this->params->get('show_no_articles', 1)) : ?>
<p><?php echo JText::_('COM_CONTENT_NO_ARTICLES'); ?></p>
<?php endif; ?>

<?php else : ?>

<table class="category table table-striped table-bordered table-hover">
<?php
$headerTitle = '';
$headerDate = '';
$headerAuthor = '';
$headerHits = '';
$headerVotes = '';
$headerRatings = '';
$headerEdit = '';
?>
<?php if ($this->params->get('show_headings')) : ?>
<?php
$headerTitle = 'headers="categorylist_header_title"';
$headerDate = 'headers="categorylist_header_date"';
$headerAuthor = 'headers="categorylist_header_author"';
$headerHits = 'headers="categorylist_header_hits"';
$headerVotes = 'headers="categorylist_header_votes"';
$headerRatings = 'headers="categorylist_header_ratings"';
$headerEdit = 'headers="categorylist_header_edit"';
?>
<thead>
<table class="category table table-striped table-bordered table-hover<?php echo $tableClass; ?>">
<caption class="hide"><?php echo JText::sprintf('COM_CONTENT_CATEGORY_LIST_TABLE_CAPTION', $this->category->title); ?></caption>
<thead>
<tr>
<th id="categorylist_header_title">
<th scope="col" id="categorylist_header_title">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<?php if ($date = $this->params->get('list_show_date')) : ?>
<th id="categorylist_header_date">
<th scope="col" id="categorylist_header_date">
<?php if ($date == "created") : ?>
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_' . $date . '_DATE', 'a.created', $listDirn, $listOrder); ?>
<?php elseif ($date == "modified") : ?>
Expand All @@ -112,39 +107,38 @@
</th>
<?php endif; ?>
<?php if ($this->params->get('list_show_author')) : ?>
<th id="categorylist_header_author">
<th scope="col" id="categorylist_header_author">
<?php echo JHtml::_('grid.sort', 'JAUTHOR', 'author', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if ($this->params->get('list_show_hits')) : ?>
<th id="categorylist_header_hits">
<th scope="col" id="categorylist_header_hits">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<th id="categorylist_header_votes">
<th scope="col" id="categorylist_header_votes">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_VOTES', 'rating_count', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<th id="categorylist_header_ratings">
<th scope="col" id="categorylist_header_ratings">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_RATINGS', 'rating', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if ($isEditable) : ?>
<th id="categorylist_header_edit"><?php echo JText::_('COM_CONTENT_EDIT_ITEM'); ?></th>
<th scope="col" id="categorylist_header_edit"><?php echo JText::_('COM_CONTENT_EDIT_ITEM'); ?></th>
<?php endif; ?>
</tr>
</thead>
<?php endif; ?>
</thead>
<tbody>
<?php foreach ($this->items as $i => $article) : ?>
<?php if ($this->items[$i]->state == 0) : ?>
<tr class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else: ?>
<tr class="cat-list-row<?php echo $i % 2; ?>" >
<?php endif; ?>
<td <?php echo $headerTitle; ?> class="list-title">
<td headers="categorylist_header_title" class="list-title">
<?php if (in_array($article->access, $this->user->getAuthorisedViewLevels())) : ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language)); ?>">
<?php echo $this->escape($article->title); ?>
Expand Down Expand Up @@ -203,7 +197,7 @@
<?php endif; ?>
</td>
<?php if ($this->params->get('list_show_date')) : ?>
<td <?php echo $headerDate; ?> class="list-date small">
<td headers="categorylist_header_date" class="list-date small">
<?php
echo JHtml::_(
'date', $article->displayDate,
Expand All @@ -212,7 +206,7 @@
</td>
<?php endif; ?>
<?php if ($this->params->get('list_show_author', 1)) : ?>
<td <?php echo $headerAuthor; ?> class="list-author">
<td headers="categorylist_header_author" class="list-author">
<?php if (!empty($article->author) || !empty($article->created_by_alias)) : ?>
<?php $author = $article->author ?>
<?php $author = ($article->created_by_alias ? $article->created_by_alias : $author); ?>
Expand All @@ -225,28 +219,28 @@
</td>
<?php endif; ?>
<?php if ($this->params->get('list_show_hits', 1)) : ?>
<td <?php echo $headerHits; ?> class="list-hits">
<td headers="categorylist_header_hits" class="list-hits">
<span class="badge badge-info">
<?php echo JText::sprintf('JGLOBAL_HITS_COUNT', $article->hits); ?>
</span>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<td <?php echo $headerVotes; ?> class="list-votes">
<td headers="categorylist_header_votes" class="list-votes">
<span class="badge badge-success">
<?php echo JText::sprintf('COM_CONTENT_VOTES_COUNT', $article->rating_count); ?>
</span>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<td <?php echo $headerRatings; ?> class="list-ratings">
<td headers="categorylist_header_ratings" class="list-ratings">
<span class="badge badge-warning">
<?php echo JText::sprintf('COM_CONTENT_RATINGS_COUNT', $article->rating); ?>
</span>
</td>
<?php endif; ?>
<?php if ($isEditable) : ?>
<td <?php echo $headerEdit; ?> class="list-edit">
<td headers="categorylist_header_edit" class="list-edit">
<?php if ($article->params->get('access-edit')) : ?>
<?php echo JHtml::_('icon.edit', $article, $params); ?>
<?php endif; ?>
Expand Down
3 changes: 3 additions & 0 deletions language/en-GB/en-GB.com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND="Parent category not found"
COM_CONTENT_FEED_READMORE="Read More ..."
COM_CONTENT_FILTER_SEARCH_DESC="Content Filter Search"
COM_CONTENT_FORM_EDIT_ARTICLE="Edit an article"
COM_CONTENT_FORM_FILTER_LEGEND="Filters"
COM_CONTENT_FORM_FILTER_SUBMIT="Filter"
COM_CONTENT_CATEGORY_LIST_TABLE_CAPTION="List of articles in category %s"
COM_CONTENT_HEADING_TITLE="Title"
COM_CONTENT_HITS_FILTER_LABEL="Hits Filter"
COM_CONTENT_INTROTEXT="Article must have some content."
Expand Down
11 changes: 11 additions & 0 deletions media/jui/less/tables.less
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,14 @@ table th[class*="span"],
background-color: darken(@infoBackground, 5%);
}
}


// TABLE WITHOUT HEADER
// -----------------
// Table with table header hidden
.table-noheader {
border-collapse: collapse;
thead {
display: none;
}
}
6 changes: 6 additions & 0 deletions templates/protostar/css/template.css
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,12 @@ table th[class*="span"],
.table-hover tbody tr.info:hover > td {
background-color: #c4e3f3;
}
.table-noheader {
border-collapse: collapse;
}
.table-noheader thead {
display: none;
}
.dropup,
.dropdown {
position: relative;
Expand Down

0 comments on commit 40defc9

Please sign in to comment.