(I thought I submitted this just now, but it's not showing up.)

Drupal.truncateUtf8 = function (string, len, wordsafe, dots) {
  if (string.length <= len) {
    return string;
  }

  if (dots) {
    len -= 4;
  }

  if (wordsafe) {
    string = string.substring(0, len + 1);
    if (lastSpace = string.lastIndexOf(' ')) {
      string = string.substring(0, lastSpace);
    }
    else {
      string = string.substring(0, len);
    }
  }
  else {
    string = string.substring(0, len);
  }

  if (dots) {
    string += ' ...';
  }

  return string;
}
CommentFileSizeAuthor
#2 example.patch1.05 KBjpmckinney

Comments

litwol’s picture

Status: Needs review » Needs work

Submit a patch please. information on how to make patches is here: http://drupal.org/patch

jpmckinney’s picture

StatusFileSize
new1.05 KB
jpmckinney’s picture

Status: Needs work » Needs review