Very useful lets me create a dynamically sizing title. Thank you for posting.
Here is some simple logic to handle title sizing in the bar.
Code:
this.getWhatCategoryView().setTitle( this.calcFontSize( data.get("Title"), 20 ) );
// create a nice way to fit title on to the screen
//
calcFontSize : function( titleToDisplay, checkwidth ) {
var ilen = titleToDisplay.length;
var fontsize = 1;
if ( checkwidth == undefined || checkwidth == null) {
checkwidth = 30;
}
if ( ilen < 10 ) {
fontsize = 1;
} else if ( ilen < checkwidth ) {
fontsize = .84;
} else {
fontsize = .55;
}
return '<font style="font-size:' + fontsize + 'em;">' + titleToDisplay
'</font>';
},