You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

155 lines
5.3 KiB

  1. //自由驱动工作室
  2. //作者:林鑫
  3. $(function(){
  4. var Initials=$('.initials');
  5. var LetterBox=$('#letter');
  6. Initials.find('ul').html('<li>A</li><li>B</li><li>C</li><li>D</li><li>E</li><li>F</li><li>G</li><li>H</li><li>I</li><li>J</li><li>K</li><li>L</li><li>M</li><li>N</li><li>O</li><li>P</li><li>Q</li><li>R</li><li>S</li><li>T</li><li>U</li><li>V</li><li>W</li><li>X</li><li>Y</li><li>Z</li><li>#</li>');
  7. initials();
  8. $(".initials ul li").mouseover(function(){
  9. var _this=$(this);
  10. var LetterHtml=_this.html();
  11. LetterBox.html(LetterHtml).fadeIn();
  12. Initials.css('background','rgba(145,145,145,0.6)');
  13. setTimeout(function(){
  14. Initials.css('background','rgba(145,145,145,0)');
  15. LetterBox.fadeOut();
  16. },1000);
  17. var _index = _this.index()
  18. if(_index==0){
  19. $('html,body').animate({scrollTop: '0px'}, 300);//点击第一个滚到顶部
  20. }else if(_index==27){
  21. var DefaultTop=$('#default').position().top;
  22. $('html,body').animate({scrollTop: DefaultTop+'px'}, 300);//点击最后一个滚到#号
  23. }else{
  24. var letter = _this.text();
  25. if($('#'+letter).length>0){
  26. var LetterTop = $('#'+letter).position().top;
  27. $('html,body').animate({scrollTop: LetterTop-45+'px'}, 300);
  28. }
  29. }
  30. })
  31. var windowHeight=$(window).height();
  32. var InitHeight=windowHeight-150;
  33. Initials.height(InitHeight);
  34. var LiHeight=InitHeight/27;
  35. Initials.find('li').height(LiHeight);
  36. })
  37. function initials() {//公众号排序
  38. var SortList=$(".sort_list");
  39. var SortBox=$(".sort_box");
  40. SortList.sort(asc_sort).appendTo('.sort_box');//按首字母排序
  41. function asc_sort(a, b) {
  42. return makePy($(b).find('.num_name').text().charAt(0))[0].toUpperCase() < makePy($(a).find('.num_name').text().charAt(0))[0].toUpperCase() ? 1 : -1;
  43. }
  44. var initials = [];
  45. var num=0;
  46. SortList.each(function(i) {
  47. var initial = makePy($(this).find('.num_name').text().charAt(0))[0].toUpperCase();
  48. if(initial>='A'&&initial<='Z'){
  49. if (initials.indexOf(initial) === -1)
  50. initials.push(initial);
  51. }else{
  52. num++;
  53. }
  54. });
  55. $.each(initials, function(index, value) {//添加首字母标签
  56. SortBox.append('<div class="sort_letter" id="'+ value +'">' + value + '</div>');
  57. });
  58. if(num!=0){SortBox.append('<div class="sort_letter" id="default">#</div>');}
  59. for (var i =0;i<SortList.length;i++) {//插入到对应的首字母后面
  60. var letter=makePy(SortList.eq(i).find('.num_name').text().charAt(0))[0].toUpperCase();
  61. switch(letter){
  62. case "A":
  63. $('#A').after(SortList.eq(i));
  64. break;
  65. case "B":
  66. $('#B').after(SortList.eq(i));
  67. break;
  68. case "C":
  69. $('#C').after(SortList.eq(i));
  70. break;
  71. case "D":
  72. $('#D').after(SortList.eq(i));
  73. break;
  74. case "E":
  75. $('#E').after(SortList.eq(i));
  76. break;
  77. case "F":
  78. $('#F').after(SortList.eq(i));
  79. break;
  80. case "G":
  81. $('#G').after(SortList.eq(i));
  82. break;
  83. case "H":
  84. $('#H').after(SortList.eq(i));
  85. break;
  86. case "I":
  87. $('#I').after(SortList.eq(i));
  88. break;
  89. case "J":
  90. $('#J').after(SortList.eq(i));
  91. break;
  92. case "K":
  93. $('#K').after(SortList.eq(i));
  94. break;
  95. case "L":
  96. $('#L').after(SortList.eq(i));
  97. break;
  98. case "M":
  99. $('#M').after(SortList.eq(i));
  100. break;
  101. case "N":
  102. $('#N').after(SortList.eq(i));
  103. break;
  104. case "O":
  105. $('#O').after(SortList.eq(i));
  106. break;
  107. case "P":
  108. $('#P').after(SortList.eq(i));
  109. break;
  110. case "Q":
  111. $('#Q').after(SortList.eq(i));
  112. break;
  113. case "R":
  114. $('#R').after(SortList.eq(i));
  115. break;
  116. case "S":
  117. $('#S').after(SortList.eq(i));
  118. break;
  119. case "T":
  120. $('#T').after(SortList.eq(i));
  121. break;
  122. case "U":
  123. $('#U').after(SortList.eq(i));
  124. break;
  125. case "V":
  126. $('#V').after(SortList.eq(i));
  127. break;
  128. case "W":
  129. $('#W').after(SortList.eq(i));
  130. break;
  131. case "X":
  132. $('#X').after(SortList.eq(i));
  133. break;
  134. case "Y":
  135. $('#Y').after(SortList.eq(i));
  136. break;
  137. case "Z":
  138. $('#Z').after(SortList.eq(i));
  139. break;
  140. default:
  141. $('#default').after(SortList.eq(i));
  142. break;
  143. }
  144. };
  145. }