infohome.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var curPage = 0;
  2. var pageLen = 6;
  3. var totalLen = $("#new-video li").length;
  4. var V = {
  5. init : function(){
  6. V.scrollNews();
  7. V.triggerTab("hotVd-tab");
  8. },
  9. scrollNews : function() { // 新闻翻滚
  10. var $scrollNews = $('#scrollNews');
  11. if (!$scrollNews) return;
  12. var news = $scrollNews.children(),
  13. len = news.length,
  14. cHeight = $scrollNews.height(),
  15. perHeight = cHeight / len,
  16. interval = 2000,
  17. index = 0,//初始记录
  18. timer = setInterval(function () {
  19. $scrollNews.animate({
  20. top: - (perHeight * index) + "px"
  21. }, interval / 3)
  22. if (index === len - 1)
  23. index = 0;
  24. else
  25. index++;
  26. }, interval);
  27. },
  28. triggerTab : function(id){ //tab切换
  29. $ul=$("#"+id);
  30. $ul.on("click","li",function(){
  31. var index = $(this).index();
  32. $(this).addClass("active").siblings().removeClass("active");
  33. $($(this).attr("data-id")).show().siblings("ul").hide();
  34. $ul.parent().find(".more").eq(index).show().siblings(".more").hide();
  35. })
  36. }
  37. }
  38. var C = {
  39. init : function(){
  40. // 最新视频刷新
  41. $(".col-right").on("click",".refresh",function(){
  42. ++curPage;
  43. if(curPage >= totalLen/pageLen){
  44. curPage = 0;
  45. }
  46. $("#new-video li").addClass("u-hide");
  47. for(var i=0; i<pageLen; i++){
  48. var $curLi = $("#new-video li").eq(curPage*pageLen+i);
  49. var $curImg = $curLi.find("img");
  50. var original = $curImg.attr("data-original");
  51. if(original){
  52. $curImg.removeAttr("data-original").attr("src",original);
  53. }
  54. $curLi.removeClass("u-hide");
  55. }
  56. });
  57. }
  58. }
  59. C.init();
  60. V.init();