added lib_lettering
This commit is contained in:
commit
c5336db4a6
3
autoload.inc
Normal file
3
autoload.inc
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'LIB');
|
||||
\LIB\lib_controll::register('\LIB\lib_lettering');
|
||||
13
lib/CONTRIBUTING.md
Normal file
13
lib/CONTRIBUTING.md
Normal file
@ -0,0 +1,13 @@
|
||||
## Submitting issues
|
||||
|
||||
### Reduced test case required
|
||||
|
||||
All bug reports and problem issues require a reduced test case. See [CSS Tricks - Reduced Test Cases](http://css-tricks.com/reduced-test-cases/) on why they _"are the absolute, ... number one way to troubleshoot bugs."_
|
||||
|
||||
+ A reduced test case is an isolated example that demonstrates the bug or issue.
|
||||
+ It contains the bare minimum HTML, CSS, and JavaScript required to demonstrate the bug. No extra functionality or styling.
|
||||
+ A link to your site is **not** a reduced test case.
|
||||
+ A [CodePen](http://codepen.io) is preferred so we can help you fix an error.
|
||||
+ Until you provide a reduced test case, your issue will be closed.
|
||||
|
||||
This guideline may seem a little harsh, but it helps dramatically. Reduced test cases help you identify the issue at hand and understand your own code. On our side, they greatly reduce the amount of time spent resolving the issue.
|
||||
58
lib/README.md
Normal file
58
lib/README.md
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
## Lettering.js, a jQuery plugin for radical Web Typography
|
||||
We developed a lightweight, easy to use Javascript `span` injector for radical Web Typography, we're calling it "lettering-jay-ess", and we're releasing it today for free over on Github. Let me demo it for you: `</stevejobs>`
|
||||
|
||||
### Individual Letter Control with Lettering.js
|
||||
We'll start with some really basic markup:
|
||||
|
||||
<h1 class="fancy_title">Some Title</h1>
|
||||
|
||||
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:
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(".fancy_title").lettering();
|
||||
});
|
||||
</script>
|
||||
|
||||
The resulting code will churn your `.fancy_title` and output the following:
|
||||
|
||||
<h1 class="fancy_title">
|
||||
<span class="char1">S</span>
|
||||
<span class="char2">o</span>
|
||||
<span class="char3">m</span>
|
||||
<span class="char4">e</span>
|
||||
<span class="char5"></span>
|
||||
<span class="char6">T</span>
|
||||
<span class="char7">i</span>
|
||||
<span class="char8">t</span>
|
||||
<span class="char9">l</span>
|
||||
<span class="char10">e</span>
|
||||
</h1>
|
||||
|
||||
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 `</body>` 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 `<head>`. 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.
|
||||
12
lib/bower.json
Normal file
12
lib/bower.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "letteringjs",
|
||||
"version": "0.7.0",
|
||||
"main": "jquery.lettering.js",
|
||||
"ignore": [
|
||||
"examples",
|
||||
"**/.*"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">= 1.6.2"
|
||||
}
|
||||
}
|
||||
135
lib/examples/index.html
Normal file
135
lib/examples/index.html
Normal file
@ -0,0 +1,135 @@
|
||||
<!doctype html>
|
||||
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
|
||||
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
|
||||
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
|
||||
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
|
||||
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
|
||||
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<title>Lettering.js Examples</title>
|
||||
<meta name="description" content="A jQuery Plugin that allows you to style each individual letter and more.">
|
||||
<meta name="author" content="Dave Rupert">
|
||||
|
||||
<meta name="viewport" content="width=device-width; initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css" type="text/css" media="screen"></link>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
.demo {
|
||||
padding: 50px;
|
||||
border:1px solid #ccc;
|
||||
font-weight:bold;
|
||||
color: red;
|
||||
background:#d0d0d0;
|
||||
font-size:20px;
|
||||
line-height:1.5;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.demo h1 { font-size:72px; text-transform:uppercase; margin-bottom:0px;}
|
||||
.char2,
|
||||
#demo2 .word2,
|
||||
.line2 { color: orange; }
|
||||
.char3,
|
||||
.word3,
|
||||
.line3 { color: yellow; }
|
||||
.char4,
|
||||
.line4 { color: blue; }
|
||||
.char5 { color: green; }
|
||||
.char6 { color: indigo; }
|
||||
.char7 { color: violet; }
|
||||
</style>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
||||
<script src="../jquery.lettering.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#demo1 h1").lettering();
|
||||
$("#demo2 h1").lettering('words');
|
||||
$("#demo3 p").lettering('lines');
|
||||
$("#demo4 h1").lettering('words').children("span").lettering();
|
||||
$("#demo5 h1").lettering().children("span").css({'display':'inline-block', '-webkit-transform':'rotate(-25deg)'});
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
<header>
|
||||
<h1 id="thebrand">Lettering.JS</h1>
|
||||
<p>The following are some hokey examples of how you can implement LETTERING.JS.
|
||||
</header>
|
||||
|
||||
<article id="main">
|
||||
<section id='lettering-demo'>
|
||||
<h2>Letters</h2>
|
||||
<h4>The HTML</h4>
|
||||
<pre><code> <div id="demo1" class="demo">
|
||||
<h1>Rainbow</h1>
|
||||
</div>
|
||||
</code></pre>
|
||||
|
||||
<h4>The jQuery</h4>
|
||||
<pre><code>$(document).ready(function() {
|
||||
$("#demo1 h1").lettering();
|
||||
});
|
||||
</code></pre>
|
||||
|
||||
<h4>The Result</h4>
|
||||
<div id="demo1" class="demo">
|
||||
<h1>Rainbow</h1>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section id='words-demo'>
|
||||
<h2>Words</h2>
|
||||
<code><pre>$("#demo2 h1").lettering('words');</pre></code>
|
||||
|
||||
<h4>The Result</h4>
|
||||
<div id="demo2" class="demo">
|
||||
<h1>Hi, Multi Color</h1>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id='lines-demo'>
|
||||
<h2>Lines</h2>
|
||||
<code><pre>$("#demo3 p").lettering('lines');</pre></code>
|
||||
|
||||
<h4>The Result</h4>
|
||||
<div id="demo3" class="demo">
|
||||
<p>This is an amazing<br/> Revolution in Typography. <br/> The possibilities are endless: <br/> Coloring, Vertical spacing, and Kerning.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id='advanced1-demo'>
|
||||
<h2>Advanced #1: Chaining 2 Methods</h2>
|
||||
<code><pre>$("#demo4 h1").lettering('words').children("span").lettering();</pre></code>
|
||||
<h4>The Result</h4>
|
||||
<div id="demo4" class="demo">
|
||||
<h1>Double Rainbow</h1>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id='advanced2-demo'>
|
||||
<h2>Advanced #2: Chaining and Styling</h2>
|
||||
<code><pre>$("#demo5 h1").lettering()
|
||||
.children("span").css({'display':'inline-block', '-webkit-transform':'rotate(-25deg)'});</pre></code>
|
||||
<h4>The Result</h4>
|
||||
<div id="demo5" class="demo">
|
||||
<h1>WOOOoo!</h1>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
|
||||
<footer>
|
||||
<p>©2010 Dave Rupert <a href="http://daverupert.com">http://daverupert.com</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
171
lib/examples/style.css
Normal file
171
lib/examples/style.css
Normal file
@ -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; }
|
||||
}
|
||||
72
lib/jquery.lettering.js
Normal file
72
lib/jquery.lettering.js
Normal file
@ -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 += '<span class="'+klass+(i+1)+'" aria-hidden="true">'+item+'</span>'+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 <br/> tag consistently across browsers,
|
||||
// (*ahem* IE *ahem*), we replace all <br/> 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);
|
||||
10
lib_lettering.php
Normal file
10
lib_lettering.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace LIB;
|
||||
class lib_lettering extends \LIB\lib_js{
|
||||
public static function get_class(){
|
||||
return self::class;}
|
||||
public static function js_path(){
|
||||
return \SYSTEM\WEBPATH(new \SYSTEM\PLIB(),'tablesorter/lib/jquery.lettering.js');}
|
||||
public static function version(){
|
||||
return '<a href="https://github.com/davatron5000/Lettering.js" target="_blank">https://github.com/davatron5000/Lettering.js</a> (commit: 48388649e0)';}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user