123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /**
- * Created by zhumingyue on 2016/7/3.
- */
- TimeAxisInfo = function(){
- var _this = this;
- this.init = function(params){
- _this.loadBox(params.heading,params.subhead);
- var leftArr = [];
- var rightArr = [];
- for(var i = 0; i < params.data.length; i++){
- if(i % 2 == 0){
- rightArr.push(params.data[i]);
- }else{
- leftArr.push(params.data[i]);
- }
- }
- _this.loadLeftBox(leftArr);
- _this.loadRightBox(rightArr);
- };
- /**
- * 创建主体DIV
- */
- this.loadBox = function(head,subhead){
- var $box = document.createElement("div");
- $($box).addClass("tai_box");
- $("#shaft_info_nav").append($box);
- var $head = document.createElement("p");
- $($head).addClass("tai_title");
- $($head).html(head);
- $($box).append($head);
- var $subhead = document.createElement("p");
- $($subhead).addClass("tai_subtitle");
- $($subhead).html(subhead);
- $($box).append($subhead);
- var $tai_left = document.createElement("div");
- $($tai_left).addClass("tai_left");
- var boxW = $($box).width();
- var lrw = (boxW - 140)/2;
- $($tai_left).css("width",lrw);
- $($box).append($tai_left);
- var $tai_axis = document.createElement("div");
- $($tai_axis).addClass("tai_axis");
- $($box).append($tai_axis);
- var $axis_img = document.createElement("img");
- $($axis_img).attr("src","/nwyj/images/business/em/floods/history.png");
- $($tai_axis).append($axis_img);
- var $tai_right = document.createElement("div");
- $($tai_right).addClass("tai_right");
- $($tai_right).css("width",lrw);
- $($box).append($tai_right);
- };
- /**
- * 创建左边内容
- */
- this.loadLeftBox = function(leftArr){
- var $ul = document.createElement("ul");
- $(".tai_left").append($ul);
- for(var i = 0; i < leftArr.length; i++){
- var $li = document.createElement("li");
- $($li).addClass("count_left");
- var $title_span = document.createElement("span");
- $($title_span).addClass("title_span fr");
- $($title_span).html(leftArr[i].title);
- $($li).append($title_span);
- if(i==0){
- $($li).css("margin-top","242px");
- }else{
- $($li).css("margin-top","65px");
- }
- var $count_p_span = document.createElement("span");
- $($count_p_span).addClass("count_p_span").html(leftArr[i].details);
- $($count_p_span).attr("title",leftArr[i].details);
- var $count_p = document.createElement("p");
- $($count_p).addClass("count_p fr").append($count_p_span);
- $($li).append($count_p);
- $($ul).append($li);
- }
- };
- /**
- * 创建右边内容
- */
- this.loadRightBox = function(rightArr){
- var $ul = document.createElement("ul");
- $(".tai_right").append($ul);
- for(var i = 0; i < rightArr.length; i++){
- var $li = document.createElement("li");
- $($li).addClass("count_right");
- var $title_span = document.createElement("span");
- $($title_span).addClass("title_span fl");
- $($title_span).html(rightArr[i].title);
- $($li).append($title_span);
- if(i==0){
- $($li).css("margin-top","157px");
- }else{
- $($li).css("margin-top","65px");
- }
- var $count_p_span = document.createElement("span");
- $($count_p_span).addClass("count_p_span").html(rightArr[i].details);
- $($count_p_span).attr("title",rightArr[i].details);
- var $count_p = document.createElement("p");
- $($count_p).addClass("count_p fl").append($count_p_span);
- $($li).append($count_p);
- $($ul).append($li);
- }
- };
- };
|