Шаблон:Collapse: различия между версиями

Материал из hpluswiki
Перейти к навигации Перейти к поиску
Нет описания правки
Нет описания правки
 
(не показано 45 промежуточных версий этого же участника)
Строка 1: Строка 1:
<noinclude>
<includeonly>
{{Documentation}}
<div class="mw-collapsible mw-collapsed" style="width:100%; solid #aaa; margin-bottom:10px;">
</noinclude><includeonly>
  <div class="mw-collapsible-toggle" style="font-weight:bold; background:#f8f9fa; padding:5px;">
<div class="mw-collapsible" style="width:100%;">
    {{{1|Заголовок}}}
<div style="display:flex; justify-content:space-between; align-items:center; cursor:pointer;"
  </div>
    onclick="toggleCollapse(this)">
  <div class="mw-collapsible-content" style="padding:10px;">
<span style="font-weight:bold;">{{{1|Заголовок}}}</span>
    {{{2|Содержимое}}}
<span class="collapse-arrow"></span>
  </div>
</div>
</div>
<div class="collapse-content" style="padding:5px 0 0 10px; display:none;">
<div style="clear: both;"></div>  
{{{2|Содержимое блока}}}
</div>
</div>
 
<script type="text/javascript">
function toggleCollapse(element) {
  const content = element.nextElementSibling;
  const arrow = element.querySelector('.collapse-arrow');
  content.style.display = content.style.display === 'none' ? 'block' : 'none';
  arrow.textContent = content.style.display === 'none' ? '▶' : '▼';
}
 
// Инициализация при загрузке
document.addEventListener('DOMContentLoaded', function() {
  document.querySelectorAll('.mw-collapsible').forEach(el => {
    const content = el.querySelector('.collapse-content');
    const arrow = el.querySelector('.collapse-arrow');
    if (content) content.style.display = 'none';
    if (arrow) arrow.textContent = '▶';
  });
});
</script>
</includeonly>
</includeonly>

Текущая версия от 22:17, 9 мая 2025