Действия

Widget

Порталы: различия между версиями

Материал из ВикиВоины

 
(не показано 28 промежуточных версий этого же участника)
Строка 108: Строка 108:
 
     $(this).removeClass("rotate");
 
     $(this).removeClass("rotate");
 
   });
 
   });
 
  var isFixed = false;
 
  var linkList;
 
 
  if (window.innerWidth > 640) {
 
  linkList = $('<ul class="side-nav"></ul>');
 
  } else {
 
  linkList = $('<ul></ul>');
 
  }
 
 
  var contentLabel = $('<label class="sidebar" id="p-tb">Содержание</label>');
 
  var contentListItem = $('<li></li>');
 
  contentListItem.append(contentLabel);
 
  linkList.append(contentListItem);
 
 
  $('.sections_title, .period_title').each(function() {
 
    var sectionTitle = $(this).text().trim();
 
    var sectionLink = $('');
 
    sectionLink.text(sectionTitle);
 
    sectionLink.attr('href', '#' + $(this).attr('id'));
 
 
    var listItem = $('<li></li>');
 
    listItem.append(sectionLink);
 
 
    if ($(this).hasClass('period_title')) {
 
      listItem.addClass('side-nav');
 
    }
 
 
    linkList.append(listItem);
 
  });
 
 
  var portalContents = $('<div class="portal-contents side-nav"></div>');
 
  portalContents.append(linkList);
 
  $('#sidebar:last').append(portalContents);
 
 
  var contentItemWrapList = linkList.clone();
 
  contentItemWrapList.find('.sidebar').remove();
 
 
  setTimeout(function() {
 
    $('.contents-item-wrap').append(contentItemWrapList);
 
  }, 1000);
 
 
  var sidebarTop = $('.sidebar:last').offset().top;
 
  var portalContentsTop = portalContents.offset().top;
 
 
  $(window).scroll(function() {
 
    var scrollTop = $(window).scrollTop();
 
 
    if (scrollTop > sidebarTop && scrollTop > portalContentsTop && !isFixed) {
 
      portalContents.addClass('fixed');
 
      isFixed = true;
 
    } else if ((scrollTop <= sidebarTop || scrollTop <= portalContentsTop) && isFixed) {
 
      portalContents.removeClass('fixed');
 
      isFixed = false;
 
    }
 
  });
 
 
$(window).scroll(function() {
 
    var currentPosition = $(this).scrollTop();
 
    $('.sections_title, .period_title').each(function() {
 
        var sectionTop = $(this).offset().top;
 
        var sectionId = $(this).attr('id');
 
        if (currentPosition >= sectionTop) {
 
            $('.side-nav li').removeClass('active');
 
            var activeElement = $('.side-nav li').find('a[href="#' + sectionId + '"]').parent();
 
            activeElement.addClass('active');
 
        }
 
    });
 
});
 
 
 
  
 
});
 
});
Строка 269: Строка 198:
 
}
 
}
  
.period_title a {
+
.period_title span {
 
   color: #fff;
 
   color: #fff;
 
}
 
}
Строка 468: Строка 397:
 
}
 
}
  
.portal-contents {
+
.toc {
    position: relative;
+
display: none!important;
    padding: 0;
 
    margin-top: -25px;
 
}
 
 
 
.portal-contents.fixed {
 
  position: fixed;
 
  width: 215px;
 
  top: 1.875rem;
 
  left: 0.875rem;
 
  z-index: 9;
 
 
}
 
}
  
.portal-contents ul.side-nav li.side-nav {
 
  margin-left: 1em;
 
  padding: 0;
 
}
 
  
 
@media only screen and (max-width:640px) {
 
@media only screen and (max-width:640px) {
Строка 574: Строка 489:
 
}
 
}
  
.contents-item-wrap ul {
 
  margin: 0;
 
}
 
 
.contents-item-wrap ul li.side-nav {
 
  margin: 0;
 
  padding: 3px;
 
}
 
 
.contents-item-wrap ul li:first-child {
 
  display: none;
 
}
 
  
  

Текущая версия на 11:33, 5 мая 2024