Fixes issue #298 re saving favorites with long names.

This is *not* the fix one might expect. Instead of actually making the AJAX better and making it report errors, we just block users from making any errors by:

  1. Setting the maxlength for the input, and
  2. Not inputting too long of a string in our own code.

 The first was done previously, but this issue reported that when we had long case names, we were putting that entire thing into the input when loading the page, circumventing the maxlength and creating an error for the user. Not cool.

 This commit fixes that in the view (easy fix), but also fixes a number of bugs that I found in the `trunc()` function when using it to add ellipses. Also included is a small suite of tests to prevent future regressions to the method.

  So: The fix: 1 line, six characters. Other bug found along the way and tests for that: 70 lines.