PageRenderTime 80ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/timeline/timeline-bundle-debug.js

http://showslow.googlecode.com/
JavaScript | 2950 lines | 2911 code | 26 blank | 13 comment | 197 complexity | 7291e2b177ef0134c5916c11f1d23649 MD5 | raw file
  1. /* band.js */
  2. Timeline._Band=function(timeline,bandInfo,index){if(timeline.autoWidth&&typeof bandInfo.width=="string"){bandInfo.width=bandInfo.width.indexOf("%")>-1?0:parseInt(bandInfo.width);
  3. }this._timeline=timeline;
  4. this._bandInfo=bandInfo;
  5. this._index=index;
  6. this._locale=("locale" in bandInfo)?bandInfo.locale:Timeline.getDefaultLocale();
  7. this._timeZone=("timeZone" in bandInfo)?bandInfo.timeZone:0;
  8. this._labeller=("labeller" in bandInfo)?bandInfo.labeller:(("createLabeller" in timeline.getUnit())?timeline.getUnit().createLabeller(this._locale,this._timeZone):new Timeline.GregorianDateLabeller(this._locale,this._timeZone));
  9. this._theme=bandInfo.theme;
  10. this._zoomIndex=("zoomIndex" in bandInfo)?bandInfo.zoomIndex:0;
  11. this._zoomSteps=("zoomSteps" in bandInfo)?bandInfo.zoomSteps:null;
  12. this._dragging=false;
  13. this._changing=false;
  14. this._originalScrollSpeed=5;
  15. this._scrollSpeed=this._originalScrollSpeed;
  16. this._onScrollListeners=[];
  17. this._orthogonalDragging=false;
  18. this._viewOrthogonalOffset=0;
  19. this._onOrthogonalScrollListeners=[];
  20. var b=this;
  21. this._syncWithBand=null;
  22. this._syncWithBandHandler=function(band){b._onHighlightBandScroll();
  23. };
  24. this._syncWithBandOrthogonalScrollHandler=function(band){b._onHighlightBandOrthogonalScroll();
  25. };
  26. this._selectorListener=function(band){b._onHighlightBandScroll();
  27. };
  28. var inputDiv=this._timeline.getDocument().createElement("div");
  29. inputDiv.className="timeline-band-input";
  30. this._timeline.addDiv(inputDiv);
  31. this._keyboardInput=document.createElement("input");
  32. this._keyboardInput.type="text";
  33. inputDiv.appendChild(this._keyboardInput);
  34. SimileAjax.DOM.registerEventWithObject(this._keyboardInput,"keydown",this,"_onKeyDown");
  35. SimileAjax.DOM.registerEventWithObject(this._keyboardInput,"keyup",this,"_onKeyUp");
  36. this._div=this._timeline.getDocument().createElement("div");
  37. this._div.id="timeline-band-"+index;
  38. this._div.className="timeline-band timeline-band-"+index;
  39. this._timeline.addDiv(this._div);
  40. SimileAjax.DOM.registerEventWithObject(this._div,"dblclick",this,"_onDblClick");
  41. SimileAjax.DOM.registerEventWithObject(this._div,"mousedown",this,"_onMouseDown");
  42. SimileAjax.DOM.registerEventWithObject(document.body,"mousemove",this,"_onMouseMove");
  43. SimileAjax.DOM.registerEventWithObject(document.body,"mouseup",this,"_onMouseUp");
  44. SimileAjax.DOM.registerEventWithObject(document.body,"mouseout",this,"_onMouseOut");
  45. var mouseWheel=this._theme!=null?this._theme.mouseWheel:"scroll";
  46. if(mouseWheel==="zoom"||mouseWheel==="scroll"||this._zoomSteps){if(SimileAjax.Platform.browser.isFirefox){SimileAjax.DOM.registerEventWithObject(this._div,"DOMMouseScroll",this,"_onMouseScroll");
  47. }else{SimileAjax.DOM.registerEventWithObject(this._div,"mousewheel",this,"_onMouseScroll");
  48. }}this._innerDiv=this._timeline.getDocument().createElement("div");
  49. this._innerDiv.className="timeline-band-inner";
  50. this._div.appendChild(this._innerDiv);
  51. this._ether=bandInfo.ether;
  52. bandInfo.ether.initialize(this,timeline);
  53. this._etherPainter=bandInfo.etherPainter;
  54. bandInfo.etherPainter.initialize(this,timeline);
  55. this._eventSource=bandInfo.eventSource;
  56. if(this._eventSource){this._eventListener={onAddMany:function(){b._onAddMany();
  57. },onClear:function(){b._onClear();
  58. }};
  59. this._eventSource.addListener(this._eventListener);
  60. }this._eventPainter=bandInfo.eventPainter;
  61. this._eventTracksNeeded=0;
  62. this._eventTrackIncrement=0;
  63. bandInfo.eventPainter.initialize(this,timeline);
  64. this._decorators=("decorators" in bandInfo)?bandInfo.decorators:[];
  65. for(var i=0;
  66. i<this._decorators.length;
  67. i++){this._decorators[i].initialize(this,timeline);
  68. }this._supportsOrthogonalScrolling=("supportsOrthogonalScrolling" in this._eventPainter)&&this._eventPainter.supportsOrthogonalScrolling();
  69. if(this._supportsOrthogonalScrolling){this._scrollBar=this._timeline.getDocument().createElement("div");
  70. this._scrollBar.id="timeline-band-scrollbar-"+index;
  71. this._scrollBar.className="timeline-band-scrollbar";
  72. this._timeline.addDiv(this._scrollBar);
  73. this._scrollBar.innerHTML='<div class="timeline-band-scrollbar-thumb"> </div>';
  74. var scrollbarThumb=this._scrollBar.firstChild;
  75. if(SimileAjax.Platform.browser.isIE){scrollbarThumb.style.cursor="move";
  76. }else{scrollbarThumb.style.cursor="-moz-grab";
  77. }SimileAjax.DOM.registerEventWithObject(scrollbarThumb,"mousedown",this,"_onScrollBarMouseDown");
  78. }};
  79. Timeline._Band.SCROLL_MULTIPLES=5;
  80. Timeline._Band.prototype.dispose=function(){this.closeBubble();
  81. if(this._eventSource){this._eventSource.removeListener(this._eventListener);
  82. this._eventListener=null;
  83. this._eventSource=null;
  84. }this._timeline=null;
  85. this._bandInfo=null;
  86. this._labeller=null;
  87. this._ether=null;
  88. this._etherPainter=null;
  89. this._eventPainter=null;
  90. this._decorators=null;
  91. this._onScrollListeners=null;
  92. this._syncWithBandHandler=null;
  93. this._syncWithBandOrthogonalScrollHandler=null;
  94. this._selectorListener=null;
  95. this._div=null;
  96. this._innerDiv=null;
  97. this._keyboardInput=null;
  98. this._scrollBar=null;
  99. };
  100. Timeline._Band.prototype.addOnScrollListener=function(listener){this._onScrollListeners.push(listener);
  101. };
  102. Timeline._Band.prototype.removeOnScrollListener=function(listener){for(var i=0;
  103. i<this._onScrollListeners.length;
  104. i++){if(this._onScrollListeners[i]==listener){this._onScrollListeners.splice(i,1);
  105. break;
  106. }}};
  107. Timeline._Band.prototype.addOnOrthogonalScrollListener=function(listener){this._onOrthogonalScrollListeners.push(listener);
  108. };
  109. Timeline._Band.prototype.removeOnOrthogonalScrollListener=function(listener){for(var i=0;
  110. i<this._onOrthogonalScrollListeners.length;
  111. i++){if(this._onOrthogonalScrollListeners[i]==listener){this._onOrthogonalScrollListeners.splice(i,1);
  112. break;
  113. }}};
  114. Timeline._Band.prototype.setSyncWithBand=function(band,highlight){if(this._syncWithBand){this._syncWithBand.removeOnScrollListener(this._syncWithBandHandler);
  115. this._syncWithBand.removeOnOrthogonalScrollListener(this._syncWithBandOrthogonalScrollHandler);
  116. }this._syncWithBand=band;
  117. this._syncWithBand.addOnScrollListener(this._syncWithBandHandler);
  118. this._syncWithBand.addOnOrthogonalScrollListener(this._syncWithBandOrthogonalScrollHandler);
  119. this._highlight=highlight;
  120. this._positionHighlight();
  121. };
  122. Timeline._Band.prototype.getLocale=function(){return this._locale;
  123. };
  124. Timeline._Band.prototype.getTimeZone=function(){return this._timeZone;
  125. };
  126. Timeline._Band.prototype.getLabeller=function(){return this._labeller;
  127. };
  128. Timeline._Band.prototype.getIndex=function(){return this._index;
  129. };
  130. Timeline._Band.prototype.getEther=function(){return this._ether;
  131. };
  132. Timeline._Band.prototype.getEtherPainter=function(){return this._etherPainter;
  133. };
  134. Timeline._Band.prototype.getEventSource=function(){return this._eventSource;
  135. };
  136. Timeline._Band.prototype.getEventPainter=function(){return this._eventPainter;
  137. };
  138. Timeline._Band.prototype.getTimeline=function(){return this._timeline;
  139. };
  140. Timeline._Band.prototype.updateEventTrackInfo=function(tracks,increment){this._eventTrackIncrement=increment;
  141. if(tracks>this._eventTracksNeeded){this._eventTracksNeeded=tracks;
  142. }};
  143. Timeline._Band.prototype.checkAutoWidth=function(){if(!this._timeline.autoWidth){return ;
  144. }var overviewBand=this._eventPainter.getType()=="overview";
  145. var margin=overviewBand?this._theme.event.overviewTrack.autoWidthMargin:this._theme.event.track.autoWidthMargin;
  146. var desiredWidth=Math.ceil((this._eventTracksNeeded+margin)*this._eventTrackIncrement);
  147. desiredWidth+=overviewBand?this._theme.event.overviewTrack.offset:this._theme.event.track.offset;
  148. var bandInfo=this._bandInfo;
  149. if(desiredWidth!=bandInfo.width){bandInfo.width=desiredWidth;
  150. }};
  151. Timeline._Band.prototype.layout=function(){this.paint();
  152. };
  153. Timeline._Band.prototype.paint=function(){this._etherPainter.paint();
  154. this._paintDecorators();
  155. this._paintEvents();
  156. };
  157. Timeline._Band.prototype.softLayout=function(){this.softPaint();
  158. };
  159. Timeline._Band.prototype.softPaint=function(){this._etherPainter.softPaint();
  160. this._softPaintDecorators();
  161. this._softPaintEvents();
  162. };
  163. Timeline._Band.prototype.setBandShiftAndWidth=function(shift,width){var inputDiv=this._keyboardInput.parentNode;
  164. var middle=shift+Math.floor(width/2);
  165. if(this._timeline.isHorizontal()){this._div.style.top=shift+"px";
  166. this._div.style.height=width+"px";
  167. inputDiv.style.top=middle+"px";
  168. inputDiv.style.left="-1em";
  169. }else{this._div.style.left=shift+"px";
  170. this._div.style.width=width+"px";
  171. inputDiv.style.left=middle+"px";
  172. inputDiv.style.top="-1em";
  173. }};
  174. Timeline._Band.prototype.getViewWidth=function(){if(this._timeline.isHorizontal()){return this._div.offsetHeight;
  175. }else{return this._div.offsetWidth;
  176. }};
  177. Timeline._Band.prototype.setViewLength=function(length){this._viewLength=length;
  178. this._recenterDiv();
  179. this._onChanging();
  180. };
  181. Timeline._Band.prototype.getViewLength=function(){return this._viewLength;
  182. };
  183. Timeline._Band.prototype.getTotalViewLength=function(){return Timeline._Band.SCROLL_MULTIPLES*this._viewLength;
  184. };
  185. Timeline._Band.prototype.getViewOffset=function(){return this._viewOffset;
  186. };
  187. Timeline._Band.prototype.getMinDate=function(){return this._ether.pixelOffsetToDate(this._viewOffset);
  188. };
  189. Timeline._Band.prototype.getMaxDate=function(){return this._ether.pixelOffsetToDate(this._viewOffset+Timeline._Band.SCROLL_MULTIPLES*this._viewLength);
  190. };
  191. Timeline._Band.prototype.getMinVisibleDate=function(){return this._ether.pixelOffsetToDate(0);
  192. };
  193. Timeline._Band.prototype.getMinVisibleDateAfterDelta=function(delta){return this._ether.pixelOffsetToDate(delta);
  194. };
  195. Timeline._Band.prototype.getMaxVisibleDate=function(){return this._ether.pixelOffsetToDate(this._viewLength);
  196. };
  197. Timeline._Band.prototype.getMaxVisibleDateAfterDelta=function(delta){return this._ether.pixelOffsetToDate(this._viewLength+delta);
  198. };
  199. Timeline._Band.prototype.getCenterVisibleDate=function(){return this._ether.pixelOffsetToDate(this._viewLength/2);
  200. };
  201. Timeline._Band.prototype.setMinVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(-this._ether.dateToPixelOffset(date)));
  202. }};
  203. Timeline._Band.prototype.setMaxVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(this._viewLength-this._ether.dateToPixelOffset(date)));
  204. }};
  205. Timeline._Band.prototype.setCenterVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(this._viewLength/2-this._ether.dateToPixelOffset(date)));
  206. }};
  207. Timeline._Band.prototype.dateToPixelOffset=function(date){return this._ether.dateToPixelOffset(date)-this._viewOffset;
  208. };
  209. Timeline._Band.prototype.pixelOffsetToDate=function(pixels){return this._ether.pixelOffsetToDate(pixels+this._viewOffset);
  210. };
  211. Timeline._Band.prototype.getViewOrthogonalOffset=function(){return this._viewOrthogonalOffset;
  212. };
  213. Timeline._Band.prototype.setViewOrthogonalOffset=function(offset){this._viewOrthogonalOffset=Math.max(0,offset);
  214. };
  215. Timeline._Band.prototype.createLayerDiv=function(zIndex,className){var div=this._timeline.getDocument().createElement("div");
  216. div.className="timeline-band-layer"+(typeof className=="string"?(" "+className):"");
  217. div.style.zIndex=zIndex;
  218. this._innerDiv.appendChild(div);
  219. var innerDiv=this._timeline.getDocument().createElement("div");
  220. innerDiv.className="timeline-band-layer-inner";
  221. if(SimileAjax.Platform.browser.isIE){innerDiv.style.cursor="move";
  222. }else{innerDiv.style.cursor="-moz-grab";
  223. }div.appendChild(innerDiv);
  224. return innerDiv;
  225. };
  226. Timeline._Band.prototype.removeLayerDiv=function(div){this._innerDiv.removeChild(div.parentNode);
  227. };
  228. Timeline._Band.prototype.scrollToCenter=function(date,f){var pixelOffset=this._ether.dateToPixelOffset(date);
  229. if(pixelOffset<-this._viewLength/2){this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset+this._viewLength));
  230. }else{if(pixelOffset>3*this._viewLength/2){this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset-this._viewLength));
  231. }}this._autoScroll(Math.round(this._viewLength/2-this._ether.dateToPixelOffset(date)),f);
  232. };
  233. Timeline._Band.prototype.showBubbleForEvent=function(eventID){var evt=this.getEventSource().getEvent(eventID);
  234. if(evt){var self=this;
  235. this.scrollToCenter(evt.getStart(),function(){self._eventPainter.showBubble(evt);
  236. });
  237. }};
  238. Timeline._Band.prototype.zoom=function(zoomIn,x,y,target){if(!this._zoomSteps){return ;
  239. }x+=this._viewOffset;
  240. var zoomDate=this._ether.pixelOffsetToDate(x);
  241. var netIntervalChange=this._ether.zoom(zoomIn);
  242. this._etherPainter.zoom(netIntervalChange);
  243. this._moveEther(Math.round(-this._ether.dateToPixelOffset(zoomDate)));
  244. this._moveEther(x);
  245. };
  246. Timeline._Band.prototype._onMouseDown=function(elmt,evt,target){if(!this._dragging){this.closeBubble();
  247. this._dragging=true;
  248. this._dragX=evt.clientX;
  249. this._dragY=evt.clientY;
  250. return this._cancelEvent(evt);
  251. }};
  252. Timeline._Band.prototype._onMouseMove=function(elmt,evt,target){if(this._dragging||this._orthogonalDragging){var diffX=evt.clientX-this._dragX;
  253. var diffY=evt.clientY-this._dragY;
  254. this._dragX=evt.clientX;
  255. this._dragY=evt.clientY;
  256. }if(this._dragging){if(this._timeline.isHorizontal()){this._moveEther(diffX,diffY);
  257. }else{this._moveEther(diffY,diffX);
  258. }}else{if(this._orthogonalDragging){var viewWidth=this.getViewWidth();
  259. var scrollbarThumb=this._scrollBar.firstChild;
  260. if(this._timeline.isHorizontal()){this._moveEther(0,-diffY*viewWidth/scrollbarThumb.offsetHeight);
  261. }else{this._moveEther(0,-diffX*viewWidth/scrollbarThumb.offsetWidth);
  262. }}else{return ;
  263. }}this._positionHighlight();
  264. this._showScrollbar();
  265. return this._cancelEvent(evt);
  266. };
  267. Timeline._Band.prototype._onMouseUp=function(elmt,evt,target){if(this._dragging){this._dragging=false;
  268. }else{if(this._orthogonalDragging){this._orthogonalDragging=false;
  269. }else{return ;
  270. }}this._keyboardInput.focus();
  271. this._bounceBack();
  272. return this._cancelEvent(evt);
  273. };
  274. Timeline._Band.prototype._onMouseOut=function(elmt,evt,target){if(target==document.body){if(this._dragging){this._dragging=false;
  275. }else{if(this._orthogonalDragging){this._orthogonalDragging=false;
  276. }else{return ;
  277. }}this._bounceBack();
  278. return this._cancelEvent(evt);
  279. }};
  280. Timeline._Band.prototype._onScrollBarMouseDown=function(elmt,evt,target){if(!this._orthogonalDragging){this.closeBubble();
  281. this._orthogonalDragging=true;
  282. this._dragX=evt.clientX;
  283. this._dragY=evt.clientY;
  284. return this._cancelEvent(evt);
  285. }};
  286. Timeline._Band.prototype._onMouseScroll=function(innerFrame,evt,target){var now=new Date();
  287. now=now.getTime();
  288. if(!this._lastScrollTime||((now-this._lastScrollTime)>50)){this._lastScrollTime=now;
  289. var delta=0;
  290. if(evt.wheelDelta){delta=evt.wheelDelta/120;
  291. }else{if(evt.detail){delta=-evt.detail/3;
  292. }}var mouseWheel=this._theme.mouseWheel;
  293. if(this._zoomSteps||mouseWheel==="zoom"){var loc=SimileAjax.DOM.getEventRelativeCoordinates(evt,innerFrame);
  294. if(delta!=0){var zoomIn;
  295. if(delta>0){zoomIn=true;
  296. }if(delta<0){zoomIn=false;
  297. }this._timeline.zoom(zoomIn,loc.x,loc.y,innerFrame);
  298. }}else{if(mouseWheel==="scroll"){var move_amt=50*(delta<0?-1:1);
  299. this._moveEther(move_amt);
  300. }}}if(evt.stopPropagation){evt.stopPropagation();
  301. }evt.cancelBubble=true;
  302. if(evt.preventDefault){evt.preventDefault();
  303. }evt.returnValue=false;
  304. };
  305. Timeline._Band.prototype._onDblClick=function(innerFrame,evt,target){var coords=SimileAjax.DOM.getEventRelativeCoordinates(evt,innerFrame);
  306. var distance=coords.x-(this._viewLength/2-this._viewOffset);
  307. this._autoScroll(-distance);
  308. };
  309. Timeline._Band.prototype._onKeyDown=function(keyboardInput,evt,target){if(!this._dragging){switch(evt.keyCode){case 27:break;
  310. case 37:case 38:this._scrollSpeed=Math.min(50,Math.abs(this._scrollSpeed*1.05));
  311. this._moveEther(this._scrollSpeed);
  312. break;
  313. case 39:case 40:this._scrollSpeed=-Math.min(50,Math.abs(this._scrollSpeed*1.05));
  314. this._moveEther(this._scrollSpeed);
  315. break;
  316. default:return true;
  317. }this.closeBubble();
  318. SimileAjax.DOM.cancelEvent(evt);
  319. return false;
  320. }return true;
  321. };
  322. Timeline._Band.prototype._onKeyUp=function(keyboardInput,evt,target){if(!this._dragging){this._scrollSpeed=this._originalScrollSpeed;
  323. switch(evt.keyCode){case 35:this.setCenterVisibleDate(this._eventSource.getLatestDate());
  324. break;
  325. case 36:this.setCenterVisibleDate(this._eventSource.getEarliestDate());
  326. break;
  327. case 33:this._autoScroll(this._timeline.getPixelLength());
  328. break;
  329. case 34:this._autoScroll(-this._timeline.getPixelLength());
  330. break;
  331. default:return true;
  332. }this.closeBubble();
  333. SimileAjax.DOM.cancelEvent(evt);
  334. return false;
  335. }return true;
  336. };
  337. Timeline._Band.prototype._autoScroll=function(distance,f){var b=this;
  338. var a=SimileAjax.Graphics.createAnimation(function(abs,diff){b._moveEther(diff);
  339. },0,distance,1000,f);
  340. a.run();
  341. };
  342. Timeline._Band.prototype._moveEther=function(shift,orthogonalShift){if(orthogonalShift===undefined){orthogonalShift=0;
  343. }this.closeBubble();
  344. if(!this._timeline.shiftOK(this._index,shift)){return ;
  345. }this._viewOffset+=shift;
  346. this._ether.shiftPixels(-shift);
  347. if(this._timeline.isHorizontal()){this._div.style.left=this._viewOffset+"px";
  348. }else{this._div.style.top=this._viewOffset+"px";
  349. }if(this._supportsOrthogonalScrolling){if(this._eventPainter.getOrthogonalExtent()<=this.getViewWidth()){this._viewOrthogonalOffset=0;
  350. }else{this._viewOrthogonalOffset=this._viewOrthogonalOffset+orthogonalShift;
  351. }}if(this._viewOffset>-this._viewLength*0.5||this._viewOffset<-this._viewLength*(Timeline._Band.SCROLL_MULTIPLES-1.5)){this._recenterDiv();
  352. }else{this.softLayout();
  353. }this._onChanging();
  354. };
  355. Timeline._Band.prototype._onChanging=function(){this._changing=true;
  356. this._fireOnScroll();
  357. this._setSyncWithBandDate();
  358. this._changing=false;
  359. };
  360. Timeline._Band.prototype.busy=function(){return(this._changing);
  361. };
  362. Timeline._Band.prototype._fireOnScroll=function(){for(var i=0;
  363. i<this._onScrollListeners.length;
  364. i++){this._onScrollListeners[i](this);
  365. }};
  366. Timeline._Band.prototype._fireOnOrthogonalScroll=function(){for(var i=0;
  367. i<this._onOrthogonalScrollListeners.length;
  368. i++){this._onOrthogonalScrollListeners[i](this);
  369. }};
  370. Timeline._Band.prototype._setSyncWithBandDate=function(){if(this._syncWithBand){var centerDate=this._ether.pixelOffsetToDate(this.getViewLength()/2);
  371. this._syncWithBand.setCenterVisibleDate(centerDate);
  372. }};
  373. Timeline._Band.prototype._onHighlightBandScroll=function(){if(this._syncWithBand){var centerDate=this._syncWithBand.getCenterVisibleDate();
  374. var centerPixelOffset=this._ether.dateToPixelOffset(centerDate);
  375. this._moveEther(Math.round(this._viewLength/2-centerPixelOffset));
  376. this._positionHighlight();
  377. }};
  378. Timeline._Band.prototype._onHighlightBandOrthogonalScroll=function(){if(this._syncWithBand){this._positionHighlight();
  379. }};
  380. Timeline._Band.prototype._onAddMany=function(){this._paintEvents();
  381. };
  382. Timeline._Band.prototype._onClear=function(){this._paintEvents();
  383. };
  384. Timeline._Band.prototype._positionHighlight=function(){if(this._syncWithBand){var startDate=this._syncWithBand.getMinVisibleDate();
  385. var endDate=this._syncWithBand.getMaxVisibleDate();
  386. if(this._highlight){var offset=0;
  387. var extent=1;
  388. var syncEventPainter=this._syncWithBand.getEventPainter();
  389. if("supportsOrthogonalScrolling" in syncEventPainter&&syncEventPainter.supportsOrthogonalScrolling()){var orthogonalExtent=syncEventPainter.getOrthogonalExtent();
  390. var visibleWidth=this._syncWithBand.getViewWidth();
  391. var totalWidth=Math.max(visibleWidth,orthogonalExtent);
  392. extent=visibleWidth/totalWidth;
  393. offset=-this._syncWithBand.getViewOrthogonalOffset()/totalWidth;
  394. }this._etherPainter.setHighlight(startDate,endDate,offset,extent);
  395. }}};
  396. Timeline._Band.prototype._recenterDiv=function(){this._viewOffset=-this._viewLength*(Timeline._Band.SCROLL_MULTIPLES-1)/2;
  397. if(this._timeline.isHorizontal()){this._div.style.left=this._viewOffset+"px";
  398. this._div.style.width=(Timeline._Band.SCROLL_MULTIPLES*this._viewLength)+"px";
  399. }else{this._div.style.top=this._viewOffset+"px";
  400. this._div.style.height=(Timeline._Band.SCROLL_MULTIPLES*this._viewLength)+"px";
  401. }this.layout();
  402. };
  403. Timeline._Band.prototype._paintEvents=function(){this._eventPainter.paint();
  404. this._showScrollbar();
  405. this._fireOnOrthogonalScroll();
  406. };
  407. Timeline._Band.prototype._softPaintEvents=function(){this._eventPainter.softPaint();
  408. };
  409. Timeline._Band.prototype._paintDecorators=function(){for(var i=0;
  410. i<this._decorators.length;
  411. i++){this._decorators[i].paint();
  412. }};
  413. Timeline._Band.prototype._softPaintDecorators=function(){for(var i=0;
  414. i<this._decorators.length;
  415. i++){this._decorators[i].softPaint();
  416. }};
  417. Timeline._Band.prototype.closeBubble=function(){SimileAjax.WindowManager.cancelPopups();
  418. };
  419. Timeline._Band.prototype._bounceBack=function(f){if(!this._supportsOrthogonalScrolling){return ;
  420. }var target=0;
  421. if(this._viewOrthogonalOffset<0){var orthogonalExtent=this._eventPainter.getOrthogonalExtent();
  422. if(this._viewOrthogonalOffset+orthogonalExtent>=this.getViewWidth()){target=this._viewOrthogonalOffset;
  423. }else{target=Math.min(0,this.getViewWidth()-orthogonalExtent);
  424. }}if(target!=this._viewOrthogonalOffset){var self=this;
  425. SimileAjax.Graphics.createAnimation(function(abs,diff){self._viewOrthogonalOffset=abs;
  426. self._eventPainter.softPaint();
  427. self._showScrollbar();
  428. self._fireOnOrthogonalScroll();
  429. },this._viewOrthogonalOffset,target,300,function(){self._hideScrollbar();
  430. }).run();
  431. }else{this._hideScrollbar();
  432. }};
  433. Timeline._Band.prototype._showScrollbar=function(){if(!this._supportsOrthogonalScrolling){return ;
  434. }var orthogonalExtent=this._eventPainter.getOrthogonalExtent();
  435. var visibleWidth=this.getViewWidth();
  436. var totalWidth=Math.max(visibleWidth,orthogonalExtent);
  437. var ratio=(visibleWidth/totalWidth);
  438. var thumbWidth=Math.round(visibleWidth*ratio)+"px";
  439. var thumbOffset=Math.round(-this._viewOrthogonalOffset*ratio)+"px";
  440. var thumbThickness=12;
  441. var thumb=this._scrollBar.firstChild;
  442. if(this._timeline.isHorizontal()){this._scrollBar.style.top=this._div.style.top;
  443. this._scrollBar.style.height=this._div.style.height;
  444. this._scrollBar.style.right="0px";
  445. this._scrollBar.style.width=thumbThickness+"px";
  446. thumb.style.top=thumbOffset;
  447. thumb.style.height=thumbWidth;
  448. }else{this._scrollBar.style.left=this._div.style.left;
  449. this._scrollBar.style.width=this._div.style.width;
  450. this._scrollBar.style.bottom="0px";
  451. this._scrollBar.style.height=thumbThickness+"px";
  452. thumb.style.left=thumbOffset;
  453. thumb.style.width=thumbWidth;
  454. }if(ratio>=1&&this._viewOrthogonalOffset==0){this._scrollBar.style.display="none";
  455. }else{this._scrollBar.style.display="block";
  456. }};
  457. Timeline._Band.prototype._hideScrollbar=function(){if(!this._supportsOrthogonalScrolling){return ;
  458. }};
  459. Timeline._Band.prototype._cancelEvent=function(evt){SimileAjax.DOM.cancelEvent(evt);
  460. return false;
  461. };
  462. /* compact-painter.js */
  463. Timeline.CompactEventPainter=function(params){this._params=params;
  464. this._onSelectListeners=[];
  465. this._filterMatcher=null;
  466. this._highlightMatcher=null;
  467. this._frc=null;
  468. this._eventIdToElmt={};
  469. };
  470. Timeline.CompactEventPainter.prototype.getType=function(){return"compact";
  471. };
  472. Timeline.CompactEventPainter.prototype.initialize=function(band,timeline){this._band=band;
  473. this._timeline=timeline;
  474. this._backLayer=null;
  475. this._eventLayer=null;
  476. this._lineLayer=null;
  477. this._highlightLayer=null;
  478. this._eventIdToElmt=null;
  479. };
  480. Timeline.CompactEventPainter.prototype.supportsOrthogonalScrolling=function(){return true;
  481. };
  482. Timeline.CompactEventPainter.prototype.addOnSelectListener=function(listener){this._onSelectListeners.push(listener);
  483. };
  484. Timeline.CompactEventPainter.prototype.removeOnSelectListener=function(listener){for(var i=0;
  485. i<this._onSelectListeners.length;
  486. i++){if(this._onSelectListeners[i]==listener){this._onSelectListeners.splice(i,1);
  487. break;
  488. }}};
  489. Timeline.CompactEventPainter.prototype.getFilterMatcher=function(){return this._filterMatcher;
  490. };
  491. Timeline.CompactEventPainter.prototype.setFilterMatcher=function(filterMatcher){this._filterMatcher=filterMatcher;
  492. };
  493. Timeline.CompactEventPainter.prototype.getHighlightMatcher=function(){return this._highlightMatcher;
  494. };
  495. Timeline.CompactEventPainter.prototype.setHighlightMatcher=function(highlightMatcher){this._highlightMatcher=highlightMatcher;
  496. };
  497. Timeline.CompactEventPainter.prototype.paint=function(){var eventSource=this._band.getEventSource();
  498. if(eventSource==null){return ;
  499. }this._eventIdToElmt={};
  500. this._prepareForPainting();
  501. var metrics=this._computeMetrics();
  502. var minDate=this._band.getMinDate();
  503. var maxDate=this._band.getMaxDate();
  504. var filterMatcher=(this._filterMatcher!=null)?this._filterMatcher:function(evt){return true;
  505. };
  506. var highlightMatcher=(this._highlightMatcher!=null)?this._highlightMatcher:function(evt){return -1;
  507. };
  508. var iterator=eventSource.getEventIterator(minDate,maxDate);
  509. var stackConcurrentPreciseInstantEvents="stackConcurrentPreciseInstantEvents" in this._params&&typeof this._params.stackConcurrentPreciseInstantEvents=="object";
  510. var collapseConcurrentPreciseInstantEvents="collapseConcurrentPreciseInstantEvents" in this._params&&this._params.collapseConcurrentPreciseInstantEvents;
  511. if(collapseConcurrentPreciseInstantEvents||stackConcurrentPreciseInstantEvents){var bufferedEvents=[];
  512. var previousInstantEvent=null;
  513. while(iterator.hasNext()){var evt=iterator.next();
  514. if(filterMatcher(evt)){if(!evt.isInstant()||evt.isImprecise()){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
  515. }else{if(previousInstantEvent!=null&&previousInstantEvent.getStart().getTime()==evt.getStart().getTime()){bufferedEvents[bufferedEvents.length-1].push(evt);
  516. }else{bufferedEvents.push([evt]);
  517. previousInstantEvent=evt;
  518. }}}}for(var i=0;
  519. i<bufferedEvents.length;
  520. i++){var compositeEvents=bufferedEvents[i];
  521. if(compositeEvents.length==1){this.paintEvent(compositeEvents[0],metrics,this._params.theme,highlightMatcher(evt));
  522. }else{var match=-1;
  523. for(var j=0;
  524. match<0&&j<compositeEvents.length;
  525. j++){match=highlightMatcher(compositeEvents[j]);
  526. }if(stackConcurrentPreciseInstantEvents){this.paintStackedPreciseInstantEvents(compositeEvents,metrics,this._params.theme,match);
  527. }else{this.paintCompositePreciseInstantEvents(compositeEvents,metrics,this._params.theme,match);
  528. }}}}else{while(iterator.hasNext()){var evt=iterator.next();
  529. if(filterMatcher(evt)){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
  530. }}}this._highlightLayer.style.display="block";
  531. this._lineLayer.style.display="block";
  532. this._eventLayer.style.display="block";
  533. this._setOrthogonalOffset(metrics);
  534. };
  535. Timeline.CompactEventPainter.prototype.softPaint=function(){this._setOrthogonalOffset(this._computeMetrics());
  536. };
  537. Timeline.CompactEventPainter.prototype.getOrthogonalExtent=function(){var metrics=this._computeMetrics();
  538. return 2*metrics.trackOffset+this._tracks.length*metrics.trackHeight;
  539. };
  540. Timeline.CompactEventPainter.prototype._setOrthogonalOffset=function(metrics){var orthogonalOffset=this._band.getViewOrthogonalOffset();
  541. this._highlightLayer.style.top=this._lineLayer.style.top=this._eventLayer.style.top=orthogonalOffset+"px";
  542. };
  543. Timeline.CompactEventPainter.prototype._computeMetrics=function(){var theme=this._params.theme;
  544. var eventTheme=theme.event;
  545. var metrics={trackOffset:"trackOffset" in this._params?this._params.trackOffset:10,trackHeight:"trackHeight" in this._params?this._params.trackHeight:10,tapeHeight:theme.event.tape.height,tapeBottomMargin:"tapeBottomMargin" in this._params?this._params.tapeBottomMargin:2,labelBottomMargin:"labelBottomMargin" in this._params?this._params.labelBottomMargin:5,labelRightMargin:"labelRightMargin" in this._params?this._params.labelRightMargin:5,defaultIcon:eventTheme.instant.icon,defaultIconWidth:eventTheme.instant.iconWidth,defaultIconHeight:eventTheme.instant.iconHeight,customIconWidth:"iconWidth" in this._params?this._params.iconWidth:eventTheme.instant.iconWidth,customIconHeight:"iconHeight" in this._params?this._params.iconHeight:eventTheme.instant.iconHeight,iconLabelGap:"iconLabelGap" in this._params?this._params.iconLabelGap:2,iconBottomMargin:"iconBottomMargin" in this._params?this._params.iconBottomMargin:2};
  546. if("compositeIcon" in this._params){metrics.compositeIcon=this._params.compositeIcon;
  547. metrics.compositeIconWidth=this._params.compositeIconWidth||metrics.customIconWidth;
  548. metrics.compositeIconHeight=this._params.compositeIconHeight||metrics.customIconHeight;
  549. }else{metrics.compositeIcon=metrics.defaultIcon;
  550. metrics.compositeIconWidth=metrics.defaultIconWidth;
  551. metrics.compositeIconHeight=metrics.defaultIconHeight;
  552. }metrics.defaultStackIcon=("stackConcurrentPreciseInstantEvents" in this._params&&"icon" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.icon:metrics.defaultIcon;
  553. metrics.defaultStackIconWidth=("stackConcurrentPreciseInstantEvents" in this._params&&"iconWidth" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.iconWidth:metrics.defaultIconWidth;
  554. metrics.defaultStackIconHeight=("stackConcurrentPreciseInstantEvents" in this._params&&"iconHeight" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.iconHeight:metrics.defaultIconHeight;
  555. return metrics;
  556. };
  557. Timeline.CompactEventPainter.prototype._prepareForPainting=function(){var band=this._band;
  558. if(this._backLayer==null){this._backLayer=this._band.createLayerDiv(0,"timeline-band-events");
  559. this._backLayer.style.visibility="hidden";
  560. var eventLabelPrototype=document.createElement("span");
  561. eventLabelPrototype.className="timeline-event-label";
  562. this._backLayer.appendChild(eventLabelPrototype);
  563. this._frc=SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
  564. }this._frc.update();
  565. this._tracks=[];
  566. if(this._highlightLayer!=null){band.removeLayerDiv(this._highlightLayer);
  567. }this._highlightLayer=band.createLayerDiv(105,"timeline-band-highlights");
  568. this._highlightLayer.style.display="none";
  569. if(this._lineLayer!=null){band.removeLayerDiv(this._lineLayer);
  570. }this._lineLayer=band.createLayerDiv(110,"timeline-band-lines");
  571. this._lineLayer.style.display="none";
  572. if(this._eventLayer!=null){band.removeLayerDiv(this._eventLayer);
  573. }this._eventLayer=band.createLayerDiv(115,"timeline-band-events");
  574. this._eventLayer.style.display="none";
  575. };
  576. Timeline.CompactEventPainter.prototype.paintEvent=function(evt,metrics,theme,highlightIndex){if(evt.isInstant()){this.paintInstantEvent(evt,metrics,theme,highlightIndex);
  577. }else{this.paintDurationEvent(evt,metrics,theme,highlightIndex);
  578. }};
  579. Timeline.CompactEventPainter.prototype.paintInstantEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseInstantEvent(evt,metrics,theme,highlightIndex);
  580. }else{this.paintPreciseInstantEvent(evt,metrics,theme,highlightIndex);
  581. }};
  582. Timeline.CompactEventPainter.prototype.paintDurationEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseDurationEvent(evt,metrics,theme,highlightIndex);
  583. }else{this.paintPreciseDurationEvent(evt,metrics,theme,highlightIndex);
  584. }};
  585. Timeline.CompactEventPainter.prototype.paintPreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
  586. var iconData={url:evt.getIcon()};
  587. if(iconData.url==null){iconData.url=metrics.defaultIcon;
  588. iconData.width=metrics.defaultIconWidth;
  589. iconData.height=metrics.defaultIconHeight;
  590. iconData.className="timeline-event-icon-default";
  591. }else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
  592. iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
  593. }var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
  594. var result=this.paintTapeIconLabel(evt.getStart(),commonData,null,iconData,labelData,metrics,theme,highlightIndex);
  595. var self=this;
  596. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
  597. };
  598. SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
  599. SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
  600. this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
  601. };
  602. Timeline.CompactEventPainter.prototype.paintCompositePreciseInstantEvents=function(events,metrics,theme,highlightIndex){var evt=events[0];
  603. var tooltips=[];
  604. for(var i=0;
  605. i<events.length;
  606. i++){tooltips.push(events[i].getProperty("tooltip")||events[i].getText());
  607. }var commonData={tooltip:tooltips.join("; ")};
  608. var iconData={url:metrics.compositeIcon,width:metrics.compositeIconWidth,height:metrics.compositeIconHeight,className:"timeline-event-icon-composite"};
  609. var labelData={text:String.substitute(this._params.compositeEventLabelTemplate,[events.length])};
  610. var result=this.paintTapeIconLabel(evt.getStart(),commonData,null,iconData,labelData,metrics,theme,highlightIndex);
  611. var self=this;
  612. var clickHandler=function(elmt,domEvt,target){return self._onClickMultiplePreciseInstantEvent(result.iconElmtData.elmt,domEvt,events);
  613. };
  614. SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
  615. SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
  616. for(var i=0;
  617. i<events.length;
  618. i++){this._eventIdToElmt[events[i].getID()]=result.iconElmtData.elmt;
  619. }};
  620. Timeline.CompactEventPainter.prototype.paintStackedPreciseInstantEvents=function(events,metrics,theme,highlightIndex){var limit="limit" in this._params.stackConcurrentPreciseInstantEvents?this._params.stackConcurrentPreciseInstantEvents.limit:10;
  621. var moreMessageTemplate="moreMessageTemplate" in this._params.stackConcurrentPreciseInstantEvents?this._params.stackConcurrentPreciseInstantEvents.moreMessageTemplate:"%0 More Events";
  622. var showMoreMessage=limit<=events.length-2;
  623. var band=this._band;
  624. var getPixelOffset=function(date){return Math.round(band.dateToPixelOffset(date));
  625. };
  626. var getIconData=function(evt){var iconData={url:evt.getIcon()};
  627. if(iconData.url==null){iconData.url=metrics.defaultStackIcon;
  628. iconData.width=metrics.defaultStackIconWidth;
  629. iconData.height=metrics.defaultStackIconHeight;
  630. iconData.className="timeline-event-icon-stack timeline-event-icon-default";
  631. }else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
  632. iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
  633. iconData.className="timeline-event-icon-stack";
  634. }return iconData;
  635. };
  636. var firstIconData=getIconData(events[0]);
  637. var horizontalIncrement=5;
  638. var leftIconEdge=0;
  639. var totalLabelWidth=0;
  640. var totalLabelHeight=0;
  641. var totalIconHeight=0;
  642. var records=[];
  643. for(var i=0;
  644. i<events.length&&(!showMoreMessage||i<limit);
  645. i++){var evt=events[i];
  646. var text=evt.getText();
  647. var iconData=getIconData(evt);
  648. var labelSize=this._frc.computeSize(text);
  649. var record={text:text,iconData:iconData,labelSize:labelSize,iconLeft:firstIconData.width+i*horizontalIncrement-iconData.width};
  650. record.labelLeft=firstIconData.width+i*horizontalIncrement+metrics.iconLabelGap;
  651. record.top=totalLabelHeight;
  652. records.push(record);
  653. leftIconEdge=Math.min(leftIconEdge,record.iconLeft);
  654. totalLabelHeight+=labelSize.height;
  655. totalLabelWidth=Math.max(totalLabelWidth,record.labelLeft+labelSize.width);
  656. totalIconHeight=Math.max(totalIconHeight,record.top+iconData.height);
  657. }if(showMoreMessage){var moreMessage=String.substitute(moreMessageTemplate,[events.length-limit]);
  658. var moreMessageLabelSize=this._frc.computeSize(moreMessage);
  659. var moreMessageLabelLeft=firstIconData.width+(limit-1)*horizontalIncrement+metrics.iconLabelGap;
  660. var moreMessageLabelTop=totalLabelHeight;
  661. totalLabelHeight+=moreMessageLabelSize.height;
  662. totalLabelWidth=Math.max(totalLabelWidth,moreMessageLabelLeft+moreMessageLabelSize.width);
  663. }totalLabelWidth+=metrics.labelRightMargin;
  664. totalLabelHeight+=metrics.labelBottomMargin;
  665. totalIconHeight+=metrics.iconBottomMargin;
  666. var anchorPixel=getPixelOffset(events[0].getStart());
  667. var newTracks=[];
  668. var trackCount=Math.ceil(Math.max(totalIconHeight,totalLabelHeight)/metrics.trackHeight);
  669. var rightIconEdge=firstIconData.width+(events.length-1)*horizontalIncrement;
  670. for(var i=0;
  671. i<trackCount;
  672. i++){newTracks.push({start:leftIconEdge,end:rightIconEdge});
  673. }var labelTrackCount=Math.ceil(totalLabelHeight/metrics.trackHeight);
  674. for(var i=0;
  675. i<labelTrackCount;
  676. i++){var track=newTracks[i];
  677. track.end=Math.max(track.end,totalLabelWidth);
  678. }var firstTrack=this._fitTracks(anchorPixel,newTracks);
  679. var verticalPixelOffset=firstTrack*metrics.trackHeight+metrics.trackOffset;
  680. var iconStackDiv=this._timeline.getDocument().createElement("div");
  681. iconStackDiv.className="timeline-event-icon-stack";
  682. iconStackDiv.style.position="absolute";
  683. iconStackDiv.style.overflow="visible";
  684. iconStackDiv.style.left=anchorPixel+"px";
  685. iconStackDiv.style.top=verticalPixelOffset+"px";
  686. iconStackDiv.style.width=rightIconEdge+"px";
  687. iconStackDiv.style.height=totalIconHeight+"px";
  688. iconStackDiv.innerHTML="<div style='position: relative'></div>";
  689. this._eventLayer.appendChild(iconStackDiv);
  690. var self=this;
  691. var onMouseOver=function(domEvt){try{var n=parseInt(this.getAttribute("index"));
  692. var childNodes=iconStackDiv.firstChild.childNodes;
  693. for(var i=0;
  694. i<childNodes.length;
  695. i++){var child=childNodes[i];
  696. if(i==n){child.style.zIndex=childNodes.length;
  697. }else{child.style.zIndex=childNodes.length-i;
  698. }}}catch(e){}};
  699. var paintEvent=function(index){var record=records[index];
  700. var evt=events[index];
  701. var tooltip=evt.getProperty("tooltip")||evt.getText();
  702. var labelElmtData=self._paintEventLabel({tooltip:tooltip},{text:record.text},anchorPixel+record.labelLeft,verticalPixelOffset+record.top,record.labelSize.width,record.labelSize.height,theme);
  703. labelElmtData.elmt.setAttribute("index",index);
  704. labelElmtData.elmt.onmouseover=onMouseOver;
  705. var img=SimileAjax.Graphics.createTranslucentImage(record.iconData.url);
  706. var iconDiv=self._timeline.getDocument().createElement("div");
  707. iconDiv.className="timeline-event-icon"+("className" in record.iconData?(" "+record.iconData.className):"");
  708. iconDiv.style.left=record.iconLeft+"px";
  709. iconDiv.style.top=record.top+"px";
  710. iconDiv.style.zIndex=(records.length-index);
  711. iconDiv.appendChild(img);
  712. iconDiv.setAttribute("index",index);
  713. iconDiv.onmouseover=onMouseOver;
  714. iconStackDiv.firstChild.appendChild(iconDiv);
  715. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(labelElmtData.elmt,domEvt,evt);
  716. };
  717. SimileAjax.DOM.registerEvent(iconDiv,"mousedown",clickHandler);
  718. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  719. self._eventIdToElmt[evt.getID()]=iconDiv;
  720. };
  721. for(var i=0;
  722. i<records.length;
  723. i++){paintEvent(i);
  724. }if(showMoreMessage){var moreEvents=events.slice(limit);
  725. var moreMessageLabelElmtData=this._paintEventLabel({tooltip:moreMessage},{text:moreMessage},anchorPixel+moreMessageLabelLeft,verticalPixelOffset+moreMessageLabelTop,moreMessageLabelSize.width,moreMessageLabelSize.height,theme);
  726. var moreMessageClickHandler=function(elmt,domEvt,target){return self._onClickMultiplePreciseInstantEvent(moreMessageLabelElmtData.elmt,domEvt,moreEvents);
  727. };
  728. SimileAjax.DOM.registerEvent(moreMessageLabelElmtData.elmt,"mousedown",moreMessageClickHandler);
  729. for(var i=0;
  730. i<moreEvents.length;
  731. i++){this._eventIdToElmt[moreEvents[i].getID()]=moreMessageLabelElmtData.elmt;
  732. }}};
  733. Timeline.CompactEventPainter.prototype.paintImpreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
  734. var tapeData={start:evt.getStart(),end:evt.getEnd(),latestStart:evt.getLatestStart(),earliestEnd:evt.getEarliestEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:true};
  735. var iconData={url:evt.getIcon()};
  736. if(iconData.url==null){iconData=null;
  737. }else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
  738. iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
  739. }var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
  740. var result=this.paintTapeIconLabel(evt.getStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
  741. var self=this;
  742. var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
  743. }:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
  744. };
  745. SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
  746. SimileAjax.DOM.registerEvent(result.impreciseTapeElmtData.elmt,"mousedown",clickHandler);
  747. if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
  748. this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
  749. }else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
  750. }};
  751. Timeline.CompactEventPainter.prototype.paintPreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
  752. var tapeData={start:evt.getStart(),end:evt.getEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:false};
  753. var iconData={url:evt.getIcon()};
  754. if(iconData.url==null){iconData=null;
  755. }else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
  756. iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
  757. }var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
  758. var result=this.paintTapeIconLabel(evt.getLatestStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
  759. var self=this;
  760. var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
  761. }:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
  762. };
  763. SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
  764. SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt,"mousedown",clickHandler);
  765. if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
  766. this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
  767. }else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
  768. }};
  769. Timeline.CompactEventPainter.prototype.paintImpreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
  770. var tapeData={start:evt.getStart(),end:evt.getEnd(),latestStart:evt.getLatestStart(),earliestEnd:evt.getEarliestEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:false};
  771. var iconData={url:evt.getIcon()};
  772. if(iconData.url==null){iconData=null;
  773. }else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
  774. iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
  775. }var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
  776. var result=this.paintTapeIconLabel(evt.getLatestStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
  777. var self=this;
  778. var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
  779. }:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
  780. };
  781. SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
  782. SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt,"mousedown",clickHandler);
  783. if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
  784. this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
  785. }else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
  786. }};
  787. Timeline.CompactEventPainter.prototype.paintTapeIconLabel=function(anchorDate,commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex){var band=this._band;
  788. var getPixelOffset=function(date){return Math.round(band.dateToPixelOffset(date));
  789. };
  790. var anchorPixel=getPixelOffset(anchorDate);
  791. var newTracks=[];
  792. var tapeHeightOccupied=0;
  793. var tapeTrackCount=0;
  794. var tapeLastTrackExtraSpace=0;
  795. if(tapeData!=null){tapeHeightOccupied=metrics.tapeHeight+metrics.tapeBottomMargin;
  796. tapeTrackCount=Math.ceil(metrics.tapeHeight/metrics.trackHeight);
  797. var tapeEndPixelOffset=getPixelOffset(tapeData.end)-anchorPixel;
  798. var tapeStartPixelOffset=getPixelOffset(tapeData.start)-anchorPixel;
  799. for(var t=0;
  800. t<tapeTrackCount;
  801. t++){newTracks.push({start:tapeStartPixelOffset,end:tapeEndPixelOffset});
  802. }tapeLastTrackExtraSpace=metrics.trackHeight-(tapeHeightOccupied%metrics.tapeHeight);
  803. }var iconStartPixelOffset=0;
  804. var iconHorizontalSpaceOccupied=0;
  805. if(iconData!=null){if("iconAlign" in iconData&&iconData.iconAlign=="center"){iconStartPixelOffset=-Math.floor(iconData.width/2);
  806. }iconHorizontalSpaceOccupied=iconStartPixelOffset+iconData.width+metrics.iconLabelGap;
  807. if(tapeTrackCount>0){newTracks[tapeTrackCount-1].end=Math.max(newTracks[tapeTrackCount-1].end,iconHorizontalSpaceOccupied);
  808. }var iconHeight=iconData.height+metrics.iconBottomMargin+tapeLastTrackExtraSpace;
  809. while(iconHeight>0){newTracks.push({start:iconStartPixelOffset,end:iconHorizontalSpaceOccupied});
  810. iconHeight-=metrics.trackHeight;
  811. }}var text=labelData.text;
  812. var labelSize=this._frc.computeSize(text);
  813. var labelHeight=labelSize.height+metrics.labelBottomMargin+tapeLastTrackExtraSpace;
  814. var labelEndPixelOffset=iconHorizontalSpaceOccupied+labelSize.width+metrics.labelRightMargin;
  815. if(tapeTrackCount>0){newTracks[tapeTrackCount-1].end=Math.max(newTracks[tapeTrackCount-1].end,labelEndPixelOffset);
  816. }for(var i=0;
  817. labelHeight>0;
  818. i++){if(tapeTrackCount+i<newTracks.length){var track=newTracks[tapeTrackCount+i];
  819. track.end=labelEndPixelOffset;
  820. }else{newTracks.push({start:0,end:labelEndPixelOffset});
  821. }labelHeight-=metrics.trackHeight;
  822. }var firstTrack=this._fitTracks(anchorPixel,newTracks);
  823. var verticalPixelOffset=firstTrack*metrics.trackHeight+metrics.trackOffset;
  824. var result={};
  825. result.labelElmtData=this._paintEventLabel(commonData,labelData,anchorPixel+iconHorizontalSpaceOccupied,verticalPixelOffset+tapeHeightOccupied,labelSize.width,labelSize.height,theme);
  826. if(tapeData!=null){if("latestStart" in tapeData||"earliestEnd" in tapeData){result.impreciseTapeElmtData=this._paintEventTape(commonData,tapeData,metrics.tapeHeight,verticalPixelOffset,getPixelOffset(tapeData.start),getPixelOffset(tapeData.end),theme.event.duration.impreciseColor,theme.event.duration.impreciseOpacity,metrics,theme);
  827. }if(!tapeData.isInstant&&"start" in tapeData&&"end" in tapeData){result.tapeElmtData=this._paintEventTape(commonData,tapeData,metrics.tapeHeight,verticalPixelOffset,anchorPixel,getPixelOffset("earliestEnd" in tapeData?tapeData.earliestEnd:tapeData.end),tapeData.color,100,metrics,theme);
  828. }}if(iconData!=null){result.iconElmtData=this._paintEventIcon(commonData,iconData,verticalPixelOffset+tapeHeightOccupied,anchorPixel+iconStartPixelOffset,metrics,theme);
  829. }return result;
  830. };
  831. Timeline.CompactEventPainter.prototype._fitTracks=function(anchorPixel,newTracks){var firstTrack;
  832. for(firstTrack=0;
  833. firstTrack<this._tracks.length;
  834. firstTrack++){var fit=true;
  835. for(var j=0;
  836. j<newTracks.length&&(firstTrack+j)<this._tracks.length;
  837. j++){var existingTrack=this._tracks[firstTrack+j];
  838. var newTrack=newTracks[j];
  839. if(anchorPixel+newTrack.start<existingTrack){fit=false;
  840. break;
  841. }}if(fit){break;
  842. }}for(var i=0;
  843. i<newTracks.length;
  844. i++){this._tracks[firstTrack+i]=anchorPixel+newTracks[i].end;
  845. }return firstTrack;
  846. };
  847. Timeline.CompactEventPainter.prototype._paintEventIcon=function(commonData,iconData,top,left,metrics,theme){var img=SimileAjax.Graphics.createTranslucentImage(iconData.url);
  848. var iconDiv=this._timeline.getDocument().createElement("div");
  849. iconDiv.className="timeline-event-icon"+("className" in iconData?(" "+iconData.className):"");
  850. iconDiv.style.left=left+"px";
  851. iconDiv.style.top=top+"px";
  852. iconDiv.appendChild(img);
  853. if("tooltip" in commonData&&typeof commonData.tooltip=="string"){iconDiv.title=commonData.tooltip;
  854. }this._eventLayer.appendChild(iconDiv);
  855. return{left:left,top:top,width:metrics.iconWidth,height:metrics.iconHeight,elmt:iconDiv};
  856. };
  857. Timeline.CompactEventPainter.prototype._paintEventLabel=function(commonData,labelData,left,top,width,height,theme){var doc=this._timeline.getDocument();
  858. var labelDiv=doc.createElement("div");
  859. labelDiv.className="timeline-event-label";
  860. labelDiv.style.left=left+"px";
  861. labelDiv.style.width=(width+1)+"px";
  862. labelDiv.style.top=top+"px";
  863. labelDiv.innerHTML=labelData.text;
  864. if("tooltip" in commonData&&typeof commonData.tooltip=="string"){labelDiv.title=commonData.tooltip;
  865. }if("color" in labelData&&typeof labelData.color=="string"){labelDiv.style.color=labelData.color;
  866. }if("className" in labelData&&typeof labelData.className=="string"){labelDiv.className+=" "+labelData.className;
  867. }this._eventLayer.appendChild(labelDiv);
  868. return{left:left,top:top,width:width,height:height,elmt:labelDiv};
  869. };
  870. Timeline.CompactEventPainter.prototype._paintEventTape=function(commonData,tapeData,height,top,startPixel,endPixel,color,opacity,metrics,theme){var width=endPixel-startPixel;
  871. var tapeDiv=this._timeline.getDocument().createElement("div");
  872. tapeDiv.className="timeline-event-tape";
  873. tapeDiv.style.left=startPixel+"px";
  874. tapeDiv.style.top=top+"px";
  875. tapeDiv.style.width=width+"px";
  876. tapeDiv.style.height=height+"px";
  877. if("tooltip" in commonData&&typeof commonData.tooltip=="string"){tapeDiv.title=commonData.tooltip;
  878. }if(color!=null&&typeof tapeData.color=="string"){tapeDiv.style.backgroundColor=color;
  879. }if("backgroundImage" in tapeData&&typeof tapeData.backgroundImage=="string"){tapeDiv.style.backgroundImage="url("+backgroundImage+")";
  880. tapeDiv.style.backgroundRepeat=("backgroundRepeat" in tapeData&&typeof tapeData.backgroundRepeat=="string")?tapeData.backgroundRepeat:"repeat";
  881. }SimileAjax.Graphics.setOpacity(tapeDiv,opacity);
  882. if("className" in tapeData&&typeof tapeData.className=="string"){tapeDiv.className+=" "+tapeData.className;
  883. }this._eventLayer.appendChild(tapeDiv);
  884. return{left:startPixel,top:top,width:width,height:height,elmt:tapeDiv};
  885. };
  886. Timeline.CompactEventPainter.prototype._createHighlightDiv=function(highlightIndex,dimensions,theme){if(highlightIndex>=0){var doc=this._timeline.getDocument();
  887. var eventTheme=theme.event;
  888. var color=eventTheme.highlightColors[Math.min(highlightIndex,eventTheme.highlightColors.length-1)];
  889. var div=doc.createElement("div");
  890. div.style.position="absolute";
  891. div.style.overflow="hidden";
  892. div.style.left=(dimensions.left-2)+"px";
  893. div.style.width=(dimensions.width+4)+"px";
  894. div.style.top=(dimensions.top-2)+"px";
  895. div.style.height=(dimensions.height+4)+"px";
  896. this._highlightLayer.appendChild(div);
  897. }};
  898. Timeline.CompactEventPainter.prototype._onClickMultiplePreciseInstantEvent=function(icon,domEvt,events){var c=SimileAjax.DOM.getPageCoordinates(icon);
  899. this._showBubble(c.left+Math.ceil(icon.offsetWidth/2),c.top+Math.ceil(icon.offsetHeight/2),events);
  900. var ids=[];
  901. for(var i=0;
  902. i<events.length;
  903. i++){ids.push(events[i].getID());
  904. }this._fireOnSelect(ids);
  905. domEvt.cancelBubble=true;
  906. SimileAjax.DOM.cancelEvent(domEvt);
  907. return false;
  908. };
  909. Timeline.CompactEventPainter.prototype._onClickInstantEvent=function(icon,domEvt,evt){var c=SimileAjax.DOM.getPageCoordinates(icon);
  910. this._showBubble(c.left+Math.ceil(icon.offsetWidth/2),c.top+Math.ceil(icon.offsetHeight/2),[evt]);
  911. this._fireOnSelect([evt.getID()]);
  912. domEvt.cancelBubble=true;
  913. SimileAjax.DOM.cancelEvent(domEvt);
  914. return false;
  915. };
  916. Timeline.CompactEventPainter.prototype._onClickDurationEvent=function(target,domEvt,evt){if("pageX" in domEvt){var x=domEvt.pageX;
  917. var y=domEvt.pageY;
  918. }else{var c=SimileAjax.DOM.getPageCoordinates(target);
  919. var x=domEvt.offsetX+c.left;
  920. var y=domEvt.offsetY+c.top;
  921. }this._showBubble(x,y,[evt]);
  922. this._fireOnSelect([evt.getID()]);
  923. domEvt.cancelBubble=true;
  924. SimileAjax.DOM.cancelEvent(domEvt);
  925. return false;
  926. };
  927. Timeline.CompactEventPainter.prototype.showBubble=function(evt){var elmt=this._eventIdToElmt[evt.getID()];
  928. if(elmt){var c=SimileAjax.DOM.getPageCoordinates(elmt);
  929. this._showBubble(c.left+elmt.offsetWidth/2,c.top+elmt.offsetHeight/2,[evt]);
  930. }};
  931. Timeline.CompactEventPainter.prototype._showBubble=function(x,y,evts){var div=document.createElement("div");
  932. evts=("fillInfoBubble" in evts)?[evts]:evts;
  933. for(var i=0;
  934. i<evts.length;
  935. i++){var div2=document.createElement("div");
  936. div.appendChild(div2);
  937. evts[i].fillInfoBubble(div2,this._params.theme,this._band.getLabeller());
  938. }SimileAjax.WindowManager.cancelPopups();
  939. SimileAjax.Graphics.createBubbleForContentAndPoint(div,x,y,this._params.theme.event.bubble.width);
  940. };
  941. Timeline.CompactEventPainter.prototype._fireOnSelect=function(eventIDs){for(var i=0;
  942. i<this._onSelectListeners.length;
  943. i++){this._onSelectListeners[i](eventIDs);
  944. }};
  945. /* decorators.js */
  946. Timeline.SpanHighlightDecorator=function(params){this._unit=params.unit!=null?params.unit:SimileAjax.NativeDateUnit;
  947. this._startDate=(typeof params.startDate=="string")?this._unit.parseFromObject(params.startDate):params.startDate;
  948. this._endDate=(typeof params.endDate=="string")?this._unit.parseFromObject(params.endDate):params.endDate;
  949. this._startLabel=params.startLabel!=null?params.startLabel:"";
  950. this._endLabel=params.endLabel!=null?params.endLabel:"";
  951. this._color=params.color;
  952. this._cssClass=params.cssClass!=null?params.cssClass:null;
  953. this._opacity=params.opacity!=null?params.opacity:100;
  954. this._zIndex=(params.inFront!=null&&params.inFront)?113:10;
  955. };
  956. Timeline.SpanHighlightDecorator.prototype.initialize=function(band,timeline){this._band=band;
  957. this._timeline=timeline;
  958. this._layerDiv=null;
  959. };
  960. Timeline.SpanHighlightDecorator.prototype.paint=function(){if(this._layerDiv!=null){this._band.removeLayerDiv(this._layerDiv);
  961. }this._layerDiv=this._band.createLayerDiv(this._zIndex);
  962. this._layerDiv.setAttribute("name","span-highlight-decorator");
  963. this._layerDiv.style.display="none";
  964. var minDate=this._band.getMinDate();
  965. var maxDate=this._band.getMaxDate();
  966. if(this._unit.compare(this._startDate,maxDate)<0&&this._unit.compare(this._endDate,minDate)>0){minDate=this._unit.later(minDate,this._startDate);
  967. maxDate=this._unit.earlier(maxDate,this._endDate);
  968. var minPixel=this._band.dateToPixelOffset(minDate);
  969. var maxPixel=this._band.dateToPixelOffset(maxDate);
  970. var doc=this._timeline.getDocument();
  971. var createTable=function(){var table=doc.createElement("table");
  972. table.insertRow(0).insertCell(0);
  973. return table;
  974. };
  975. var div=doc.createElement("div");
  976. div.className="timeline-highlight-decorator";
  977. if(this._cssClass){div.className+=" "+this._cssClass;
  978. }if(this._color!=null){div.style.backgroundColor=this._color;
  979. }if(this._opacity<100){SimileAjax.Graphics.setOpacity(div,this._opacity);
  980. }this._layerDiv.appendChild(div);
  981. var tableStartLabel=createTable();
  982. tableStartLabel.className="timeline-highlight-label timeline-highlight-label-start";
  983. var tdStart=tableStartLabel.rows[0].cells[0];
  984. tdStart.innerHTML=this._startLabel;
  985. if(this._cssClass){tdStart.className="label_"+this._cssClass;
  986. }this._layerDiv.appendChild(tableStartLabel);
  987. var tableEndLabel=createTable();
  988. tableEndLabel.className="timeline-highlight-label timeline-highlight-label-end";
  989. var tdEnd=tableEndLabel.rows[0].cells[0];
  990. tdEnd.innerHTML=this._endLabel;
  991. if(this._cssClass){tdEnd.className="label_"+this._cssClass;
  992. }this._layerDiv.appendChild(tableEndLabel);
  993. if(this._timeline.isHorizontal()){div.style.left=minPixel+"px";
  994. div.style.width=(maxPixel-minPixel)+"px";
  995. tableStartLabel.style.right=(this._band.getTotalViewLength()-minPixel)+"px";
  996. tableStartLabel.style.width=(this._startLabel.length)+"em";
  997. tableEndLabel.style.left=maxPixel+"px";
  998. tableEndLabel.style.width=(this._endLabel.length)+"em";
  999. }else{div.style.top=minPixel+"px";
  1000. div.style.height=(maxPixel-minPixel)+"px";
  1001. tableStartLabel.style.bottom=minPixel+"px";
  1002. tableStartLabel.style.height="1.5px";
  1003. tableEndLabel.style.top=maxPixel+"px";
  1004. tableEndLabel.style.height="1.5px";
  1005. }}this._layerDiv.style.display="block";
  1006. };
  1007. Timeline.SpanHighlightDecorator.prototype.softPaint=function(){};
  1008. Timeline.PointHighlightDecorator=function(params){this._unit=params.unit!=null?params.unit:SimileAjax.NativeDateUnit;
  1009. this._date=(typeof params.date=="string")?this._unit.parseFromObject(params.date):params.date;
  1010. this._width=params.width!=null?params.width:10;
  1011. this._color=params.color;
  1012. this._cssClass=params.cssClass!=null?params.cssClass:"";
  1013. this._opacity=params.opacity!=null?params.opacity:100;
  1014. };
  1015. Timeline.PointHighlightDecorator.prototype.initialize=function(band,timeline){this._band=band;
  1016. this._timeline=timeline;
  1017. this._layerDiv=null;
  1018. };
  1019. Timeline.PointHighlightDecorator.prototype.paint=function(){if(this._layerDiv!=null){this._band.removeLayerDiv(this._layerDiv);
  1020. }this._layerDiv=this._band.createLayerDiv(10);
  1021. this._layerDiv.setAttribute("name","span-highlight-decorator");
  1022. this._layerDiv.style.display="none";
  1023. var minDate=this._band.getMinDate();
  1024. var maxDate=this._band.getMaxDate();
  1025. if(this._unit.compare(this._date,maxDate)<0&&this._unit.compare(this._date,minDate)>0){var pixel=this._band.dateToPixelOffset(this._date);
  1026. var minPixel=pixel-Math.round(this._width/2);
  1027. var doc=this._timeline.getDocument();
  1028. var div=doc.createElement("div");
  1029. div.className="timeline-highlight-point-decorator";
  1030. div.className+=" "+this._cssClass;
  1031. if(this._color!=null){div.style.backgroundColor=this._color;
  1032. }if(this._opacity<100){SimileAjax.Graphics.setOpacity(div,this._opacity);
  1033. }this._layerDiv.appendChild(div);
  1034. if(this._timeline.isHorizontal()){div.style.left=minPixel+"px";
  1035. div.style.width=this._width+"px";
  1036. }else{div.style.top=minPixel+"px";
  1037. div.style.height=this._width+"px";
  1038. }}this._layerDiv.style.display="block";
  1039. };
  1040. Timeline.PointHighlightDecorator.prototype.softPaint=function(){};
  1041. /* detailed-painter.js */
  1042. Timeline.DetailedEventPainter=function(params){this._params=params;
  1043. this._onSelectListeners=[];
  1044. this._filterMatcher=null;
  1045. this._highlightMatcher=null;
  1046. this._frc=null;
  1047. this._eventIdToElmt={};
  1048. };
  1049. Timeline.DetailedEventPainter.prototype.initialize=function(band,timeline){this._band=band;
  1050. this._timeline=timeline;
  1051. this._backLayer=null;
  1052. this._eventLayer=null;
  1053. this._lineLayer=null;
  1054. this._highlightLayer=null;
  1055. this._eventIdToElmt=null;
  1056. };
  1057. Timeline.DetailedEventPainter.prototype.getType=function(){return"detailed";
  1058. };
  1059. Timeline.DetailedEventPainter.prototype.addOnSelectListener=function(listener){this._onSelectListeners.push(listener);
  1060. };
  1061. Timeline.DetailedEventPainter.prototype.removeOnSelectListener=function(listener){for(var i=0;
  1062. i<this._onSelectListeners.length;
  1063. i++){if(this._onSelectListeners[i]==listener){this._onSelectListeners.splice(i,1);
  1064. break;
  1065. }}};
  1066. Timeline.DetailedEventPainter.prototype.getFilterMatcher=function(){return this._filterMatcher;
  1067. };
  1068. Timeline.DetailedEventPainter.prototype.setFilterMatcher=function(filterMatcher){this._filterMatcher=filterMatcher;
  1069. };
  1070. Timeline.DetailedEventPainter.prototype.getHighlightMatcher=function(){return this._highlightMatcher;
  1071. };
  1072. Timeline.DetailedEventPainter.prototype.setHighlightMatcher=function(highlightMatcher){this._highlightMatcher=highlightMatcher;
  1073. };
  1074. Timeline.DetailedEventPainter.prototype.paint=function(){var eventSource=this._band.getEventSource();
  1075. if(eventSource==null){return ;
  1076. }this._eventIdToElmt={};
  1077. this._prepareForPainting();
  1078. var eventTheme=this._params.theme.event;
  1079. var trackHeight=Math.max(eventTheme.track.height,this._frc.getLineHeight());
  1080. var metrics={trackOffset:Math.round(this._band.getViewWidth()/2-trackHeight/2),trackHeight:trackHeight,trackGap:eventTheme.track.gap,trackIncrement:trackHeight+eventTheme.track.gap,icon:eventTheme.instant.icon,iconWidth:eventTheme.instant.iconWidth,iconHeight:eventTheme.instant.iconHeight,labelWidth:eventTheme.label.width};
  1081. var minDate=this._band.getMinDate();
  1082. var maxDate=this._band.getMaxDate();
  1083. var filterMatcher=(this._filterMatcher!=null)?this._filterMatcher:function(evt){return true;
  1084. };
  1085. var highlightMatcher=(this._highlightMatcher!=null)?this._highlightMatcher:function(evt){return -1;
  1086. };
  1087. var iterator=eventSource.getEventReverseIterator(minDate,maxDate);
  1088. while(iterator.hasNext()){var evt=iterator.next();
  1089. if(filterMatcher(evt)){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
  1090. }}this._highlightLayer.style.display="block";
  1091. this._lineLayer.style.display="block";
  1092. this._eventLayer.style.display="block";
  1093. this._band.updateEventTrackInfo(this._lowerTracks.length+this._upperTracks.length,metrics.trackIncrement);
  1094. };
  1095. Timeline.DetailedEventPainter.prototype.softPaint=function(){};
  1096. Timeline.DetailedEventPainter.prototype._prepareForPainting=function(){var band=this._band;
  1097. if(this._backLayer==null){this._backLayer=this._band.createLayerDiv(0,"timeline-band-events");
  1098. this._backLayer.style.visibility="hidden";
  1099. var eventLabelPrototype=document.createElement("span");
  1100. eventLabelPrototype.className="timeline-event-label";
  1101. this._backLayer.appendChild(eventLabelPrototype);
  1102. this._frc=SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
  1103. }this._frc.update();
  1104. this._lowerTracks=[];
  1105. this._upperTracks=[];
  1106. if(this._highlightLayer!=null){band.removeLayerDiv(this._highlightLayer);
  1107. }this._highlightLayer=band.createLayerDiv(105,"timeline-band-highlights");
  1108. this._highlightLayer.style.display="none";
  1109. if(this._lineLayer!=null){band.removeLayerDiv(this._lineLayer);
  1110. }this._lineLayer=band.createLayerDiv(110,"timeline-band-lines");
  1111. this._lineLayer.style.display="none";
  1112. if(this._eventLayer!=null){band.removeLayerDiv(this._eventLayer);
  1113. }this._eventLayer=band.createLayerDiv(110,"timeline-band-events");
  1114. this._eventLayer.style.display="none";
  1115. };
  1116. Timeline.DetailedEventPainter.prototype.paintEvent=function(evt,metrics,theme,highlightIndex){if(evt.isInstant()){this.paintInstantEvent(evt,metrics,theme,highlightIndex);
  1117. }else{this.paintDurationEvent(evt,metrics,theme,highlightIndex);
  1118. }};
  1119. Timeline.DetailedEventPainter.prototype.paintInstantEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseInstantEvent(evt,metrics,theme,highlightIndex);
  1120. }else{this.paintPreciseInstantEvent(evt,metrics,theme,highlightIndex);
  1121. }};
  1122. Timeline.DetailedEventPainter.prototype.paintDurationEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseDurationEvent(evt,metrics,theme,highlightIndex);
  1123. }else{this.paintPreciseDurationEvent(evt,metrics,theme,highlightIndex);
  1124. }};
  1125. Timeline.DetailedEventPainter.prototype.paintPreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  1126. var text=evt.getText();
  1127. var startDate=evt.getStart();
  1128. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  1129. var iconRightEdge=Math.round(startPixel+metrics.iconWidth/2);
  1130. var iconLeftEdge=Math.round(startPixel-metrics.iconWidth/2);
  1131. var labelSize=this._frc.computeSize(text);
  1132. var iconTrack=this._findFreeTrackForSolid(iconRightEdge,startPixel);
  1133. var iconElmtData=this._paintEventIcon(evt,iconTrack,iconLeftEdge,metrics,theme);
  1134. var labelLeft=iconRightEdge+theme.event.label.offsetFromLine;
  1135. var labelTrack=iconTrack;
  1136. var iconTrackData=this._getTrackData(iconTrack);
  1137. if(Math.min(iconTrackData.solid,iconTrackData.text)>=labelLeft+labelSize.width){iconTrackData.solid=iconLeftEdge;
  1138. iconTrackData.text=labelLeft;
  1139. }else{iconTrackData.solid=iconLeftEdge;
  1140. labelLeft=startPixel+theme.event.label.offsetFromLine;
  1141. labelTrack=this._findFreeTrackForText(iconTrack,labelLeft+labelSize.width,function(t){t.line=startPixel-2;
  1142. });
  1143. this._getTrackData(labelTrack).text=iconLeftEdge;
  1144. this._paintEventLine(evt,startPixel,iconTrack,labelTrack,metrics,theme);
  1145. }var labelTop=Math.round(metrics.trackOffset+labelTrack*metrics.trackIncrement+metrics.trackHeight/2-labelSize.height/2);
  1146. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme);
  1147. var self=this;
  1148. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(iconElmtData.elmt,domEvt,evt);
  1149. };
  1150. SimileAjax.DOM.registerEvent(iconElmtData.elmt,"mousedown",clickHandler);
  1151. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  1152. this._createHighlightDiv(highlightIndex,iconElmtData,theme);
  1153. this._eventIdToElmt[evt.getID()]=iconElmtData.elmt;
  1154. };
  1155. Timeline.DetailedEventPainter.prototype.paintImpreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  1156. var text=evt.getText();
  1157. var startDate=evt.getStart();
  1158. var endDate=evt.getEnd();
  1159. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  1160. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  1161. var iconRightEdge=Math.round(startPixel+metrics.iconWidth/2);
  1162. var iconLeftEdge=Math.round(startPixel-metrics.iconWidth/2);
  1163. var labelSize=this._frc.computeSize(text);
  1164. var iconTrack=this._findFreeTrackForSolid(endPixel,startPixel);
  1165. var tapeElmtData=this._paintEventTape(evt,iconTrack,startPixel,endPixel,theme.event.instant.impreciseColor,theme.event.instant.impreciseOpacity,metrics,theme);
  1166. var iconElmtData=this._paintEventIcon(evt,iconTrack,iconLeftEdge,metrics,theme);
  1167. var iconTrackData=this._getTrackData(iconTrack);
  1168. iconTrackData.solid=iconLeftEdge;
  1169. var labelLeft=iconRightEdge+theme.event.label.offsetFromLine;
  1170. var labelRight=labelLeft+labelSize.width;
  1171. var labelTrack;
  1172. if(labelRight<endPixel){labelTrack=iconTrack;
  1173. }else{labelLeft=startPixel+theme.event.label.offsetFromLine;
  1174. labelRight=labelLeft+labelSize.width;
  1175. labelTrack=this._findFreeTrackForText(iconTrack,labelRight,function(t){t.line=startPixel-2;
  1176. });
  1177. this._getTrackData(labelTrack).text=iconLeftEdge;
  1178. this._paintEventLine(evt,startPixel,iconTrack,labelTrack,metrics,theme);
  1179. }var labelTop=Math.round(metrics.trackOffset+labelTrack*metrics.trackIncrement+metrics.trackHeight/2-labelSize.height/2);
  1180. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme);
  1181. var self=this;
  1182. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(iconElmtData.elmt,domEvt,evt);
  1183. };
  1184. SimileAjax.DOM.registerEvent(iconElmtData.elmt,"mousedown",clickHandler);
  1185. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  1186. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  1187. this._createHighlightDiv(highlightIndex,iconElmtData,theme);
  1188. this._eventIdToElmt[evt.getID()]=iconElmtData.elmt;
  1189. };
  1190. Timeline.DetailedEventPainter.prototype.paintPreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  1191. var text=evt.getText();
  1192. var startDate=evt.getStart();
  1193. var endDate=evt.getEnd();
  1194. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  1195. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  1196. var labelSize=this._frc.computeSize(text);
  1197. var tapeTrack=this._findFreeTrackForSolid(endPixel);
  1198. var color=evt.getColor();
  1199. color=color!=null?color:theme.event.duration.color;
  1200. var tapeElmtData=this._paintEventTape(evt,tapeTrack,startPixel,endPixel,color,100,metrics,theme);
  1201. var tapeTrackData=this._getTrackData(tapeTrack);
  1202. tapeTrackData.solid=startPixel;
  1203. var labelLeft=startPixel+theme.event.label.offsetFromLine;
  1204. var labelTrack=this._findFreeTrackForText(tapeTrack,labelLeft+labelSize.width,function(t){t.line=startPixel-2;
  1205. });
  1206. this._getTrackData(labelTrack).text=startPixel-2;
  1207. this._paintEventLine(evt,startPixel,tapeTrack,labelTrack,metrics,theme);
  1208. var labelTop=Math.round(metrics.trackOffset+labelTrack*metrics.trackIncrement+metrics.trackHeight/2-labelSize.height/2);
  1209. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme);
  1210. var self=this;
  1211. var clickHandler=function(elmt,domEvt,target){return self._onClickDurationEvent(tapeElmtData.elmt,domEvt,evt);
  1212. };
  1213. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  1214. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  1215. this._createHighlightDiv(highlightIndex,tapeElmtData,theme);
  1216. this._eventIdToElmt[evt.getID()]=tapeElmtData.elmt;
  1217. };
  1218. Timeline.DetailedEventPainter.prototype.paintImpreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  1219. var text=evt.getText();
  1220. var startDate=evt.getStart();
  1221. var latestStartDate=evt.getLatestStart();
  1222. var endDate=evt.getEnd();
  1223. var earliestEndDate=evt.getEarliestEnd();
  1224. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  1225. var latestStartPixel=Math.round(this._band.dateToPixelOffset(latestStartDate));
  1226. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  1227. var earliestEndPixel=Math.round(this._band.dateToPixelOffset(earliestEndDate));
  1228. var labelSize=this._frc.computeSize(text);
  1229. var tapeTrack=this._findFreeTrackForSolid(endPixel);
  1230. var color=evt.getColor();
  1231. color=color!=null?color:theme.event.duration.color;
  1232. var impreciseTapeElmtData=this._paintEventTape(evt,tapeTrack,startPixel,endPixel,theme.event.duration.impreciseColor,theme.event.duration.impreciseOpacity,metrics,theme);
  1233. var tapeElmtData=this._paintEventTape(evt,tapeTrack,latestStartPixel,earliestEndPixel,color,100,metrics,theme);
  1234. var tapeTrackData=this._getTrackData(tapeTrack);
  1235. tapeTrackData.solid=startPixel;
  1236. var labelLeft=latestStartPixel+theme.event.label.offsetFromLine;
  1237. var labelTrack=this._findFreeTrackForText(tapeTrack,labelLeft+labelSize.width,function(t){t.line=latestStartPixel-2;
  1238. });
  1239. this._getTrackData(labelTrack).text=latestStartPixel-2;
  1240. this._paintEventLine(evt,latestStartPixel,tapeTrack,labelTrack,metrics,theme);
  1241. var labelTop=Math.round(metrics.trackOffset+labelTrack*metrics.trackIncrement+metrics.trackHeight/2-labelSize.height/2);
  1242. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme);
  1243. var self=this;
  1244. var clickHandler=function(elmt,domEvt,target){return self._onClickDurationEvent(tapeElmtData.elmt,domEvt,evt);
  1245. };
  1246. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  1247. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  1248. this._createHighlightDiv(highlightIndex,tapeElmtData,theme);
  1249. this._eventIdToElmt[evt.getID()]=tapeElmtData.elmt;
  1250. };
  1251. Timeline.DetailedEventPainter.prototype._findFreeTrackForSolid=function(solidEdge,softEdge){for(var i=0;
  1252. true;
  1253. i++){if(i<this._lowerTracks.length){var t=this._lowerTracks[i];
  1254. if(Math.min(t.solid,t.text)>solidEdge&&(!(softEdge)||t.line>softEdge)){return i;
  1255. }}else{this._lowerTracks.push({solid:Number.POSITIVE_INFINITY,text:Number.POSITIVE_INFINITY,line:Number.POSITIVE_INFINITY});
  1256. return i;
  1257. }if(i<this._upperTracks.length){var t=this._upperTracks[i];
  1258. if(Math.min(t.solid,t.text)>solidEdge&&(!(softEdge)||t.line>softEdge)){return -1-i;
  1259. }}else{this._upperTracks.push({solid:Number.POSITIVE_INFINITY,text:Number.POSITIVE_INFINITY,line:Number.POSITIVE_INFINITY});
  1260. return -1-i;
  1261. }}};
  1262. Timeline.DetailedEventPainter.prototype._findFreeTrackForText=function(fromTrack,edge,occupiedTrackVisitor){var extendUp;
  1263. var index;
  1264. var firstIndex;
  1265. var result;
  1266. if(fromTrack<0){extendUp=true;
  1267. firstIndex=-fromTrack;
  1268. index=this._findFreeUpperTrackForText(firstIndex,edge);
  1269. result=-1-index;
  1270. }else{if(fromTrack>0){extendUp=false;
  1271. firstIndex=fromTrack+1;
  1272. index=this._findFreeLowerTrackForText(firstIndex,edge);
  1273. result=index;
  1274. }else{var upIndex=this._findFreeUpperTrackForText(0,edge);
  1275. var downIndex=this._findFreeLowerTrackForText(1,edge);
  1276. if(downIndex-1<=upIndex){extendUp=false;
  1277. firstIndex=1;
  1278. index=downIndex;
  1279. result=index;
  1280. }else{extendUp=true;
  1281. firstIndex=0;
  1282. index=upIndex;
  1283. result=-1-index;
  1284. }}}if(extendUp){if(index==this._upperTracks.length){this._upperTracks.push({solid:Number.POSITIVE_INFINITY,text:Number.POSITIVE_INFINITY,line:Number.POSITIVE_INFINITY});
  1285. }for(var i=firstIndex;
  1286. i<index;
  1287. i++){occupiedTrackVisitor(this._upperTracks[i]);
  1288. }}else{if(index==this._lowerTracks.length){this._lowerTracks.push({solid:Number.POSITIVE_INFINITY,text:Number.POSITIVE_INFINITY,line:Number.POSITIVE_INFINITY});
  1289. }for(var i=firstIndex;
  1290. i<index;
  1291. i++){occupiedTrackVisitor(this._lowerTracks[i]);
  1292. }}return result;
  1293. };
  1294. Timeline.DetailedEventPainter.prototype._findFreeLowerTrackForText=function(index,edge){for(;
  1295. index<this._lowerTracks.length;
  1296. index++){var t=this._lowerTracks[index];
  1297. if(Math.min(t.solid,t.text)>=edge){break;
  1298. }}return index;
  1299. };
  1300. Timeline.DetailedEventPainter.prototype._findFreeUpperTrackForText=function(index,edge){for(;
  1301. index<this._upperTracks.length;
  1302. index++){var t=this._upperTracks[index];
  1303. if(Math.min(t.solid,t.text)>=edge){break;
  1304. }}return index;
  1305. };
  1306. Timeline.DetailedEventPainter.prototype._getTrackData=function(index){return(index<0)?this._upperTracks[-index-1]:this._lowerTracks[index];
  1307. };
  1308. Timeline.DetailedEventPainter.prototype._paintEventLine=function(evt,left,startTrack,endTrack,metrics,theme){var top=Math.round(metrics.trackOffset+startTrack*metrics.trackIncrement+metrics.trackHeight/2);
  1309. var height=Math.round(Math.abs(endTrack-startTrack)*metrics.trackIncrement);
  1310. var lineStyle="1px solid "+theme.event.label.lineColor;
  1311. var lineDiv=this._timeline.getDocument().createElement("div");
  1312. lineDiv.style.position="absolute";
  1313. lineDiv.style.left=left+"px";
  1314. lineDiv.style.width=theme.event.label.offsetFromLine+"px";
  1315. lineDiv.style.height=height+"px";
  1316. if(startTrack>endTrack){lineDiv.style.top=(top-height)+"px";
  1317. lineDiv.style.borderTop=lineStyle;
  1318. }else{lineDiv.style.top=top+"px";
  1319. lineDiv.style.borderBottom=lineStyle;
  1320. }lineDiv.style.borderLeft=lineStyle;
  1321. this._lineLayer.appendChild(lineDiv);
  1322. };
  1323. Timeline.DetailedEventPainter.prototype._paintEventIcon=function(evt,iconTrack,left,metrics,theme){var icon=evt.getIcon();
  1324. icon=icon!=null?icon:metrics.icon;
  1325. var middle=metrics.trackOffset+iconTrack*metrics.trackIncrement+metrics.trackHeight/2;
  1326. var top=Math.round(middle-metrics.iconHeight/2);
  1327. var img=SimileAjax.Graphics.createTranslucentImage(icon);
  1328. var iconDiv=this._timeline.getDocument().createElement("div");
  1329. iconDiv.style.position="absolute";
  1330. iconDiv.style.left=left+"px";
  1331. iconDiv.style.top=top+"px";
  1332. iconDiv.appendChild(img);
  1333. iconDiv.style.cursor="pointer";
  1334. if(evt._title!=null){iconDiv.title=evt._title;
  1335. }this._eventLayer.appendChild(iconDiv);
  1336. return{left:left,top:top,width:metrics.iconWidth,height:metrics.iconHeight,elmt:iconDiv};
  1337. };
  1338. Timeline.DetailedEventPainter.prototype._paintEventLabel=function(evt,text,left,top,width,height,theme){var doc=this._timeline.getDocument();
  1339. var labelBackgroundDiv=doc.createElement("div");
  1340. labelBackgroundDiv.style.position="absolute";
  1341. labelBackgroundDiv.style.left=left+"px";
  1342. labelBackgroundDiv.style.width=width+"px";
  1343. labelBackgroundDiv.style.top=top+"px";
  1344. labelBackgroundDiv.style.height=height+"px";
  1345. labelBackgroundDiv.style.backgroundColor=theme.event.label.backgroundColor;
  1346. SimileAjax.Graphics.setOpacity(labelBackgroundDiv,theme.event.label.backgroundOpacity);
  1347. this._eventLayer.appendChild(labelBackgroundDiv);
  1348. var labelDiv=doc.createElement("div");
  1349. labelDiv.style.position="absolute";
  1350. labelDiv.style.left=left+"px";
  1351. labelDiv.style.width=width+"px";
  1352. labelDiv.style.top=top+"px";
  1353. labelDiv.innerHTML=text;
  1354. labelDiv.style.cursor="pointer";
  1355. if(evt._title!=null){labelDiv.title=evt._title;
  1356. }var color=evt.getTextColor();
  1357. if(color==null){color=evt.getColor();
  1358. }if(color!=null){labelDiv.style.color=color;
  1359. }this._eventLayer.appendChild(labelDiv);
  1360. return{left:left,top:top,width:width,height:height,elmt:labelDiv};
  1361. };
  1362. Timeline.DetailedEventPainter.prototype._paintEventTape=function(evt,iconTrack,startPixel,endPixel,color,opacity,metrics,theme){var tapeWidth=endPixel-startPixel;
  1363. var tapeHeight=theme.event.tape.height;
  1364. var middle=metrics.trackOffset+iconTrack*metrics.trackIncrement+metrics.trackHeight/2;
  1365. var top=Math.round(middle-tapeHeight/2);
  1366. var tapeDiv=this._timeline.getDocument().createElement("div");
  1367. tapeDiv.style.position="absolute";
  1368. tapeDiv.style.left=startPixel+"px";
  1369. tapeDiv.style.width=tapeWidth+"px";
  1370. tapeDiv.style.top=top+"px";
  1371. tapeDiv.style.height=tapeHeight+"px";
  1372. tapeDiv.style.backgroundColor=color;
  1373. tapeDiv.style.overflow="hidden";
  1374. tapeDiv.style.cursor="pointer";
  1375. if(evt._title!=null){tapeDiv.title=evt._title;
  1376. }SimileAjax.Graphics.setOpacity(tapeDiv,opacity);
  1377. this._eventLayer.appendChild(tapeDiv);
  1378. return{left:startPixel,top:top,width:tapeWidth,height:tapeHeight,elmt:tapeDiv};
  1379. };
  1380. Timeline.DetailedEventPainter.prototype._createHighlightDiv=function(highlightIndex,dimensions,theme){if(highlightIndex>=0){var doc=this._timeline.getDocument();
  1381. var eventTheme=theme.event;
  1382. var color=eventTheme.highlightColors[Math.min(highlightIndex,eventTheme.highlightColors.length-1)];
  1383. var div=doc.createElement("div");
  1384. div.style.position="absolute";
  1385. div.style.overflow="hidden";
  1386. div.style.left=(dimensions.left-2)+"px";
  1387. div.style.width=(dimensions.width+4)+"px";
  1388. div.style.top=(dimensions.top-2)+"px";
  1389. div.style.height=(dimensions.height+4)+"px";
  1390. div.style.background=color;
  1391. this._highlightLayer.appendChild(div);
  1392. }};
  1393. Timeline.DetailedEventPainter.prototype._onClickInstantEvent=function(icon,domEvt,evt){var c=SimileAjax.DOM.getPageCoordinates(icon);
  1394. this._showBubble(c.left+Math.ceil(icon.offsetWidth/2),c.top+Math.ceil(icon.offsetHeight/2),evt);
  1395. this._fireOnSelect(evt.getID());
  1396. domEvt.cancelBubble=true;
  1397. SimileAjax.DOM.cancelEvent(domEvt);
  1398. return false;
  1399. };
  1400. Timeline.DetailedEventPainter.prototype._onClickDurationEvent=function(target,domEvt,evt){if("pageX" in domEvt){var x=domEvt.pageX;
  1401. var y=domEvt.pageY;
  1402. }else{var c=SimileAjax.DOM.getPageCoordinates(target);
  1403. var x=domEvt.offsetX+c.left;
  1404. var y=domEvt.offsetY+c.top;
  1405. }this._showBubble(x,y,evt);
  1406. this._fireOnSelect(evt.getID());
  1407. domEvt.cancelBubble=true;
  1408. SimileAjax.DOM.cancelEvent(domEvt);
  1409. return false;
  1410. };
  1411. Timeline.DetailedEventPainter.prototype.showBubble=function(evt){var elmt=this._eventIdToElmt[evt.getID()];
  1412. if(elmt){var c=SimileAjax.DOM.getPageCoordinates(elmt);
  1413. this._showBubble(c.left+elmt.offsetWidth/2,c.top+elmt.offsetHeight/2,evt);
  1414. }};
  1415. Timeline.DetailedEventPainter.prototype._showBubble=function(x,y,evt){var div=document.createElement("div");
  1416. var themeBubble=this._params.theme.event.bubble;
  1417. evt.fillInfoBubble(div,this._params.theme,this._band.getLabeller());
  1418. SimileAjax.WindowManager.cancelPopups();
  1419. SimileAjax.Graphics.createBubbleForContentAndPoint(div,x,y,themeBubble.width,null,themeBubble.maxHeight);
  1420. };
  1421. Timeline.DetailedEventPainter.prototype._fireOnSelect=function(eventID){for(var i=0;
  1422. i<this._onSelectListeners.length;
  1423. i++){this._onSelectListeners[i](eventID);
  1424. }};
  1425. /* ether-painters.js */
  1426. Timeline.GregorianEtherPainter=function(params){this._params=params;
  1427. this._theme=params.theme;
  1428. this._unit=params.unit;
  1429. this._multiple=("multiple" in params)?params.multiple:1;
  1430. };
  1431. Timeline.GregorianEtherPainter.prototype.initialize=function(band,timeline){this._band=band;
  1432. this._timeline=timeline;
  1433. this._backgroundLayer=band.createLayerDiv(0);
  1434. this._backgroundLayer.setAttribute("name","ether-background");
  1435. this._backgroundLayer.className="timeline-ether-bg";
  1436. this._markerLayer=null;
  1437. this._lineLayer=null;
  1438. var align=("align" in this._params&&this._params.align!=undefined)?this._params.align:this._theme.ether.interval.marker[timeline.isHorizontal()?"hAlign":"vAlign"];
  1439. var showLine=("showLine" in this._params)?this._params.showLine:this._theme.ether.interval.line.show;
  1440. this._intervalMarkerLayout=new Timeline.EtherIntervalMarkerLayout(this._timeline,this._band,this._theme,align,showLine);
  1441. this._highlight=new Timeline.EtherHighlight(this._timeline,this._band,this._theme,this._backgroundLayer);
  1442. };
  1443. Timeline.GregorianEtherPainter.prototype.setHighlight=function(startDate,endDate,orthogonalOffset,orthogonalExtent){this._highlight.position(startDate,endDate,orthogonalOffset,orthogonalExtent);
  1444. };
  1445. Timeline.GregorianEtherPainter.prototype.paint=function(){if(this._markerLayer){this._band.removeLayerDiv(this._markerLayer);
  1446. }this._markerLayer=this._band.createLayerDiv(100);
  1447. this._markerLayer.setAttribute("name","ether-markers");
  1448. this._markerLayer.style.display="none";
  1449. if(this._lineLayer){this._band.removeLayerDiv(this._lineLayer);
  1450. }this._lineLayer=this._band.createLayerDiv(1);
  1451. this._lineLayer.setAttribute("name","ether-lines");
  1452. this._lineLayer.style.display="none";
  1453. var minDate=this._band.getMinDate();
  1454. var maxDate=this._band.getMaxDate();
  1455. var timeZone=this._band.getTimeZone();
  1456. var labeller=this._band.getLabeller();
  1457. SimileAjax.DateTime.roundDownToInterval(minDate,this._unit,timeZone,this._multiple,this._theme.firstDayOfWeek);
  1458. var p=this;
  1459. var incrementDate=function(date){for(var i=0;
  1460. i<p._multiple;
  1461. i++){SimileAjax.DateTime.incrementByInterval(date,p._unit);
  1462. }};
  1463. while(minDate.getTime()<maxDate.getTime()){this._intervalMarkerLayout.createIntervalMarker(minDate,labeller,this._unit,this._markerLayer,this._lineLayer);
  1464. incrementDate(minDate);
  1465. }this._markerLayer.style.display="block";
  1466. this._lineLayer.style.display="block";
  1467. };
  1468. Timeline.GregorianEtherPainter.prototype.softPaint=function(){};
  1469. Timeline.GregorianEtherPainter.prototype.zoom=function(netIntervalChange){if(netIntervalChange!=0){this._unit+=netIntervalChange;
  1470. }};
  1471. Timeline.HotZoneGregorianEtherPainter=function(params){this._params=params;
  1472. this._theme=params.theme;
  1473. this._zones=[{startTime:Number.NEGATIVE_INFINITY,endTime:Number.POSITIVE_INFINITY,unit:params.unit,multiple:1}];
  1474. for(var i=0;
  1475. i<params.zones.length;
  1476. i++){var zone=params.zones[i];
  1477. var zoneStart=SimileAjax.DateTime.parseGregorianDateTime(zone.start).getTime();
  1478. var zoneEnd=SimileAjax.DateTime.parseGregorianDateTime(zone.end).getTime();
  1479. for(var j=0;
  1480. j<this._zones.length&&zoneEnd>zoneStart;
  1481. j++){var zone2=this._zones[j];
  1482. if(zoneStart<zone2.endTime){if(zoneStart>zone2.startTime){this._zones.splice(j,0,{startTime:zone2.startTime,endTime:zoneStart,unit:zone2.unit,multiple:zone2.multiple});
  1483. j++;
  1484. zone2.startTime=zoneStart;
  1485. }if(zoneEnd<zone2.endTime){this._zones.splice(j,0,{startTime:zoneStart,endTime:zoneEnd,unit:zone.unit,multiple:(zone.multiple)?zone.multiple:1});
  1486. j++;
  1487. zone2.startTime=zoneEnd;
  1488. zoneStart=zoneEnd;
  1489. }else{zone2.multiple=zone.multiple;
  1490. zone2.unit=zone.unit;
  1491. zoneStart=zone2.endTime;
  1492. }}}}};
  1493. Timeline.HotZoneGregorianEtherPainter.prototype.initialize=function(band,timeline){this._band=band;
  1494. this._timeline=timeline;
  1495. this._backgroundLayer=band.createLayerDiv(0);
  1496. this._backgroundLayer.setAttribute("name","ether-background");
  1497. this._backgroundLayer.className="timeline-ether-bg";
  1498. this._markerLayer=null;
  1499. this._lineLayer=null;
  1500. var align=("align" in this._params&&this._params.align!=undefined)?this._params.align:this._theme.ether.interval.marker[timeline.isHorizontal()?"hAlign":"vAlign"];
  1501. var showLine=("showLine" in this._params)?this._params.showLine:this._theme.ether.interval.line.show;
  1502. this._intervalMarkerLayout=new Timeline.EtherIntervalMarkerLayout(this._timeline,this._band,this._theme,align,showLine);
  1503. this._highlight=new Timeline.EtherHighlight(this._timeline,this._band,this._theme,this._backgroundLayer);
  1504. };
  1505. Timeline.HotZoneGregorianEtherPainter.prototype.setHighlight=function(startDate,endDate){this._highlight.position(startDate,endDate);
  1506. };
  1507. Timeline.HotZoneGregorianEtherPainter.prototype.paint=function(){if(this._markerLayer){this._band.removeLayerDiv(this._markerLayer);
  1508. }this._markerLayer=this._band.createLayerDiv(100);
  1509. this._markerLayer.setAttribute("name","ether-markers");
  1510. this._markerLayer.style.display="none";
  1511. if(this._lineLayer){this._band.removeLayerDiv(this._lineLayer);
  1512. }this._lineLayer=this._band.createLayerDiv(1);
  1513. this._lineLayer.setAttribute("name","ether-lines");
  1514. this._lineLayer.style.display="none";
  1515. var minDate=this._band.getMinDate();
  1516. var maxDate=this._band.getMaxDate();
  1517. var timeZone=this._band.getTimeZone();
  1518. var labeller=this._band.getLabeller();
  1519. var p=this;
  1520. var incrementDate=function(date,zone){for(var i=0;
  1521. i<zone.multiple;
  1522. i++){SimileAjax.DateTime.incrementByInterval(date,zone.unit);
  1523. }};
  1524. var zStart=0;
  1525. while(zStart<this._zones.length){if(minDate.getTime()<this._zones[zStart].endTime){break;
  1526. }zStart++;
  1527. }var zEnd=this._zones.length-1;
  1528. while(zEnd>=0){if(maxDate.getTime()>this._zones[zEnd].startTime){break;
  1529. }zEnd--;
  1530. }for(var z=zStart;
  1531. z<=zEnd;
  1532. z++){var zone=this._zones[z];
  1533. var minDate2=new Date(Math.max(minDate.getTime(),zone.startTime));
  1534. var maxDate2=new Date(Math.min(maxDate.getTime(),zone.endTime));
  1535. SimileAjax.DateTime.roundDownToInterval(minDate2,zone.unit,timeZone,zone.multiple,this._theme.firstDayOfWeek);
  1536. SimileAjax.DateTime.roundUpToInterval(maxDate2,zone.unit,timeZone,zone.multiple,this._theme.firstDayOfWeek);
  1537. while(minDate2.getTime()<maxDate2.getTime()){this._intervalMarkerLayout.createIntervalMarker(minDate2,labeller,zone.unit,this._markerLayer,this._lineLayer);
  1538. incrementDate(minDate2,zone);
  1539. }}this._markerLayer.style.display="block";
  1540. this._lineLayer.style.display="block";
  1541. };
  1542. Timeline.HotZoneGregorianEtherPainter.prototype.softPaint=function(){};
  1543. Timeline.HotZoneGregorianEtherPainter.prototype.zoom=function(netIntervalChange){if(netIntervalChange!=0){for(var i=0;
  1544. i<this._zones.length;
  1545. ++i){if(this._zones[i]){this._zones[i].unit+=netIntervalChange;
  1546. }}}};
  1547. Timeline.YearCountEtherPainter=function(params){this._params=params;
  1548. this._theme=params.theme;
  1549. this._startDate=SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
  1550. this._multiple=("multiple" in params)?params.multiple:1;
  1551. };
  1552. Timeline.YearCountEtherPainter.prototype.initialize=function(band,timeline){this._band=band;
  1553. this._timeline=timeline;
  1554. this._backgroundLayer=band.createLayerDiv(0);
  1555. this._backgroundLayer.setAttribute("name","ether-background");
  1556. this._backgroundLayer.className="timeline-ether-bg";
  1557. this._markerLayer=null;
  1558. this._lineLayer=null;
  1559. var align=("align" in this._params)?this._params.align:this._theme.ether.interval.marker[timeline.isHorizontal()?"hAlign":"vAlign"];
  1560. var showLine=("showLine" in this._params)?this._params.showLine:this._theme.ether.interval.line.show;
  1561. this._intervalMarkerLayout=new Timeline.EtherIntervalMarkerLayout(this._timeline,this._band,this._theme,align,showLine);
  1562. this._highlight=new Timeline.EtherHighlight(this._timeline,this._band,this._theme,this._backgroundLayer);
  1563. };
  1564. Timeline.YearCountEtherPainter.prototype.setHighlight=function(startDate,endDate){this._highlight.position(startDate,endDate);
  1565. };
  1566. Timeline.YearCountEtherPainter.prototype.paint=function(){if(this._markerLayer){this._band.removeLayerDiv(this._markerLayer);
  1567. }this._markerLayer=this._band.createLayerDiv(100);
  1568. this._markerLayer.setAttribute("name","ether-markers");
  1569. this._markerLayer.style.display="none";
  1570. if(this._lineLayer){this._band.removeLayerDiv(this._lineLayer);
  1571. }this._lineLayer=this._band.createLayerDiv(1);
  1572. this._lineLayer.setAttribute("name","ether-lines");
  1573. this._lineLayer.style.display="none";
  1574. var minDate=new Date(this._startDate.getTime());
  1575. var maxDate=this._band.getMaxDate();
  1576. var yearDiff=this._band.getMinDate().getUTCFullYear()-this._startDate.getUTCFullYear();
  1577. minDate.setUTCFullYear(this._band.getMinDate().getUTCFullYear()-yearDiff%this._multiple);
  1578. var p=this;
  1579. var incrementDate=function(date){for(var i=0;
  1580. i<p._multiple;
  1581. i++){SimileAjax.DateTime.incrementByInterval(date,SimileAjax.DateTime.YEAR);
  1582. }};
  1583. var labeller={labelInterval:function(date,intervalUnit){var diff=date.getUTCFullYear()-p._startDate.getUTCFullYear();
  1584. return{text:diff,emphasized:diff==0};
  1585. }};
  1586. while(minDate.getTime()<maxDate.getTime()){this._intervalMarkerLayout.createIntervalMarker(minDate,labeller,SimileAjax.DateTime.YEAR,this._markerLayer,this._lineLayer);
  1587. incrementDate(minDate);
  1588. }this._markerLayer.style.display="block";
  1589. this._lineLayer.style.display="block";
  1590. };
  1591. Timeline.YearCountEtherPainter.prototype.softPaint=function(){};
  1592. Timeline.QuarterlyEtherPainter=function(params){this._params=params;
  1593. this._theme=params.theme;
  1594. this._startDate=SimileAjax.DateTime.parseGregorianDateTime(params.startDate);
  1595. };
  1596. Timeline.QuarterlyEtherPainter.prototype.initialize=function(band,timeline){this._band=band;
  1597. this._timeline=timeline;
  1598. this._backgroundLayer=band.createLayerDiv(0);
  1599. this._backgroundLayer.setAttribute("name","ether-background");
  1600. this._backgroundLayer.className="timeline-ether-bg";
  1601. this._markerLayer=null;
  1602. this._lineLayer=null;
  1603. var align=("align" in this._params)?this._params.align:this._theme.ether.interval.marker[timeline.isHorizontal()?"hAlign":"vAlign"];
  1604. var showLine=("showLine" in this._params)?this._params.showLine:this._theme.ether.interval.line.show;
  1605. this._intervalMarkerLayout=new Timeline.EtherIntervalMarkerLayout(this._timeline,this._band,this._theme,align,showLine);
  1606. this._highlight=new Timeline.EtherHighlight(this._timeline,this._band,this._theme,this._backgroundLayer);
  1607. };
  1608. Timeline.QuarterlyEtherPainter.prototype.setHighlight=function(startDate,endDate){this._highlight.position(startDate,endDate);
  1609. };
  1610. Timeline.QuarterlyEtherPainter.prototype.paint=function(){if(this._markerLayer){this._band.removeLayerDiv(this._markerLayer);
  1611. }this._markerLayer=this._band.createLayerDiv(100);
  1612. this._markerLayer.setAttribute("name","ether-markers");
  1613. this._markerLayer.style.display="none";
  1614. if(this._lineLayer){this._band.removeLayerDiv(this._lineLayer);
  1615. }this._lineLayer=this._band.createLayerDiv(1);
  1616. this._lineLayer.setAttribute("name","ether-lines");
  1617. this._lineLayer.style.display="none";
  1618. var minDate=new Date(0);
  1619. var maxDate=this._band.getMaxDate();
  1620. minDate.setUTCFullYear(Math.max(this._startDate.getUTCFullYear(),this._band.getMinDate().getUTCFullYear()));
  1621. minDate.setUTCMonth(this._startDate.getUTCMonth());
  1622. var p=this;
  1623. var incrementDate=function(date){date.setUTCMonth(date.getUTCMonth()+3);
  1624. };
  1625. var labeller={labelInterval:function(date,intervalUnit){var quarters=(4+(date.getUTCMonth()-p._startDate.getUTCMonth())/3)%4;
  1626. if(quarters!=0){return{text:"Q"+(quarters+1),emphasized:false};
  1627. }else{return{text:"Y"+(date.getUTCFullYear()-p._startDate.getUTCFullYear()+1),emphasized:true};
  1628. }}};
  1629. while(minDate.getTime()<maxDate.getTime()){this._intervalMarkerLayout.createIntervalMarker(minDate,labeller,SimileAjax.DateTime.YEAR,this._markerLayer,this._lineLayer);
  1630. incrementDate(minDate);
  1631. }this._markerLayer.style.display="block";
  1632. this._lineLayer.style.display="block";
  1633. };
  1634. Timeline.QuarterlyEtherPainter.prototype.softPaint=function(){};
  1635. Timeline.EtherIntervalMarkerLayout=function(timeline,band,theme,align,showLine){var horizontal=timeline.isHorizontal();
  1636. if(horizontal){if(align=="Top"){this.positionDiv=function(div,offset){div.style.left=offset+"px";
  1637. div.style.top="0px";
  1638. };
  1639. }else{this.positionDiv=function(div,offset){div.style.left=offset+"px";
  1640. div.style.bottom="0px";
  1641. };
  1642. }}else{if(align=="Left"){this.positionDiv=function(div,offset){div.style.top=offset+"px";
  1643. div.style.left="0px";
  1644. };
  1645. }else{this.positionDiv=function(div,offset){div.style.top=offset+"px";
  1646. div.style.right="0px";
  1647. };
  1648. }}var markerTheme=theme.ether.interval.marker;
  1649. var lineTheme=theme.ether.interval.line;
  1650. var weekendTheme=theme.ether.interval.weekend;
  1651. var stylePrefix=(horizontal?"h":"v")+align;
  1652. var labelStyler=markerTheme[stylePrefix+"Styler"];
  1653. var emphasizedLabelStyler=markerTheme[stylePrefix+"EmphasizedStyler"];
  1654. var day=SimileAjax.DateTime.gregorianUnitLengths[SimileAjax.DateTime.DAY];
  1655. this.createIntervalMarker=function(date,labeller,unit,markerDiv,lineDiv){var offset=Math.round(band.dateToPixelOffset(date));
  1656. if(showLine&&unit!=SimileAjax.DateTime.WEEK){var divLine=timeline.getDocument().createElement("div");
  1657. divLine.className="timeline-ether-lines";
  1658. if(lineTheme.opacity<100){SimileAjax.Graphics.setOpacity(divLine,lineTheme.opacity);
  1659. }if(horizontal){divLine.style.left=offset+"px";
  1660. }else{divLine.style.top=offset+"px";
  1661. }lineDiv.appendChild(divLine);
  1662. }if(unit==SimileAjax.DateTime.WEEK){var firstDayOfWeek=theme.firstDayOfWeek;
  1663. var saturday=new Date(date.getTime()+(6-firstDayOfWeek-7)*day);
  1664. var monday=new Date(saturday.getTime()+2*day);
  1665. var saturdayPixel=Math.round(band.dateToPixelOffset(saturday));
  1666. var mondayPixel=Math.round(band.dateToPixelOffset(monday));
  1667. var length=Math.max(1,mondayPixel-saturdayPixel);
  1668. var divWeekend=timeline.getDocument().createElement("div");
  1669. divWeekend.className="timeline-ether-weekends";
  1670. if(weekendTheme.opacity<100){SimileAjax.Graphics.setOpacity(divWeekend,weekendTheme.opacity);
  1671. }if(horizontal){divWeekend.style.left=saturdayPixel+"px";
  1672. divWeekend.style.width=length+"px";
  1673. }else{divWeekend.style.top=saturdayPixel+"px";
  1674. divWeekend.style.height=length+"px";
  1675. }lineDiv.appendChild(divWeekend);
  1676. }var label=labeller.labelInterval(date,unit);
  1677. var div=timeline.getDocument().createElement("div");
  1678. div.innerHTML=label.text;
  1679. div.className="timeline-date-label";
  1680. if(label.emphasized){div.className+=" timeline-date-label-em";
  1681. }this.positionDiv(div,offset);
  1682. markerDiv.appendChild(div);
  1683. return div;
  1684. };
  1685. };
  1686. Timeline.EtherHighlight=function(timeline,band,theme,backgroundLayer){var horizontal=timeline.isHorizontal();
  1687. this._highlightDiv=null;
  1688. this._createHighlightDiv=function(){if(this._highlightDiv==null){this._highlightDiv=timeline.getDocument().createElement("div");
  1689. this._highlightDiv.setAttribute("name","ether-highlight");
  1690. this._highlightDiv.className="timeline-ether-highlight";
  1691. var opacity=theme.ether.highlightOpacity;
  1692. if(opacity<100){SimileAjax.Graphics.setOpacity(this._highlightDiv,opacity);
  1693. }backgroundLayer.appendChild(this._highlightDiv);
  1694. }};
  1695. this.position=function(startDate,endDate,orthogonalOffset,orthogonalExtent){orthogonalOffset=orthogonalOffset||0;
  1696. orthogonalExtent=orthogonalExtent||1;
  1697. this._createHighlightDiv();
  1698. var startPixel=Math.round(band.dateToPixelOffset(startDate));
  1699. var endPixel=Math.round(band.dateToPixelOffset(endDate));
  1700. var length=Math.max(endPixel-startPixel,3);
  1701. var totalWidth=band.getViewWidth()-4;
  1702. if(horizontal){this._highlightDiv.style.left=startPixel+"px";
  1703. this._highlightDiv.style.width=length+"px";
  1704. this._highlightDiv.style.top=Math.round(orthogonalOffset*totalWidth)+"px";
  1705. this._highlightDiv.style.height=Math.round(orthogonalExtent*totalWidth)+"px";
  1706. }else{this._highlightDiv.style.top=startPixel+"px";
  1707. this._highlightDiv.style.height=length+"px";
  1708. this._highlightDiv.style.left=Math.round(orthogonalOffset*totalWidth)+"px";
  1709. this._highlightDiv.style.width=Math.round(orthogonalExtent*totalWidth)+"px";
  1710. }};
  1711. };
  1712. /* ethers.js */
  1713. Timeline.LinearEther=function(params){this._params=params;
  1714. this._interval=params.interval;
  1715. this._pixelsPerInterval=params.pixelsPerInterval;
  1716. };
  1717. Timeline.LinearEther.prototype.initialize=function(band,timeline){this._band=band;
  1718. this._timeline=timeline;
  1719. this._unit=timeline.getUnit();
  1720. if("startsOn" in this._params){this._start=this._unit.parseFromObject(this._params.startsOn);
  1721. }else{if("endsOn" in this._params){this._start=this._unit.parseFromObject(this._params.endsOn);
  1722. this.shiftPixels(-this._timeline.getPixelLength());
  1723. }else{if("centersOn" in this._params){this._start=this._unit.parseFromObject(this._params.centersOn);
  1724. this.shiftPixels(-this._timeline.getPixelLength()/2);
  1725. }else{this._start=this._unit.makeDefaultValue();
  1726. this.shiftPixels(-this._timeline.getPixelLength()/2);
  1727. }}}};
  1728. Timeline.LinearEther.prototype.setDate=function(date){this._start=this._unit.cloneValue(date);
  1729. };
  1730. Timeline.LinearEther.prototype.shiftPixels=function(pixels){var numeric=this._interval*pixels/this._pixelsPerInterval;
  1731. this._start=this._unit.change(this._start,numeric);
  1732. };
  1733. Timeline.LinearEther.prototype.dateToPixelOffset=function(date){var numeric=this._unit.compare(date,this._start);
  1734. return this._pixelsPerInterval*numeric/this._interval;
  1735. };
  1736. Timeline.LinearEther.prototype.pixelOffsetToDate=function(pixels){var numeric=pixels*this._interval/this._pixelsPerInterval;
  1737. return this._unit.change(this._start,numeric);
  1738. };
  1739. Timeline.LinearEther.prototype.zoom=function(zoomIn){var netIntervalChange=0;
  1740. var currentZoomIndex=this._band._zoomIndex;
  1741. var newZoomIndex=currentZoomIndex;
  1742. if(zoomIn&&(currentZoomIndex>0)){newZoomIndex=currentZoomIndex-1;
  1743. }if(!zoomIn&&(currentZoomIndex<(this._band._zoomSteps.length-1))){newZoomIndex=currentZoomIndex+1;
  1744. }this._band._zoomIndex=newZoomIndex;
  1745. this._interval=SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
  1746. this._pixelsPerInterval=this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
  1747. netIntervalChange=this._band._zoomSteps[newZoomIndex].unit-this._band._zoomSteps[currentZoomIndex].unit;
  1748. return netIntervalChange;
  1749. };
  1750. Timeline.HotZoneEther=function(params){this._params=params;
  1751. this._interval=params.interval;
  1752. this._pixelsPerInterval=params.pixelsPerInterval;
  1753. this._theme=params.theme;
  1754. };
  1755. Timeline.HotZoneEther.prototype.initialize=function(band,timeline){this._band=band;
  1756. this._timeline=timeline;
  1757. this._unit=timeline.getUnit();
  1758. this._zones=[{startTime:Number.NEGATIVE_INFINITY,endTime:Number.POSITIVE_INFINITY,magnify:1}];
  1759. var params=this._params;
  1760. for(var i=0;
  1761. i<params.zones.length;
  1762. i++){var zone=params.zones[i];
  1763. var zoneStart=this._unit.parseFromObject(zone.start);
  1764. var zoneEnd=this._unit.parseFromObject(zone.end);
  1765. for(var j=0;
  1766. j<this._zones.length&&this._unit.compare(zoneEnd,zoneStart)>0;
  1767. j++){var zone2=this._zones[j];
  1768. if(this._unit.compare(zoneStart,zone2.endTime)<0){if(this._unit.compare(zoneStart,zone2.startTime)>0){this._zones.splice(j,0,{startTime:zone2.startTime,endTime:zoneStart,magnify:zone2.magnify});
  1769. j++;
  1770. zone2.startTime=zoneStart;
  1771. }if(this._unit.compare(zoneEnd,zone2.endTime)<0){this._zones.splice(j,0,{startTime:zoneStart,endTime:zoneEnd,magnify:zone.magnify*zone2.magnify});
  1772. j++;
  1773. zone2.startTime=zoneEnd;
  1774. zoneStart=zoneEnd;
  1775. }else{zone2.magnify*=zone.magnify;
  1776. zoneStart=zone2.endTime;
  1777. }}}}if("startsOn" in this._params){this._start=this._unit.parseFromObject(this._params.startsOn);
  1778. }else{if("endsOn" in this._params){this._start=this._unit.parseFromObject(this._params.endsOn);
  1779. this.shiftPixels(-this._timeline.getPixelLength());
  1780. }else{if("centersOn" in this._params){this._start=this._unit.parseFromObject(this._params.centersOn);
  1781. this.shiftPixels(-this._timeline.getPixelLength()/2);
  1782. }else{this._start=this._unit.makeDefaultValue();
  1783. this.shiftPixels(-this._timeline.getPixelLength()/2);
  1784. }}}};
  1785. Timeline.HotZoneEther.prototype.setDate=function(date){this._start=this._unit.cloneValue(date);
  1786. };
  1787. Timeline.HotZoneEther.prototype.shiftPixels=function(pixels){this._start=this.pixelOffsetToDate(pixels);
  1788. };
  1789. Timeline.HotZoneEther.prototype.dateToPixelOffset=function(date){return this._dateDiffToPixelOffset(this._start,date);
  1790. };
  1791. Timeline.HotZoneEther.prototype.pixelOffsetToDate=function(pixels){return this._pixelOffsetToDate(pixels,this._start);
  1792. };
  1793. Timeline.HotZoneEther.prototype.zoom=function(zoomIn){var netIntervalChange=0;
  1794. var currentZoomIndex=this._band._zoomIndex;
  1795. var newZoomIndex=currentZoomIndex;
  1796. if(zoomIn&&(currentZoomIndex>0)){newZoomIndex=currentZoomIndex-1;
  1797. }if(!zoomIn&&(currentZoomIndex<(this._band._zoomSteps.length-1))){newZoomIndex=currentZoomIndex+1;
  1798. }this._band._zoomIndex=newZoomIndex;
  1799. this._interval=SimileAjax.DateTime.gregorianUnitLengths[this._band._zoomSteps[newZoomIndex].unit];
  1800. this._pixelsPerInterval=this._band._zoomSteps[newZoomIndex].pixelsPerInterval;
  1801. netIntervalChange=this._band._zoomSteps[newZoomIndex].unit-this._band._zoomSteps[currentZoomIndex].unit;
  1802. return netIntervalChange;
  1803. };
  1804. Timeline.HotZoneEther.prototype._dateDiffToPixelOffset=function(fromDate,toDate){var scale=this._getScale();
  1805. var fromTime=fromDate;
  1806. var toTime=toDate;
  1807. var pixels=0;
  1808. if(this._unit.compare(fromTime,toTime)<0){var z=0;
  1809. while(z<this._zones.length){if(this._unit.compare(fromTime,this._zones[z].endTime)<0){break;
  1810. }z++;
  1811. }while(this._unit.compare(fromTime,toTime)<0){var zone=this._zones[z];
  1812. var toTime2=this._unit.earlier(toTime,zone.endTime);
  1813. pixels+=(this._unit.compare(toTime2,fromTime)/(scale/zone.magnify));
  1814. fromTime=toTime2;
  1815. z++;
  1816. }}else{var z=this._zones.length-1;
  1817. while(z>=0){if(this._unit.compare(fromTime,this._zones[z].startTime)>0){break;
  1818. }z--;
  1819. }while(this._unit.compare(fromTime,toTime)>0){var zone=this._zones[z];
  1820. var toTime2=this._unit.later(toTime,zone.startTime);
  1821. pixels+=(this._unit.compare(toTime2,fromTime)/(scale/zone.magnify));
  1822. fromTime=toTime2;
  1823. z--;
  1824. }}return pixels;
  1825. };
  1826. Timeline.HotZoneEther.prototype._pixelOffsetToDate=function(pixels,fromDate){var scale=this._getScale();
  1827. var time=fromDate;
  1828. if(pixels>0){var z=0;
  1829. while(z<this._zones.length){if(this._unit.compare(time,this._zones[z].endTime)<0){break;
  1830. }z++;
  1831. }while(pixels>0){var zone=this._zones[z];
  1832. var scale2=scale/zone.magnify;
  1833. if(zone.endTime==Number.POSITIVE_INFINITY){time=this._unit.change(time,pixels*scale2);
  1834. pixels=0;
  1835. }else{var pixels2=this._unit.compare(zone.endTime,time)/scale2;
  1836. if(pixels2>pixels){time=this._unit.change(time,pixels*scale2);
  1837. pixels=0;
  1838. }else{time=zone.endTime;
  1839. pixels-=pixels2;
  1840. }}z++;
  1841. }}else{var z=this._zones.length-1;
  1842. while(z>=0){if(this._unit.compare(time,this._zones[z].startTime)>0){break;
  1843. }z--;
  1844. }pixels=-pixels;
  1845. while(pixels>0){var zone=this._zones[z];
  1846. var scale2=scale/zone.magnify;
  1847. if(zone.startTime==Number.NEGATIVE_INFINITY){time=this._unit.change(time,-pixels*scale2);
  1848. pixels=0;
  1849. }else{var pixels2=this._unit.compare(time,zone.startTime)/scale2;
  1850. if(pixels2>pixels){time=this._unit.change(time,-pixels*scale2);
  1851. pixels=0;
  1852. }else{time=zone.startTime;
  1853. pixels-=pixels2;
  1854. }}z--;
  1855. }}return time;
  1856. };
  1857. Timeline.HotZoneEther.prototype._getScale=function(){return this._interval/this._pixelsPerInterval;
  1858. };
  1859. /* event-utils.js */
  1860. Timeline.EventUtils={};
  1861. Timeline.EventUtils.getNewEventID=function(){if(this._lastEventID==null){this._lastEventID=0;
  1862. }this._lastEventID+=1;
  1863. return"e"+this._lastEventID;
  1864. };
  1865. Timeline.EventUtils.decodeEventElID=function(elementID){var parts=elementID.split("-");
  1866. if(parts[1]!="tl"){alert("Internal Timeline problem 101, please consult support");
  1867. return{band:null,evt:null};
  1868. }var timeline=Timeline.getTimelineFromID(parts[2]);
  1869. var band=timeline.getBand(parts[3]);
  1870. var evt=band.getEventSource.getEvent(parts[4]);
  1871. return{band:band,evt:evt};
  1872. };
  1873. Timeline.EventUtils.encodeEventElID=function(timeline,band,elType,evt){return elType+"-tl-"+timeline.timelineID+"-"+band.getIndex()+"-"+evt.getID();
  1874. };
  1875. /* labellers.js */
  1876. Timeline.GregorianDateLabeller=function(locale,timeZone){this._locale=locale;
  1877. this._timeZone=timeZone;
  1878. };
  1879. Timeline.GregorianDateLabeller.monthNames=[];
  1880. Timeline.GregorianDateLabeller.dayNames=[];
  1881. Timeline.GregorianDateLabeller.labelIntervalFunctions=[];
  1882. Timeline.GregorianDateLabeller.getMonthName=function(month,locale){return Timeline.GregorianDateLabeller.monthNames[locale][month];
  1883. };
  1884. Timeline.GregorianDateLabeller.prototype.labelInterval=function(date,intervalUnit){var f=Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale];
  1885. if(f==null){f=Timeline.GregorianDateLabeller.prototype.defaultLabelInterval;
  1886. }return f.call(this,date,intervalUnit);
  1887. };
  1888. Timeline.GregorianDateLabeller.prototype.labelPrecise=function(date){return SimileAjax.DateTime.removeTimeZoneOffset(date,this._timeZone).toUTCString();
  1889. };
  1890. Timeline.GregorianDateLabeller.prototype.defaultLabelInterval=function(date,intervalUnit){var text;
  1891. var emphasized=false;
  1892. date=SimileAjax.DateTime.removeTimeZoneOffset(date,this._timeZone);
  1893. switch(intervalUnit){case SimileAjax.DateTime.MILLISECOND:text=date.getUTCMilliseconds();
  1894. break;
  1895. case SimileAjax.DateTime.SECOND:text=date.getUTCSeconds();
  1896. break;
  1897. case SimileAjax.DateTime.MINUTE:var m=date.getUTCMinutes();
  1898. if(m==0){text=date.getUTCHours()+":00";
  1899. emphasized=true;
  1900. }else{text=m;
  1901. }break;
  1902. case SimileAjax.DateTime.HOUR:text=date.getUTCHours()+"hr";
  1903. break;
  1904. case SimileAjax.DateTime.DAY:text=Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(),this._locale)+" "+date.getUTCDate();
  1905. break;
  1906. case SimileAjax.DateTime.WEEK:text=Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(),this._locale)+" "+date.getUTCDate();
  1907. break;
  1908. case SimileAjax.DateTime.MONTH:var m=date.getUTCMonth();
  1909. if(m!=0){text=Timeline.GregorianDateLabeller.getMonthName(m,this._locale);
  1910. break;
  1911. }case SimileAjax.DateTime.YEAR:case SimileAjax.DateTime.DECADE:case SimileAjax.DateTime.CENTURY:case SimileAjax.DateTime.MILLENNIUM:var y=date.getUTCFullYear();
  1912. if(y>0){text=date.getUTCFullYear();
  1913. }else{text=(1-y)+"BC";
  1914. }emphasized=(intervalUnit==SimileAjax.DateTime.MONTH)||(intervalUnit==SimileAjax.DateTime.DECADE&&y%100==0)||(intervalUnit==SimileAjax.DateTime.CENTURY&&y%1000==0);
  1915. break;
  1916. default:text=date.toUTCString();
  1917. }return{text:text,emphasized:emphasized};
  1918. };
  1919. /* original-painter.js */
  1920. Timeline.OriginalEventPainter=function(params){this._params=params;
  1921. this._onSelectListeners=[];
  1922. this._eventPaintListeners=[];
  1923. this._filterMatcher=null;
  1924. this._highlightMatcher=null;
  1925. this._frc=null;
  1926. this._eventIdToElmt={};
  1927. };
  1928. Timeline.OriginalEventPainter.prototype.initialize=function(band,timeline){this._band=band;
  1929. this._timeline=timeline;
  1930. this._backLayer=null;
  1931. this._eventLayer=null;
  1932. this._lineLayer=null;
  1933. this._highlightLayer=null;
  1934. this._eventIdToElmt=null;
  1935. };
  1936. Timeline.OriginalEventPainter.prototype.getType=function(){return"original";
  1937. };
  1938. Timeline.OriginalEventPainter.prototype.supportsOrthogonalScrolling=function(){return true;
  1939. };
  1940. Timeline.OriginalEventPainter.prototype.addOnSelectListener=function(listener){this._onSelectListeners.push(listener);
  1941. };
  1942. Timeline.OriginalEventPainter.prototype.removeOnSelectListener=function(listener){for(var i=0;
  1943. i<this._onSelectListeners.length;
  1944. i++){if(this._onSelectListeners[i]==listener){this._onSelectListeners.splice(i,1);
  1945. break;
  1946. }}};
  1947. Timeline.OriginalEventPainter.prototype.addEventPaintListener=function(listener){this._eventPaintListeners.push(listener);
  1948. };
  1949. Timeline.OriginalEventPainter.prototype.removeEventPaintListener=function(listener){for(var i=0;
  1950. i<this._eventPaintListeners.length;
  1951. i++){if(this._eventPaintListeners[i]==listener){this._eventPaintListeners.splice(i,1);
  1952. break;
  1953. }}};
  1954. Timeline.OriginalEventPainter.prototype.getFilterMatcher=function(){return this._filterMatcher;
  1955. };
  1956. Timeline.OriginalEventPainter.prototype.setFilterMatcher=function(filterMatcher){this._filterMatcher=filterMatcher;
  1957. };
  1958. Timeline.OriginalEventPainter.prototype.getHighlightMatcher=function(){return this._highlightMatcher;
  1959. };
  1960. Timeline.OriginalEventPainter.prototype.setHighlightMatcher=function(highlightMatcher){this._highlightMatcher=highlightMatcher;
  1961. };
  1962. Timeline.OriginalEventPainter.prototype.paint=function(){var eventSource=this._band.getEventSource();
  1963. if(eventSource==null){return ;
  1964. }this._eventIdToElmt={};
  1965. this._fireEventPaintListeners("paintStarting",null,null);
  1966. this._prepareForPainting();
  1967. var metrics=this._computeMetrics();
  1968. var minDate=this._band.getMinDate();
  1969. var maxDate=this._band.getMaxDate();
  1970. var filterMatcher=(this._filterMatcher!=null)?this._filterMatcher:function(evt){return true;
  1971. };
  1972. var highlightMatcher=(this._highlightMatcher!=null)?this._highlightMatcher:function(evt){return -1;
  1973. };
  1974. var iterator=eventSource.getEventReverseIterator(minDate,maxDate);
  1975. while(iterator.hasNext()){var evt=iterator.next();
  1976. if(filterMatcher(evt)){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
  1977. }}this._highlightLayer.style.display="block";
  1978. this._lineLayer.style.display="block";
  1979. this._eventLayer.style.display="block";
  1980. this._band.updateEventTrackInfo(this._tracks.length,metrics.trackIncrement);
  1981. this._fireEventPaintListeners("paintEnded",null,null);
  1982. this._setOrthogonalOffset(metrics);
  1983. };
  1984. Timeline.OriginalEventPainter.prototype.softPaint=function(){this._setOrthogonalOffset(this._computeMetrics());
  1985. };
  1986. Timeline.OriginalEventPainter.prototype.getOrthogonalExtent=function(){var metrics=this._computeMetrics();
  1987. return 2*metrics.trackOffset+this._tracks.length*metrics.trackIncrement;
  1988. };
  1989. Timeline.OriginalEventPainter.prototype._setOrthogonalOffset=function(metrics){var orthogonalOffset=this._band.getViewOrthogonalOffset();
  1990. this._highlightLayer.style.top=this._lineLayer.style.top=this._eventLayer.style.top=orthogonalOffset+"px";
  1991. };
  1992. Timeline.OriginalEventPainter.prototype._computeMetrics=function(){var eventTheme=this._params.theme.event;
  1993. var trackHeight=Math.max(eventTheme.track.height,eventTheme.tape.height+this._frc.getLineHeight());
  1994. var metrics={trackOffset:eventTheme.track.offset,trackHeight:trackHeight,trackGap:eventTheme.track.gap,trackIncrement:trackHeight+eventTheme.track.gap,icon:eventTheme.instant.icon,iconWidth:eventTheme.instant.iconWidth,iconHeight:eventTheme.instant.iconHeight,labelWidth:eventTheme.label.width,maxLabelChar:eventTheme.label.maxLabelChar,impreciseIconMargin:eventTheme.instant.impreciseIconMargin};
  1995. return metrics;
  1996. };
  1997. Timeline.OriginalEventPainter.prototype._prepareForPainting=function(){var band=this._band;
  1998. if(this._backLayer==null){this._backLayer=this._band.createLayerDiv(0,"timeline-band-events");
  1999. this._backLayer.style.visibility="hidden";
  2000. var eventLabelPrototype=document.createElement("span");
  2001. eventLabelPrototype.className="timeline-event-label";
  2002. this._backLayer.appendChild(eventLabelPrototype);
  2003. this._frc=SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
  2004. }this._frc.update();
  2005. this._tracks=[];
  2006. if(this._highlightLayer!=null){band.removeLayerDiv(this._highlightLayer);
  2007. }this._highlightLayer=band.createLayerDiv(105,"timeline-band-highlights");
  2008. this._highlightLayer.style.display="none";
  2009. if(this._lineLayer!=null){band.removeLayerDiv(this._lineLayer);
  2010. }this._lineLayer=band.createLayerDiv(110,"timeline-band-lines");
  2011. this._lineLayer.style.display="none";
  2012. if(this._eventLayer!=null){band.removeLayerDiv(this._eventLayer);
  2013. }this._eventLayer=band.createLayerDiv(115,"timeline-band-events");
  2014. this._eventLayer.style.display="none";
  2015. };
  2016. Timeline.OriginalEventPainter.prototype.paintEvent=function(evt,metrics,theme,highlightIndex){if(evt.isInstant()){this.paintInstantEvent(evt,metrics,theme,highlightIndex);
  2017. }else{this.paintDurationEvent(evt,metrics,theme,highlightIndex);
  2018. }};
  2019. Timeline.OriginalEventPainter.prototype.paintInstantEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseInstantEvent(evt,metrics,theme,highlightIndex);
  2020. }else{this.paintPreciseInstantEvent(evt,metrics,theme,highlightIndex);
  2021. }};
  2022. Timeline.OriginalEventPainter.prototype.paintDurationEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseDurationEvent(evt,metrics,theme,highlightIndex);
  2023. }else{this.paintPreciseDurationEvent(evt,metrics,theme,highlightIndex);
  2024. }};
  2025. Timeline.OriginalEventPainter.prototype.paintPreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  2026. var text=evt.getText();
  2027. var startDate=evt.getStart();
  2028. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  2029. var iconRightEdge=Math.round(startPixel+metrics.iconWidth/2);
  2030. var iconLeftEdge=Math.round(startPixel-metrics.iconWidth/2);
  2031. var labelDivClassName=this._getLabelDivClassName(evt);
  2032. var labelSize=this._frc.computeSize(text,labelDivClassName);
  2033. var labelLeft=iconRightEdge+theme.event.label.offsetFromLine;
  2034. var labelRight=labelLeft+labelSize.width;
  2035. var rightEdge=labelRight;
  2036. var track=this._findFreeTrack(evt,rightEdge);
  2037. var labelTop=Math.round(metrics.trackOffset+track*metrics.trackIncrement+metrics.trackHeight/2-labelSize.height/2);
  2038. var iconElmtData=this._paintEventIcon(evt,track,iconLeftEdge,metrics,theme,0);
  2039. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme,labelDivClassName,highlightIndex);
  2040. var els=[iconElmtData.elmt,labelElmtData.elmt];
  2041. var self=this;
  2042. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(iconElmtData.elmt,domEvt,evt);
  2043. };
  2044. SimileAjax.DOM.registerEvent(iconElmtData.elmt,"mousedown",clickHandler);
  2045. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  2046. var hDiv=this._createHighlightDiv(highlightIndex,iconElmtData,theme,evt);
  2047. if(hDiv!=null){els.push(hDiv);
  2048. }this._fireEventPaintListeners("paintedEvent",evt,els);
  2049. this._eventIdToElmt[evt.getID()]=iconElmtData.elmt;
  2050. this._tracks[track]=iconLeftEdge;
  2051. };
  2052. Timeline.OriginalEventPainter.prototype.paintImpreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  2053. var text=evt.getText();
  2054. var startDate=evt.getStart();
  2055. var endDate=evt.getEnd();
  2056. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  2057. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  2058. var iconRightEdge=Math.round(startPixel+metrics.iconWidth/2);
  2059. var iconLeftEdge=Math.round(startPixel-metrics.iconWidth/2);
  2060. var labelDivClassName=this._getLabelDivClassName(evt);
  2061. var labelSize=this._frc.computeSize(text,labelDivClassName);
  2062. var labelLeft=iconRightEdge+theme.event.label.offsetFromLine;
  2063. var labelRight=labelLeft+labelSize.width;
  2064. var rightEdge=Math.max(labelRight,endPixel);
  2065. var track=this._findFreeTrack(evt,rightEdge);
  2066. var tapeHeight=theme.event.tape.height;
  2067. var labelTop=Math.round(metrics.trackOffset+track*metrics.trackIncrement+tapeHeight);
  2068. var iconElmtData=this._paintEventIcon(evt,track,iconLeftEdge,metrics,theme,tapeHeight);
  2069. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme,labelDivClassName,highlightIndex);
  2070. var color=evt.getColor();
  2071. color=color!=null?color:theme.event.instant.impreciseColor;
  2072. var tapeElmtData=this._paintEventTape(evt,track,startPixel,endPixel,color,theme.event.instant.impreciseOpacity,metrics,theme,0);
  2073. var els=[iconElmtData.elmt,labelElmtData.elmt,tapeElmtData.elmt];
  2074. var self=this;
  2075. var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(iconElmtData.elmt,domEvt,evt);
  2076. };
  2077. SimileAjax.DOM.registerEvent(iconElmtData.elmt,"mousedown",clickHandler);
  2078. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  2079. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  2080. var hDiv=this._createHighlightDiv(highlightIndex,iconElmtData,theme,evt);
  2081. if(hDiv!=null){els.push(hDiv);
  2082. }this._fireEventPaintListeners("paintedEvent",evt,els);
  2083. this._eventIdToElmt[evt.getID()]=iconElmtData.elmt;
  2084. this._tracks[track]=iconLeftEdge;
  2085. };
  2086. Timeline.OriginalEventPainter.prototype.paintPreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  2087. var text=evt.getText();
  2088. var startDate=evt.getStart();
  2089. var endDate=evt.getEnd();
  2090. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  2091. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  2092. var labelDivClassName=this._getLabelDivClassName(evt);
  2093. var labelSize=this._frc.computeSize(text,labelDivClassName);
  2094. var labelLeft=startPixel;
  2095. var labelRight=labelLeft+labelSize.width;
  2096. var rightEdge=Math.max(labelRight,endPixel);
  2097. var track=this._findFreeTrack(evt,rightEdge);
  2098. var labelTop=Math.round(metrics.trackOffset+track*metrics.trackIncrement+theme.event.tape.height);
  2099. var color=evt.getColor();
  2100. color=color!=null?color:theme.event.duration.color;
  2101. var tapeElmtData=this._paintEventTape(evt,track,startPixel,endPixel,color,100,metrics,theme,0);
  2102. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme,labelDivClassName,highlightIndex);
  2103. var els=[tapeElmtData.elmt,labelElmtData.elmt];
  2104. var self=this;
  2105. var clickHandler=function(elmt,domEvt,target){return self._onClickDurationEvent(tapeElmtData.elmt,domEvt,evt);
  2106. };
  2107. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  2108. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  2109. var hDiv=this._createHighlightDiv(highlightIndex,tapeElmtData,theme,evt);
  2110. if(hDiv!=null){els.push(hDiv);
  2111. }this._fireEventPaintListeners("paintedEvent",evt,els);
  2112. this._eventIdToElmt[evt.getID()]=tapeElmtData.elmt;
  2113. this._tracks[track]=startPixel;
  2114. };
  2115. Timeline.OriginalEventPainter.prototype.paintImpreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var doc=this._timeline.getDocument();
  2116. var text=evt.getText();
  2117. var startDate=evt.getStart();
  2118. var latestStartDate=evt.getLatestStart();
  2119. var endDate=evt.getEnd();
  2120. var earliestEndDate=evt.getEarliestEnd();
  2121. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  2122. var latestStartPixel=Math.round(this._band.dateToPixelOffset(latestStartDate));
  2123. var endPixel=Math.round(this._band.dateToPixelOffset(endDate));
  2124. var earliestEndPixel=Math.round(this._band.dateToPixelOffset(earliestEndDate));
  2125. var labelDivClassName=this._getLabelDivClassName(evt);
  2126. var labelSize=this._frc.computeSize(text,labelDivClassName);
  2127. var labelLeft=latestStartPixel;
  2128. var labelRight=labelLeft+labelSize.width;
  2129. var rightEdge=Math.max(labelRight,endPixel);
  2130. var track=this._findFreeTrack(evt,rightEdge);
  2131. var labelTop=Math.round(metrics.trackOffset+track*metrics.trackIncrement+theme.event.tape.height);
  2132. var color=evt.getColor();
  2133. color=color!=null?color:theme.event.duration.color;
  2134. var impreciseTapeElmtData=this._paintEventTape(evt,track,startPixel,endPixel,theme.event.duration.impreciseColor,theme.event.duration.impreciseOpacity,metrics,theme,0);
  2135. var tapeElmtData=this._paintEventTape(evt,track,latestStartPixel,earliestEndPixel,color,100,metrics,theme,1);
  2136. var labelElmtData=this._paintEventLabel(evt,text,labelLeft,labelTop,labelSize.width,labelSize.height,theme,labelDivClassName,highlightIndex);
  2137. var els=[impreciseTapeElmtData.elmt,tapeElmtData.elmt,labelElmtData.elmt];
  2138. var self=this;
  2139. var clickHandler=function(elmt,domEvt,target){return self._onClickDurationEvent(tapeElmtData.elmt,domEvt,evt);
  2140. };
  2141. SimileAjax.DOM.registerEvent(tapeElmtData.elmt,"mousedown",clickHandler);
  2142. SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
  2143. var hDiv=this._createHighlightDiv(highlightIndex,tapeElmtData,theme,evt);
  2144. if(hDiv!=null){els.push(hDiv);
  2145. }this._fireEventPaintListeners("paintedEvent",evt,els);
  2146. this._eventIdToElmt[evt.getID()]=tapeElmtData.elmt;
  2147. this._tracks[track]=startPixel;
  2148. };
  2149. Timeline.OriginalEventPainter.prototype._encodeEventElID=function(elType,evt){return Timeline.EventUtils.encodeEventElID(this._timeline,this._band,elType,evt);
  2150. };
  2151. Timeline.OriginalEventPainter.prototype._findFreeTrack=function(event,rightEdge){var trackAttribute=event.getTrackNum();
  2152. if(trackAttribute!=null){return trackAttribute;
  2153. }for(var i=0;
  2154. i<this._tracks.length;
  2155. i++){var t=this._tracks[i];
  2156. if(t>rightEdge){break;
  2157. }}return i;
  2158. };
  2159. Timeline.OriginalEventPainter.prototype._paintEventIcon=function(evt,iconTrack,left,metrics,theme,tapeHeight){var icon=evt.getIcon();
  2160. icon=icon!=null?icon:metrics.icon;
  2161. var top;
  2162. if(tapeHeight>0){top=metrics.trackOffset+iconTrack*metrics.trackIncrement+tapeHeight+metrics.impreciseIconMargin;
  2163. }else{var middle=metrics.trackOffset+iconTrack*metrics.trackIncrement+metrics.trackHeight/2;
  2164. top=Math.round(middle-metrics.iconHeight/2);
  2165. }var img=SimileAjax.Graphics.createTranslucentImage(icon);
  2166. var iconDiv=this._timeline.getDocument().createElement("div");
  2167. iconDiv.className=this._getElClassName("timeline-event-icon",evt,"icon");
  2168. iconDiv.id=this._encodeEventElID("icon",evt);
  2169. iconDiv.style.left=left+"px";
  2170. iconDiv.style.top=top+"px";
  2171. iconDiv.appendChild(img);
  2172. if(evt._title!=null){iconDiv.title=evt._title;
  2173. }this._eventLayer.appendChild(iconDiv);
  2174. return{left:left,top:top,width:metrics.iconWidth,height:metrics.iconHeight,elmt:iconDiv};
  2175. };
  2176. Timeline.OriginalEventPainter.prototype._paintEventLabel=function(evt,text,left,top,width,height,theme,labelDivClassName,highlightIndex){var doc=this._timeline.getDocument();
  2177. var labelDiv=doc.createElement("div");
  2178. labelDiv.className=labelDivClassName;
  2179. labelDiv.id=this._encodeEventElID("label",evt);
  2180. labelDiv.style.left=left+"px";
  2181. labelDiv.style.width=width+"px";
  2182. labelDiv.style.top=top+"px";
  2183. labelDiv.innerHTML=text;
  2184. if(evt._title!=null){labelDiv.title=evt._title;
  2185. }var color=evt.getTextColor();
  2186. if(color==null){color=evt.getColor();
  2187. }if(color!=null){labelDiv.style.color=color;
  2188. }if(theme.event.highlightLabelBackground&&highlightIndex>=0){labelDiv.style.background=this._getHighlightColor(highlightIndex,theme);
  2189. }this._eventLayer.appendChild(labelDiv);
  2190. return{left:left,top:top,width:width,height:height,elmt:labelDiv};
  2191. };
  2192. Timeline.OriginalEventPainter.prototype._paintEventTape=function(evt,iconTrack,startPixel,endPixel,color,opacity,metrics,theme,tape_index){var tapeWidth=endPixel-startPixel;
  2193. var tapeHeight=theme.event.tape.height;
  2194. var top=metrics.trackOffset+iconTrack*metrics.trackIncrement;
  2195. var tapeDiv=this._timeline.getDocument().createElement("div");
  2196. tapeDiv.className=this._getElClassName("timeline-event-tape",evt,"tape");
  2197. tapeDiv.id=this._encodeEventElID("tape"+tape_index,evt);
  2198. tapeDiv.style.left=startPixel+"px";
  2199. tapeDiv.style.width=tapeWidth+"px";
  2200. tapeDiv.style.height=tapeHeight+"px";
  2201. tapeDiv.style.top=top+"px";
  2202. if(evt._title!=null){tapeDiv.title=evt._title;
  2203. }if(color!=null){tapeDiv.style.backgroundColor=color;
  2204. }var backgroundImage=evt.getTapeImage();
  2205. var backgroundRepeat=evt.getTapeRepeat();
  2206. backgroundRepeat=backgroundRepeat!=null?backgroundRepeat:"repeat";
  2207. if(backgroundImage!=null){tapeDiv.style.backgroundImage="url("+backgroundImage+")";
  2208. tapeDiv.style.backgroundRepeat=backgroundRepeat;
  2209. }SimileAjax.Graphics.setOpacity(tapeDiv,opacity);
  2210. this._eventLayer.appendChild(tapeDiv);
  2211. return{left:startPixel,top:top,width:tapeWidth,height:tapeHeight,elmt:tapeDiv};
  2212. };
  2213. Timeline.OriginalEventPainter.prototype._getLabelDivClassName=function(evt){return this._getElClassName("timeline-event-label",evt,"label");
  2214. };
  2215. Timeline.OriginalEventPainter.prototype._getElClassName=function(elClassName,evt,prefix){var evt_classname=evt.getClassName(),pieces=[];
  2216. if(evt_classname){if(prefix){pieces.push(prefix+"-"+evt_classname+" ");
  2217. }pieces.push(evt_classname+" ");
  2218. }pieces.push(elClassName);
  2219. return(pieces.join(""));
  2220. };
  2221. Timeline.OriginalEventPainter.prototype._getHighlightColor=function(highlightIndex,theme){var highlightColors=theme.event.highlightColors;
  2222. return highlightColors[Math.min(highlightIndex,highlightColors.length-1)];
  2223. };
  2224. Timeline.OriginalEventPainter.prototype._createHighlightDiv=function(highlightIndex,dimensions,theme,evt){var div=null;
  2225. if(highlightIndex>=0){var doc=this._timeline.getDocument();
  2226. var color=this._getHighlightColor(highlightIndex,theme);
  2227. div=doc.createElement("div");
  2228. div.className=this._getElClassName("timeline-event-highlight",evt,"highlight");
  2229. div.id=this._encodeEventElID("highlight0",evt);
  2230. div.style.position="absolute";
  2231. div.style.overflow="hidden";
  2232. div.style.left=(dimensions.left-2)+"px";
  2233. div.style.width=(dimensions.width+4)+"px";
  2234. div.style.top=(dimensions.top-2)+"px";
  2235. div.style.height=(dimensions.height+4)+"px";
  2236. div.style.background=color;
  2237. this._highlightLayer.appendChild(div);
  2238. }return div;
  2239. };
  2240. Timeline.OriginalEventPainter.prototype._onClickInstantEvent=function(icon,domEvt,evt){var c=SimileAjax.DOM.getPageCoordinates(icon);
  2241. this._showBubble(c.left+Math.ceil(icon.offsetWidth/2),c.top+Math.ceil(icon.offsetHeight/2),evt);
  2242. this._fireOnSelect(evt.getID());
  2243. domEvt.cancelBubble=true;
  2244. SimileAjax.DOM.cancelEvent(domEvt);
  2245. return false;
  2246. };
  2247. Timeline.OriginalEventPainter.prototype._onClickDurationEvent=function(target,domEvt,evt){if("pageX" in domEvt){var x=domEvt.pageX;
  2248. var y=domEvt.pageY;
  2249. }else{var c=SimileAjax.DOM.getPageCoordinates(target);
  2250. var x=domEvt.offsetX+c.left;
  2251. var y=domEvt.offsetY+c.top;
  2252. }this._showBubble(x,y,evt);
  2253. this._fireOnSelect(evt.getID());
  2254. domEvt.cancelBubble=true;
  2255. SimileAjax.DOM.cancelEvent(domEvt);
  2256. return false;
  2257. };
  2258. Timeline.OriginalEventPainter.prototype.showBubble=function(evt){var elmt=this._eventIdToElmt[evt.getID()];
  2259. if(elmt){var c=SimileAjax.DOM.getPageCoordinates(elmt);
  2260. this._showBubble(c.left+elmt.offsetWidth/2,c.top+elmt.offsetHeight/2,evt);
  2261. }};
  2262. Timeline.OriginalEventPainter.prototype._showBubble=function(x,y,evt){var div=document.createElement("div");
  2263. var themeBubble=this._params.theme.event.bubble;
  2264. evt.fillInfoBubble(div,this._params.theme,this._band.getLabeller());
  2265. SimileAjax.WindowManager.cancelPopups();
  2266. SimileAjax.Graphics.createBubbleForContentAndPoint(div,x,y,themeBubble.width,null,themeBubble.maxHeight);
  2267. };
  2268. Timeline.OriginalEventPainter.prototype._fireOnSelect=function(eventID){for(var i=0;
  2269. i<this._onSelectListeners.length;
  2270. i++){this._onSelectListeners[i](eventID);
  2271. }};
  2272. Timeline.OriginalEventPainter.prototype._fireEventPaintListeners=function(op,evt,els){for(var i=0;
  2273. i<this._eventPaintListeners.length;
  2274. i++){this._eventPaintListeners[i](this._band,op,evt,els);
  2275. }};
  2276. /* overview-painter.js */
  2277. Timeline.OverviewEventPainter=function(params){this._params=params;
  2278. this._onSelectListeners=[];
  2279. this._filterMatcher=null;
  2280. this._highlightMatcher=null;
  2281. };
  2282. Timeline.OverviewEventPainter.prototype.initialize=function(band,timeline){this._band=band;
  2283. this._timeline=timeline;
  2284. this._eventLayer=null;
  2285. this._highlightLayer=null;
  2286. };
  2287. Timeline.OverviewEventPainter.prototype.getType=function(){return"overview";
  2288. };
  2289. Timeline.OverviewEventPainter.prototype.addOnSelectListener=function(listener){this._onSelectListeners.push(listener);
  2290. };
  2291. Timeline.OverviewEventPainter.prototype.removeOnSelectListener=function(listener){for(var i=0;
  2292. i<this._onSelectListeners.length;
  2293. i++){if(this._onSelectListeners[i]==listener){this._onSelectListeners.splice(i,1);
  2294. break;
  2295. }}};
  2296. Timeline.OverviewEventPainter.prototype.getFilterMatcher=function(){return this._filterMatcher;
  2297. };
  2298. Timeline.OverviewEventPainter.prototype.setFilterMatcher=function(filterMatcher){this._filterMatcher=filterMatcher;
  2299. };
  2300. Timeline.OverviewEventPainter.prototype.getHighlightMatcher=function(){return this._highlightMatcher;
  2301. };
  2302. Timeline.OverviewEventPainter.prototype.setHighlightMatcher=function(highlightMatcher){this._highlightMatcher=highlightMatcher;
  2303. };
  2304. Timeline.OverviewEventPainter.prototype.paint=function(){var eventSource=this._band.getEventSource();
  2305. if(eventSource==null){return ;
  2306. }this._prepareForPainting();
  2307. var eventTheme=this._params.theme.event;
  2308. var metrics={trackOffset:eventTheme.overviewTrack.offset,trackHeight:eventTheme.overviewTrack.height,trackGap:eventTheme.overviewTrack.gap,trackIncrement:eventTheme.overviewTrack.height+eventTheme.overviewTrack.gap};
  2309. var minDate=this._band.getMinDate();
  2310. var maxDate=this._band.getMaxDate();
  2311. var filterMatcher=(this._filterMatcher!=null)?this._filterMatcher:function(evt){return true;
  2312. };
  2313. var highlightMatcher=(this._highlightMatcher!=null)?this._highlightMatcher:function(evt){return -1;
  2314. };
  2315. var iterator=eventSource.getEventReverseIterator(minDate,maxDate);
  2316. while(iterator.hasNext()){var evt=iterator.next();
  2317. if(filterMatcher(evt)){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
  2318. }}this._highlightLayer.style.display="block";
  2319. this._eventLayer.style.display="block";
  2320. this._band.updateEventTrackInfo(this._tracks.length,metrics.trackIncrement);
  2321. };
  2322. Timeline.OverviewEventPainter.prototype.softPaint=function(){};
  2323. Timeline.OverviewEventPainter.prototype._prepareForPainting=function(){var band=this._band;
  2324. this._tracks=[];
  2325. if(this._highlightLayer!=null){band.removeLayerDiv(this._highlightLayer);
  2326. }this._highlightLayer=band.createLayerDiv(105,"timeline-band-highlights");
  2327. this._highlightLayer.style.display="none";
  2328. if(this._eventLayer!=null){band.removeLayerDiv(this._eventLayer);
  2329. }this._eventLayer=band.createLayerDiv(110,"timeline-band-events");
  2330. this._eventLayer.style.display="none";
  2331. };
  2332. Timeline.OverviewEventPainter.prototype.paintEvent=function(evt,metrics,theme,highlightIndex){if(evt.isInstant()){this.paintInstantEvent(evt,metrics,theme,highlightIndex);
  2333. }else{this.paintDurationEvent(evt,metrics,theme,highlightIndex);
  2334. }};
  2335. Timeline.OverviewEventPainter.prototype.paintInstantEvent=function(evt,metrics,theme,highlightIndex){var startDate=evt.getStart();
  2336. var startPixel=Math.round(this._band.dateToPixelOffset(startDate));
  2337. var color=evt.getColor(),klassName=evt.getClassName();
  2338. if(klassName){color=null;
  2339. }else{color=color!=null?color:theme.event.duration.color;
  2340. }var tickElmtData=this._paintEventTick(evt,startPixel,color,100,metrics,theme);
  2341. this._createHighlightDiv(highlightIndex,tickElmtData,theme);
  2342. };
  2343. Timeline.OverviewEventPainter.prototype.paintDurationEvent=function(evt,metrics,theme,highlightIndex){var latestStartDate=evt.getLatestStart();
  2344. var earliestEndDate=evt.getEarliestEnd();
  2345. var latestStartPixel=Math.round(this._band.dateToPixelOffset(latestStartDate));
  2346. var earliestEndPixel=Math.round(this._band.dateToPixelOffset(earliestEndDate));
  2347. var tapeTrack=0;
  2348. for(;
  2349. tapeTrack<this._tracks.length;
  2350. tapeTrack++){if(earliestEndPixel<this._tracks[tapeTrack]){break;
  2351. }}this._tracks[tapeTrack]=earliestEndPixel;
  2352. var color=evt.getColor(),klassName=evt.getClassName();
  2353. if(klassName){color=null;
  2354. }else{color=color!=null?color:theme.event.duration.color;
  2355. }var tapeElmtData=this._paintEventTape(evt,tapeTrack,latestStartPixel,earliestEndPixel,color,100,metrics,theme,klassName);
  2356. this._createHighlightDiv(highlightIndex,tapeElmtData,theme);
  2357. };
  2358. Timeline.OverviewEventPainter.prototype._paintEventTape=function(evt,track,left,right,color,opacity,metrics,theme,klassName){var top=metrics.trackOffset+track*metrics.trackIncrement;
  2359. var width=right-left;
  2360. var height=metrics.trackHeight;
  2361. var tapeDiv=this._timeline.getDocument().createElement("div");
  2362. tapeDiv.className="timeline-small-event-tape";
  2363. if(klassName){tapeDiv.className+=" small-"+klassName;
  2364. }tapeDiv.style.left=left+"px";
  2365. tapeDiv.style.width=width+"px";
  2366. tapeDiv.style.top=top+"px";
  2367. tapeDiv.style.height=height+"px";
  2368. if(color){tapeDiv.style.backgroundColor=color;
  2369. }if(opacity<100){SimileAjax.Graphics.setOpacity(tapeDiv,opacity);
  2370. }this._eventLayer.appendChild(tapeDiv);
  2371. return{left:left,top:top,width:width,height:height,elmt:tapeDiv};
  2372. };
  2373. Timeline.OverviewEventPainter.prototype._paintEventTick=function(evt,left,color,opacity,metrics,theme){var height=theme.event.overviewTrack.tickHeight;
  2374. var top=metrics.trackOffset-height;
  2375. var width=1;
  2376. var tickDiv=this._timeline.getDocument().createElement("div");
  2377. tickDiv.className="timeline-small-event-icon";
  2378. tickDiv.style.left=left+"px";
  2379. tickDiv.style.top=top+"px";
  2380. var klassName=evt.getClassName();
  2381. if(klassName){tickDiv.className+=" small-"+klassName;
  2382. }if(opacity<100){SimileAjax.Graphics.setOpacity(tickDiv,opacity);
  2383. }this._eventLayer.appendChild(tickDiv);
  2384. return{left:left,top:top,width:width,height:height,elmt:tickDiv};
  2385. };
  2386. Timeline.OverviewEventPainter.prototype._createHighlightDiv=function(highlightIndex,dimensions,theme){if(highlightIndex>=0){var doc=this._timeline.getDocument();
  2387. var eventTheme=theme.event;
  2388. var color=eventTheme.highlightColors[Math.min(highlightIndex,eventTheme.highlightColors.length-1)];
  2389. var div=doc.createElement("div");
  2390. div.style.position="absolute";
  2391. div.style.overflow="hidden";
  2392. div.style.left=(dimensions.left-1)+"px";
  2393. div.style.width=(dimensions.width+2)+"px";
  2394. div.style.top=(dimensions.top-1)+"px";
  2395. div.style.height=(dimensions.height+2)+"px";
  2396. div.style.background=color;
  2397. this._highlightLayer.appendChild(div);
  2398. }};
  2399. Timeline.OverviewEventPainter.prototype.showBubble=function(evt){};
  2400. /* sources.js */
  2401. Timeline.DefaultEventSource=function(eventIndex){this._events=(eventIndex instanceof Object)?eventIndex:new SimileAjax.EventIndex();
  2402. this._listeners=[];
  2403. };
  2404. Timeline.DefaultEventSource.prototype.addListener=function(listener){this._listeners.push(listener);
  2405. };
  2406. Timeline.DefaultEventSource.prototype.removeListener=function(listener){for(var i=0;
  2407. i<this._listeners.length;
  2408. i++){if(this._listeners[i]==listener){this._listeners.splice(i,1);
  2409. break;
  2410. }}};
  2411. Timeline.DefaultEventSource.prototype.loadXML=function(xml,url){var base=this._getBaseURL(url);
  2412. var wikiURL=xml.documentElement.getAttribute("wiki-url");
  2413. var wikiSection=xml.documentElement.getAttribute("wiki-section");
  2414. var dateTimeFormat=xml.documentElement.getAttribute("date-time-format");
  2415. var parseDateTimeFunction=this._events.getUnit().getParser(dateTimeFormat);
  2416. var node=xml.documentElement.firstChild;
  2417. var added=false;
  2418. while(node!=null){if(node.nodeType==1){var description="";
  2419. if(node.firstChild!=null&&node.firstChild.nodeType==3){description=node.firstChild.nodeValue;
  2420. }var instant=(node.getAttribute("isDuration")===null&&node.getAttribute("durationEvent")===null)||node.getAttribute("isDuration")=="false"||node.getAttribute("durationEvent")=="false";
  2421. var evt=new Timeline.DefaultEventSource.Event({id:node.getAttribute("id"),start:parseDateTimeFunction(node.getAttribute("start")),end:parseDateTimeFunction(node.getAttribute("end")),latestStart:parseDateTimeFunction(node.getAttribute("latestStart")),earliestEnd:parseDateTimeFunction(node.getAttribute("earliestEnd")),instant:instant,text:node.getAttribute("title"),description:description,image:this._resolveRelativeURL(node.getAttribute("image"),base),link:this._resolveRelativeURL(node.getAttribute("link"),base),icon:this._resolveRelativeURL(node.getAttribute("icon"),base),color:node.getAttribute("color"),textColor:node.getAttribute("textColor"),hoverText:node.getAttribute("hoverText"),classname:node.getAttribute("classname"),tapeImage:node.getAttribute("tapeImage"),tapeRepeat:node.getAttribute("tapeRepeat"),caption:node.getAttribute("caption"),eventID:node.getAttribute("eventID"),trackNum:node.getAttribute("trackNum")});
  2422. evt._node=node;
  2423. evt.getProperty=function(name){return this._node.getAttribute(name);
  2424. };
  2425. evt.setWikiInfo(wikiURL,wikiSection);
  2426. this._events.add(evt);
  2427. added=true;
  2428. }node=node.nextSibling;
  2429. }if(added){this._fire("onAddMany",[]);
  2430. }};
  2431. Timeline.DefaultEventSource.prototype.loadJSON=function(data,url){var base=this._getBaseURL(url);
  2432. var added=false;
  2433. if(data&&data.events){var wikiURL=("wikiURL" in data)?data.wikiURL:null;
  2434. var wikiSection=("wikiSection" in data)?data.wikiSection:null;
  2435. var dateTimeFormat=("dateTimeFormat" in data)?data.dateTimeFormat:null;
  2436. var parseDateTimeFunction=this._events.getUnit().getParser(dateTimeFormat);
  2437. for(var i=0;
  2438. i<data.events.length;
  2439. i++){var evnt=data.events[i];
  2440. var instant=evnt.isDuration||(("durationEvent" in evnt)&&!evnt.durationEvent)||(("de" in evnt)&&!evnt.de);
  2441. var evt=new Timeline.DefaultEventSource.Event({id:("id" in evnt)?evnt.id:undefined,start:parseDateTimeFunction(evnt.start||evnt.s),end:parseDateTimeFunction(evnt.end||evnt.e),latestStart:parseDateTimeFunction(evnt.latestStart||evnt.ls),earliestEnd:parseDateTimeFunction(evnt.earliestEnd||evnt.ee),instant:instant,text:evnt.title||evnt.t,description:evnt.description||evnt.d,image:this._resolveRelativeURL(evnt.image,base),link:this._resolveRelativeURL(evnt.link,base),icon:this._resolveRelativeURL(evnt.icon,base),color:evnt.color,textColor:evnt.textColor,hoverText:evnt.hoverText,classname:evnt.classname||evnt.c,tapeImage:evnt.tapeImage,tapeRepeat:evnt.tapeRepeat,caption:evnt.caption,eventID:evnt.eventID||evnt.eid,trackNum:evnt.trackNum});
  2442. evt._obj=evnt;
  2443. evt.getProperty=function(name){return this._obj[name];
  2444. };
  2445. evt.setWikiInfo(wikiURL,wikiSection);
  2446. this._events.add(evt);
  2447. added=true;
  2448. }}if(added){this._fire("onAddMany",[]);
  2449. }};
  2450. Timeline.DefaultEventSource.prototype.loadSPARQL=function(xml,url){var base=this._getBaseURL(url);
  2451. var dateTimeFormat="iso8601";
  2452. var parseDateTimeFunction=this._events.getUnit().getParser(dateTimeFormat);
  2453. if(xml==null){return ;
  2454. }var node=xml.documentElement.firstChild;
  2455. while(node!=null&&(node.nodeType!=1||node.nodeName!="results")){node=node.nextSibling;
  2456. }var wikiURL=null;
  2457. var wikiSection=null;
  2458. if(node!=null){wikiURL=node.getAttribute("wiki-url");
  2459. wikiSection=node.getAttribute("wiki-section");
  2460. node=node.firstChild;
  2461. }var added=false;
  2462. while(node!=null){if(node.nodeType==1){var bindings={};
  2463. var binding=node.firstChild;
  2464. while(binding!=null){if(binding.nodeType==1&&binding.firstChild!=null&&binding.firstChild.nodeType==1&&binding.firstChild.firstChild!=null&&binding.firstChild.firstChild.nodeType==3){bindings[binding.getAttribute("name")]=binding.firstChild.firstChild.nodeValue;
  2465. }binding=binding.nextSibling;
  2466. }if(bindings["start"]==null&&bindings["date"]!=null){bindings["start"]=bindings["date"];
  2467. }var instant=(bindings["isDuration"]===null&&bindings["durationEvent"]===null)||bindings["isDuration"]=="false"||bindings["durationEvent"]=="false";
  2468. var evt=new Timeline.DefaultEventSource.Event({id:bindings["id"