Skip to content

Commit

Permalink
make HTMLFeatures show the description if at the appropriate scale, e…
Browse files Browse the repository at this point in the history
…ven if the feature e has no name (label)
  • Loading branch information
rbuels committed Mar 7, 2013
1 parent 4b97bf7 commit b345c74
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/JBrowse/View/Track/HTMLFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,15 @@ var HTMLFeatures = declare( [ BlockBased, YScaleMixin, ExportMixin, FeatureDetai

// add the label div (which includes the description) to the
// calculated height of the feature if it will be displayed
if( this.showLabels && scale >= labelScale ) {
if (name) {
layoutEnd = Math.max(layoutEnd, layoutStart + (''+name).length * this.labelWidth / scale );
levelHeight += this.labelHeight + this.labelPad;
}
if( description ) {
layoutEnd = Math.max( layoutEnd, layoutStart + (''+description).length * this.labelWidth / scale );
levelHeight += this.labelHeight + this.labelPad;
}
if( this.showLabels && scale >= labelScale && name ) {
layoutEnd = Math.max(layoutEnd, layoutStart + (''+name).length * this.labelWidth / scale );
levelHeight += this.labelHeight + this.labelPad;
}
if( description ) {
layoutEnd = Math.max( layoutEnd, layoutStart + (''+description).length * this.labelWidth / scale );
levelHeight += this.labelHeight + this.labelPad;
}

layoutEnd += Math.max(1, this.padding / scale);

var top = this._getLayout( scale )
Expand Down Expand Up @@ -814,10 +813,10 @@ var HTMLFeatures = declare( [ BlockBased, YScaleMixin, ExportMixin, FeatureDetai
}
}

if (name && this.showLabels && scale >= labelScale) {
if (name && this.showLabels && scale >= labelScale || description ) {
var labelDiv = dojo.create( 'div', {
className: "feature-label" + ( highlighted ? ' highlighted' : '' ),
innerHTML: '<div class="feature-name">'+name+'</div>'
innerHTML: ( name ? '<div class="feature-name">'+name+'</div>' : '' )
+( description ? ' <div class="feature-description">'+description+'</div>' : '' ),
style: {
top: (top + this.glyphHeight + 2) + "px",
Expand Down

0 comments on commit b345c74

Please sign in to comment.