Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom data attributes, character escape function, and character class for kerning pairs #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions jquery.lettering.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
* Date: Mon Sep 20 17:14:00 2010 -0600
*/
(function($){

function injector(t, splitter, klass, after) {
var a = t.text().split(splitter), inject = '';
if (a.length) {
$(a).each(function(i, item) {
inject += '<span class="'+klass+(i+1)+'">'+item+'</span>'+after;
escitem = escape(item);
inject += '<span class="'+klass+(i+1)+'" data-'+klass+'="'+escitem+'">'+item+'</span>'+after;
});
t.empty().append(inject);
}
}

function escape(str) {
return String(str).replace(/&amp;/g, '&').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); // avoids double encoding &amp; See comments from http://css-tricks.com/snippets/javascript/htmlentities-for-javascript/
}
var methods = {
init : function() {

Expand Down