Toggle icon Plus/Minus when expanding/collapsing

Ported to com_weblinks from a similar PR in core
(https://github.com/joomla/joomla-cms/pull/5469)
This commit is contained in:
Sergio Manzi 2014-12-19 11:21:11 +01:00
parent 8008a986b9
commit 93a093441c
2 changed files with 14 additions and 1 deletions

View File

@ -11,6 +11,18 @@ defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JHtml::_('behavior.caption');
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');
});
});
});");
echo JLayoutHelper::render('joomla.content.categories_default', $this);
echo $this->loadTemplate('items');
?>

View File

@ -34,7 +34,8 @@ if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) :
</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_subcat_desc_cat') == 1) :?>