Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 14th, 2018, 01:02 PM
traba5058 traba5058 is offline
Regular Contributor
 
Join Date: Jan 2012
Location: Atlanta, GA
Posts: 77
Post Font Color & Weight Changes in FusionPro

All,

I need help.

I have a customer that can add up to 2 phone numbers on a business card. The field tags vary.

They need to bold the two phone tag fields and change the color for the divider between the 2 numbers if both are used.

I have Treat as Tagged Text selected.

I have tried both <b></b> and <f name=""></f>

My rule current rule is
Code:
if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone")+' '+<color name="c0m36y100k8">|</color>+' '+<f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return <f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";
When I check fonts used under advanced, I see Gotham Book and Gotham Bold I also see this in the text frame.

The color name for the color I want to use is c0m36y100k8. I see this in both the text frame color drop down as well as colors under advanced.

My phone format rules are formatting the numbers as (000) 000-0000.

I'm not getting any errors on compose, but it is returning the following:

Field("Phone 1 Tag") (404) 213-8360 | Field("Phone 2 Tag") (404) 941-2631

The whole line is black and there is no bold.

I appreciate any of the help I can get.

Thanks,
Traba
Reply With Quote
  #2  
Old February 14th, 2018, 01:35 PM
traba5058 traba5058 is offline
Regular Contributor
 
Join Date: Jan 2012
Location: Atlanta, GA
Posts: 77
Post Re: Font Color & Weight Changes in FusionPro

All,

I updated my rule to
Code:
if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";
And am getting the bold font & color changes. However, I've lost the space after the divider when 2 numbers are used and it is not showing the tag.

It's returning:
Field("Phone 1 Tag") (404) 213-8360 |Field("Phone 2 Tag") (404) 941-2631
with bold tags & yellow |. And missing the space between the | and phone 2 tag.

Any ideas?
Reply With Quote
  #3  
Old February 14th, 2018, 03:08 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,388
Default Re: Font Color & Weight Changes in FusionPro

You need to be more careful with your quotes, so that the JavaScript engine knows what parts of your code are literal strings vs. function calls. You should be able to see what's being returned in the Rule Editor when you click Validate, without even composing, to see whether you're on the right track or not. And actually, even without clicking Validate, the syntax coloring in the Rule Editor should give you an idea of what's a literal string and what isn't. (You can click the Editor Settings button to change the Char Color and Strings Color settings to something with more contrast if that helps.)

This should work to keep the Field function calls from being output literally:
Code:
if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";
Though you may also need to use entities or <space> tags in order to be able to output a space after a tag (such as </f>), so this should fix that:
Code:
if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color><space>'+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";
I'll also note that there are several ways in which this code can be made simpler and more succinct. For instance:
Code:
var items = [];

if (Field("Phone 1"))
    items.push('<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>' + Rule("Rule_FormatPhone"));

if (Field("Phone 2"))
    items.push('<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>' + Rule("Rule_FormatPhone2"));

return items.join('  <color name="c0m36y100k8">|</color><space>');
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Tags
bold, color, color text, font

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:12 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.