From c5336db4a661246ecc3d0d62d79be4d07493a296 Mon Sep 17 00:00:00 2001 From: Messerbill Date: Tue, 9 Jun 2015 14:10:38 +0200 Subject: [PATCH] added lib_lettering --- autoload.inc | 3 + lib/CONTRIBUTING.md | 13 +++ lib/README.md | 58 ++++++++++++++ lib/bower.json | 12 +++ lib/examples/index.html | 135 +++++++++++++++++++++++++++++++ lib/examples/style.css | 171 ++++++++++++++++++++++++++++++++++++++++ lib/jquery.lettering.js | 72 +++++++++++++++++ lib_lettering.php | 10 +++ 8 files changed, 474 insertions(+) create mode 100644 autoload.inc create mode 100644 lib/CONTRIBUTING.md create mode 100644 lib/README.md create mode 100644 lib/bower.json create mode 100644 lib/examples/index.html create mode 100644 lib/examples/style.css create mode 100644 lib/jquery.lettering.js create mode 100644 lib_lettering.php diff --git a/autoload.inc b/autoload.inc new file mode 100644 index 0000000..01503d0 --- /dev/null +++ b/autoload.inc @@ -0,0 +1,3 @@ +` + +### Individual Letter Control with Lettering.js +We'll start with some really basic markup: + +

Some Title

+ +After including `jQuery 1.6.2+`, [download and include the minified version of Lettering.js](http://github.com/davatron5000/Lettering.js/downloads), then a script block with the magical `.lettering()` method: + + + +The resulting code will churn your `.fancy_title` and output the following: + +

+ S + o + m + e + + T + i + t + l + e +

+ +Magical. Now the text is easy to manipulate in your CSS using an ordinal `.char#` pattern. This plugin assumes basic counting skills, but it's a pretty fast and easy way to get control over every letter. + +### Letters, words, lines, and more! + +There you have it, but Lettering.js does even more! Lettering.js has the ability to split `words` and `lines` as well. If you want more information on how you can get radical with text, read the Lettering.js Wiki: + +[https://github.com/davatron5000/Lettering.js/wiki](https://github.com/davatron5000/Lettering.js/wiki) + +#### Best Practices +We've found this to be a pretty quick and elegant solution to create typographical CSS3 posters. It's also a great solution for really custom type headings, while keeping the text selectable. Be smart and use sparingly. You'll probably break your browser if you try to wrap every letter on your page in a `span` tag, so don't do that. Look to use this in your Headings, Blockquotes, Asides, etc. + +#### Kern Well +If you're going through the trouble to load a fancy font and that word or phrase is the largest on the site, then it's important for it to be kerned well. With Lettering.js, kerning is a breeze. You can simply use `$("#id-of-what-i-want-to-kern").lettering();` and then on each `.char#`, you can set relative position or left/right margin. Works like a charm. + +### Accessibility + +Lettering.js is now accessible by default. It uses an `aria-label` on the parent element and `aria-hidden` on each of the children to prevent screenreaders from pausing while reading each individual characters or words. + +### Non-Javascript Fallback +As with any kind of Javascript, have a fall back plan in case the user doesn't have javascript enabled. The bottom line is up to you, my bottom line would be "legible and on the screen". Also, use `lettering.min.js` [Download the Minified Version of Lettering.js here](http://github.com/davatron5000/Lettering.js/downloads) + +#### Performance Anti-Pattern +Web performance patterns advise that you put Javascripts at the bottom of your page before your `` tag. There is an unfortunate side effect where you may experiences a [FOUT (Flash of Unstyled Text)](http://paulirish.com/2009/fighting-the-font-face-fout/) when you're manipulating your text after the DOM has loaded. Unfortunately, we found the best solution to avoid/minimize the FOUT caused by this plugin is to put your scripts (jQuery, Lettering.js) in the document ``. On the one hand, your page will load slower. On the other hand, a flash/restyling makes your site feel slow. Users might ultimately feel the site is faster if they don't see the FOUT. + +### Download, Fork, Commit, Please. +We really want Lettering.js to be a quality helper for web typography. If you have any feedback or suggestions, please leave those over on the Github. We're excited about typography on the web and want to help make it print quality. diff --git a/lib/bower.json b/lib/bower.json new file mode 100644 index 0000000..73b1a5d --- /dev/null +++ b/lib/bower.json @@ -0,0 +1,12 @@ +{ + "name": "letteringjs", + "version": "0.7.0", + "main": "jquery.lettering.js", + "ignore": [ + "examples", + "**/.*" + ], + "dependencies": { + "jquery": ">= 1.6.2" + } +} diff --git a/lib/examples/index.html b/lib/examples/index.html new file mode 100644 index 0000000..97283ce --- /dev/null +++ b/lib/examples/index.html @@ -0,0 +1,135 @@ + + + + + + + + + + + + Lettering.js Examples + + + + + + + + + + + + + + + +
+
+

