2012-06-26 07:59:28 +00:00
|
|
|
//for timeline parent library, will be accessable by main library and API library for other people to use.. default inherits orbitDesktopAPI
|
|
|
|
// Harry Bomrah
|
|
|
|
|
|
|
|
var orbitTimeline = function(dom){
|
|
|
|
t = this;
|
2012-07-06 08:11:03 +00:00
|
|
|
this.dom = $(dom);
|
2012-06-26 07:59:28 +00:00
|
|
|
this.timelineHtml = $("<div class='t_bottom t_scale' id='timeline_scale'></div>");
|
|
|
|
//this.marker = t.timelineHtml.find("#timline_marker");
|
2012-07-02 13:06:20 +00:00
|
|
|
this.scale = "";
|
2012-06-26 07:59:28 +00:00
|
|
|
//this.container = t.timelineHtml.find("#t_container");
|
2012-06-26 13:09:33 +00:00
|
|
|
this.events = new Array;
|
|
|
|
this.monthList = ["","January","February","March","April","May","June","July","August","September","October","November","December"];
|
2012-07-02 13:06:20 +00:00
|
|
|
this.dt = new Date();
|
|
|
|
this.fromdate = [t.dt.getFullYear(),t.dt.getMonth()+1];
|
|
|
|
this.ajaxload = true;
|
2012-06-26 07:59:28 +00:00
|
|
|
this.initialize = function(){
|
|
|
|
t.dom.html(t.timelineHtml);
|
|
|
|
$("div.scrollbar").hide();
|
2012-06-26 13:09:33 +00:00
|
|
|
t.constructTimeScale(function(timelineScale){
|
|
|
|
$("#timeline_scale").html(timelineScale);
|
2012-07-06 08:11:03 +00:00
|
|
|
var totalyearwidth =timelineScale.find(".year").length * timelineScale.find(".year").outerWidth();
|
2012-06-28 09:31:48 +00:00
|
|
|
var totalul = 0;
|
2012-07-06 08:11:03 +00:00
|
|
|
$(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+500 + "px"})
|
2012-06-26 13:09:33 +00:00
|
|
|
for(eve in t.events){
|
|
|
|
t.makeBubble(t.events[eve]);
|
2012-06-28 09:31:48 +00:00
|
|
|
totalul = $("#scale_wrapper ul").length
|
|
|
|
$(".t_scale").width((totalul*350) + totalyearwidth);
|
2012-06-26 13:09:33 +00:00
|
|
|
}
|
2012-07-05 08:23:13 +00:00
|
|
|
t.bubble_fx();
|
2012-07-02 13:06:20 +00:00
|
|
|
$('.tinycanvas').tinyscrollbar({
|
|
|
|
axis: 'x',
|
|
|
|
onMove: function(x){
|
2012-07-06 08:11:03 +00:00
|
|
|
var limit = $("#timeline_scale").outerWidth() - $(".tinycanvas .scrollbar").outerWidth();
|
2012-07-02 13:06:20 +00:00
|
|
|
if(t.ajaxload){
|
|
|
|
if((limit - x) < 10){
|
|
|
|
t.eventAjaxLoad(function(){
|
|
|
|
var totalul = 0;
|
|
|
|
for(eve in t.events){
|
|
|
|
t.makeBubble(t.events[eve]);
|
|
|
|
totalul = $("#scale_wrapper ul").length
|
2012-07-05 08:23:13 +00:00
|
|
|
$(".t_scale").width((totalul*360) + totalyearwidth + 314);
|
2012-07-02 13:06:20 +00:00
|
|
|
}
|
|
|
|
$('.tinycanvas').tinyscrollbar_update(x);
|
2012-07-05 08:23:13 +00:00
|
|
|
t.bubble_fx();
|
2012-07-02 13:06:20 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-06-26 13:09:33 +00:00
|
|
|
});
|
2012-06-26 07:59:28 +00:00
|
|
|
}
|
2012-06-26 13:09:33 +00:00
|
|
|
this.constructTimeScale = function(callbackFn){
|
2012-07-02 13:06:20 +00:00
|
|
|
var mon ="",year="",formname;
|
2012-06-26 13:09:33 +00:00
|
|
|
var scale = $("<div id='scale_wrapper'></div>");
|
2012-07-06 08:11:03 +00:00
|
|
|
$.getJSON("desktop_orbit/gettimelinespan",{"get":"papers"},function(years){
|
|
|
|
var $ul = $("<ul></ul>");
|
|
|
|
var startyear = years.startyear, endyear = years.endyear,year = years.startyear;
|
|
|
|
$ul.append('<li><a href="'+startyear+'" class="wh3 hh3 admbg active" onclick="return false;">'+startyear+'</a></li>');
|
|
|
|
while(year > endyear){
|
|
|
|
year--;
|
|
|
|
$ul.append('<li><a href="'+year+'" class="wh3 hh3 admbg" onclick="return false;">'+year+'</a></li>');
|
|
|
|
}
|
|
|
|
$("div#orbit div#year_navigation").html($ul);
|
|
|
|
})
|
2012-07-03 11:45:47 +00:00
|
|
|
$.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){
|
|
|
|
$.each(papersArray,function(i,pa){
|
|
|
|
$.each(pa.papers,function(i,paper){
|
|
|
|
var dt = new Date(paper.created_at);
|
|
|
|
var cur_mon = paper.created_at.substr(5,2);
|
|
|
|
var cur_year = dt.getFullYear();
|
|
|
|
var cdt = paper.created_at.substr(0,7).replace("-","");
|
|
|
|
formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon)
|
|
|
|
var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt}
|
|
|
|
t.events.push(bubbleData);
|
|
|
|
if(cur_year != year){
|
|
|
|
year = cur_year;
|
2012-07-06 08:11:03 +00:00
|
|
|
scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+year+"'></div>"));
|
2012-07-03 11:45:47 +00:00
|
|
|
}
|
|
|
|
if(cur_mon != mon){
|
|
|
|
mon = cur_mon;
|
|
|
|
var yr = scale.find("div[data-content="+year+"]");
|
2012-07-05 08:23:13 +00:00
|
|
|
yr.append($("<div class='group month' data-content='"+cdt+"'><div class='month_heading vp hp'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>"))
|
2012-07-03 11:45:47 +00:00
|
|
|
}
|
|
|
|
});
|
2012-06-26 13:09:33 +00:00
|
|
|
});
|
2012-07-06 08:11:03 +00:00
|
|
|
//scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+(year-1)+"'></div>"));
|
2012-07-02 13:06:20 +00:00
|
|
|
t.fromdate = [year,formname-1];
|
|
|
|
if(typeof callbackFn == "function"){
|
|
|
|
callbackFn.call(this,scale);
|
|
|
|
}
|
2012-07-03 11:53:34 +00:00
|
|
|
})
|
2012-07-04 05:35:24 +00:00
|
|
|
|
2012-06-26 07:59:28 +00:00
|
|
|
}
|
2012-06-26 13:09:33 +00:00
|
|
|
this.makeBubble = function(bubbleData){
|
|
|
|
var totalul = $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] ul").length;
|
|
|
|
var targetul = $("#scale_wrapper div[data-content="+bubbleData.timestamp+"] div.bubble_list ul").eq(totalul-1);
|
2012-06-26 07:59:28 +00:00
|
|
|
if(totalul == 0){
|
|
|
|
var ul = $("<ul></ul>");
|
2012-06-26 13:09:33 +00:00
|
|
|
$("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul);
|
2012-06-26 07:59:28 +00:00
|
|
|
targetul = ul;
|
|
|
|
}else{
|
|
|
|
var totalli = targetul.find("li").length;
|
|
|
|
if(totalli >= 5){
|
|
|
|
var ul = $("<ul></ul>");
|
2012-06-26 13:09:33 +00:00
|
|
|
$("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul);
|
2012-06-26 07:59:28 +00:00
|
|
|
targetul = ul;
|
|
|
|
}
|
|
|
|
}
|
2012-06-26 13:09:33 +00:00
|
|
|
var bt = (bubbleData.title.length > 70? bubbleData.title.substr(0,70) + "..." : bubbleData.title);
|
2012-07-04 05:35:24 +00:00
|
|
|
var bubble = $("<li class='bubble hh3 admbg vp hp'>"+bt+"<span class='date'>"+bubbleData.fulldate+"</span></li>");
|
2012-06-26 07:59:28 +00:00
|
|
|
targetul.prepend(bubble);
|
2012-06-26 13:09:33 +00:00
|
|
|
bubble.show();
|
2012-06-26 07:59:28 +00:00
|
|
|
bubble.click(function(){
|
2012-07-06 08:11:03 +00:00
|
|
|
var thisbubble = $(this);
|
|
|
|
$(this).parents(dom)
|
|
|
|
.find('.bubble, .date')
|
|
|
|
.removeClass('thmc1 thmtxt');
|
|
|
|
|
2012-06-26 07:59:28 +00:00
|
|
|
o.toolPopup({
|
2012-07-05 08:23:13 +00:00
|
|
|
parent: $(this).parent(),
|
|
|
|
html : "<div class='bubble_content'><h2>"+bubbleData.jtitle+"</h2><h3>Co-Authors</h3><span class='context'>"+bubbleData.coauthors+"</span><h3>Abstract</h3><span class='context'>"+bubbleData.abstract+"</span></div>",
|
|
|
|
height: "392px",
|
2012-07-06 08:11:03 +00:00
|
|
|
width:"310px",
|
|
|
|
beforeClose : function(){
|
|
|
|
$("div.bubble_arrow").remove();
|
|
|
|
thisbubble.parents(dom)
|
|
|
|
.find('.bubble, .date')
|
|
|
|
.removeClass('thmc1 thmtxt');
|
|
|
|
},
|
|
|
|
onOpen : function(){
|
|
|
|
thisbubble.append('<div class="bubble_arrow"/>');
|
|
|
|
},
|
|
|
|
beforeOpen : function(){
|
|
|
|
thisbubble.addClass('thmc1 thmtxt');
|
|
|
|
thisbubble.find('.date').addClass('thmtxt');
|
|
|
|
}
|
2012-06-26 07:59:28 +00:00
|
|
|
});
|
2012-07-06 08:11:03 +00:00
|
|
|
})
|
2012-06-26 07:59:28 +00:00
|
|
|
}
|
2012-07-02 13:06:20 +00:00
|
|
|
this.eventAjaxLoad = function(callbackFn){
|
|
|
|
t.events = [];
|
|
|
|
var mon ="",year="",formname;
|
|
|
|
var scale = $("#scale_wrapper");
|
|
|
|
|
|
|
|
t.ajaxload = false;
|
|
|
|
$.getJSON("desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){
|
|
|
|
$.each(papersArray,function(i,pa){
|
|
|
|
$.each(pa.papers,function(i,paper){
|
|
|
|
var dt = new Date(paper.created_at);
|
|
|
|
var cur_mon = paper.created_at.substr(5,2);
|
|
|
|
var cur_year = dt.getFullYear();
|
|
|
|
var cdt = paper.created_at.substr(0,7).replace("-","");
|
|
|
|
formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon)
|
|
|
|
var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt}
|
|
|
|
t.events.push(bubbleData);
|
|
|
|
if(cur_year != year){
|
|
|
|
year = cur_year;
|
|
|
|
if(scale.find("div[data-content="+year+"]").length == 0){
|
2012-07-06 08:11:03 +00:00
|
|
|
scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+year+"'></div>"));
|
2012-07-02 13:06:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(cur_mon != mon){
|
|
|
|
mon = cur_mon;
|
|
|
|
var yr = scale.find("div[data-content="+year+"]");
|
2012-07-05 08:23:13 +00:00
|
|
|
yr.append($("<div class='group month' data-content='"+cdt+"'><div class='month_heading vp hp'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>"))
|
2012-07-02 13:06:20 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if(papersArray.length != 0){
|
2012-07-06 08:11:03 +00:00
|
|
|
// if(scale.find("div[data-content="+(year-1)+"]").length == 0)
|
|
|
|
// scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+(year-1)+"'></div>"));
|
2012-07-02 13:06:20 +00:00
|
|
|
t.ajaxload = true;
|
|
|
|
t.fromdate = [year,formname-1];
|
|
|
|
}
|
|
|
|
if(typeof callbackFn == "function"){
|
|
|
|
callbackFn.call(this,scale);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
2012-07-05 08:23:13 +00:00
|
|
|
this.bubble_fx = function(){
|
|
|
|
$('.bubble').on({
|
2012-07-06 08:11:03 +00:00
|
|
|
mouseover: function(){
|
|
|
|
$(this)
|
|
|
|
.addClass('hover')
|
|
|
|
.append('<span class="icon-chevron-right" />');
|
|
|
|
},
|
|
|
|
mouseout: function(){
|
|
|
|
$(this)
|
|
|
|
.removeClass('hover')
|
|
|
|
.find('.icon-chevron-right').remove();
|
|
|
|
},
|
|
|
|
});
|
2012-07-05 08:23:13 +00:00
|
|
|
}
|
2012-06-26 07:59:28 +00:00
|
|
|
}
|