1/*global jQuery */ 2/*! 3* Lettering.JS 0.7.0 4* 5* Copyright 2010, Dave Rupert http://daverupert.com 6* Released under the WTFPL license 7* http://sam.zoy.org/wtfpl/ 8* 9* Thanks to Paul Irish - http://paulirish.com - for the feedback. 10* 11* Date: Mon Sep 20 17:14:00 2010 -0600 12*/ 13(function($){ 14 // function injector(t, splitter, klass, after) { 15 // var text = t.text() 16 // , a = text.split(splitter) 17 // , inject = ''; 18 // if (a.length) { 19 // $(a).each(function(i, item) { 20 // inject += '<span class="'+klass+(i+1)+'" aria-hidden="true">'+item+'</span>'+after; 21 // }); 22 // t.attr('aria-label',text) 23 // .empty() 24 // .append(inject) 25 26 // } 27 // } 28 29 function injector(t, splitter, klass, after) { 30 var text = t.text() 31 , a = text.split(splitter) 32 , inject = ''; 33 if (a.length) { 34 console.log(a); 35 $(a).each(function(i, item) { 36 if(item === " "){ 37 inject += '<span class="'+klass+(i+1)+' char-empty" aria-hidden="true">'+item+'</span>'+after; 38 }else{ 39 inject += '<span class="'+klass+(i+1)+'" aria-hidden="true">'+item+'</span>'+after; 40 } 41 }); 42 t.attr('aria-label',text) 43 .empty() 44 .append(inject) 45 46 } 47 } 48 49 50 var methods = { 51 init : function() { 52 53 return this.each(function() { 54 injector($(this), '', 'char', ''); 55 }); 56 57 }, 58 59 words : function() { 60 61 return this.each(function() { 62 injector($(this), ' ', 'word', ' '); 63 }); 64 65 }, 66 67 lines : function() { 68 69 return this.each(function() { 70 var r = "eefec303079ad17405c889e092e105b0"; 71 // Because it's hard to split a <br/> tag consistently across browsers, 72 // (*ahem* IE *ahem*), we replace all <br/> instances with an md5 hash 73 // (of the word "split"). If you're trying to use this plugin on that 74 // md5 hash string, it will fail because you're being ridiculous. 75 injector($(this).children("br").replaceWith(r).end(), r, 'line', ''); 76 }); 77 78 } 79 }; 80 81 $.fn.lettering = function( method ) { 82 // Method calling logic 83 if ( method && methods[method] ) { 84 return methods[ method ].apply( this, [].slice.call( arguments, 1 )); 85 } else if ( method === 'letters' || ! method ) { 86 return methods.init.apply( this, [].slice.call( arguments, 0 ) ); // always pass an array 87 } 88 $.error( 'Method ' + method + ' does not exist on jQuery.lettering' ); 89 return this; 90 }; 91 92})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.