Created
November 15, 2013 22:35
-
-
Save ijones922/7492837 to your computer and use it in GitHub Desktop.
ellipsis
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
/* elipsify any text you want to truncate. Simply use .text(cut([n])) then .append() to add in any character(s) you want after. ex: ('...')*/ | |
function cut(n) { | |
return function textCutter(i, text) { | |
var short = text.substr(0, n); | |
if (/^\S/.test(text.substr(n))) | |
return short.replace(/\s+\S*$/, ""); | |
return short; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment