Search the Community
Showing results for tags 'styling text'.
-
Wanted to create a function that allows users to choose a style from Field A that formats the text they enter in Field B. I came up with the following function which appears to work pretty well. My problem arrises when I come to the "Bullets" case I need bulleted text to have a tab stop of .125 in and a second line indent of 0p9. Is there a way to include this in the switch statement so that it doesn't effect all the other fields in the text frame? function styleText(style,text){ titleFormat = '<color name="NSU green"><f name ="Interstate Black"><z newsize="28">'; subtitleFormat = '<color name="NSU green"><f name ="Interstate RegularCondensed"><z newsize="20">'; headFormat = '<color name="NSU green"><f name ="Interstate BlackCondensed"><z newsize="16"><uppercase>'; subheadFormat = '<color name="black"><f name ="Interstate RegularCondensed"><z newsize="14">'; bulletCharFormat = '<color name="nsultgreen"><f name ="Interstate Black"><z nesize="10">'; bulletTextFormat = '<color name="black"><f name ="Aldine401 BT"><z newsize="10">'; plainTextFormat ='<color name="black"><f name ="Aldine401 BT"><z newsize="10">'; var result; switch (style) { case "Title": result = titleFormat+text; break; case "Subtitle": result = subtitleFormat+text; break; case "Head": result = headFormat+text; break; case "Subhead": result = subheadFormat+text; break; case "Bullets": var MyVar=text; var MyArray=MyVar.split("<p>"); var MyString='<p>'+bulletCharFormat+'»<t>'+bulletTextFormat+MyArray[0]; if (MyVar==""){ return ""; }else{ for (i=1;i<MyArray.length;i++){ MyString+='<br><p>'+bulletCharFormat+'»<t>'+bulletTextFormat +MyArray[i]; } }; return MyString; break; case "Plain Text": result = plainTextFormat+text; break; default: result = plainTextFormat+text; } return result; };
- 3 replies
-
- styling text
- switch statement
-
(and 1 more)
Tagged with: