diff --git a/jquery.lettering.js b/jquery.lettering.js index 8a693c8..1177420 100644 --- a/jquery.lettering.js +++ b/jquery.lettering.js @@ -1,9 +1,9 @@ /*global jQuery */ -/*! +/*! * Lettering.JS 0.6.1 * * Copyright 2010, Dave Rupert http://daverupert.com -* Released under the WTFPL license +* Released under the WTFPL license * http://sam.zoy.org/wtfpl/ * * Thanks to Paul Irish - http://paulirish.com - for the feedback. @@ -11,16 +11,35 @@ * Date: Mon Sep 20 17:14:00 2010 -0600 */ (function($){ - function injector(t, splitter, klass, after) { - var a = t.text().split(splitter), inject = ''; + var format = { + line: function(i, line) { + return ''+line+''; + }, + + word: function(i, word) { + return ''+word+''; + }, + + char: function(i, char) { + if (char === '&') { + char = '&'; + } + quot = char === '"' ? "'" : '"'; + return ''+char+''; + } + }; + + function injector(t, splitter, type, after) { + var a = t.text().split(splitter), + inject = ''; if (a.length) { - $(a).each(function(i, item) { - inject += ''+item+''+after; - }); + $.each(a, function(i, item) { + inject += format[type](i, item)+after; + }); t.empty().append(inject); } } - + var methods = { init : function() { @@ -37,14 +56,14 @@ }); }, - + lines : function() { return this.each(function() { var r = "eefec303079ad17405c889e092e105b0"; // Because it's hard to split a
tag consistently across browsers, - // (*ahem* IE *ahem*), we replace all
instances with an md5 hash - // (of the word "split"). If you're trying to use this plugin on that + // (*ahem* IE *ahem*), we replace all
instances with an md5 hash + // (of the word "split"). If you're trying to use this plugin on that // md5 hash string, it will fail because you're being ridiculous. injector($(this).children("br").replaceWith(r).end(), r, 'line', ''); });