Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Montezuma Theme »

Split Headlines on punctuation (code update)


 
Prev Previous Post   Next Post Next
  #1  
Old Nov 21, 2012, 02:38 PM
troyp
 
10 posts · Mar 2011
Split Headlines on punctuation (code update)

I wanted to split the headlines on a few punctuation characters I use on my site for headers. To do that I updated the SPLIT HEADERS section of includes/get_javascript.php

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 );
});
"

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
No spaces after punctuation studentofstone Atahualpa 3 Wordpress theme 6 Nov 22, 2011 04:38 PM
SPACES REMOVED after punctuation in 3.6.7 avantlit New Versions, & Updating 8 Sep 16, 2011 05:34 PM
Spaces removed after punctuation mlanger Atahualpa 3 Wordpress theme 2 Jul 30, 2011 04:30 AM
[SOLVED] Lost Google Analytics code with last update sjolyjuly New Versions, & Updating 4 May 10, 2011 08:28 AM
[SOLVED] Keep post headlines, remove page headlines verymarie Center area post/pages 1 Mar 17, 2011 12:14 PM


All times are GMT -6. The time now is 09:14 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.