71a46e90ba607e83844f65cfdccbeaab81a4fc2d.svn-base 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Created by zhumingyue on 2016/7/1.
  3. */
  4. TimeAxis = function(){
  5. var _this = this;
  6. /**
  7. * 创建年轴
  8. * @param params
  9. */
  10. this.init = function(params){
  11. var $history_box = document.createElement("div");
  12. $history_box.id = "history_box";
  13. $history_box = document.getElementById("shaft_nav").appendChild($history_box);
  14. $($history_box).addClass("history_box line");
  15. var flg = true;
  16. for(var key in params){
  17. var $dn_year = document.createElement("div");
  18. $dn_year = document.getElementById("history_box").appendChild($dn_year);
  19. $($dn_year).addClass("year_box");
  20. var $ul = document.createElement("ul");
  21. $($dn_year).append($ul);
  22. var $h2 = document.createElement("h2");
  23. $($ul).append($h2);
  24. $($h2).addClass("hide_bgk");
  25. var $year_a = document.createElement("a");
  26. $year_a.href = "javascript:void;";
  27. $($h2).append($year_a);
  28. $($year_a).html(params[key].year);
  29. $($year_a).on("click",function(){
  30. $(this).parent().parent().children("li").slideToggle("fast");
  31. });
  32. if(flg){
  33. $($h2).removeClass("hide_bgk");
  34. _this.createItem($ul,params[key].mone,flg);
  35. flg = false;
  36. }else{
  37. _this.createItem($ul,params[key].mone,flg);
  38. };
  39. }
  40. };
  41. /**
  42. * 创建月轴
  43. */
  44. this.createItem = function ($ul,params,flg) {
  45. for(var key in params){
  46. var $li = document.createElement("li");
  47. var $mone_a = document.createElement("a");
  48. $mone_a.href = "javascript:void;";
  49. $($mone_a).html(params[key]);
  50. /*$($mone_a).on("click",function(){
  51. });*/
  52. $($li).append($mone_a);
  53. $($ul).append($li);
  54. $($li).addClass("hide_li");
  55. if(flg){
  56. $($li).removeClass("hide_li");
  57. }
  58. $($li).on("click",function(){
  59. var res = {};
  60. res.year = $(this).parent().children("h2").children("a").html();
  61. var mone = $(this).children("a").html();
  62. mone = mone.substring(0,mone.length-1);
  63. res.mone = mone;
  64. clickMone(res);
  65. });
  66. };
  67. }
  68. };