Added all the new documentation files.
This commit is contained in:
parent
49747af6b1
commit
f2d4bffcc7
9 changed files with 4614 additions and 0 deletions
58
docs/doc.js
Normal file
58
docs/doc.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
var rules = {
|
||||
self: "{$}",
|
||||
type: function(a){ /*console.log( a, types[a] );*/ return types[a]; },
|
||||
"self[*]": "<li><span class='type'><span title='{@type($.type)}'>{$.type}</span></span> <span class='fn'>" +
|
||||
"<a href='#{$.name}' class='name' title='{$.name}: {$.short}'>{$.name}</a>({$.params})</span>" +
|
||||
"<div class='short'>{$.short}</div><div class='more'><div class='desc'>{$.desc}</div>{$.examples}</div></li>",
|
||||
"self[*].params[*]": " <span class='arg-type' title='{@type($.type)}'>{$.type}</span> <span class='arg-name' title='{$.desc}'>{$.name}</span> ",
|
||||
"self[*].examples[*]": "<div class='example'><h5>Example:</h5><p>{$.desc}</p><pre>{$.code}</pre><b>HTML:</b><pre>{$.before}</pre><b>Result:</b><pre>{$.result}</pre></div>"
|
||||
};
|
||||
|
||||
var types = {
|
||||
jQuery: "A jQuery object.",
|
||||
Object: "A simple Javascript object. For example, it could be a String or a Number.",
|
||||
String: "A string of characters.",
|
||||
Number: "A numeric valid.",
|
||||
Element: "The Javascript object representation of a DOM Element.",
|
||||
Hash: "A Javascript object that contains key/value pairs in the form of properties and values.",
|
||||
"Array<Element>": "An Array of DOM Elements.",
|
||||
"Array<String>": "An Array of strings.",
|
||||
Function: "A reference to a Javascript function."
|
||||
};
|
||||
|
||||
function docsLoaded(docs) {
|
||||
// Make sure that there are no private functions
|
||||
docs = jQuery.grep( docs, "!a.private" )
|
||||
// Sort by function name
|
||||
.sort(function(a,b){
|
||||
if ( a.name < b.name ) return -1;
|
||||
else if ( a.name == b.name ) {
|
||||
// Sort by number of parameters
|
||||
if ( a.params.length < b.params.length ) return -1;
|
||||
else if ( a.params.length == b.params.length ) return 0;
|
||||
else return 1;
|
||||
} else return 1;
|
||||
});
|
||||
|
||||
// Put in the DOM, when it's ready
|
||||
$(document).ready(function(){
|
||||
$("#docs").html( jsonT( docs, rules ) );
|
||||
setTimeout(function(){
|
||||
$("#docs").pager( function(){return this.firstChild.nextSibling.nextSibling.firstChild.innerHTML;}, function(s,e){
|
||||
$(this).html( jsonT( docs.slice( s, e ), rules ) );
|
||||
/*$(this).slideUp("slow",function(){
|
||||
this.style.opacity = 1;
|
||||
this.style.width = "";
|
||||
this.style.height = "";
|
||||
$(this).html( jsonT( docs.slice( s, e ), rules ) );
|
||||
$(this).slideDown("slow");
|
||||
});*/
|
||||
$("span",this).filter("[@title]").addClass("tooltip").ToolTipDemo('#fff');
|
||||
$("a.name",this).click(function(){
|
||||
$("div.more,div.short",this.parentNode.parentNode).toggle();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}, 13);
|
||||
});
|
||||
}
|
92
docs/gen.pl
Normal file
92
docs/gen.pl
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
$Data::Dumper::Pair = ": ";
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
$Data::Dumper::Terse = 1;
|
||||
|
||||
open( F, $ARGV[0] || "../jquery-svn.js" );
|
||||
my $f = join('', <F>);
|
||||
close( F );
|
||||
|
||||
my @c;
|
||||
|
||||
while ( $f =~ /\/\*\*\s*(.*?)\s*\*\//gs ) {
|
||||
my $c = $1;
|
||||
$c =~ s/^\s*\* ?//mg;
|
||||
$c .= "!!!";
|
||||
my %ret;
|
||||
|
||||
$ret{ 'params' } = [];
|
||||
$ret{ 'examples' } = [];
|
||||
|
||||
#while ( $c =~ s/^\@(\S+)\s*<pre>(.*?)<\/pre>\n//ms ) {
|
||||
#print "PARAM '$1' '$2'\n";
|
||||
#}
|
||||
while ( $c =~ s/^\@(\S+) *(.*?)(?=\n\@|!!!)//ms ) {
|
||||
my $n = $1;
|
||||
my $v = $2;
|
||||
$v =~ s/\s*$//g;
|
||||
$v =~ s/^\s*//g;
|
||||
$v =~ s/&/&/g;
|
||||
$v =~ s/(\s\s+)/" " x length($1)/eg;
|
||||
$v =~ s/</</g;
|
||||
$v =~ s/>/>/g;
|
||||
$v =~ s/\n/<br>/g;
|
||||
$v = 1 if ( $v eq '' );
|
||||
|
||||
if ( $n eq 'param' ) {
|
||||
my ( $type, $name, @v ) = split( /\s+/, $v );
|
||||
$v = { "type" => $type, "name" => $name, "desc" => join(' ', @v) };
|
||||
$n = "params";
|
||||
} elsif ( $n eq 'example' ) {
|
||||
$v = { "code" => $v };
|
||||
$n = "examples";
|
||||
}
|
||||
|
||||
if ( $n eq 'desc' || $n eq 'before' || $n eq 'after' || $n eq 'result' ) {
|
||||
my @e = @{$ret{'examples'}};
|
||||
$e[ $#e ]{ $n } = $v;
|
||||
} else {
|
||||
|
||||
if ( exists $ret{ $n } ) {
|
||||
if ( ref $ret{ $n } eq 'ARRAY' ) {
|
||||
push( @{$ret{ $n }}, $v );
|
||||
} else {
|
||||
$ret{ $n } = [ $ret{ $n }, $v ];
|
||||
}
|
||||
} else {
|
||||
$ret{ $n } = $v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$c =~ s/\s*!!!$//;
|
||||
$c =~ s/\n\n/<br><br>/g;
|
||||
$c =~ s/\n/ /g;
|
||||
|
||||
$ret{ 'desc' } = $c;
|
||||
|
||||
if ( $c =~ /^(.*?(\.|$))/s ) {
|
||||
$ret{ 'short' } = $1;
|
||||
#$ret{ 'short' } =~ s/<br>/ /g;
|
||||
}
|
||||
|
||||
#print "###\n" . $c . "\n###\n";
|
||||
|
||||
if ( exists $ret{ 'name' } ) {
|
||||
push( @c, \%ret );
|
||||
}
|
||||
}
|
||||
|
||||
open( F, ">" . ($ARGV[1] || "jquery-docs-json.js") );
|
||||
print F Dumper( \@c );
|
||||
close( F );
|
||||
|
||||
$Data::Dumper::Indent = 0;
|
||||
|
||||
open( F, ">" . ($ARGV[2] || "jquery-docs-jsonp.js") );
|
||||
print F "docsLoaded(" . Dumper( \@c ) . ")";
|
||||
close( F );
|
18
docs/index.html
Normal file
18
docs/index.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>jQuery Documentation</title>
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
<script src="../jquery-svn.js"></script>
|
||||
<script src="tooltip.js"></script>
|
||||
<script src="pager.js"></script>
|
||||
<script src="jsont.js"></script>
|
||||
<script src="doc.js"></script>
|
||||
<script src="jquery-docs-jsonp.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>jQuery Docs » API</h1>
|
||||
<ul id="docs">
|
||||
<li>Loading...</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
4094
docs/jquery-docs-json.js
vendored
Normal file
4094
docs/jquery-docs-json.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
docs/jquery-docs-jsonp.js
vendored
Normal file
1
docs/jquery-docs-jsonp.js
vendored
Normal file
File diff suppressed because one or more lines are too long
58
docs/jsont.js
Normal file
58
docs/jsont.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
function jsonT(self, rules) {
|
||||
var T = {
|
||||
output: false,
|
||||
init: function() {
|
||||
for (var rule in rules)
|
||||
if (rule.substr(0,4) != "self")
|
||||
rules["self."+rule] = rules[rule];
|
||||
return this;
|
||||
},
|
||||
apply: function(expr) {
|
||||
var trf = function(s){ return s.replace(/{([A-Za-z0-9_\$\.\[\]\'@\(\)]+)}/g,
|
||||
function($0,$1){return T.processArg($1, expr);})},
|
||||
x = expr.replace(/\[[0-9]+\]/g, "[*]"), res;
|
||||
if (x in rules) {
|
||||
if (typeof(rules[x]) == "string")
|
||||
res = trf(rules[x]);
|
||||
else if (typeof(rules[x]) == "function")
|
||||
res = trf(rules[x](eval(expr)).toString());
|
||||
}
|
||||
else
|
||||
res = T.eval(expr);
|
||||
return res;
|
||||
},
|
||||
processArg: function(arg, parentExpr) {
|
||||
var expand = function(a,e){return (e=a.replace(/^\$/,e)).substr(0,4)!="self" ? ("self."+e) : e; },
|
||||
res = "";
|
||||
T.output = true;
|
||||
if (arg.charAt(0) == "@")
|
||||
res = eval(arg.replace(/@([A-za-z0-9_]+)\(([A-Za-z0-9_\$\.\[\]\']+)\)/,
|
||||
function($0,$1,$2){return "rules['self."+$1+"']("+expand($2,parentExpr)+")";}));
|
||||
else if (arg != "$")
|
||||
res = T.apply(expand(arg, parentExpr));
|
||||
else
|
||||
res = T.eval(parentExpr);
|
||||
T.output = false;
|
||||
return res;
|
||||
},
|
||||
eval: function(expr) {
|
||||
var v = eval(expr), res = "";
|
||||
if (typeof(v) != "undefined") {
|
||||
if (v instanceof Array) {
|
||||
for (var i=0; i<v.length; i++)
|
||||
if (typeof(v[i]) != "undefined")
|
||||
res += T.apply(expr+"["+i+"]");
|
||||
}
|
||||
else if (typeof(v) == "object") {
|
||||
for (var m in v)
|
||||
if (typeof(v[m]) != "undefined")
|
||||
res += T.apply(expr+"."+m);
|
||||
}
|
||||
else if (T.output)
|
||||
res += v;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
return T.init().apply("self");
|
||||
}
|
93
docs/pager.js
Normal file
93
docs/pager.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
$.fn.clone = function(){
|
||||
return this.pushStack( $.map(this,"a.cloneNode(true)"), arguments );
|
||||
};
|
||||
|
||||
|
||||
$.fn.pager = function(step,fn) {
|
||||
var types = {
|
||||
UL: "li",
|
||||
OL: "li",
|
||||
DL: "dt",
|
||||
TABLE: "tbody > tr"
|
||||
};
|
||||
|
||||
return this.each(function(){
|
||||
var pagedUI = this;
|
||||
var rows = $(types[this.nodeName], this);
|
||||
var curPage = 0;
|
||||
var names = [], num = [];
|
||||
|
||||
if ( !step || step.constructor != Function ) {
|
||||
step = step || 10;
|
||||
|
||||
if (rows.length > step)
|
||||
for ( var i = 0; i <= rows.length; i += step ) {
|
||||
names.push( names.length + 1 );
|
||||
num.push( [ i * step, step ] );
|
||||
}
|
||||
} else {
|
||||
var last;
|
||||
rows.each(function(){
|
||||
var l = step.apply( this ).substr(0,1);
|
||||
if ( l != last ) {
|
||||
names.push( l.toUpperCase() );
|
||||
var pre = num.length ? num[ num.length - 1 ][0] + num[ num.length - 1 ][1] : 0;
|
||||
|
||||
num.push( [ pre, 0 ] );
|
||||
last = l;
|
||||
}
|
||||
|
||||
num[ num.length - 1 ][1]++;
|
||||
});
|
||||
}
|
||||
|
||||
if ( names.length ) {
|
||||
var pager = $("<ul class='nav-page'></ul>");
|
||||
|
||||
for ( var i = 0; i < names.length; i++ )
|
||||
$("<a href=''></a>").rel( i ).html( names[i] ).click(function() {
|
||||
return handleCrop( this.rel );
|
||||
}).wrap("<li></li>").parent().appendTo(pager);
|
||||
|
||||
pager.insertBefore( this );
|
||||
|
||||
var prev = $("<a href=''>« Prev</a>").click(function(){
|
||||
return handleCrop( --curPage );
|
||||
}).wrap("<li class='prev'></li>").parent().prependTo(pager);
|
||||
|
||||
var next = $("<a href=''>Next »</a>").click(function(){
|
||||
return handleCrop( ++curPage );
|
||||
}).wrap("<li class='next'></li>").parent().appendTo(pager);
|
||||
|
||||
handleCrop( 0 );
|
||||
}
|
||||
|
||||
function handleCrop( page ) {
|
||||
curPage = page - 0;
|
||||
var s = num[ curPage ][0];
|
||||
var e = s + num[ curPage ][1];
|
||||
|
||||
if ( !curPage ) prev.hide();
|
||||
else prev.show();
|
||||
|
||||
if ( curPage == names.length - 1 ) next.hide();
|
||||
else next.show();
|
||||
|
||||
$("li",pager)
|
||||
.removeClass("cur")
|
||||
.eq( curPage + 1 )
|
||||
.addClass("cur");
|
||||
|
||||
rows
|
||||
.hide()
|
||||
.gt(s - 1).lt(e)
|
||||
.show()
|
||||
.end().end();
|
||||
|
||||
if ( fn )
|
||||
fn.apply( pagedUI, [ s, e ] );
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
128
docs/style.css
Normal file
128
docs/style.css
Normal file
|
@ -0,0 +1,128 @@
|
|||
html, body {
|
||||
background: #212121;
|
||||
font-family: Arial;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 15px auto;
|
||||
text-align: left;
|
||||
width: 600px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
ul.nav-page {
|
||||
margin: 15px auto;
|
||||
width: 600px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
ul.nav-page li {
|
||||
padding: 0 3px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
ul.nav-page li.cur a {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
ul.nav-page li a {
|
||||
font-size: 14px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
ul.nav-page li.prev {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
ul.nav-page li.next {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
ul.nav-page li.next a, ul.nav-page li.prev a {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul#docs {
|
||||
list-style: none;
|
||||
margin: 0 auto;
|
||||
padding: 5px;
|
||||
width: 600px;
|
||||
background: #FFF;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ul#docs li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
ul#docs li span.tooltip {
|
||||
border-bottom: 1px dashed #666;
|
||||
}
|
||||
|
||||
ul#docs li a.name {
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul#docs li span.type {
|
||||
display: block;
|
||||
float: left;
|
||||
color: #666;
|
||||
width: 100px;
|
||||
margin-right: 10px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
font-family: Courier;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
ul#docs li span.arg-type {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
ul#docs li div.short {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-left: 110px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
ul#docs span.fn {
|
||||
font-family: Courier;
|
||||
}
|
||||
|
||||
ul#docs div.tooltipdemo {
|
||||
font-size: 12px;
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
ul#docs li div.more {
|
||||
display: none;
|
||||
margin-left: 110px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
ul#docs li div.example {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
ul#docs li div.example h5 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
ul#docs li div.example pre {
|
||||
color: #4F4;
|
||||
background: #000;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
}
|
72
docs/tooltip.js
Normal file
72
docs/tooltip.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Description:
|
||||
|
||||
jQuery ToolTip Demo. Demo of how to add elements and get mouse coordinates
|
||||
There is also a ToolTip plugin found at http://www.eyecon.ro/interface/,
|
||||
which uses a CSS class to style the tooltip, but shows it below the input/anchor, rather than where the mouse is
|
||||
|
||||
Usage:
|
||||
|
||||
$(window).load(
|
||||
function()
|
||||
{
|
||||
$("a,input").ToolTipDemo('#fff');
|
||||
}
|
||||
);
|
||||
|
||||
Parameters:
|
||||
|
||||
bgcolour : Background colour
|
||||
*/
|
||||
$.fn.ToolTipDemo = function(bgcolour)
|
||||
{
|
||||
this.mouseover(
|
||||
function(e)
|
||||
{
|
||||
if((!this.title && !this.alt) && !this.tooltipset) return;
|
||||
// get mouse coordinates
|
||||
// based on code from http://www.quirksmode.org/js/events_properties.html
|
||||
var mouseX = e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft : 0);
|
||||
var mouseY = e.pageY || (e.clientY ? e.clientY + document.body.scrollTop : 0);
|
||||
mouseX += 10;
|
||||
mouseY += 10;
|
||||
bgcolour = bgcolour || "#eee";
|
||||
// if there is no sibling after this one, or the next siblings className is not tooltipdemo
|
||||
if(!this.nextSibling || this.nextSibling.className != "tooltipdemo")
|
||||
{
|
||||
// create a div and style it
|
||||
var div = document.createElement("div");
|
||||
$(div).css(
|
||||
{
|
||||
border: "2px outset #ddd",
|
||||
padding: "2px",
|
||||
backgroundColor: bgcolour,
|
||||
position: "absolute"
|
||||
})
|
||||
// add the title/alt attribute to it
|
||||
.html((this.title || this.alt)).addClass("tooltipdemo");
|
||||
this.title = "";
|
||||
this.alt = "";
|
||||
if(this.nextSibling)
|
||||
{
|
||||
this.parentNode.insertBefore(div, this.nextSibling);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parentNode.appendChild(div);
|
||||
}
|
||||
this.tooltipset = true;
|
||||
}
|
||||
$(this.nextSibling).show().css({left: mouseX + "px", top: mouseY + 3 + "px"});
|
||||
}
|
||||
).mouseout(
|
||||
function()
|
||||
{
|
||||
if(this.nextSibling && this.nextSibling.className == "tooltipdemo")
|
||||
{
|
||||
$(this.nextSibling).hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
return this;
|
||||
}
|
Loading…
Reference in a new issue