Skip to content

Commit

Permalink
Bonus: toggle categories buttons
Browse files Browse the repository at this point in the history
When expanding/collapsing categories, toggle the button from '+' to '-'
  • Loading branch information
smz committed Dec 19, 2014
1 parent 84d13af commit 1354bce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
</span>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0 && $this->maxLevelcat > 1) : ?>
<a href="#category-<?php echo $item->id;?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<a id="category-btn-<?php echo $item->id;?>" href="#category-<?php echo $item->id;?>"
data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php endif;?>
</h3>
<?php if ($this->params->get('show_description_image') && $item->getParams()->get('image')) : ?>
Expand Down
11 changes: 11 additions & 0 deletions layouts/joomla/content/categories_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

defined('_JEXEC') or die;

JFactory::getDocument()->addScriptDeclaration("
jQuery(function($) {
$('.categories-list').find('[id^=category-btn-]').each(function(index, btn) {
var btn = $(btn);
btn.on('click', function() {
btn.find('span').toggleClass('icon-plus');
btn.find('span').toggleClass('icon-minus');
});
});
});");

?>
<div class="categories-list<?php echo $displayData->pageclass_sfx;?>">
<?php if ($displayData->params->get('show_page_heading')) : ?>
Expand Down

0 comments on commit 1354bce

Please sign in to comment.