comm.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $(document).ready(function() {
  2. //search
  3. $(".is-search,.go-left").click(function() {
  4. $(".search-page").toggle();
  5. });
  6. $('#tab li').hover(function(){
  7. $(this).addClass('tab-current').siblings().removeClass('tab-current');
  8. $('#tab-content>section:eq('+$(this).index()+')').show().siblings().hide();
  9. });
  10. //nav
  11. $("#mnavh").click(function(){
  12. $("#starlist").toggle();
  13. $("#mnavh").toggleClass("open");
  14. $(".sub").hide();
  15. });
  16. //nav menu
  17. $(".menu").click(function(event) {
  18. $(this).children('.sub').slideToggle();
  19. $(this).siblings('.menu').children('.sub').slideUp('');
  20. event.stopPropagation()
  21. });
  22. $(".menu a").click(function(event) {
  23. event.stopPropagation();
  24. });
  25. $(".sub li").click(function(event) {
  26. event.stopPropagation();
  27. });
  28. //scroll to top
  29. var offset = 300,
  30. offset_opacity = 1200,
  31. scroll_top_duration = 700,
  32. $back_to_top = $('.icon-top');
  33. $(window).scroll(function () {
  34. ($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
  35. if ($(this).scrollTop() > offset_opacity) {
  36. $back_to_top.addClass('cd-fade-out');
  37. }
  38. });
  39. $back_to_top.on('click', function (event) {
  40. event.preventDefault();
  41. $('body,html').animate({
  42. scrollTop: 0,
  43. }, scroll_top_duration
  44. );
  45. });
  46. });