Created
December 3, 2013 22:33
-
-
Save alanleard/7778819 to your computer and use it in GitHub Desktop.
Font Size Manipulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var args = arguments[0] || {}; | |
var changeFontSize = null; | |
$.sectionTitle.text = args.title; | |
function setTitles(callback){ | |
if(args.criteria) { | |
var cLength = args.criteria.length; | |
for(var i=0; i<cLength; i++){ | |
var title = Ti.UI.createLabel({ | |
text:" "+args.criteria[i].title+" ", | |
left:((590/(cLength))*(i)), | |
color:Alloy.Globals.Data.Colors.one, | |
font:{fontFamily:Alloy.Globals.Data.Fonts.primary, fontSize:16, fontWeight:"bold"}, | |
width:(590/cLength), | |
textAlign:"center", | |
height:Ti.UI.FILL, | |
ellipsize:true, | |
verticalAlign:Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER | |
}); | |
$.criteria.add(title); | |
if(title.text == " Not Applicable "){ | |
title.text = " N/A "; | |
} | |
if(title.width*.07<title.text.length){ | |
changeFontSize = true; | |
} | |
if(i == (cLength-1)){ | |
callback(); | |
} | |
} | |
} | |
} | |
setTitles(function(){ | |
if(changeFontSize){ | |
for(var i in $.criteria.children){ | |
if($.criteria.children[i]){ | |
$.criteria.children[i].font = {fontFamily:Alloy.Globals.Data.Fonts.primary, fontSize:14, fontWeight:"bold"}; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment