Thanks! I'll try, but I don't like js and I always try to maximally minimize its usage,
I'm using php scripts when possible, It's much more rock solid. So I'm not js master at all,
but I'll try, if I'll found out how to save its state, I'll post the solution here. The solution
require removing all code you've posted, to prevent header collapse by core code.
HERE IT IS. It will change "collapse" image and image alt/title attributes according to
header content visibility and save header state to
header_state cookie as true or false. Then,
on page reload, it will check this cookie and change header content visibility according to
header_state cookie.
Сollapse img code id should be
#header_collapse, its
src should be
src="{$theme['imgdir']}/collapse.png",
initial alt/title attributes should be "[-]" header content div id should be
#header_content. Here is the code:
<script type="text/javascript">
jQuery(document).ready(function($) {
if (Cookies.get('header-state') === 'false') {
$('#header_content').css('display', 'none');
document.getElementById('header_collapse').src = 'https://your.site/images/collapse_collapsed.png';
document.getElementById('header_collapse').title = '[+]';
document.getElementById('header_collapse').alt = '[+]'; }
$('#header_collapse').on('click', function() {
$('#header_content').toggle('fast', function() {
Cookies.set('header-state', $('#header_content').is(':visible'), { expires: 365, path:'/' });
if ($('#header_content').is(':visible')) {
document.getElementById('header_collapse').src = 'https://your.site/images/collapse.png';
document.getElementById('header_collapse').title = '[-]';
document.getElementById('header_collapse').alt = '[-]'; }
else { document.getElementById('header_collapse').src = 'https://your.site/images/collapse_collapsed.png';
document.getElementById('header_collapse').title = '[+]';
document.getElementById('header_collapse').alt = '[+]'; }
});
});
});
</script>
Thank you for the tips, .m.!
Maybe I'll create such modification in future, to add custom "collapse" buttons, when I'll decide that this function is perfect.
But, on the other hand, this code is pretty easy to adopt to every theme, because you just need to set correct ids of collapse image and of header content div,
so if someone will need it, I think he'll find this topic easily.