b0db918874b5a3b0b219030630cd7f9cda28d7cc.svn-base 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Created by zhumingyue on 2016/7/3.
  3. */
  4. TimeAxisInfo = function(){
  5. var _this = this;
  6. this.init = function(params){
  7. _this.loadBox(params.heading,params.subhead);
  8. var leftArr = [];
  9. var rightArr = [];
  10. for(var i = 0; i < params.data.length; i++){
  11. if(i % 2 == 0){
  12. rightArr.push(params.data[i]);
  13. }else{
  14. leftArr.push(params.data[i]);
  15. }
  16. }
  17. _this.loadLeftBox(leftArr);
  18. _this.loadRightBox(rightArr);
  19. };
  20. /**
  21. * 创建主体DIV
  22. */
  23. this.loadBox = function(head,subhead){
  24. var $box = document.createElement("div");
  25. $($box).addClass("tai_box");
  26. $("#shaft_info_nav").append($box);
  27. var $head = document.createElement("p");
  28. $($head).addClass("tai_title");
  29. $($head).html(head);
  30. $($box).append($head);
  31. var $subhead = document.createElement("p");
  32. $($subhead).addClass("tai_subtitle");
  33. $($subhead).html(subhead);
  34. $($box).append($subhead);
  35. var $tai_left = document.createElement("div");
  36. $($tai_left).addClass("tai_left");
  37. var boxW = $($box).width();
  38. var lrw = (boxW - 140)/2;
  39. $($tai_left).css("width",lrw);
  40. $($box).append($tai_left);
  41. var $tai_axis = document.createElement("div");
  42. $($tai_axis).addClass("tai_axis");
  43. $($box).append($tai_axis);
  44. var $axis_img = document.createElement("img");
  45. $($axis_img).attr("src","/nwyj/images/business/em/floods/history.png");
  46. $($tai_axis).append($axis_img);
  47. var $tai_right = document.createElement("div");
  48. $($tai_right).addClass("tai_right");
  49. $($tai_right).css("width",lrw);
  50. $($box).append($tai_right);
  51. };
  52. /**
  53. * 创建左边内容
  54. */
  55. this.loadLeftBox = function(leftArr){
  56. var $ul = document.createElement("ul");
  57. $(".tai_left").append($ul);
  58. for(var i = 0; i < leftArr.length; i++){
  59. var $li = document.createElement("li");
  60. $($li).addClass("count_left");
  61. var $title_span = document.createElement("span");
  62. $($title_span).addClass("title_span fr");
  63. $($title_span).html(leftArr[i].title);
  64. $($li).append($title_span);
  65. if(i==0){
  66. $($li).css("margin-top","242px");
  67. }else{
  68. $($li).css("margin-top","65px");
  69. }
  70. var $count_p_span = document.createElement("span");
  71. $($count_p_span).addClass("count_p_span").html(leftArr[i].details);
  72. $($count_p_span).attr("title",leftArr[i].details);
  73. var $count_p = document.createElement("p");
  74. $($count_p).addClass("count_p fr").append($count_p_span);
  75. $($li).append($count_p);
  76. $($ul).append($li);
  77. }
  78. };
  79. /**
  80. * 创建右边内容
  81. */
  82. this.loadRightBox = function(rightArr){
  83. var $ul = document.createElement("ul");
  84. $(".tai_right").append($ul);
  85. for(var i = 0; i < rightArr.length; i++){
  86. var $li = document.createElement("li");
  87. $($li).addClass("count_right");
  88. var $title_span = document.createElement("span");
  89. $($title_span).addClass("title_span fl");
  90. $($title_span).html(rightArr[i].title);
  91. $($li).append($title_span);
  92. if(i==0){
  93. $($li).css("margin-top","157px");
  94. }else{
  95. $($li).css("margin-top","65px");
  96. }
  97. var $count_p_span = document.createElement("span");
  98. $($count_p_span).addClass("count_p_span").html(rightArr[i].details);
  99. $($count_p_span).attr("title",rightArr[i].details);
  100. var $count_p = document.createElement("p");
  101. $($count_p).addClass("count_p fl").append($count_p_span);
  102. $($li).append($count_p);
  103. $($ul).append($li);
  104. }
  105. };
  106. };