12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /**
- * Created by zhumingyue on 2016/7/1.
- */
- TimeAxis = function(){
- var _this = this;
- /**
- * 创建年轴
- * @param params
- */
- this.init = function(params){
- var $history_box = document.createElement("div");
- $history_box.id = "history_box";
- $history_box = document.getElementById("shaft_nav").appendChild($history_box);
- $($history_box).addClass("history_box line");
- var flg = true;
- for(var key in params){
- var $dn_year = document.createElement("div");
- $dn_year = document.getElementById("history_box").appendChild($dn_year);
- $($dn_year).addClass("year_box");
- var $ul = document.createElement("ul");
- $($dn_year).append($ul);
- var $h2 = document.createElement("h2");
- $($ul).append($h2);
- $($h2).addClass("hide_bgk");
- var $year_a = document.createElement("a");
- $year_a.href = "javascript:void;";
- $($h2).append($year_a);
- $($year_a).html(params[key].year);
- $($year_a).on("click",function(){
- $(this).parent().parent().children("li").slideToggle("fast");
- });
- if(flg){
- $($h2).removeClass("hide_bgk");
- _this.createItem($ul,params[key].mone,flg);
- flg = false;
- }else{
- _this.createItem($ul,params[key].mone,flg);
- };
- }
- };
- /**
- * 创建月轴
- */
- this.createItem = function ($ul,params,flg) {
- for(var key in params){
- var $li = document.createElement("li");
- var $mone_a = document.createElement("a");
- $mone_a.href = "javascript:void;";
- $($mone_a).html(params[key]);
- /*$($mone_a).on("click",function(){
- });*/
- $($li).append($mone_a);
- $($ul).append($li);
- $($li).addClass("hide_li");
- if(flg){
- $($li).removeClass("hide_li");
- }
- $($li).on("click",function(){
- var res = {};
- res.year = $(this).parent().children("h2").children("a").html();
- var mone = $(this).children("a").html();
- mone = mone.substring(0,mone.length-1);
- res.mone = mone;
- clickMone(res);
- });
- };
- }
- };
|