Created
April 8, 2013 17:17
-
-
Save MikeMcChillin/5338560 to your computer and use it in GitHub Desktop.
Prevents widows in headlines.
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
####################################### | |
## Prevent widows on headlines! | |
####################################### | |
widowSelector = $('header h2') | |
widowSelector.each -> | |
wordArray = $(this).text().split(" ") | |
finalTitle = "" | |
i = 0 | |
while i <= wordArray.length - 1 | |
finalTitle += wordArray[i] | |
if i is (wordArray.length - 2) | |
finalTitle += " " | |
else | |
finalTitle += " " | |
i++ | |
$(this).html finalTitle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment