PageRenderTime 884ms CodeModel.GetById 119ms app.highlight 593ms RepoModel.GetById 58ms app.codeStats 3ms

/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
  2
  3/* band.js */
  4Timeline._Band=function(timeline,bandInfo,index){if(timeline.autoWidth&&typeof bandInfo.width=="string"){bandInfo.width=bandInfo.width.indexOf("%")>-1?0:parseInt(bandInfo.width);
  5}this._timeline=timeline;
  6this._bandInfo=bandInfo;
  7this._index=index;
  8this._locale=("locale" in bandInfo)?bandInfo.locale:Timeline.getDefaultLocale();
  9this._timeZone=("timeZone" in bandInfo)?bandInfo.timeZone:0;
 10this._labeller=("labeller" in bandInfo)?bandInfo.labeller:(("createLabeller" in timeline.getUnit())?timeline.getUnit().createLabeller(this._locale,this._timeZone):new Timeline.GregorianDateLabeller(this._locale,this._timeZone));
 11this._theme=bandInfo.theme;
 12this._zoomIndex=("zoomIndex" in bandInfo)?bandInfo.zoomIndex:0;
 13this._zoomSteps=("zoomSteps" in bandInfo)?bandInfo.zoomSteps:null;
 14this._dragging=false;
 15this._changing=false;
 16this._originalScrollSpeed=5;
 17this._scrollSpeed=this._originalScrollSpeed;
 18this._onScrollListeners=[];
 19this._orthogonalDragging=false;
 20this._viewOrthogonalOffset=0;
 21this._onOrthogonalScrollListeners=[];
 22var b=this;
 23this._syncWithBand=null;
 24this._syncWithBandHandler=function(band){b._onHighlightBandScroll();
 25};
 26this._syncWithBandOrthogonalScrollHandler=function(band){b._onHighlightBandOrthogonalScroll();
 27};
 28this._selectorListener=function(band){b._onHighlightBandScroll();
 29};
 30var inputDiv=this._timeline.getDocument().createElement("div");
 31inputDiv.className="timeline-band-input";
 32this._timeline.addDiv(inputDiv);
 33this._keyboardInput=document.createElement("input");
 34this._keyboardInput.type="text";
 35inputDiv.appendChild(this._keyboardInput);
 36SimileAjax.DOM.registerEventWithObject(this._keyboardInput,"keydown",this,"_onKeyDown");
 37SimileAjax.DOM.registerEventWithObject(this._keyboardInput,"keyup",this,"_onKeyUp");
 38this._div=this._timeline.getDocument().createElement("div");
 39this._div.id="timeline-band-"+index;
 40this._div.className="timeline-band timeline-band-"+index;
 41this._timeline.addDiv(this._div);
 42SimileAjax.DOM.registerEventWithObject(this._div,"dblclick",this,"_onDblClick");
 43SimileAjax.DOM.registerEventWithObject(this._div,"mousedown",this,"_onMouseDown");
 44SimileAjax.DOM.registerEventWithObject(document.body,"mousemove",this,"_onMouseMove");
 45SimileAjax.DOM.registerEventWithObject(document.body,"mouseup",this,"_onMouseUp");
 46SimileAjax.DOM.registerEventWithObject(document.body,"mouseout",this,"_onMouseOut");
 47var mouseWheel=this._theme!=null?this._theme.mouseWheel:"scroll";
 48if(mouseWheel==="zoom"||mouseWheel==="scroll"||this._zoomSteps){if(SimileAjax.Platform.browser.isFirefox){SimileAjax.DOM.registerEventWithObject(this._div,"DOMMouseScroll",this,"_onMouseScroll");
 49}else{SimileAjax.DOM.registerEventWithObject(this._div,"mousewheel",this,"_onMouseScroll");
 50}}this._innerDiv=this._timeline.getDocument().createElement("div");
 51this._innerDiv.className="timeline-band-inner";
 52this._div.appendChild(this._innerDiv);
 53this._ether=bandInfo.ether;
 54bandInfo.ether.initialize(this,timeline);
 55this._etherPainter=bandInfo.etherPainter;
 56bandInfo.etherPainter.initialize(this,timeline);
 57this._eventSource=bandInfo.eventSource;
 58if(this._eventSource){this._eventListener={onAddMany:function(){b._onAddMany();
 59},onClear:function(){b._onClear();
 60}};
 61this._eventSource.addListener(this._eventListener);
 62}this._eventPainter=bandInfo.eventPainter;
 63this._eventTracksNeeded=0;
 64this._eventTrackIncrement=0;
 65bandInfo.eventPainter.initialize(this,timeline);
 66this._decorators=("decorators" in bandInfo)?bandInfo.decorators:[];
 67for(var i=0;
 68i<this._decorators.length;
 69i++){this._decorators[i].initialize(this,timeline);
 70}this._supportsOrthogonalScrolling=("supportsOrthogonalScrolling" in this._eventPainter)&&this._eventPainter.supportsOrthogonalScrolling();
 71if(this._supportsOrthogonalScrolling){this._scrollBar=this._timeline.getDocument().createElement("div");
 72this._scrollBar.id="timeline-band-scrollbar-"+index;
 73this._scrollBar.className="timeline-band-scrollbar";
 74this._timeline.addDiv(this._scrollBar);
 75this._scrollBar.innerHTML='<div class="timeline-band-scrollbar-thumb"> </div>';
 76var scrollbarThumb=this._scrollBar.firstChild;
 77if(SimileAjax.Platform.browser.isIE){scrollbarThumb.style.cursor="move";
 78}else{scrollbarThumb.style.cursor="-moz-grab";
 79}SimileAjax.DOM.registerEventWithObject(scrollbarThumb,"mousedown",this,"_onScrollBarMouseDown");
 80}};
 81Timeline._Band.SCROLL_MULTIPLES=5;
 82Timeline._Band.prototype.dispose=function(){this.closeBubble();
 83if(this._eventSource){this._eventSource.removeListener(this._eventListener);
 84this._eventListener=null;
 85this._eventSource=null;
 86}this._timeline=null;
 87this._bandInfo=null;
 88this._labeller=null;
 89this._ether=null;
 90this._etherPainter=null;
 91this._eventPainter=null;
 92this._decorators=null;
 93this._onScrollListeners=null;
 94this._syncWithBandHandler=null;
 95this._syncWithBandOrthogonalScrollHandler=null;
 96this._selectorListener=null;
 97this._div=null;
 98this._innerDiv=null;
 99this._keyboardInput=null;
100this._scrollBar=null;
101};
102Timeline._Band.prototype.addOnScrollListener=function(listener){this._onScrollListeners.push(listener);
103};
104Timeline._Band.prototype.removeOnScrollListener=function(listener){for(var i=0;
105i<this._onScrollListeners.length;
106i++){if(this._onScrollListeners[i]==listener){this._onScrollListeners.splice(i,1);
107break;
108}}};
109Timeline._Band.prototype.addOnOrthogonalScrollListener=function(listener){this._onOrthogonalScrollListeners.push(listener);
110};
111Timeline._Band.prototype.removeOnOrthogonalScrollListener=function(listener){for(var i=0;
112i<this._onOrthogonalScrollListeners.length;
113i++){if(this._onOrthogonalScrollListeners[i]==listener){this._onOrthogonalScrollListeners.splice(i,1);
114break;
115}}};
116Timeline._Band.prototype.setSyncWithBand=function(band,highlight){if(this._syncWithBand){this._syncWithBand.removeOnScrollListener(this._syncWithBandHandler);
117this._syncWithBand.removeOnOrthogonalScrollListener(this._syncWithBandOrthogonalScrollHandler);
118}this._syncWithBand=band;
119this._syncWithBand.addOnScrollListener(this._syncWithBandHandler);
120this._syncWithBand.addOnOrthogonalScrollListener(this._syncWithBandOrthogonalScrollHandler);
121this._highlight=highlight;
122this._positionHighlight();
123};
124Timeline._Band.prototype.getLocale=function(){return this._locale;
125};
126Timeline._Band.prototype.getTimeZone=function(){return this._timeZone;
127};
128Timeline._Band.prototype.getLabeller=function(){return this._labeller;
129};
130Timeline._Band.prototype.getIndex=function(){return this._index;
131};
132Timeline._Band.prototype.getEther=function(){return this._ether;
133};
134Timeline._Band.prototype.getEtherPainter=function(){return this._etherPainter;
135};
136Timeline._Band.prototype.getEventSource=function(){return this._eventSource;
137};
138Timeline._Band.prototype.getEventPainter=function(){return this._eventPainter;
139};
140Timeline._Band.prototype.getTimeline=function(){return this._timeline;
141};
142Timeline._Band.prototype.updateEventTrackInfo=function(tracks,increment){this._eventTrackIncrement=increment;
143if(tracks>this._eventTracksNeeded){this._eventTracksNeeded=tracks;
144}};
145Timeline._Band.prototype.checkAutoWidth=function(){if(!this._timeline.autoWidth){return ;
146}var overviewBand=this._eventPainter.getType()=="overview";
147var margin=overviewBand?this._theme.event.overviewTrack.autoWidthMargin:this._theme.event.track.autoWidthMargin;
148var desiredWidth=Math.ceil((this._eventTracksNeeded+margin)*this._eventTrackIncrement);
149desiredWidth+=overviewBand?this._theme.event.overviewTrack.offset:this._theme.event.track.offset;
150var bandInfo=this._bandInfo;
151if(desiredWidth!=bandInfo.width){bandInfo.width=desiredWidth;
152}};
153Timeline._Band.prototype.layout=function(){this.paint();
154};
155Timeline._Band.prototype.paint=function(){this._etherPainter.paint();
156this._paintDecorators();
157this._paintEvents();
158};
159Timeline._Band.prototype.softLayout=function(){this.softPaint();
160};
161Timeline._Band.prototype.softPaint=function(){this._etherPainter.softPaint();
162this._softPaintDecorators();
163this._softPaintEvents();
164};
165Timeline._Band.prototype.setBandShiftAndWidth=function(shift,width){var inputDiv=this._keyboardInput.parentNode;
166var middle=shift+Math.floor(width/2);
167if(this._timeline.isHorizontal()){this._div.style.top=shift+"px";
168this._div.style.height=width+"px";
169inputDiv.style.top=middle+"px";
170inputDiv.style.left="-1em";
171}else{this._div.style.left=shift+"px";
172this._div.style.width=width+"px";
173inputDiv.style.left=middle+"px";
174inputDiv.style.top="-1em";
175}};
176Timeline._Band.prototype.getViewWidth=function(){if(this._timeline.isHorizontal()){return this._div.offsetHeight;
177}else{return this._div.offsetWidth;
178}};
179Timeline._Band.prototype.setViewLength=function(length){this._viewLength=length;
180this._recenterDiv();
181this._onChanging();
182};
183Timeline._Band.prototype.getViewLength=function(){return this._viewLength;
184};
185Timeline._Band.prototype.getTotalViewLength=function(){return Timeline._Band.SCROLL_MULTIPLES*this._viewLength;
186};
187Timeline._Band.prototype.getViewOffset=function(){return this._viewOffset;
188};
189Timeline._Band.prototype.getMinDate=function(){return this._ether.pixelOffsetToDate(this._viewOffset);
190};
191Timeline._Band.prototype.getMaxDate=function(){return this._ether.pixelOffsetToDate(this._viewOffset+Timeline._Band.SCROLL_MULTIPLES*this._viewLength);
192};
193Timeline._Band.prototype.getMinVisibleDate=function(){return this._ether.pixelOffsetToDate(0);
194};
195Timeline._Band.prototype.getMinVisibleDateAfterDelta=function(delta){return this._ether.pixelOffsetToDate(delta);
196};
197Timeline._Band.prototype.getMaxVisibleDate=function(){return this._ether.pixelOffsetToDate(this._viewLength);
198};
199Timeline._Band.prototype.getMaxVisibleDateAfterDelta=function(delta){return this._ether.pixelOffsetToDate(this._viewLength+delta);
200};
201Timeline._Band.prototype.getCenterVisibleDate=function(){return this._ether.pixelOffsetToDate(this._viewLength/2);
202};
203Timeline._Band.prototype.setMinVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(-this._ether.dateToPixelOffset(date)));
204}};
205Timeline._Band.prototype.setMaxVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(this._viewLength-this._ether.dateToPixelOffset(date)));
206}};
207Timeline._Band.prototype.setCenterVisibleDate=function(date){if(!this._changing){this._moveEther(Math.round(this._viewLength/2-this._ether.dateToPixelOffset(date)));
208}};
209Timeline._Band.prototype.dateToPixelOffset=function(date){return this._ether.dateToPixelOffset(date)-this._viewOffset;
210};
211Timeline._Band.prototype.pixelOffsetToDate=function(pixels){return this._ether.pixelOffsetToDate(pixels+this._viewOffset);
212};
213Timeline._Band.prototype.getViewOrthogonalOffset=function(){return this._viewOrthogonalOffset;
214};
215Timeline._Band.prototype.setViewOrthogonalOffset=function(offset){this._viewOrthogonalOffset=Math.max(0,offset);
216};
217Timeline._Band.prototype.createLayerDiv=function(zIndex,className){var div=this._timeline.getDocument().createElement("div");
218div.className="timeline-band-layer"+(typeof className=="string"?(" "+className):"");
219div.style.zIndex=zIndex;
220this._innerDiv.appendChild(div);
221var innerDiv=this._timeline.getDocument().createElement("div");
222innerDiv.className="timeline-band-layer-inner";
223if(SimileAjax.Platform.browser.isIE){innerDiv.style.cursor="move";
224}else{innerDiv.style.cursor="-moz-grab";
225}div.appendChild(innerDiv);
226return innerDiv;
227};
228Timeline._Band.prototype.removeLayerDiv=function(div){this._innerDiv.removeChild(div.parentNode);
229};
230Timeline._Band.prototype.scrollToCenter=function(date,f){var pixelOffset=this._ether.dateToPixelOffset(date);
231if(pixelOffset<-this._viewLength/2){this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset+this._viewLength));
232}else{if(pixelOffset>3*this._viewLength/2){this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset-this._viewLength));
233}}this._autoScroll(Math.round(this._viewLength/2-this._ether.dateToPixelOffset(date)),f);
234};
235Timeline._Band.prototype.showBubbleForEvent=function(eventID){var evt=this.getEventSource().getEvent(eventID);
236if(evt){var self=this;
237this.scrollToCenter(evt.getStart(),function(){self._eventPainter.showBubble(evt);
238});
239}};
240Timeline._Band.prototype.zoom=function(zoomIn,x,y,target){if(!this._zoomSteps){return ;
241}x+=this._viewOffset;
242var zoomDate=this._ether.pixelOffsetToDate(x);
243var netIntervalChange=this._ether.zoom(zoomIn);
244this._etherPainter.zoom(netIntervalChange);
245this._moveEther(Math.round(-this._ether.dateToPixelOffset(zoomDate)));
246this._moveEther(x);
247};
248Timeline._Band.prototype._onMouseDown=function(elmt,evt,target){if(!this._dragging){this.closeBubble();
249this._dragging=true;
250this._dragX=evt.clientX;
251this._dragY=evt.clientY;
252return this._cancelEvent(evt);
253}};
254Timeline._Band.prototype._onMouseMove=function(elmt,evt,target){if(this._dragging||this._orthogonalDragging){var diffX=evt.clientX-this._dragX;
255var diffY=evt.clientY-this._dragY;
256this._dragX=evt.clientX;
257this._dragY=evt.clientY;
258}if(this._dragging){if(this._timeline.isHorizontal()){this._moveEther(diffX,diffY);
259}else{this._moveEther(diffY,diffX);
260}}else{if(this._orthogonalDragging){var viewWidth=this.getViewWidth();
261var scrollbarThumb=this._scrollBar.firstChild;
262if(this._timeline.isHorizontal()){this._moveEther(0,-diffY*viewWidth/scrollbarThumb.offsetHeight);
263}else{this._moveEther(0,-diffX*viewWidth/scrollbarThumb.offsetWidth);
264}}else{return ;
265}}this._positionHighlight();
266this._showScrollbar();
267return this._cancelEvent(evt);
268};
269Timeline._Band.prototype._onMouseUp=function(elmt,evt,target){if(this._dragging){this._dragging=false;
270}else{if(this._orthogonalDragging){this._orthogonalDragging=false;
271}else{return ;
272}}this._keyboardInput.focus();
273this._bounceBack();
274return this._cancelEvent(evt);
275};
276Timeline._Band.prototype._onMouseOut=function(elmt,evt,target){if(target==document.body){if(this._dragging){this._dragging=false;
277}else{if(this._orthogonalDragging){this._orthogonalDragging=false;
278}else{return ;
279}}this._bounceBack();
280return this._cancelEvent(evt);
281}};
282Timeline._Band.prototype._onScrollBarMouseDown=function(elmt,evt,target){if(!this._orthogonalDragging){this.closeBubble();
283this._orthogonalDragging=true;
284this._dragX=evt.clientX;
285this._dragY=evt.clientY;
286return this._cancelEvent(evt);
287}};
288Timeline._Band.prototype._onMouseScroll=function(innerFrame,evt,target){var now=new Date();
289now=now.getTime();
290if(!this._lastScrollTime||((now-this._lastScrollTime)>50)){this._lastScrollTime=now;
291var delta=0;
292if(evt.wheelDelta){delta=evt.wheelDelta/120;
293}else{if(evt.detail){delta=-evt.detail/3;
294}}var mouseWheel=this._theme.mouseWheel;
295if(this._zoomSteps||mouseWheel==="zoom"){var loc=SimileAjax.DOM.getEventRelativeCoordinates(evt,innerFrame);
296if(delta!=0){var zoomIn;
297if(delta>0){zoomIn=true;
298}if(delta<0){zoomIn=false;
299}this._timeline.zoom(zoomIn,loc.x,loc.y,innerFrame);
300}}else{if(mouseWheel==="scroll"){var move_amt=50*(delta<0?-1:1);
301this._moveEther(move_amt);
302}}}if(evt.stopPropagation){evt.stopPropagation();
303}evt.cancelBubble=true;
304if(evt.preventDefault){evt.preventDefault();
305}evt.returnValue=false;
306};
307Timeline._Band.prototype._onDblClick=function(innerFrame,evt,target){var coords=SimileAjax.DOM.getEventRelativeCoordinates(evt,innerFrame);
308var distance=coords.x-(this._viewLength/2-this._viewOffset);
309this._autoScroll(-distance);
310};
311Timeline._Band.prototype._onKeyDown=function(keyboardInput,evt,target){if(!this._dragging){switch(evt.keyCode){case 27:break;
312case 37:case 38:this._scrollSpeed=Math.min(50,Math.abs(this._scrollSpeed*1.05));
313this._moveEther(this._scrollSpeed);
314break;
315case 39:case 40:this._scrollSpeed=-Math.min(50,Math.abs(this._scrollSpeed*1.05));
316this._moveEther(this._scrollSpeed);
317break;
318default:return true;
319}this.closeBubble();
320SimileAjax.DOM.cancelEvent(evt);
321return false;
322}return true;
323};
324Timeline._Band.prototype._onKeyUp=function(keyboardInput,evt,target){if(!this._dragging){this._scrollSpeed=this._originalScrollSpeed;
325switch(evt.keyCode){case 35:this.setCenterVisibleDate(this._eventSource.getLatestDate());
326break;
327case 36:this.setCenterVisibleDate(this._eventSource.getEarliestDate());
328break;
329case 33:this._autoScroll(this._timeline.getPixelLength());
330break;
331case 34:this._autoScroll(-this._timeline.getPixelLength());
332break;
333default:return true;
334}this.closeBubble();
335SimileAjax.DOM.cancelEvent(evt);
336return false;
337}return true;
338};
339Timeline._Band.prototype._autoScroll=function(distance,f){var b=this;
340var a=SimileAjax.Graphics.createAnimation(function(abs,diff){b._moveEther(diff);
341},0,distance,1000,f);
342a.run();
343};
344Timeline._Band.prototype._moveEther=function(shift,orthogonalShift){if(orthogonalShift===undefined){orthogonalShift=0;
345}this.closeBubble();
346if(!this._timeline.shiftOK(this._index,shift)){return ;
347}this._viewOffset+=shift;
348this._ether.shiftPixels(-shift);
349if(this._timeline.isHorizontal()){this._div.style.left=this._viewOffset+"px";
350}else{this._div.style.top=this._viewOffset+"px";
351}if(this._supportsOrthogonalScrolling){if(this._eventPainter.getOrthogonalExtent()<=this.getViewWidth()){this._viewOrthogonalOffset=0;
352}else{this._viewOrthogonalOffset=this._viewOrthogonalOffset+orthogonalShift;
353}}if(this._viewOffset>-this._viewLength*0.5||this._viewOffset<-this._viewLength*(Timeline._Band.SCROLL_MULTIPLES-1.5)){this._recenterDiv();
354}else{this.softLayout();
355}this._onChanging();
356};
357Timeline._Band.prototype._onChanging=function(){this._changing=true;
358this._fireOnScroll();
359this._setSyncWithBandDate();
360this._changing=false;
361};
362Timeline._Band.prototype.busy=function(){return(this._changing);
363};
364Timeline._Band.prototype._fireOnScroll=function(){for(var i=0;
365i<this._onScrollListeners.length;
366i++){this._onScrollListeners[i](this);
367}};
368Timeline._Band.prototype._fireOnOrthogonalScroll=function(){for(var i=0;
369i<this._onOrthogonalScrollListeners.length;
370i++){this._onOrthogonalScrollListeners[i](this);
371}};
372Timeline._Band.prototype._setSyncWithBandDate=function(){if(this._syncWithBand){var centerDate=this._ether.pixelOffsetToDate(this.getViewLength()/2);
373this._syncWithBand.setCenterVisibleDate(centerDate);
374}};
375Timeline._Band.prototype._onHighlightBandScroll=function(){if(this._syncWithBand){var centerDate=this._syncWithBand.getCenterVisibleDate();
376var centerPixelOffset=this._ether.dateToPixelOffset(centerDate);
377this._moveEther(Math.round(this._viewLength/2-centerPixelOffset));
378this._positionHighlight();
379}};
380Timeline._Band.prototype._onHighlightBandOrthogonalScroll=function(){if(this._syncWithBand){this._positionHighlight();
381}};
382Timeline._Band.prototype._onAddMany=function(){this._paintEvents();
383};
384Timeline._Band.prototype._onClear=function(){this._paintEvents();
385};
386Timeline._Band.prototype._positionHighlight=function(){if(this._syncWithBand){var startDate=this._syncWithBand.getMinVisibleDate();
387var endDate=this._syncWithBand.getMaxVisibleDate();
388if(this._highlight){var offset=0;
389var extent=1;
390var syncEventPainter=this._syncWithBand.getEventPainter();
391if("supportsOrthogonalScrolling" in syncEventPainter&&syncEventPainter.supportsOrthogonalScrolling()){var orthogonalExtent=syncEventPainter.getOrthogonalExtent();
392var visibleWidth=this._syncWithBand.getViewWidth();
393var totalWidth=Math.max(visibleWidth,orthogonalExtent);
394extent=visibleWidth/totalWidth;
395offset=-this._syncWithBand.getViewOrthogonalOffset()/totalWidth;
396}this._etherPainter.setHighlight(startDate,endDate,offset,extent);
397}}};
398Timeline._Band.prototype._recenterDiv=function(){this._viewOffset=-this._viewLength*(Timeline._Band.SCROLL_MULTIPLES-1)/2;
399if(this._timeline.isHorizontal()){this._div.style.left=this._viewOffset+"px";
400this._div.style.width=(Timeline._Band.SCROLL_MULTIPLES*this._viewLength)+"px";
401}else{this._div.style.top=this._viewOffset+"px";
402this._div.style.height=(Timeline._Band.SCROLL_MULTIPLES*this._viewLength)+"px";
403}this.layout();
404};
405Timeline._Band.prototype._paintEvents=function(){this._eventPainter.paint();
406this._showScrollbar();
407this._fireOnOrthogonalScroll();
408};
409Timeline._Band.prototype._softPaintEvents=function(){this._eventPainter.softPaint();
410};
411Timeline._Band.prototype._paintDecorators=function(){for(var i=0;
412i<this._decorators.length;
413i++){this._decorators[i].paint();
414}};
415Timeline._Band.prototype._softPaintDecorators=function(){for(var i=0;
416i<this._decorators.length;
417i++){this._decorators[i].softPaint();
418}};
419Timeline._Band.prototype.closeBubble=function(){SimileAjax.WindowManager.cancelPopups();
420};
421Timeline._Band.prototype._bounceBack=function(f){if(!this._supportsOrthogonalScrolling){return ;
422}var target=0;
423if(this._viewOrthogonalOffset<0){var orthogonalExtent=this._eventPainter.getOrthogonalExtent();
424if(this._viewOrthogonalOffset+orthogonalExtent>=this.getViewWidth()){target=this._viewOrthogonalOffset;
425}else{target=Math.min(0,this.getViewWidth()-orthogonalExtent);
426}}if(target!=this._viewOrthogonalOffset){var self=this;
427SimileAjax.Graphics.createAnimation(function(abs,diff){self._viewOrthogonalOffset=abs;
428self._eventPainter.softPaint();
429self._showScrollbar();
430self._fireOnOrthogonalScroll();
431},this._viewOrthogonalOffset,target,300,function(){self._hideScrollbar();
432}).run();
433}else{this._hideScrollbar();
434}};
435Timeline._Band.prototype._showScrollbar=function(){if(!this._supportsOrthogonalScrolling){return ;
436}var orthogonalExtent=this._eventPainter.getOrthogonalExtent();
437var visibleWidth=this.getViewWidth();
438var totalWidth=Math.max(visibleWidth,orthogonalExtent);
439var ratio=(visibleWidth/totalWidth);
440var thumbWidth=Math.round(visibleWidth*ratio)+"px";
441var thumbOffset=Math.round(-this._viewOrthogonalOffset*ratio)+"px";
442var thumbThickness=12;
443var thumb=this._scrollBar.firstChild;
444if(this._timeline.isHorizontal()){this._scrollBar.style.top=this._div.style.top;
445this._scrollBar.style.height=this._div.style.height;
446this._scrollBar.style.right="0px";
447this._scrollBar.style.width=thumbThickness+"px";
448thumb.style.top=thumbOffset;
449thumb.style.height=thumbWidth;
450}else{this._scrollBar.style.left=this._div.style.left;
451this._scrollBar.style.width=this._div.style.width;
452this._scrollBar.style.bottom="0px";
453this._scrollBar.style.height=thumbThickness+"px";
454thumb.style.left=thumbOffset;
455thumb.style.width=thumbWidth;
456}if(ratio>=1&&this._viewOrthogonalOffset==0){this._scrollBar.style.display="none";
457}else{this._scrollBar.style.display="block";
458}};
459Timeline._Band.prototype._hideScrollbar=function(){if(!this._supportsOrthogonalScrolling){return ;
460}};
461Timeline._Band.prototype._cancelEvent=function(evt){SimileAjax.DOM.cancelEvent(evt);
462return false;
463};
464
465
466/* compact-painter.js */
467Timeline.CompactEventPainter=function(params){this._params=params;
468this._onSelectListeners=[];
469this._filterMatcher=null;
470this._highlightMatcher=null;
471this._frc=null;
472this._eventIdToElmt={};
473};
474Timeline.CompactEventPainter.prototype.getType=function(){return"compact";
475};
476Timeline.CompactEventPainter.prototype.initialize=function(band,timeline){this._band=band;
477this._timeline=timeline;
478this._backLayer=null;
479this._eventLayer=null;
480this._lineLayer=null;
481this._highlightLayer=null;
482this._eventIdToElmt=null;
483};
484Timeline.CompactEventPainter.prototype.supportsOrthogonalScrolling=function(){return true;
485};
486Timeline.CompactEventPainter.prototype.addOnSelectListener=function(listener){this._onSelectListeners.push(listener);
487};
488Timeline.CompactEventPainter.prototype.removeOnSelectListener=function(listener){for(var i=0;
489i<this._onSelectListeners.length;
490i++){if(this._onSelectListeners[i]==listener){this._onSelectListeners.splice(i,1);
491break;
492}}};
493Timeline.CompactEventPainter.prototype.getFilterMatcher=function(){return this._filterMatcher;
494};
495Timeline.CompactEventPainter.prototype.setFilterMatcher=function(filterMatcher){this._filterMatcher=filterMatcher;
496};
497Timeline.CompactEventPainter.prototype.getHighlightMatcher=function(){return this._highlightMatcher;
498};
499Timeline.CompactEventPainter.prototype.setHighlightMatcher=function(highlightMatcher){this._highlightMatcher=highlightMatcher;
500};
501Timeline.CompactEventPainter.prototype.paint=function(){var eventSource=this._band.getEventSource();
502if(eventSource==null){return ;
503}this._eventIdToElmt={};
504this._prepareForPainting();
505var metrics=this._computeMetrics();
506var minDate=this._band.getMinDate();
507var maxDate=this._band.getMaxDate();
508var filterMatcher=(this._filterMatcher!=null)?this._filterMatcher:function(evt){return true;
509};
510var highlightMatcher=(this._highlightMatcher!=null)?this._highlightMatcher:function(evt){return -1;
511};
512var iterator=eventSource.getEventIterator(minDate,maxDate);
513var stackConcurrentPreciseInstantEvents="stackConcurrentPreciseInstantEvents" in this._params&&typeof this._params.stackConcurrentPreciseInstantEvents=="object";
514var collapseConcurrentPreciseInstantEvents="collapseConcurrentPreciseInstantEvents" in this._params&&this._params.collapseConcurrentPreciseInstantEvents;
515if(collapseConcurrentPreciseInstantEvents||stackConcurrentPreciseInstantEvents){var bufferedEvents=[];
516var previousInstantEvent=null;
517while(iterator.hasNext()){var evt=iterator.next();
518if(filterMatcher(evt)){if(!evt.isInstant()||evt.isImprecise()){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
519}else{if(previousInstantEvent!=null&&previousInstantEvent.getStart().getTime()==evt.getStart().getTime()){bufferedEvents[bufferedEvents.length-1].push(evt);
520}else{bufferedEvents.push([evt]);
521previousInstantEvent=evt;
522}}}}for(var i=0;
523i<bufferedEvents.length;
524i++){var compositeEvents=bufferedEvents[i];
525if(compositeEvents.length==1){this.paintEvent(compositeEvents[0],metrics,this._params.theme,highlightMatcher(evt));
526}else{var match=-1;
527for(var j=0;
528match<0&&j<compositeEvents.length;
529j++){match=highlightMatcher(compositeEvents[j]);
530}if(stackConcurrentPreciseInstantEvents){this.paintStackedPreciseInstantEvents(compositeEvents,metrics,this._params.theme,match);
531}else{this.paintCompositePreciseInstantEvents(compositeEvents,metrics,this._params.theme,match);
532}}}}else{while(iterator.hasNext()){var evt=iterator.next();
533if(filterMatcher(evt)){this.paintEvent(evt,metrics,this._params.theme,highlightMatcher(evt));
534}}}this._highlightLayer.style.display="block";
535this._lineLayer.style.display="block";
536this._eventLayer.style.display="block";
537this._setOrthogonalOffset(metrics);
538};
539Timeline.CompactEventPainter.prototype.softPaint=function(){this._setOrthogonalOffset(this._computeMetrics());
540};
541Timeline.CompactEventPainter.prototype.getOrthogonalExtent=function(){var metrics=this._computeMetrics();
542return 2*metrics.trackOffset+this._tracks.length*metrics.trackHeight;
543};
544Timeline.CompactEventPainter.prototype._setOrthogonalOffset=function(metrics){var orthogonalOffset=this._band.getViewOrthogonalOffset();
545this._highlightLayer.style.top=this._lineLayer.style.top=this._eventLayer.style.top=orthogonalOffset+"px";
546};
547Timeline.CompactEventPainter.prototype._computeMetrics=function(){var theme=this._params.theme;
548var eventTheme=theme.event;
549var 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};
550if("compositeIcon" in this._params){metrics.compositeIcon=this._params.compositeIcon;
551metrics.compositeIconWidth=this._params.compositeIconWidth||metrics.customIconWidth;
552metrics.compositeIconHeight=this._params.compositeIconHeight||metrics.customIconHeight;
553}else{metrics.compositeIcon=metrics.defaultIcon;
554metrics.compositeIconWidth=metrics.defaultIconWidth;
555metrics.compositeIconHeight=metrics.defaultIconHeight;
556}metrics.defaultStackIcon=("stackConcurrentPreciseInstantEvents" in this._params&&"icon" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.icon:metrics.defaultIcon;
557metrics.defaultStackIconWidth=("stackConcurrentPreciseInstantEvents" in this._params&&"iconWidth" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.iconWidth:metrics.defaultIconWidth;
558metrics.defaultStackIconHeight=("stackConcurrentPreciseInstantEvents" in this._params&&"iconHeight" in this._params.stackConcurrentPreciseInstantEvents)?this._params.stackConcurrentPreciseInstantEvents.iconHeight:metrics.defaultIconHeight;
559return metrics;
560};
561Timeline.CompactEventPainter.prototype._prepareForPainting=function(){var band=this._band;
562if(this._backLayer==null){this._backLayer=this._band.createLayerDiv(0,"timeline-band-events");
563this._backLayer.style.visibility="hidden";
564var eventLabelPrototype=document.createElement("span");
565eventLabelPrototype.className="timeline-event-label";
566this._backLayer.appendChild(eventLabelPrototype);
567this._frc=SimileAjax.Graphics.getFontRenderingContext(eventLabelPrototype);
568}this._frc.update();
569this._tracks=[];
570if(this._highlightLayer!=null){band.removeLayerDiv(this._highlightLayer);
571}this._highlightLayer=band.createLayerDiv(105,"timeline-band-highlights");
572this._highlightLayer.style.display="none";
573if(this._lineLayer!=null){band.removeLayerDiv(this._lineLayer);
574}this._lineLayer=band.createLayerDiv(110,"timeline-band-lines");
575this._lineLayer.style.display="none";
576if(this._eventLayer!=null){band.removeLayerDiv(this._eventLayer);
577}this._eventLayer=band.createLayerDiv(115,"timeline-band-events");
578this._eventLayer.style.display="none";
579};
580Timeline.CompactEventPainter.prototype.paintEvent=function(evt,metrics,theme,highlightIndex){if(evt.isInstant()){this.paintInstantEvent(evt,metrics,theme,highlightIndex);
581}else{this.paintDurationEvent(evt,metrics,theme,highlightIndex);
582}};
583Timeline.CompactEventPainter.prototype.paintInstantEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseInstantEvent(evt,metrics,theme,highlightIndex);
584}else{this.paintPreciseInstantEvent(evt,metrics,theme,highlightIndex);
585}};
586Timeline.CompactEventPainter.prototype.paintDurationEvent=function(evt,metrics,theme,highlightIndex){if(evt.isImprecise()){this.paintImpreciseDurationEvent(evt,metrics,theme,highlightIndex);
587}else{this.paintPreciseDurationEvent(evt,metrics,theme,highlightIndex);
588}};
589Timeline.CompactEventPainter.prototype.paintPreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
590var iconData={url:evt.getIcon()};
591if(iconData.url==null){iconData.url=metrics.defaultIcon;
592iconData.width=metrics.defaultIconWidth;
593iconData.height=metrics.defaultIconHeight;
594iconData.className="timeline-event-icon-default";
595}else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
596iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
597}var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
598var result=this.paintTapeIconLabel(evt.getStart(),commonData,null,iconData,labelData,metrics,theme,highlightIndex);
599var self=this;
600var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
601};
602SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
603SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
604this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
605};
606Timeline.CompactEventPainter.prototype.paintCompositePreciseInstantEvents=function(events,metrics,theme,highlightIndex){var evt=events[0];
607var tooltips=[];
608for(var i=0;
609i<events.length;
610i++){tooltips.push(events[i].getProperty("tooltip")||events[i].getText());
611}var commonData={tooltip:tooltips.join("; ")};
612var iconData={url:metrics.compositeIcon,width:metrics.compositeIconWidth,height:metrics.compositeIconHeight,className:"timeline-event-icon-composite"};
613var labelData={text:String.substitute(this._params.compositeEventLabelTemplate,[events.length])};
614var result=this.paintTapeIconLabel(evt.getStart(),commonData,null,iconData,labelData,metrics,theme,highlightIndex);
615var self=this;
616var clickHandler=function(elmt,domEvt,target){return self._onClickMultiplePreciseInstantEvent(result.iconElmtData.elmt,domEvt,events);
617};
618SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
619SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
620for(var i=0;
621i<events.length;
622i++){this._eventIdToElmt[events[i].getID()]=result.iconElmtData.elmt;
623}};
624Timeline.CompactEventPainter.prototype.paintStackedPreciseInstantEvents=function(events,metrics,theme,highlightIndex){var limit="limit" in this._params.stackConcurrentPreciseInstantEvents?this._params.stackConcurrentPreciseInstantEvents.limit:10;
625var moreMessageTemplate="moreMessageTemplate" in this._params.stackConcurrentPreciseInstantEvents?this._params.stackConcurrentPreciseInstantEvents.moreMessageTemplate:"%0 More Events";
626var showMoreMessage=limit<=events.length-2;
627var band=this._band;
628var getPixelOffset=function(date){return Math.round(band.dateToPixelOffset(date));
629};
630var getIconData=function(evt){var iconData={url:evt.getIcon()};
631if(iconData.url==null){iconData.url=metrics.defaultStackIcon;
632iconData.width=metrics.defaultStackIconWidth;
633iconData.height=metrics.defaultStackIconHeight;
634iconData.className="timeline-event-icon-stack timeline-event-icon-default";
635}else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
636iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
637iconData.className="timeline-event-icon-stack";
638}return iconData;
639};
640var firstIconData=getIconData(events[0]);
641var horizontalIncrement=5;
642var leftIconEdge=0;
643var totalLabelWidth=0;
644var totalLabelHeight=0;
645var totalIconHeight=0;
646var records=[];
647for(var i=0;
648i<events.length&&(!showMoreMessage||i<limit);
649i++){var evt=events[i];
650var text=evt.getText();
651var iconData=getIconData(evt);
652var labelSize=this._frc.computeSize(text);
653var record={text:text,iconData:iconData,labelSize:labelSize,iconLeft:firstIconData.width+i*horizontalIncrement-iconData.width};
654record.labelLeft=firstIconData.width+i*horizontalIncrement+metrics.iconLabelGap;
655record.top=totalLabelHeight;
656records.push(record);
657leftIconEdge=Math.min(leftIconEdge,record.iconLeft);
658totalLabelHeight+=labelSize.height;
659totalLabelWidth=Math.max(totalLabelWidth,record.labelLeft+labelSize.width);
660totalIconHeight=Math.max(totalIconHeight,record.top+iconData.height);
661}if(showMoreMessage){var moreMessage=String.substitute(moreMessageTemplate,[events.length-limit]);
662var moreMessageLabelSize=this._frc.computeSize(moreMessage);
663var moreMessageLabelLeft=firstIconData.width+(limit-1)*horizontalIncrement+metrics.iconLabelGap;
664var moreMessageLabelTop=totalLabelHeight;
665totalLabelHeight+=moreMessageLabelSize.height;
666totalLabelWidth=Math.max(totalLabelWidth,moreMessageLabelLeft+moreMessageLabelSize.width);
667}totalLabelWidth+=metrics.labelRightMargin;
668totalLabelHeight+=metrics.labelBottomMargin;
669totalIconHeight+=metrics.iconBottomMargin;
670var anchorPixel=getPixelOffset(events[0].getStart());
671var newTracks=[];
672var trackCount=Math.ceil(Math.max(totalIconHeight,totalLabelHeight)/metrics.trackHeight);
673var rightIconEdge=firstIconData.width+(events.length-1)*horizontalIncrement;
674for(var i=0;
675i<trackCount;
676i++){newTracks.push({start:leftIconEdge,end:rightIconEdge});
677}var labelTrackCount=Math.ceil(totalLabelHeight/metrics.trackHeight);
678for(var i=0;
679i<labelTrackCount;
680i++){var track=newTracks[i];
681track.end=Math.max(track.end,totalLabelWidth);
682}var firstTrack=this._fitTracks(anchorPixel,newTracks);
683var verticalPixelOffset=firstTrack*metrics.trackHeight+metrics.trackOffset;
684var iconStackDiv=this._timeline.getDocument().createElement("div");
685iconStackDiv.className="timeline-event-icon-stack";
686iconStackDiv.style.position="absolute";
687iconStackDiv.style.overflow="visible";
688iconStackDiv.style.left=anchorPixel+"px";
689iconStackDiv.style.top=verticalPixelOffset+"px";
690iconStackDiv.style.width=rightIconEdge+"px";
691iconStackDiv.style.height=totalIconHeight+"px";
692iconStackDiv.innerHTML="<div style='position: relative'></div>";
693this._eventLayer.appendChild(iconStackDiv);
694var self=this;
695var onMouseOver=function(domEvt){try{var n=parseInt(this.getAttribute("index"));
696var childNodes=iconStackDiv.firstChild.childNodes;
697for(var i=0;
698i<childNodes.length;
699i++){var child=childNodes[i];
700if(i==n){child.style.zIndex=childNodes.length;
701}else{child.style.zIndex=childNodes.length-i;
702}}}catch(e){}};
703var paintEvent=function(index){var record=records[index];
704var evt=events[index];
705var tooltip=evt.getProperty("tooltip")||evt.getText();
706var labelElmtData=self._paintEventLabel({tooltip:tooltip},{text:record.text},anchorPixel+record.labelLeft,verticalPixelOffset+record.top,record.labelSize.width,record.labelSize.height,theme);
707labelElmtData.elmt.setAttribute("index",index);
708labelElmtData.elmt.onmouseover=onMouseOver;
709var img=SimileAjax.Graphics.createTranslucentImage(record.iconData.url);
710var iconDiv=self._timeline.getDocument().createElement("div");
711iconDiv.className="timeline-event-icon"+("className" in record.iconData?(" "+record.iconData.className):"");
712iconDiv.style.left=record.iconLeft+"px";
713iconDiv.style.top=record.top+"px";
714iconDiv.style.zIndex=(records.length-index);
715iconDiv.appendChild(img);
716iconDiv.setAttribute("index",index);
717iconDiv.onmouseover=onMouseOver;
718iconStackDiv.firstChild.appendChild(iconDiv);
719var clickHandler=function(elmt,domEvt,target){return self._onClickInstantEvent(labelElmtData.elmt,domEvt,evt);
720};
721SimileAjax.DOM.registerEvent(iconDiv,"mousedown",clickHandler);
722SimileAjax.DOM.registerEvent(labelElmtData.elmt,"mousedown",clickHandler);
723self._eventIdToElmt[evt.getID()]=iconDiv;
724};
725for(var i=0;
726i<records.length;
727i++){paintEvent(i);
728}if(showMoreMessage){var moreEvents=events.slice(limit);
729var moreMessageLabelElmtData=this._paintEventLabel({tooltip:moreMessage},{text:moreMessage},anchorPixel+moreMessageLabelLeft,verticalPixelOffset+moreMessageLabelTop,moreMessageLabelSize.width,moreMessageLabelSize.height,theme);
730var moreMessageClickHandler=function(elmt,domEvt,target){return self._onClickMultiplePreciseInstantEvent(moreMessageLabelElmtData.elmt,domEvt,moreEvents);
731};
732SimileAjax.DOM.registerEvent(moreMessageLabelElmtData.elmt,"mousedown",moreMessageClickHandler);
733for(var i=0;
734i<moreEvents.length;
735i++){this._eventIdToElmt[moreEvents[i].getID()]=moreMessageLabelElmtData.elmt;
736}}};
737Timeline.CompactEventPainter.prototype.paintImpreciseInstantEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
738var tapeData={start:evt.getStart(),end:evt.getEnd(),latestStart:evt.getLatestStart(),earliestEnd:evt.getEarliestEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:true};
739var iconData={url:evt.getIcon()};
740if(iconData.url==null){iconData=null;
741}else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
742iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
743}var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
744var result=this.paintTapeIconLabel(evt.getStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
745var self=this;
746var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
747}:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
748};
749SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
750SimileAjax.DOM.registerEvent(result.impreciseTapeElmtData.elmt,"mousedown",clickHandler);
751if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
752this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
753}else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
754}};
755Timeline.CompactEventPainter.prototype.paintPreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
756var tapeData={start:evt.getStart(),end:evt.getEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:false};
757var iconData={url:evt.getIcon()};
758if(iconData.url==null){iconData=null;
759}else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
760iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
761}var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
762var result=this.paintTapeIconLabel(evt.getLatestStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
763var self=this;
764var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
765}:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
766};
767SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
768SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt,"mousedown",clickHandler);
769if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
770this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
771}else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
772}};
773Timeline.CompactEventPainter.prototype.paintImpreciseDurationEvent=function(evt,metrics,theme,highlightIndex){var commonData={tooltip:evt.getProperty("tooltip")||evt.getText()};
774var tapeData={start:evt.getStart(),end:evt.getEnd(),latestStart:evt.getLatestStart(),earliestEnd:evt.getEarliestEnd(),color:evt.getColor()||evt.getTextColor(),isInstant:false};
775var iconData={url:evt.getIcon()};
776if(iconData.url==null){iconData=null;
777}else{iconData.width=evt.getProperty("iconWidth")||metrics.customIconWidth;
778iconData.height=evt.getProperty("iconHeight")||metrics.customIconHeight;
779}var labelData={text:evt.getText(),color:evt.getTextColor()||evt.getColor(),className:evt.getClassName()};
780var result=this.paintTapeIconLabel(evt.getLatestStart(),commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex);
781var self=this;
782var clickHandler=iconData!=null?function(elmt,domEvt,target){return self._onClickInstantEvent(result.iconElmtData.elmt,domEvt,evt);
783}:function(elmt,domEvt,target){return self._onClickInstantEvent(result.labelElmtData.elmt,domEvt,evt);
784};
785SimileAjax.DOM.registerEvent(result.labelElmtData.elmt,"mousedown",clickHandler);
786SimileAjax.DOM.registerEvent(result.tapeElmtData.elmt,"mousedown",clickHandler);
787if(iconData!=null){SimileAjax.DOM.registerEvent(result.iconElmtData.elmt,"mousedown",clickHandler);
788this._eventIdToElmt[evt.getID()]=result.iconElmtData.elmt;
789}else{this._eventIdToElmt[evt.getID()]=result.labelElmtData.elmt;
790}};
791Timeline.CompactEventPainter.prototype.paintTapeIconLabel=function(anchorDate,commonData,tapeData,iconData,labelData,metrics,theme,highlightIndex){var band=this._band;
792var getPixelOffset=function(date){return Math.round(band.dateToPixelOffset(date));
793};
794var anchorPixel=getPixelOffset(anchorDate);
795var newTracks=[];
796var tapeHeightOccupied=0;
797var tapeTrackCount=0;
798var tapeLastTrackExtraSpace=0;
799if(tapeData!=null){tapeHeightOccupied=metrics.tapeHeight+metrics.tapeBottomMargin;
800tapeTrackCount=Math.ceil(metrics.tapeHeight/metrics.trackHeight);
801var tapeEndPixelOffset=getPixelOffset(tapeData.end)-anchorPixel;
802var tapeStartPixelOffset=getPixelOffset(tapeData.start)-anchorPixel;
803for(var t=0;
804t<tapeTrackCount;
805t++){newTracks.push({start:tapeStartPixelOffset,end:tapeEndPixelOffset});
806}tapeLastTrackExtraSpace=metrics.trackHeight-(tapeHeightOccupied%metrics.tapeHeight);
807}var iconStartPixelOffset=0;
808var iconHorizontalSpaceOccupied=0;
809if(iconData!=null){if("iconAlign" in iconData&&iconData.iconAlign=="center"){iconStartPixelOffset=-Math.floor(iconData.width/2);
810}iconHorizontalSpaceOccupied=iconStartPixelOffset+iconData.width+metrics.iconLabelGap;
811if(tapeTrackCount>0){newTracks[tapeTrackCount-1].end=Math.max(newTracks[tapeTrackCount-1].end,iconHorizontalSpaceOccupied);
812}var iconHeight=iconData.height+metrics.iconBottomMargin+tapeLastTrackExtraSpace;
813while(iconHeight>0){newTracks.push({start:iconStartPixelOffset,end:iconHorizontalSpaceOccupied});
814iconHeight-=metrics.trackHeight;
815}}var text=labelData.text;
816var labelSize=this._frc.computeSize(text);
817var labelHeight=labelSize.height+metrics.labelBottomMargin+tapeLastTrackExtraSpace;
818var labelEndPixelOffset=iconHorizontalSpaceOccupied+labelSize.width+metrics.labelRightMargin;
819if(tapeTrackCount>0){newTracks[tapeTrackCount-1].end=Math.max(newTracks[tapeTrackCount-1].end,labelEndPixelOffset);
820}for(var i=0;
821labelHeight>0;
822i++){if(tapeTrackCount+i<newTracks.length){var track=newTracks[tapeTrackCount+i];
823track.end=labelEndPixelOffset;
824}else{newTracks.push({start:0,end:labelEndPixelOffset});
825}labelHeight-=metrics.trackHeight;
826}var firstTrack=this._fitTracks(anchorPixel,newTracks);
827var verticalPixelOffset=firstTrack*metrics.trackHeight+metrics.trackOffset;
828var result={};
829result.labelElmtData=this._paintEventLabel(commonData,labelData,anchorPixel+iconHorizontalSpaceOccupied,verticalPixelOffset+tapeHeightOccupied,labelSize.width,labelSize.height,theme);
830if(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);
831}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);
832}}if(iconData!=null){result.iconElmtData=this._paintEventIcon(commonData,iconData,verticalPixelOffset+tapeHeightOccupied,anchorPixel+iconStartPixelOffset,metrics,theme);
833}return result;
834};
835Timeline.CompactEventPainter.prototype._fitTracks=function(anchorPixel,newTracks){var firstTrack;
836for(firstTrack=0;
837firstTrack<this._tracks.length;
838firstTrack++){var fit=true;
839for(var j=0;
840j<newTracks.length&&(firstTrack+j)<this._tracks.length;
841j++){var existingTrack=this._tracks[firstTrack+j];
842var newTrack=newTracks[j];
843if(anchorPixel+newTrack.start<existingTrack){fit=false;
844break;
845}}if(fit){break;
846}}for(var i=0;
847i<newTracks.length;
848i++){this._tracks[firstTrack+i]=anchorPixel+newTracks[i].end;
849}return firstTrack;
850};
851Timeline.CompactEventPainter.prototype._paintEventIcon=function(commonData,iconData,top,left,metrics,theme){var img=SimileAjax.Graphics.createTranslucentImage(iconData.url);
852var iconDiv=this._timeline.getDocument().createElement("div");
853iconDiv.className="timeline-event-icon"+("className" in iconData?(" "+iconData.className):"");
854iconDiv.style.left=left+"px";
855iconDiv.style.top=top+"px";
856iconDiv.appendChild(img);
857if("tooltip" in commonData&&typeof commonData.tooltip=="string"){iconDiv.title=commonData.tooltip;
858}this._eventLayer.appendChild(iconDiv);
859return{left:left,top:top,width:metrics.iconWidth,height:metrics.iconHeight,elmt:iconDiv};
860};
861Timeline.CompactEventPainter.prototype._paintEventLabel=function(commonData,labelData,left,top,width,height,theme){var doc=this._timeline.getDocument();
862var labelDiv=doc.createElement("div");
863labelDiv.className="timeline-event-label";
864labelDiv.style.left=left+"px";
865labelDiv.style.width=(width+1)+"px";
866labelDiv.style.top=top+"px";
867labelDiv.innerHTML=labelData.text;
868if("tooltip" in commonData&&typeof commonData.tooltip=="string"){labelDiv.title=commonData.tooltip;
869}if("color" in labelData&&typeof labelData.color=="string"){labelDiv.style.color=labelData.color;
870}if("className" in labelData&&typeof labelData.className=="string"){labelDiv.className+=" "+labelData.className;
871}this._eventLayer.appendChild(labelDiv);
872return{left:left,top:top,width:width,height:height,elmt:labelDiv};
873};
874Timeline.CompactEventPainter.prototype._paintEventTape=function(commonData,tapeData,height,top,startPixel,endPixel,color,opacity,metrics,theme){var width=endPixel-startPixel;
875var tapeDiv=this._timeline.getDocument().createElement("div");
876tapeDiv.className="timeline-event-tape";
877tapeDiv.style.left=startPixel+"px";
878tapeDiv.style.top=top+"px";
879tapeDiv.style.width=width+"px";
880tapeDiv.style.height=height+"px";
881if("tooltip" in commonData&&typeof commonData.tooltip=="string"){tapeDiv.title=commonData.tooltip;
882}if(color!=null&&typeof tapeData.color=="string"){tapeDiv.style.backgroundColor=color;
883}if("backgroundImage" in tapeData&&typeof tapeData.backgroundImage=="string"){tapeDiv.style.backgroundImage="url("+backgroundImage+")";
884tapeDiv.style.backgroundRepeat=("backgroundRepeat" in tapeData&&typeof tapeData.backgroundRepeat=="string")?tapeData.backgroundRepeat:"repeat";
885}SimileAjax.Graphics.setOpacity(tapeDiv,opacity);
886if("className" in tapeData&&typeof tapeData.className=="string"){tapeDiv.className+=" "+tapeData.className;
887}this._eventLayer.appendChild(tapeDiv);
888return{left:startPixel,top:top,width:width,height:height,elmt:tapeDiv};
889};
890Timeline.CompactEventPainter.prototype._createHighlightDiv=function(highlightIndex,dimensions,theme){if(highlightIndex>=0){var doc=this._timeline.getDocument();
891var eventTheme=theme.event;
892var color=eventTheme.highlightColors[Math.min(highlightIndex,eventTheme.highlightColors.length-1)];
893var div=doc.createElement("div");
894div.style.position="absolute";
895div.style.overflow="hidden";
896div.style.left=(dimensions.left-2)+"px";
897div.style.width=(dimensions.width+4)+"px";
898div.style.top=(dimensions.top-2)+"px";
899div.style.height=(dimensions.height+4)+"px";
900this._highlightLayer.appendChild(div);
901}};
902Timeline.CompactEventPainter.prototype._onClickMultiplePreciseInstantEvent=function(icon,domEvt,events){var c=SimileAjax.DOM.getPageCoordinates(icon);
903this._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