MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 1: Строка 1:
document.querySelectorAll('.recipe-list li').forEach(function(item) {
<script>
  if (item.classList.contains('instruction')) return;
document.addEventListener('DOMContentLoaded', function () {
  if (item === item.parentElement.lastElementChild) return;
  document.querySelectorAll('.recipe-card').forEach(function (card) {
  if (item.querySelector('.chem-icon')) return;  
    var borderColor = card.getAttribute('data-border');
    if (borderColor) {
      card.style.borderColor = borderColor;
      card.querySelectorAll('.collapsible-content').forEach(function (block) {
        block.style.borderLeftColor = borderColor;
      });
    }
  });


   var icon = document.createElement('img');
   document.querySelectorAll('.recipe-list li').forEach(function (item) {
  icon.className = 'chem-icon';
    if (item.classList.contains('instruction')) return;
  icon.src = 'Beaker.png';
    if (item.querySelector('.chem-icon')) return;
  item.insertBefore(icon, item.firstChild);
 
});
    var icon = document.createElement('img');
    icon.className = 'chem-icon';
    icon.src = 'Beaker.png';
    item.insertBefore(icon, item.firstChild);
  });


$('.collapsible-header').click(function() {
   document.querySelectorAll('.collapsible-header').forEach(function (header) {
   var content = $(this).next('.collapsible-content');
     header.addEventListener('click', function () {
  content.slideToggle(300, function() {
       var content = this.nextElementSibling;
     $(this).find('li').each(function(index) {
      content.classList.toggle('active');
       $(this).css('animation-delay', (index * 0.1) + 's')
            .toggleClass('visible', $(this).is(':visible'));
     });
     });
   }).toggleClass('active');
   });
});
});
</script>

Версия от 17:47, 5 мая 2025

<script>
document.addEventListener('DOMContentLoaded', function () {
  document.querySelectorAll('.recipe-card').forEach(function (card) {
    var borderColor = card.getAttribute('data-border');
    if (borderColor) {
      card.style.borderColor = borderColor;
      card.querySelectorAll('.collapsible-content').forEach(function (block) {
        block.style.borderLeftColor = borderColor;
      });
    }
  });

  document.querySelectorAll('.recipe-list li').forEach(function (item) {
    if (item.classList.contains('instruction')) return;
    if (item.querySelector('.chem-icon')) return;

    var icon = document.createElement('img');
    icon.className = 'chem-icon';
    icon.src = 'Beaker.png';
    item.insertBefore(icon, item.firstChild);
  });

  document.querySelectorAll('.collapsible-header').forEach(function (header) {
    header.addEventListener('click', function () {
      var content = this.nextElementSibling;
      content.classList.toggle('active');
    });
  });
});
</script>