Now the code will split around a hypen, vertical bar, colon, or else default back to spaces.
I've included my initials in comments around my changes. I hope this helps others.
PHP Code:
$js .= "
/*******************************
* SPLIT TITLES
******************************/
/* Split titles: 2-color titles for site-, post- and widget titles */
$('" . $dual_title_colors . "').each( function() {
var str = $(this).text();
/*TRP add more tests here */
if( str.indexOf('–') > 0 ) { var space = '–'; } else
if( str.indexOf('|') > 0 ) { var space = '|'; } else
if( str.indexOf(':') > 0 ) { var space = ':'; } else /*TRP end of tests */
if( str.indexOf(' ') > 0 ) { var space = ' '; }
else { var space = ''; }
var strArray = str.split(space),
fullLength = strArray.length,
halfLength = Math.ceil( fullLength / 2 ),
restLength = fullLength - halfLength,
newstr = '<span class=\"firstpart\">';
for( var i = 0; i < halfLength; i++ ) {
newstr += strArray[i] + space;
}
newstr += '</span>';/*TRP don't add space here */
for( var i = halfLength; i < fullLength; i++ ) {
newstr += strArray[i] + ((i<fullLength-1)?space:'');/*TRP only add delimiter if not the last segment */
}
$(this).html( newstr );
});
";