Adding trim function check for IE8 support

I added a simple check to see if the trim function exists in JS. If not, then create it and remove whitespace with a string replace via RegEx. Adding this makes this directive IE8 compatible.