Lettering.JS

+

The following are some hokey examples of how you can implement LETTERING.JS. +

+ +
+
+

Letters

+

The HTML

+
	<div id="demo1" class="demo">
+  <h1>Rainbow</h1>
+</div>
+
+ +

The jQuery

+
$(document).ready(function() {
+  $("#demo1 h1").lettering();
+});
+
+ +

The Result

+
+

Rainbow

+
+ +
+ +
+

Words

+
$("#demo2 h1").lettering('words');
+ +

The Result

+
+

Hi, Multi Color

+
+
+ +
+

Lines

+
$("#demo3 p").lettering('lines');
+ +

The Result

+
+

This is an amazing
Revolution in Typography.
The possibilities are endless:
Coloring, Vertical spacing, and Kerning.

+
+
+ +
+

Advanced #1: Chaining 2 Methods

+
$("#demo4 h1").lettering('words').children("span").lettering();
+

The Result

+
+

Double Rainbow

+
+
+ +
+

Advanced #2: Chaining and Styling

+
$("#demo5 h1").lettering()
+	.children("span").css({'display':'inline-block', '-webkit-transform':'rotate(-25deg)'});
+

The Result

+
+

WOOOoo!

+
+
+ +
+ + +
+ + + diff --git a/lib/examples/style.css b/lib/examples/style.css new file mode 100644 index 0000000..0d9cb55 --- /dev/null +++ b/lib/examples/style.css @@ -0,0 +1,171 @@ +html, body, div, span, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, +del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, +b, i, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, +footer, header, hgroup, menu, nav, section, summary, +time, mark, audio, video { + margin:0; + padding:0; + border:0; + outline:0; + font-size:100%; + vertical-align:baseline; + background:transparent; +} + +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display:block; +} + +nav ul { list-style:none; } + +blockquote, q { quotes:none; } + +blockquote:before, blockquote:after, +q:before, q:after { content:''; content:none; } + +a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; } + +ins { background-color:#ff9; color:#000; text-decoration:none; } + +mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; } + +del { text-decoration: line-through; } + +abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; } + +/* tables still need cellspacing="0" in the markup */ +table { border-collapse:collapse; border-spacing:0; } + +hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; } + +input, select { vertical-align:middle; } +/* END RESET CSS */ + +body { font:13px/1.231 sans-serif; *font-size:small; } /* hack retained to preserve specificity */ + +select, input, textarea, button { font:99% sans-serif; } +pre, code, kbd, samp { font-family: monospace, sans-serif; } + +body, select, input, textarea { + color: #444; +} + +h1,h2,h3,h4,h5,h6 { font-weight: bold; } +html { overflow-y: scroll; } + +a:hover, a:active { outline: none; } +a, a:active, a:visited { color: #607890; } +a:hover { color: #036; } + +ul, ol { margin-left: 1.8em; } +ol { list-style-type: decimal; } + +small { font-size: 85%; } +strong, th { font-weight: bold; } + +td, td img { vertical-align: top; } + +sub { vertical-align: sub; font-size: smaller; } +sup { vertical-align: super; font-size: smaller; } + +pre { + padding: 15px; + white-space: pre; /* CSS2 */ + white-space: pre-wrap; /* CSS 2.1 */ + white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */ + word-wrap: break-word; /* IE */ +} + +textarea { overflow: auto; } +.ie6 legend, .ie7 legend { margin-left: -7px; } +input[type="radio"] { vertical-align: text-bottom; } +input[type="checkbox"] { vertical-align: bottom; } +.ie7 input[type="checkbox"] { vertical-align: baseline; } +.ie6 input { vertical-align: text-bottom; } +label, input[type=button], input[type=submit], button { cursor: pointer; } +button, input, select, textarea { margin: 0; } +input:valid, textarea:valid { } +input:invalid, textarea:invalid { + border-radius: 1px; + -moz-box-shadow: 0px 0px 5px red; + -webkit-box-shadow: 0px 0px 5px red; + box-shadow: 0px 0px 5px red; +} +.no-boxshadow input:invalid, +.no-boxshadow textarea:invalid { background-color: #f0dddd; } +::-moz-selection{ background: #FF5E99; color:#fff; text-shadow: none; } +::selection { background:#FF5E99; color:#fff; text-shadow: none; } + +a:link { -webkit-tap-highlight-color: #FF5E99; } + +button { width: auto; overflow: visible; } + +.ie7 img { -ms-interpolation-mode: bicubic; } + +.hidden { display: none; visibility: hidden; } + +.visuallyhidden { position: absolute !important; + clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ + clip: rect(1px, 1px, 1px, 1px); } +.invisible { visibility: hidden; } +.clearfix:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; } +.clearfix { zoom: 1; } + + +body { background:#baddad;} + +#container { + width: 800px; + margin:50px auto 200px; + padding:50px; + background:#fff; +} + +pre { + display:block; + border:1px solid #ccc; + background:#f8f8f8; + margin-bottom:2em; +} + +h1, h2, h3, h4 { } +h1 { font-size: 48px; text-transform:uppercase; margin-bottom: 0em; } +h2 { font-size: 28px; margin-bottom: 0.5em; } +h3 { font-size: 34px; margin-bottom: 0.5em; } +h4 { margin-bottom: 0.5em; } + +section { margin-bottom: 4em; } + +p { margin-bottom:1.5em;} + +@media print { + * { background: transparent !important; color: #444 !important; text-shadow: none !important; } + + a, a:visited { color: #444 !important; text-decoration: underline; } + + a:after { content: " (" attr(href) ")"; } + + abbr:after { content: " (" attr(title) ")"; } + + .ir a:after { content: ""; } /* Don't show links for images */ + + pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } + + thead { display: table-header-group; } /* css-discuss.incutio.com/wiki/Printing_Tables */ + + tr, img { page-break-inside: avoid; } + + @page { margin: 0.5cm; } + + p, h2, h3 { orphans: 3; widows: 3; } + + h2, h3{ page-break-after: avoid; } +} \ No newline at end of file diff --git a/lib/jquery.lettering.js b/lib/jquery.lettering.js new file mode 100644 index 0000000..70aae46 --- /dev/null +++ b/lib/jquery.lettering.js @@ -0,0 +1,72 @@ +/*global jQuery */ +/*! +* Lettering.JS 0.7.0 +* +* Copyright 2010, Dave Rupert http://daverupert.com +* Released under the WTFPL license +* http://sam.zoy.org/wtfpl/ +* +* Thanks to Paul Irish - http://paulirish.com - for the feedback. +* +* Date: Mon Sep 20 17:14:00 2010 -0600 +*/ +(function($){ + function injector(t, splitter, klass, after) { + var text = t.text() + , a = text.split(splitter) + , inject = ''; + if (a.length) { + $(a).each(function(i, item) { + inject += ''+after; + }); + t.attr('aria-label',text) + .empty() + .append(inject) + + } + } + + + var methods = { + init : function() { + + return this.each(function() { + injector($(this), '', 'char', ''); + }); + + }, + + words : function() { + + return this.each(function() { + injector($(this), ' ', 'word', ' '); + }); + + }, + + 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 + // md5 hash string, it will fail because you're being ridiculous. + injector($(this).children("br").replaceWith(r).end(), r, 'line', ''); + }); + + } + }; + + $.fn.lettering = function( method ) { + // Method calling logic + if ( method && methods[method] ) { + return methods[ method ].apply( this, [].slice.call( arguments, 1 )); + } else if ( method === 'letters' || ! method ) { + return methods.init.apply( this, [].slice.call( arguments, 0 ) ); // always pass an array + } + $.error( 'Method ' + method + ' does not exist on jQuery.lettering' ); + return this; + }; + +})(jQuery); diff --git a/lib_lettering.php b/lib_lettering.php new file mode 100644 index 0000000..5e18ae0 --- /dev/null +++ b/lib_lettering.php @@ -0,0 +1,10 @@ +https://github.com/davatron5000/Lettering.js (commit: 48388649e0)';} +} \ No newline at end of file