/** * @file timeline.js * * @brief * The Timeline is an interactive visualization chart to visualize events in * time, having a start and end date. * You can freely move and zoom in the timeline by dragging * and scrolling in the Timeline. Items are optionally dragable. The time * scale on the axis is adjusted automatically, and supports scales ranging * from milliseconds to years. * * Timeline is part of the CHAP Links library. * * Timeline is tested on Firefox 3.6, Safari 5.0, Chrome 6.0, Opera 10.6, and * Internet Explorer 6+. * * @license * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * Copyright (c) 2011-2012 Almende B.V. * * @author Jos de Jong, * @date 2012-06-15 * @version 2.1.2 *//* * TODO * * Add zooming with pinching on Android * * Bug: when an item contains a javascript onclick or a link, this does not work * when the item is not selected (when the item is being selected, * it is redrawn, which cancels any onclick or link action) * Bug: when an item contains an image without size, or a css max-width, it is not sized correctly * Bug: neglect items when they have no valid start/end, instead of throwing an error * Bug: Pinching on ipad does not work very well, sometimes the page will zoom when pinching vertically * Bug: cannot set max width for an item, like div.timeline-event-content {white-space: normal; max-width: 100px;} * Bug on IE in Quirks mode. When you have groups, and delete an item, the groups become invisible *//** * Declare a unique namespace for CHAP's Common Hybrid Visualisation Library, * "links" */typeof links=="undefined"&&(links={});typeof google=="undefined"&&(google=undefined);links.Timeline=function(e){this.dom={};this.conversion={};this.eventParams={};this.groups=[];this.groupIndexes={};this.items=[];this.visibleItems=0;this.selection=undefined;this.listeners={};this.size={actualHeight:0,axis:{characterMajorHeight:0,characterMajorWidth:0,characterMinorHeight:0,characterMinorWidth:0,height:0,labelMajorTop:0,labelMinorTop:0,line:0,lineMajorWidth:0,lineMinorHeight:0,lineMinorTop:0,lineMinorWidth:0,top:0},contentHeight:0,contentLeft:0,contentWidth:0,dataChanged:!1,frameHeight:0,frameWidth:0,groupsLeft:0,groupsWidth:0,items:{top:0}};this.dom.container=e;this.options={width:"100%",height:"auto",minHeight:0,autoHeight:!0,eventMargin:10,eventMarginAxis:20,dragAreaWidth:10,min:undefined,max:undefined,intervalMin:10,intervalMax:31536e10,moveable:!0,zoomable:!0,selectable:!0,editable:!1,snapEvents:!0,groupChangeable:!0,mousewheel:"zoom",dblclick:"edit",showCurrentTime:!0,showCustomTime:!1,showMajorLabels:!0,showNavigation:!1,showButtonAdd:!0,groupsOnRight:!1,axisOnTop:!1,stackEvents:!0,animate:!0,animateZoom:!0,style:"box",language:"en"};this.clientTimeOffset=0;var t=this.dom;while(t.container.hasChildNodes())t.container.removeChild(t.container.firstChild);this.step=new links.Timeline.StepDate;this.data=[];this.firstDraw=!0;this.setVisibleChartRange(undefined,undefined,!1);this.redrawFrame();Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;t3;for(var i=0,s=e.getNumberOfRows();i3;if(r){var i=e.getDistinctValues(3);for(var s=0,o=i.length;s0&&n.addRows(r);t.start&&n.setValue(e,0,t.start);t.end&&n.setValue(e,1,t.end);t.content&&n.setValue(e,2,t.content);t.group&&n.getNumberOfColumns()>3&&n.setValue(e,3,t.group)}else{if(!links.Timeline.isArray(n))throw"Cannot update data, unknown type of data";var i=n[e];if(i==undefined){i={};n[e]=i}t.start&&(i.start=t.start);t.end&&(i.end=t.end);t.content&&(i.content=t.content);t.group&&(i.group=t.group)}};links.Timeline.prototype.getItemIndex=function(e){var t=e,n=this.dom,r=this.items,i=undefined;while(t.parentNode&&t.parentNode!==n.items.frame)t=t.parentNode;if(t.parentNode===n.items.frame)for(var s=0,o=r.length;si&&(t=new Date(i));this.applyRange(e,t);if(n==undefined||n==1){this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame()}else this.recalcConversion()};links.Timeline.prototype.setVisibleChartRangeAuto=function(){var e=this.items,t=undefined,n=undefined;for(var r=0,i=e.length;r0){a===undefined&&(a=l);this.redrawAxisMajorText(l,r.getLabelMajor(undefined,t.language))}this.redrawAxisMajorLine(l)}else this.redrawAxisMinorLine(l);r.next()}if(t.showMajorLabels){var h=this.screenToTime(0),p=this.step.getLabelMajor(h,t.language),u=p.length*n.axis.characterMajorWidth+10;(a===undefined||ui){var s=r[i];n.removeChild(s);r.splice(i,1)}var o=e.axis.minorLines,i=t.minorLineNum;while(o.length>i){var u=o[i];n.removeChild(u);o.splice(i,1)}var a=e.axis.majorTexts,i=t.majorTextNum;while(a.length>i){var f=a[i];n.removeChild(f);a.splice(i,1)}var l=e.axis.majorLines,i=t.majorLineNum;while(l.length>i){var c=l[i];n.removeChild(c);l.splice(i,1)}};links.Timeline.prototype.redrawAxisHorizontal=function(){var e=this.dom.axis,t=this.size;if(!e.backgroundLine){var n=document.createElement("DIV");n.className="timeline-axis";n.style.position="absolute";n.style.left="0px";n.style.width="100%";n.style.border="none";e.frame.insertBefore(n,e.frame.firstChild);e.backgroundLine=n}e.backgroundLine.style.top=t.axis.top+"px";e.backgroundLine.style.height=t.axis.height+"px";if(e.line){var r=e.frame.removeChild(e.line);e.frame.appendChild(r)}else{var r=document.createElement("DIV");r.className="timeline-axis";r.style.position="absolute";r.style.left="0px";r.style.width="100%";r.style.height="0px";e.frame.appendChild(r);e.line=r}e.line.style.top=t.axis.line+"px"};links.Timeline.prototype.redrawAxisMinorText=function(e,t){var n=this.size,r=this.dom,i=n.axis.properties,s=r.axis.frame,o=r.axis.minorTexts,u=i.minorTextNum,a;if(u-n.contentWidth&&o<2*n.contentWidth;t.currentTime.style.display=u?"":"none";t.currentTime.style.left=o+"px";t.currentTime.title="Current time: "+s;if(this.currentTimeTimer!=undefined){clearTimeout(this.currentTimeTimer);delete this.currentTimeTimer}var a=this,f=function(){a.redrawCurrentTime()},l=1/this.conversion.factor/2;l<30&&(l=30);this.currentTimeTimer=setTimeout(f,l)};links.Timeline.prototype.redrawCustomTime=function(){var e=this.options,t=this.dom,n=this.size;if(!e.showCustomTime){if(t.customTime){t.contentTimelines.removeChild(t.customTime);delete t.customTime}return}if(!t.customTime){var r=document.createElement("DIV");r.className="timeline-customtime";r.style.position="absolute";r.style.top="0px";r.style.height="100%";var i=document.createElement("DIV");i.style.position="relative";i.style.top="0px";i.style.left="-10px";i.style.height="100%";i.style.width="20px";r.appendChild(i);t.contentTimelines.appendChild(r);t.customTime=r;this.customTime=new Date}var s=this.timeToScreen(this.customTime),o=s>-n.contentWidth&&s<2*n.contentWidth;t.customTime.style.display=o?"":"none";t.customTime.style.left=s+"px";t.customTime.title="Time: "+this.customTime};links.Timeline.prototype.redrawDeleteButton=function(){var e=this,t=this.options,n=this.dom,r=this.size,i=n.items.frame;if(!t.editable)return;var s=n.items.deleteButton;if(!s){s=document.createElement("DIV");s.className="timeline-navigation-delete";s.style.position="absolute";i.appendChild(s);n.items.deleteButton=s}if(this.selection){var o=this.selection.index,u=this.items[o],a=this.selection.item,f,l=u.top;switch(u.type){case"range":f=this.timeToScreen(u.end);break;case"box":f=this.timeToScreen(u.start)+u.width/2;break;case"dot":f=this.timeToScreen(u.start)+u.width}f<-r.contentWidth&&(f=-r.contentWidth);f>2*r.contentWidth&&(f=2*r.contentWidth);s.style.left=f+"px";s.style.top=l+"px";s.style.display="";i.removeChild(s);i.appendChild(s)}else s.style.display="none"};links.Timeline.prototype.redrawDragAreas=function(){var e=this,t=this.options,n=this.dom,r=this.size,i=this.dom.items.frame;if(!t.editable)return;var s=n.items.dragLeft;if(!s){s=document.createElement("DIV");s.className="timeline-event-range-drag-left";s.style.width=t.dragAreaWidth+"px";s.style.position="absolute";i.appendChild(s);n.items.dragLeft=s}var o=n.items.dragRight;if(!o){o=document.createElement("DIV");o.className="timeline-event-range-drag-right";o.style.width=t.dragAreaWidth+"px";o.style.position="absolute";i.appendChild(o);n.items.dragRight=o}if(this.selection){var u=this.selection.index,a=this.items[u];if(a.type=="range"){var f=a.dom,l=this.timeToScreen(a.start),c=this.timeToScreen(a.end),h=a.top,p=a.height;s.style.left=l+"px";s.style.top=h+"px";s.style.height=p+"px";s.style.display="";i.removeChild(s);i.appendChild(s);o.style.left=c-t.dragAreaWidth+"px";o.style.top=h+"px";o.style.height=p+"px";o.style.display="";i.removeChild(o);i.appendChild(o)}}else{s.style.display="none";o.style.display="none"}};links.Timeline.prototype.redrawNavigation=function(){var e=this,t=this.options,n=this.dom,r=n.frame,i=n.navBar;if(!i){if(t.editable||t.showNavigation){i=document.createElement("DIV");i.style.position="absolute";i.className="timeline-navigation";t.groupsOnRight?i.style.left="10px":i.style.right="10px";t.axisOnTop?i.style.bottom="10px":i.style.top="10px";n.navBar=i;r.appendChild(i)}if(t.editable&&t.showButtonAdd){i.addButton=document.createElement("DIV");i.addButton.className="timeline-navigation-new";i.addButton.title="Create new event";var s=function(n){links.Timeline.preventDefault(n);links.Timeline.stopPropagation(n);var r=e.size.contentWidth,i=r/2,s=e.screenToTime(i-r/10),o=e.screenToTime(i+r/10);if(t.snapEvents){e.step.snap(s);e.step.snap(o)}var u="New",a=e.groups.length?e.groups[0].content:undefined;e.addItem({start:s,end:o,content:u,group:a});var f=e.items.length-1;e.selectItem(f);e.applyAdd=!0;e.trigger("add");e.applyAdd||e.deleteItem(f);e.redrawDeleteButton();e.redrawDragAreas()};links.Timeline.addEventListener(i.addButton,"mousedown",s);i.appendChild(i.addButton)}if(t.editable&&t.showButtonAdd&&t.showNavigation){i.addButton.style.borderRightWidth="1px";i.addButton.style.borderRightStyle="solid"}if(t.showNavigation){i.zoomOutButton=document.createElement("DIV");i.zoomOutButton.className="timeline-navigation-zoom-out";i.zoomOutButton.title="Zoom out";var o=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.zoom(-0.7);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.zoomOutButton,"mousedown",o);i.appendChild(i.zoomOutButton);i.zoomInButton=document.createElement("DIV");i.zoomInButton.className="timeline-navigation-zoom-in";i.zoomInButton.title="Zoom in";var u=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.zoom(.7);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.zoomInButton,"mousedown",u);i.appendChild(i.zoomInButton);i.moveLeftButton=document.createElement("DIV");i.moveLeftButton.className="timeline-navigation-move-left";i.moveLeftButton.title="Move left";var a=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.move(-0.2);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.moveLeftButton,"mousedown",a);i.appendChild(i.moveLeftButton);i.moveRightButton=document.createElement("DIV");i.moveRightButton.className="timeline-navigation-move-right";i.moveRightButton.title="Move right";var f=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.move(.2);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.moveRightButton,"mousedown",f);i.appendChild(i.moveRightButton)}}};links.Timeline.prototype.setCurrentTime=function(e){var t=new Date;this.clientTimeOffset=e.getTime()-t.getTime();this.redrawCurrentTime()};links.Timeline.prototype.getCurrentTime=function(){var e=new Date;return new Date(e.getTime()+this.clientTimeOffset)};links.Timeline.prototype.setCustomTime=function(e){this.customTime=new Date(e);this.redrawCustomTime()};links.Timeline.prototype.getCustomTime=function(){return new Date(this.customTime)};links.Timeline.prototype.setScale=function(e,t){this.step.setScale(e,t);this.redrawFrame()};links.Timeline.prototype.setAutoScale=function(e){this.step.setAutoScale(e);this.redrawFrame()};links.Timeline.prototype.redraw=function(){this.setData(this.data)};links.Timeline.prototype.checkResize=function(){var e=this.recalcSize();e=this.repositionItems();e&&this.redrawFrame()};links.Timeline.filterImageUrls=function(e,t){var n=e.firstChild;while(n){if(n.tagName=="IMG"){var r=n.src;t.indexOf(r)==-1&&t.push(r)}links.Timeline.filterImageUrls(n,t);n=n.nextSibling}};links.Timeline.prototype.recalcSize=function(){var e=!1,t=this,n=this.size,r=this.options,i=r.axisOnTop,s=this.dom,o=s.axis,u=this.groups,a=s.groups.labels,f=this.items,l=n.groupsWidth,c=o.characterMinor?o.characterMinor.clientWidth:0,h=o.characterMinor?o.characterMinor.clientHeight:0,p=o.characterMajor?o.characterMajor.clientWidth:0,d=o.characterMajor?o.characterMajor.clientHeight:0,v=h+(r.showMajorLabels?d:0),m=n.actualHeight||v;if(n.dataChanged){var g=[];for(var y=0,b=f.length;yd){p=d;c.start=this.screenToTime(p)}}else if(t.itemDragRight){p=t.itemLeft;d=t.itemRight+u;c.end=this.screenToTime(d);if(i.snapEvents){this.step.snap(c.end);d=this.timeToScreen(c.end)}if(d=1&&(e=.9);e<=-1&&(e=-0.9);e<0&&(e/=1+e);var n=parseFloat(this.start.valueOf()-t.valueOf()),r=parseFloat(this.end.valueOf()-t.valueOf()),i=new Date(this.start.valueOf()-n*e),s=new Date(this.end.valueOf()-r*e);this.applyRange(i,s,t);this.recalcSize();var o=this.options.animate?this.options.animateZoom:!1;this.repositionItems();this.stackEvents(o);(!o||this.groups.length>0)&&this.redrawFrame()};links.Timeline.prototype.move=function(e){var t=parseFloat(this.end.valueOf()-this.start.valueOf()),n=new Date(this.start.valueOf()+t*e),r=new Date(this.end.valueOf()+t*e);this.applyRange(n,r);this.recalcConversion();this.repositionItems();this.stackEvents(this.options.animate);this.options.animate||this.redrawFrame()};links.Timeline.prototype.repositionItem=function(e,t,n){var r=e.dom;switch(e.type){case"range":r.style.left=t+"px";r.style.width=Math.max(n-t,1)+"px";break;case"box":r.style.left=t-e.width/2+"px";r.line.style.left=t-e.lineWidth/2+"px";r.dot.style.left=t-e.dotWidth/2+"px";break;case"dot":r.style.left=t-e.dotWidth/2+"px"}this.groups.length>0&&(r.style.top=e.top+"px")};links.Timeline.prototype.applyRange=function(e,t,n){var r=e.valueOf(),i=t.valueOf(),s=i-r,o=this.options,u=31536e6,a=Number(o.intervalMin)||10;a<10&&(a=10);var f=Number(o.intervalMax)||1e4*u;f>1e4*u&&(f=1e4*u);f=c){var h=864e5;c=l+h}f>c-l&&(f=c-l);a>c-l&&(a=c-l)}r>=i&&(i+=864e5);if(sf){var p=s-f,d=n?(n.valueOf()-r)/s:.5;r+=Math.round(p*d);i-=Math.round(p*(1-d))}if(l){var p=r-l;if(p<0){r-=p;i-=p}}if(c){var p=c-i;if(p<0){r+=p;i+=p}}this.start=new Date(r);this.end=new Date(i)};links.Timeline.prototype.confirmDeleteItem=function(e){this.applyDelete=!0;this.isSelected(e)||this.selectItem(e);this.trigger("delete");this.applyDelete&&this.deleteItem(e);delete this.applyDelete};links.Timeline.prototype.deleteItem=function(e){if(e>=this.items.length)throw"Cannot delete row, index out of range";this.unselectItem();this.items.splice(e,1);if(this.data)if(google&&google.visualization&&this.data instanceof google.visualization.DataTable)this.data.removeRow(e);else{if(!links.Timeline.isArray(this.data))throw"Cannot delete row from data, unknown data type";this.data.splice(e,1)}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(this.options.animate);this.options.animate||this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.deleteAllItems=function(){this.unselectItem();this.items=[];this.deleteGroups();if(this.data)if(google&&google.visualization&&this.data instanceof google.visualization.DataTable)this.data.removeRows(0,this.data.getNumberOfRows());else{if(!links.Timeline.isArray(this.data))throw"Cannot delete row from data, unknown data type";this.data.splice(0,this.data.length)}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(this.options.animate);this.options.animate||this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.getGroupFromHeight=function(e){var t=this.groups,n=this.options,r=this.size,i=e-(n.axisOnTop?r.axis.height:0);if(t){var s;for(var o=t.length-1;o>=0;o--){s=t[o];if(i>s.top)return s}return s}return undefined};links.Timeline.prototype.getItem=function(e){if(e>=this.items.length)throw"Cannot get item, index out of range";var t=this.items[e],n={};n.start=new Date(t.start);t.end&&(n.end=new Date(t.end));n.content=t.content;t.group&&(n.group=t.group.content);return n};links.Timeline.prototype.addItem=function(e){var t=[e];this.addItems(t)};links.Timeline.prototype.addItems=function(e){var t=e,n=this.items;for(var r=0,i=t.length;r=this.items.length)throw"Cannot change item, index out of range";var n=this.options.style,r=this.items[e];t.start&&(r.start=t.start);t.end&&(r.end=t.end);t.content&&(r.content=t.content);t.group&&(r.group=this.addGroup(t.group));this.updateData(e,t);this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.findGroup=function(e){var t=this.groupIndexes[e];return t!=undefined?this.groups[t]:undefined};links.Timeline.prototype.deleteGroups=function(){this.groups=[];this.groupIndexes={}};links.Timeline.prototype.addGroup=function(e){var t=this.groups,n=this.groupIndexes,r=undefined,i=n[e];if(i===undefined&&e!==undefined){r={content:e,labelTop:0,lineTop:0};t.push(r);t=t.sort(function(e,t){return e.content>t.content?1:e.content0){if(e[0].row!=undefined){var t=e[0].row;if(this.items[t]){var n=this.items[t];this.selectItem(t);var r=n.start,i=n.end,s;i!=undefined?s=new Date((i.valueOf()+r.valueOf())/2):s=new Date(r);var o=this.end.valueOf()-this.start.valueOf(),u=new Date(s.valueOf()-o/2),a=new Date(s.valueOf()+o/2);this.setVisibleChartRange(u,a);return!0}}}else this.unselectItem();return!1};links.Timeline.prototype.getSelection=function(){var e=[];this.selection&&e.push({row:this.selection.index});return e};links.Timeline.prototype.selectItem=function(e){this.unselectItem();this.selection=undefined;if(this.items[e]!==undefined){var t=this.items[e],n=t.dom;this.selection={index:e,item:n};this.options.editable&&(n.style.cursor="move");switch(t.type){case"range":n.className="timeline-event timeline-event-selected timeline-event-range";break;case"box":n.className="timeline-event timeline-event-selected timeline-event-box";n.line.className="timeline-event timeline-event-selected timeline-event-line";n.dot.className="timeline-event timeline-event-selected timeline-event-dot";break;case"dot":n.className="timeline-event timeline-event-selected";n.dot.className="timeline-event timeline-event-selected timeline-event-dot"}}};links.Timeline.prototype.isSelected=function(e){return this.selection&&this.selection.index===e};links.Timeline.prototype.unselectItem=function(){if(this.selection){var e=this.items[this.selection.index];if(e&&e.dom){var t=e.dom;t.style.cursor="";switch(e.type){case"range":t.className="timeline-event timeline-event-range";break;case"box":t.className="timeline-event timeline-event-box";t.line.className="timeline-event timeline-event-line";t.dot.className="timeline-event timeline-event-dot";break;case"dot":t.className="";t.dot.className="timeline-event timeline-event-dot"}}}this.selection=undefined};links.Timeline.prototype.repositionItems=function(){var e=this.size,t=e.contentWidth,n,r,i=[];for(var s=0,o=this.items.length;s2*t&&(n.right=2*t);var u=n.right>-t&&n.left<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display=""}}else if(!n.hidden){r.style.display="none";n.hidden=!0}break;case"box":n.left=this.timeToScreen(n.start);var u=n.left+n.width/2>-t&&n.left-n.width/2<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display="";r.line.style.display="";r.dot.style.display=""}}else if(!n.hidden){r.style.display="none";r.line.style.display="none";r.dot.style.display="none";n.hidden=!0}break;case"dot":n.left=this.timeToScreen(n.start);var u=n.left+n.width>-t&&n.left<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display=""}}else if(!n.hidden){r.style.display="none";n.hidden=!0}break;default:}n.hidden||i.push(n);this.items[s]=n}this.visibleItems.length!=i.length?this.visibleItemsChanged=!0:this.visibleItemsChanged=!1;this.visibleItems=i;this.itemsSizeChanged=!1};links.Timeline.prototype.stackEvents=function(e){this.trigger("on-before-stack-events");this.itemsSizeChanged&&this.recalcSizeItems();if(this.groups.length>0)return;e==undefined&&(e=!1);var t=this.stackOrder(this.items),n=this.stackCalculateFinal(t,e);if(e){var r=this.animation;if(!r){r={};this.animation=r}r.finalItems=n;var i=this,s=function(){var e=i.stackMoveOneStep(t,r.finalItems);i.recalcSize();i.repositionItems();i.redrawFrame();if(!e)r.timer=setTimeout(s,30);else{delete r.finalItems;delete r.timer}};r.timer||(r.timer=setTimeout(s,30))}else{this.stackMoveToFinal(t,n);this.recalcSize()}};links.Timeline.prototype.stackOrder=function(e){var t=e.concat([]),n=function(e,t){return e.type=="range"&&t.type!="range"?-1:e.type!="range"&&t.type=="range"?1:e.left-t.left};t.sort(n);return t};links.Timeline.prototype.stackCalculateFinal=function(e){var t=this.size,n=t.axis.top,r=this.options,i=r.axisOnTop,s=r.eventMargin,o=r.eventMarginAxis,u=[];for(var a=0,f=e.length;ao?1:-1;Math.abs(a)>4&&(f=a/4);var l=parseInt(o+f);l!=u&&(n=!1);s.top=l;s.bottom=s.top+s.height}else{s.top=r.top;s.bottom=r.bottom}s.left=r.left;s.right=r.right}return n};links.Timeline.prototype.stackMoveToFinal=function(e,t){for(i=0,iMax=e.length;i=n;u--){var a=e[u];if(s(o,a,i)&&u!=t)return a}return undefined};links.Timeline.prototype.collision=function(e,t,n){n==undefined&&(n=0);return e.left-nt.left&&e.top-nt.top};links.Timeline.prototype.trigger=function(e){var t=null;switch(e){case"rangechange":case"rangechanged":t={start:new Date(this.start),end:new Date(this.end)};break;case"timechange":case"timechanged":t={time:new Date(this.customTime)}}links.events.trigger(this,e,t);google&&google.visualization&&google.visualization.events.trigger(this,e,t)};links.events=links.events||{listeners:[],indexOf:function(e){var t=this.listeners;for(var n=0,r=this.listeners.length;nthis._end.getTime()};links.Timeline.StepDate.prototype.next=function(){var e=this.current.getTime();if(this.current.getMonth()<6)switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.getTime()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current=new Date(this.current.getTime()+this.step*1e3);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current=new Date(this.current.getTime()+this.step*1e3*60);break;case links.Timeline.StepDate.SCALE.HOUR:this.current=new Date(this.current.getTime()+this.step*1e3*60*60);var t=this.current.getHours();this.current.setHours(t-t%this.step);break;case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:}else switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.getTime()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current.setSeconds(this.current.getSeconds()+this.step);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current.setMinutes(this.current.getMinutes()+this.step);break;case links.Timeline.StepDate.SCALE.HOUR:this.current.setHours(this.current.getHours()+this.step);break;case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:}if(this.step!=1)switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current.getMilliseconds()0&&(this.step=t);this.autoScale=!1};links.Timeline.StepDate.prototype.setAutoScale=function(e){this.autoScale=e};links.Timeline.StepDate.prototype.setMinimumStep=function(e){if(e==undefined)return;var t=31104e6,n=2592e6,r=864e5,i=36e5,s=6e4,o=1e3,u=1;if(t*1e3>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1e3}if(t*500>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=500}if(t*100>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=100}if(t*50>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=50}if(t*10>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=10}if(t*5>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=5}if(t>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1}if(n*3>e){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=3}if(n>e){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=1}if(r*5>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=5}if(r*2>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=2}if(r>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1}if(i*4>e){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=4}if(i>e){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=1}if(s*15>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=15}if(s*10>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=10}if(s*5>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=5}if(s>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=1}if(o*15>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=15}if(o*10>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=10}if(o*5>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=5}if(o>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=1}if(u*200>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=200}if(u*100>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=100}if(u*50>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=50}if(u*10>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=10}if(u*5>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=5}if(u>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=1}};links.Timeline.StepDate.prototype.snap=function(e){if(this.scale==links.Timeline.StepDate.SCALE.YEAR){var t=e.getFullYear()+Math.round(e.getMonth()/12);e.setFullYear(Math.round(t/this.step)*this.step);e.setMonth(0);e.setDate(0);e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.MONTH){if(e.getDate()>15){e.setDate(1);e.setMonth(e.getMonth()+1)}else e.setDate(1);e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.DAY){switch(this.step){case 5:case 2:e.setHours(Math.round(e.getHours()/24)*24);break;default:e.setHours(Math.round(e.getHours()/12)*12)}e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.HOUR){switch(this.step){case 4:e.setMinutes(Math.round(e.getMinutes()/60)*60);break;default:e.setMinutes(Math.round(e.getMinutes()/30)*30)}e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.MINUTE){switch(this.step){case 15:case 10:e.setMinutes(Math.round(e.getMinutes()/5)*5);e.setSeconds(0);break;case 5:e.setSeconds(Math.round(e.getSeconds()/60)*60);break;default:e.setSeconds(Math.round(e.getSeconds()/30)*30)}e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.SECOND)switch(this.step){case 15:case 10:e.setSeconds(Math.round(e.getSeconds()/5)*5);e.setMilliseconds(0);break;case 5:e.setMilliseconds(Math.round(e.getMilliseconds()/1e3)*1e3);break;default:e.setMilliseconds(Math.round(e.getMilliseconds()/500)*500)}else if(this.scale==links.Timeline.StepDate.SCALE.MILLISECOND){var n=this.step>5?this.step/2:1;e.setMilliseconds(Math.round(e.getMilliseconds()/n)*n)}};links.Timeline.StepDate.prototype.isMajor=function(){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return this.current.getMilliseconds()==0;case links.Timeline.StepDate.SCALE.SECOND:return this.current.getSeconds()==0;case links.Timeline.StepDate.SCALE.MINUTE:return this.current.getHours()==0&&this.current.getMinutes()==0;case links.Timeline.StepDate.SCALE.HOUR:return this.current.getHours()==0;case links.Timeline.StepDate.SCALE.DAY:return this.current.getDate()==1;case links.Timeline.StepDate.SCALE.MONTH:return this.current.getMonth()==0;case links.Timeline.StepDate.SCALE.YEAR:return!1;default:return!1}};links.Timeline.StepDate.prototype.getLabelMinor=function(e,t){switch(t){case"fr":var n=new Array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");break;case"en":default:var n=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")}e==undefined&&(e=this.current);switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return String(e.getMilliseconds());case links.Timeline.StepDate.SCALE.SECOND:return String(e.getSeconds());case links.Timeline.StepDate.SCALE.MINUTE:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.HOUR:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.DAY:return String(e.getDate());case links.Timeline.StepDate.SCALE.MONTH:return n[e.getMonth( )];case links.Timeline.StepDate.SCALE.YEAR:return String(e.getFullYear());default:return""}};links.Timeline.StepDate.prototype.getLabelMajor=function(e,t){switch(t){case"fr":var n=new Array("Janvier","FĂ©vrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"),r=new Array("Dimanche","Lundi","Mardi","mercredi","Jeudi","Vendredi","Samedi");break;case"en":default:var n=new Array("January","February","March","April","May","June","July","August","September","October","November","December"),r=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")}e==undefined&&(e=this.current);switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2)+":"+this.addZeros(e.getSeconds(),2);case links.Timeline.StepDate.SCALE.SECOND:return e.getDate()+" "+n[e.getMonth()]+" "+this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.MINUTE:return r[e.getDay()]+" "+e.getDate()+" "+n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.HOUR:return r[e.getDay()]+" "+e.getDate()+" "+n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.DAY:return n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.MONTH:return String(e.getFullYear());default:return""}};links.Timeline.StepDate.prototype.addZeros=function(e,t){var n=""+e;while(n.length=0&&(t="DOMMouseScroll");e.addEventListener(t,n,r)}else e.attachEvent("on"+t,n)};links.Timeline.removeEventListener=function(e,t,n,r){if(e.removeEventListener){r===undefined&&(r=!1);t==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(t="DOMMouseScroll");e.removeEventListener(t,n,r)}else e.detachEvent("on"+t,n)};links.Timeline.getTarget=function(e){e||(e=window.event);var t;e.target?t=e.target:e.srcElement&&(t=e.srcElement);t.nodeType!==undefined&&t.nodeType==3&&(t=t.parentNode);return t};links.Timeline.stopPropagation=function(e){e||(e=window.event);e.stopPropagation?e.stopPropagation():e.cancelBubble=!0};links.Timeline.preventDefault=function(e){e||(e=window.event);e.preventDefault?e.preventDefault():e.returnValue=!1};links.Timeline.getAbsoluteLeft=function(e){var t=0;while(e!=null){t+=e.offsetLeft;t-=e.scrollLeft;e=e.offsetParent}!document.body.scrollLeft&&window.pageXOffset&&(t-=window.pageXOffset);return t};links.Timeline.getAbsoluteTop=function(e){var t=0;while(e!=null){t+=e.offsetTop;t-=e.scrollTop;e=e.offsetParent}!document.body.scrollTop&&window.pageYOffset&&(t-=window.pageYOffset);return t};links.Timeline.isArray=function(e){return e instanceof Array?!0:Object.prototype.toString.call(e)==="[object Array]"};