Web site meant to accompany a virtual machine setup specific to ProjPad.

jquery.lettering.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*global jQuery */
  2. /*!
  3. * Lettering.JS 0.6.1
  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 a = t.text().split(splitter), inject = '';
  16. if (a.length) {
  17. $(a).each(function(i, item) {
  18. inject += '<span class="'+klass+(i+1)+'">'+item+'</span>'+after;
  19. });
  20. t.empty().append(inject);
  21. }
  22. }
  23. var methods = {
  24. init : function() {
  25. return this.each(function() {
  26. injector($(this), '', 'char', '');
  27. });
  28. },
  29. words : function() {
  30. return this.each(function() {
  31. injector($(this), ' ', 'word', ' ');
  32. });
  33. },
  34. lines : function() {
  35. return this.each(function() {
  36. var r = "eefec303079ad17405c889e092e105b0";
  37. // Because it's hard to split a <br/> tag consistently across browsers,
  38. // (*ahem* IE *ahem*), we replaces all <br/> instances with an md5 hash
  39. // (of the word "split"). If you're trying to use this plugin on that
  40. // md5 hash string, it will fail because you're being ridiculous.
  41. injector($(this).children("br").replaceWith(r).end(), r, 'line', '');
  42. });
  43. }
  44. };
  45. $.fn.lettering = function( method ) {
  46. // Method calling logic
  47. if ( method && methods[method] ) {
  48. return methods[ method ].apply( this, [].slice.call( arguments, 1 ));
  49. } else if ( method === 'letters' || ! method ) {
  50. return methods.init.apply( this, [].slice.call( arguments, 0 ) ); // always pass an array
  51. }
  52. $.error( 'Method ' + method + ' does not exist on jQuery.lettering' );
  53. return this;
  54. };
  55. })(jQuery);