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

Страница интерфейса MediaWiki
Нет описания правки
Метка: отменено
Нет описания правки
Метка: отменено
Строка 2: Строка 2:
   var btn = $('<div>▲ Наверх</div>').css({
   var btn = $('<div>▲ Наверх</div>').css({
     position:'fixed', bottom:'20px', right:'20px',
     position:'fixed', bottom:'20px', right:'20px',
     padding:'5px 10px', background:'#444', color:'#fff',
     padding:'5px 10px', background:'#333', color:'#fff',
     cursor:'pointer', borderRadius:'5px', zIndex:9999
     cursor:'pointer', borderRadius:'5px', zIndex:9999,
    boxShadow:'0 2px 5px rgba(0,0,0,0.4)'
   }).appendTo('body');
   }).appendTo('body');


Строка 9: Строка 10:
     position:'fixed', bottom:'60px', right:'20px',
     position:'fixed', bottom:'60px', right:'20px',
     maxHeight:'300px', overflow:'auto',
     maxHeight:'300px', overflow:'auto',
     padding:'5px 10px', background:'#fff', border:'1px solid #444',
     padding:'5px 0', background:'#333', border:'1px solid #222',
     borderRadius:'5px', display:'none', zIndex:9999
     borderRadius:'5px', display:'none', zIndex:9999,
    boxShadow:'0 2px 8px rgba(0,0,0,0.5)'
   }).appendTo('body');
   }).appendTo('body');


Строка 20: Строка 22:
     }
     }
     var link = $('<div>'+$(this).text()+'</div>').css({
     var link = $('<div>'+$(this).text()+'</div>').css({
       cursor:'pointer', padding:'2px 0'
       cursor:'pointer', padding:'4px 8px',
     }).appendTo(menu);
      background:'#fff', color:'#000',
      margin:'2px 5px', borderRadius:'3px'
     }).hover(
      function(){ $(this).css('background','#eee'); },
      function(){ $(this).css('background','#fff'); }
    ).appendTo(menu);
     link.click(function() {
     link.click(function() {
       $('html, body').animate({scrollTop:$('#'+id).offset().top}, 500);
       $('html, body').animate({scrollTop:$('#'+id).offset().top}, 500);

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

$(function() {
  var btn = $('<div>▲ Наверх</div>').css({
    position:'fixed', bottom:'20px', right:'20px',
    padding:'5px 10px', background:'#333', color:'#fff',
    cursor:'pointer', borderRadius:'5px', zIndex:9999,
    boxShadow:'0 2px 5px rgba(0,0,0,0.4)'
  }).appendTo('body');

  var menu = $('<div></div>').css({
    position:'fixed', bottom:'60px', right:'20px',
    maxHeight:'300px', overflow:'auto',
    padding:'5px 0', background:'#333', border:'1px solid #222',
    borderRadius:'5px', display:'none', zIndex:9999,
    boxShadow:'0 2px 8px rgba(0,0,0,0.5)'
  }).appendTo('body');

  $('h1, h2, h3').each(function() {
    var id = $(this).attr('id');
    if (!id) {
      id = 'hdr-' + Math.random().toString(36).substr(2,5);
      $(this).attr('id', id);
    }
    var link = $('<div>'+$(this).text()+'</div>').css({
      cursor:'pointer', padding:'4px 8px',
      background:'#fff', color:'#000',
      margin:'2px 5px', borderRadius:'3px'
    }).hover(
      function(){ $(this).css('background','#eee'); },
      function(){ $(this).css('background','#fff'); }
    ).appendTo(menu);
    link.click(function() {
      $('html, body').animate({scrollTop:$('#'+id).offset().top}, 500);
      menu.hide();
    });
  });

  btn.click(function() {
    menu.toggle();
  });
});