1 // VIEW
  2 
  3 /**
  4 
  5 This track draws vertical gridlines, which are divs with height 100%,
  6 absolutely positioned at the very top of all the tracks.
  7 
  8 @class
  9 */
 10 function GridTrack(name) {
 11     Track.call(this, name, name, true, function() {});
 12 }
 13 
 14 GridTrack.prototype = new Track("");
 15 
 16 GridTrack.prototype.fillBlock = function(blockIndex, block,
 17                                          leftBlock, rightBlock,
 18                                          leftBase, rightBase, scale,
 19                                          padding, stripeWidth) {
 20 
 21     this.renderGridlines( block, leftBase, rightBase );
 22     this.heightUpdate(100, blockIndex);
 23 };
 24 
 25 GridTrack.prototype.renderGridlines = function(block,leftBase,rightBase) {
 26 
 27     var base_span = rightBase-leftBase;
 28     var minor_count =
 29         !( base_span % 20 ) ? 20 :
 30         !( base_span % 10 ) ? 10 :
 31         !( base_span % 5  ) ? 5  :
 32         !( base_span % 2  ) ? 2  :
 33                               0;
 34     var major_count = base_span == 20 ? 2 : base_span > 0 ? 1 : 0;
 35 
 36     var new_gridline = function( glclass, position ) {
 37         var gridline = document.createElement("div");
 38         gridline.style.cssText = "left: " + position + "%; width: 0px";
 39         gridline.className = "gridline "+glclass;
 40         return gridline;
 41     };
 42 
 43     for( var i=0; i<minor_count; i++ ) {
 44         var pos = 100/minor_count*i;
 45         var cls = pos == 0 || (minor_count == 20 && i == 10)
 46             ? "gridline_major"
 47             : "gridline_minor";
 48 
 49         block.appendChild( new_gridline( cls, pos) );
 50     }
 51 
 52 };
 53 
 54