I have stolen a user macro for "Expand All" from this forum, but my users have asked if it is possible to make the text in the button change based on the state of the page.
So it toggles between "Expand" or "Collapse" based on whether the button has been clicked.
This is the macro I have used, but not sure how to change to get dynamic button name:
## Macro title: Expand All
## Macro has a body: N
## Developed by: George Lewe
## Date created: 2014-09-22
## Installed by: George Lewe
## @noparams
<p align="left"><button name="toggleAll" id="toggleAll" type="button" class="aui-button" aria-pressed="false" style="background-color:blue;color:white;font-weight:bold">Expand All / Collapse All</button></p>
<script type="text/javascript">
AJS.toInit(function ()
{
AJS.$('#toggleAll').click(function()
{
var expanded = jQuery(".expand-icon.aui-iconfont-chevron-down").closest("div");
var unexpanded = jQuery(".expand-icon.aui-iconfont-chevron-right").closest("div");
if (expanded.size() > unexpanded.size()) {
expanded.each(function(){ jQuery(this).trigger("click");})
} else {
unexpanded.each(function(){ jQuery(this).trigger("click");})
}
});
});
</script>