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

Материал из SAMP
Нет описания правки
Нет описания правки
Строка 14: Строка 14:
var link = $(this).html();
var link = $(this).html();
document.location.href = 'https://wiki.samp.world/index.php/'+link;
document.location.href = 'https://wiki.samp.world/index.php/'+link;
});
$(document).ready(function () {
  $('h2, h3').each(function () {
    const $header = $(this);
    const $content = $header.nextUntil('h2, h3');
    if ($content.length === 0) return;
    const toggleBtn = $('<span>')
      .text(' [–]')
      .css({ cursor: 'pointer', color: '#00f' })
      .click(function () {
        $content.toggle();
        toggleBtn.text($content.is(':visible') ? ' [–]' : ' [+]');
      });
    $header.append(toggleBtn);
  });
});
});

Версия от 23:46, 1 августа 2025

/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */

$(document).on('click','.index_elem', function(event)
{
	var target = event["target"]["parentElement"]["className"];
	if (target != "index_subelems")
	{
		if ($(this).hasClass('active'))	{ $(this).removeClass('active'); }
		else { $(this).addClass('active');	}
	}
});
$(document).on('click','.index_subelem', function()
{
	var link = $(this).html();
	document.location.href = 'https://wiki.samp.world/index.php/'+link;
});


$(document).ready(function () {
  $('h2, h3').each(function () {
    const $header = $(this);
    const $content = $header.nextUntil('h2, h3');

    if ($content.length === 0) return;

    const toggleBtn = $('<span>')
      .text(' [–]')
      .css({ cursor: 'pointer', color: '#00f' })
      .click(function () {
        $content.toggle();
        toggleBtn.text($content.is(':visible') ? ' [–]' : ' [+]');
      });

    $header.append(toggleBtn);
  });
});