PageRenderTime 91ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 2ms

/timeline/timeline-bundle-debug.js

http://showslow.googlecode.com/
JavaScript | 2950 lines | 2911 code | 26 blank | 13 comment | 197 complexity | 7291e2b177ef0134c5916c11f1d23649 MD5 | raw file

Large files files are truncated, but you can click here to view the full 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),

Large files files are truncated, but you can click here to view the full file