mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
First commit of the new doc system.
This commit is contained in:
parent
41c94b4688
commit
8cef646d17
51
attr/attr.js
51
attr/attr.js
@ -1,51 +0,0 @@
|
||||
|
||||
var pos = [
|
||||
"height", "width", "top", "left", "bottom", "right",
|
||||
"paddingTop", "paddingRight", "paddingBottom", "paddingLeft",
|
||||
"marginTop", "marginRight", "marginBottom", "marginLeft",
|
||||
"lineHeight", "maxWidth", "maxHeight", "minWidth", "minHeight",
|
||||
"textIndent", "fontSize"
|
||||
];
|
||||
|
||||
for ( var i = 0; i < pos.length; i++ ) {
|
||||
(function(){
|
||||
var o = pos[i];
|
||||
$.fn[o] = function(a){
|
||||
return a ?
|
||||
this.css(o,a) :
|
||||
parseInt( this.css(o) );
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
var posArg = [
|
||||
"clientLeft", "clientTop", "clientWidth", "clientHeight",
|
||||
"offsetLeft", "offsetTop", "offsetWidth", "offsetHeight",
|
||||
"scrollLeft", "scrollTop", "scrollWidth", "scrollHeight"
|
||||
];
|
||||
|
||||
for ( var i = 0; i < posArg.length; i++ ) {
|
||||
(function(){
|
||||
var o = posArg[i];
|
||||
$.fn[o] = function(a){
|
||||
return a ? this.each(function(){
|
||||
this[o] = parseInt( a );
|
||||
}) : this.size() > 0 ?
|
||||
this.get(0)[o] :
|
||||
null;
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
$.fn.text = function(e) {
|
||||
e = e || this.cur;
|
||||
var t = "";
|
||||
for ( var j = 0; j < e.length; j++ ) {
|
||||
for ( var i = 0; i < e[j].childNodes.length; i++ ) {
|
||||
t += e[j].childNodes[i].nodeType != 1 ?
|
||||
e[j].childNodes[i].nodeValue :
|
||||
$.fn.text(e[j].childNodes[i].childNodes);
|
||||
}
|
||||
}
|
||||
return t;
|
||||
};
|
2
docs/build.sh
Executable file
2
docs/build.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
java -jar build/js.jar build/build.js
|
BIN
docs/build/js.jar
vendored
Normal file
BIN
docs/build/js.jar
vendored
Normal file
Binary file not shown.
1
docs/data/jquery-docs-json.js
vendored
Normal file
1
docs/data/jquery-docs-json.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/data/jquery-docs-jsonp.js
vendored
Normal file
1
docs/data/jquery-docs-jsonp.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2645
docs/data/jquery-docs-xml.xml
Normal file
2645
docs/data/jquery-docs-xml.xml
Normal file
File diff suppressed because it is too large
Load Diff
80
docs/events/gen-events.pl
Normal file
80
docs/events/gen-events.pl
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
my @stuff = split(",", "blur,focus,load,resize,scroll,unload,click,dblclick," .
|
||||
"mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," .
|
||||
"submit,keydown,keypress,keyup,error");
|
||||
|
||||
foreach (@stuff) {
|
||||
|
||||
print qq~
|
||||
/**
|
||||
* Bind a function to the $_ event of each matched element.
|
||||
*
|
||||
* \@example \$("p").$_( function() { alert("Hello"); } );
|
||||
* \@before <p>Hello</p>
|
||||
* \@result <p on$_="alert('Hello');">Hello</p>
|
||||
*
|
||||
* \@name $_
|
||||
* \@type jQuery
|
||||
* \@param Function fn A function to bind to the $_ event on each of the matched elements.
|
||||
* \@cat Events
|
||||
*/
|
||||
|
||||
/**
|
||||
* Trigger the $_ event of each matched element. This causes all of the functions
|
||||
* that have been bound to thet $_ event to be executed.
|
||||
*
|
||||
* \@example \$("p").$_();
|
||||
* \@before <p on$_="alert('Hello');">Hello</p>
|
||||
* \@result alert('Hello');
|
||||
*
|
||||
* \@name $_
|
||||
* \@type jQuery
|
||||
* \@cat Events
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bind a function to the $_ event of each matched element, which will only be executed once.
|
||||
* Unlike a call to the normal .$_() method, calling .one$_() causes the bound function to be
|
||||
* only executed the first time it is triggered, and never again (unless it is re-bound).
|
||||
*
|
||||
* \@example \$("p").one$_( function() { alert("Hello"); } );
|
||||
* \@before <p on$_="alert('Hello');">Hello</p>
|
||||
* \@result alert('Hello'); // Only executed for the first $_
|
||||
*
|
||||
* \@name one$_
|
||||
* \@type jQuery
|
||||
* \@param Function fn A function to bind to the $_ event on each of the matched elements.
|
||||
* \@cat Events
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes a bound $_ event from each of the matched
|
||||
* elements. You must pass the identical function that was used in the original
|
||||
* bind method.
|
||||
*
|
||||
* \@example \$("p").un$_( myFunction );
|
||||
* \@before <p on$_="myFunction">Hello</p>
|
||||
* \@result <p>Hello</p>
|
||||
*
|
||||
* \@name un$_
|
||||
* \@type jQuery
|
||||
* \@param Function fn A function to unbind from the $_ event on each of the matched elements.
|
||||
* \@cat Events
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes all bound $_ events from each of the matched elements.
|
||||
*
|
||||
* \@example \$("p").un$_();
|
||||
* \@before <p on$_="alert('Hello');">Hello</p>
|
||||
* \@result <p>Hello</p>
|
||||
*
|
||||
* \@name un$_
|
||||
* \@type jQuery
|
||||
* \@cat Events
|
||||
*/
|
||||
~;
|
||||
|
||||
|
||||
}
|
92
docs/gen.pl
92
docs/gen.pl
@ -1,92 +0,0 @@
|
||||
#!/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 );
|
@ -1,18 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>jQuery Documentation</title>
|
||||
<link rel="stylesheet" href="style/style.css"/>
|
||||
<script src="../jquery-svn.js"></script>
|
||||
<script src="js/tooltip.js"></script>
|
||||
<script src="js/pager.js"></script>
|
||||
<script src="js/jsont.js"></script>
|
||||
<script src="js/doc.js"></script>
|
||||
<script src="data/jquery-docs-jsonp.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>jQuery Docs » API</h1>
|
||||
<ul id="docs">
|
||||
<li>Loading...</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
2646
docs/index.xml
Normal file
2646
docs/index.xml
Normal file
File diff suppressed because it is too large
Load Diff
4094
docs/jquery-docs-json.js
vendored
4094
docs/jquery-docs-json.js
vendored
File diff suppressed because it is too large
Load Diff
1
docs/jquery-docs-jsonp.js
vendored
1
docs/jquery-docs-jsonp.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,8 @@ var rules = {
|
||||
"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> ",
|
||||
trim: function(a){ console.log( a ); return !a || a.replace(/, $/); },
|
||||
"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>"
|
||||
};
|
||||
|
||||
@ -20,39 +21,14 @@ var types = {
|
||||
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;
|
||||
$(document).ready(function(){
|
||||
$("span[@title]").addClass("tooltip").ToolTipDemo('#fff');
|
||||
$("a.name").click(function(){
|
||||
$("div.more,div.short",this.parentNode.parentNode).toggle().find("div.desc",function(){
|
||||
$(this).html( $(this).html().replace(/\n\n/g, "<br/><br/>") );
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
|
||||
$("#docs").alphaPager( 1 );
|
||||
});
|
@ -1,19 +1,39 @@
|
||||
$.fn.clone = function(){
|
||||
return this.pushStack( $.map(this,"a.cloneNode(true)"), arguments );
|
||||
$.fn.alphaPager = function(fn,type) {
|
||||
type = type || "char";
|
||||
|
||||
if ( fn == undefined ) {
|
||||
fn = function(a){ return _clean( $.fn.text.apply( a.childNodes ) ); };
|
||||
} else if ( fn.constructor == Number ) {
|
||||
var n = fn;
|
||||
fn = function(a){ return _clean( $.fn.text.apply( [a.childNodes[ n ]] ) ); };
|
||||
}
|
||||
|
||||
function _clean(a){
|
||||
switch (type) {
|
||||
case "char":
|
||||
return a.substr(0,1).toUpperCase();
|
||||
case "word":
|
||||
return /^([a-z0-9]+)/.exec(a)[1];
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
return this.pager( fn );
|
||||
};
|
||||
|
||||
|
||||
$.fn.pager = function(step,fn) {
|
||||
$.fn.pager = function(step) {
|
||||
var types = {
|
||||
UL: "li",
|
||||
OL: "li",
|
||||
DL: "dt",
|
||||
TABLE: "tbody > tr"
|
||||
TABLE: "tr"
|
||||
};
|
||||
|
||||
return this.each(function(){
|
||||
var pagedUI = this;
|
||||
var rows = $(types[this.nodeName], this);
|
||||
var type = types[this.nodeName];
|
||||
var pagedUI = type == "tr" ? $("tbody",this) : $(this);
|
||||
var rows = $(type, pagedUI);
|
||||
var curPage = 0;
|
||||
var names = [], num = [];
|
||||
|
||||
@ -23,14 +43,14 @@ $.fn.pager = function(step,fn) {
|
||||
if (rows.length > step)
|
||||
for ( var i = 0; i <= rows.length; i += step ) {
|
||||
names.push( names.length + 1 );
|
||||
num.push( [ i * step, step ] );
|
||||
num.push( [ i, step ] );
|
||||
}
|
||||
} else {
|
||||
var last;
|
||||
rows.each(function(){
|
||||
var l = step.apply( this ).substr(0,1);
|
||||
var l = step( this );
|
||||
if ( l != last ) {
|
||||
names.push( l.toUpperCase() );
|
||||
names.push( l );
|
||||
var pre = num.length ? num[ num.length - 1 ][0] + num[ num.length - 1 ][1] : 0;
|
||||
|
||||
num.push( [ pre, 0 ] );
|
||||
@ -41,8 +61,11 @@ $.fn.pager = function(step,fn) {
|
||||
});
|
||||
}
|
||||
|
||||
if ( names.length ) {
|
||||
var pager = $("<ul class='nav-page'></ul>");
|
||||
if ( names.length > 1 ) {
|
||||
var pager = $(this).prev("ul.nav-page").empty();
|
||||
|
||||
if ( !pager.length )
|
||||
pager = $("<ul class='nav-page'></ul>");
|
||||
|
||||
for ( var i = 0; i < names.length; i++ )
|
||||
$("<a href=''></a>").rel( i ).html( names[i] ).click(function() {
|
||||
@ -65,7 +88,7 @@ $.fn.pager = function(step,fn) {
|
||||
function handleCrop( page ) {
|
||||
curPage = page - 0;
|
||||
var s = num[ curPage ][0];
|
||||
var e = s + num[ curPage ][1];
|
||||
var e = num[ curPage ][1];
|
||||
|
||||
if ( !curPage ) prev.hide();
|
||||
else prev.show();
|
||||
@ -78,14 +101,9 @@ $.fn.pager = function(step,fn) {
|
||||
.eq( curPage + 1 )
|
||||
.addClass("cur");
|
||||
|
||||
rows
|
||||
.hide()
|
||||
.gt(s - 1).lt(e)
|
||||
.show()
|
||||
.end().end();
|
||||
|
||||
if ( fn )
|
||||
fn.apply( pagedUI, [ s, e ] );
|
||||
pagedUI.empty().append(
|
||||
jQuery.merge( rows, [] ).slice( s, s + e )
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
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");
|
||||
}
|
67
docs/style/docs.xsl
Normal file
67
docs/style/docs.xsl
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:template match="/*">
|
||||
<html>
|
||||
<head>
|
||||
<title>jQuery Docs - API</title>
|
||||
<link rel="stylesheet" href="style/style.css"/>
|
||||
<script src="../jquery-svn.js"></script>
|
||||
<script src="js/tooltip.js"></script>
|
||||
<script src="js/pager.js"></script>
|
||||
<script src="js/doc2.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>jQuery Docs - API</h1>
|
||||
<ul id="docs">
|
||||
<xsl:for-each select="method[not(@private)]">
|
||||
<xsl:sort select="@name"/>
|
||||
<xsl:sort select="count(params)"/>
|
||||
<li>
|
||||
<span class='type'><span title='TYPE' class='tooltip'><xsl:value-of select="@type"/></span></span>
|
||||
<span class='fn'>
|
||||
<a href='#{@name}' class='name' title=''><xsl:value-of select="@name"/></a>
|
||||
<xsl:if test="not(@property)">(
|
||||
<xsl:for-each select="params">
|
||||
<span class='arg-type tooltip' title='TYPE'><xsl:value-of select="@type"/></span><xsl:text> </xsl:text>
|
||||
<span class='arg-name tooltip' title='{@desc}'><xsl:value-of select="@name"/></span>
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:if test="@any"> or </xsl:if>
|
||||
<xsl:if test="not(@any)">, </xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
)</xsl:if>
|
||||
</span>
|
||||
<div class='short'>
|
||||
<xsl:value-of select="@short"/>
|
||||
</div>
|
||||
<div class='more'>
|
||||
<div class='desc'>
|
||||
<xsl:value-of select="desc"/>
|
||||
</div>
|
||||
<xsl:for-each select="examples">
|
||||
<div class='example'>
|
||||
<h5>Example:</h5>
|
||||
<xsl:if test="desc">
|
||||
<p><xsl:value-of select="desc"/></p>
|
||||
</xsl:if>
|
||||
<pre><xsl:value-of select="code"/></pre>
|
||||
<xsl:if test="before">
|
||||
<b>HTML:</b>
|
||||
<pre><xsl:value-of select="before"/></pre>
|
||||
</xsl:if>
|
||||
<xsl:if test="result">
|
||||
<b>Result:</b>
|
||||
<pre><xsl:value-of select="result"/></pre>
|
||||
</xsl:if>
|
||||
</div>
|
||||
</xsl:for-each>
|
||||
</div>
|
||||
</li>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
71
drag/drag.js
71
drag/drag.js
@ -1,71 +0,0 @@
|
||||
$.drug = null;
|
||||
|
||||
$.dragstart = function(e)
|
||||
{
|
||||
this.dragElement.deltaX = e.clientX - this.dragElement.offsetLeft;
|
||||
this.dragElement.deltaY = e.clientY - this.dragElement.offsetTop;
|
||||
|
||||
// Save CSS
|
||||
this.dragElement.oldPos = $.css(this.dragElement, 'position');
|
||||
this.dragElement.oldCursor = $.css(this.dragElement, 'cursor');
|
||||
this.dragElement.oldUserSelect = $.css(this.dragElement, 'user-select');
|
||||
|
||||
$(this.dragElement).css('position', 'absolute')
|
||||
.css('cursor', 'move')
|
||||
.css('user-select', 'none');
|
||||
$.drug = this.dragElement;
|
||||
};
|
||||
|
||||
$.dragstop = function(e)
|
||||
{
|
||||
$.drug = null;
|
||||
|
||||
// Restore CSS
|
||||
$(this).css('cursor', this.oldCursor)
|
||||
.css('user-select', this.oldUserSelect);
|
||||
}
|
||||
|
||||
$.drag = function(e)
|
||||
{
|
||||
if ($.drug == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update position
|
||||
var nx = (e.clientX - $.drug.deltaX);
|
||||
var ny = (e.clientY - $.drug.deltaY);
|
||||
|
||||
// Bounds check
|
||||
// Left edge
|
||||
nx = (nx < 0) ? 0 : nx;
|
||||
// right edge
|
||||
nx = (nx + $.drug.offsetWidth) > document.width ? document.width - $.drug.offsetWidth : nx;
|
||||
|
||||
// Top
|
||||
ny = (ny < window.scrollY) ? window.scrollY : ny;
|
||||
|
||||
// Bottom
|
||||
ny = (ny + $.drug.offsetHeight) > window.innerHeight + window.scrollY ? window.innerHeight + window.scrollY - $.drug.offsetHeight: ny;
|
||||
|
||||
$($.drug).css('left', nx + 'px')
|
||||
.css('top', ny + 'px');
|
||||
};
|
||||
|
||||
$.draginit = false;
|
||||
|
||||
$.fn.Draggable = function(handle)
|
||||
{
|
||||
// Don't add > 1 of these handlers
|
||||
if (!$.draginit) {
|
||||
$(document).bind('mousemove', $.drag);
|
||||
}
|
||||
|
||||
return this.each(function()
|
||||
{
|
||||
var dhe = handle ? $(this).find(handle) : $(this);
|
||||
dhe.get(0).dragElement = this;
|
||||
|
||||
dhe.bind('mousedown', $.dragstart)
|
||||
.bind('mouseup', $.dragstop);
|
||||
});
|
||||
};
|
60
sort/sort.js
60
sort/sort.js
@ -1,60 +0,0 @@
|
||||
// Work in Progress Sort Functions
|
||||
//
|
||||
|
||||
$.fn.sort = function(f) {
|
||||
cur = cur.sort(function(a,b){
|
||||
if ( typeof f == 'object' )
|
||||
var ret = f(a,b);
|
||||
else
|
||||
var ret = $.fn.genericSort(a,b,f);
|
||||
|
||||
if ( a < b )
|
||||
b.parentNode.insertBefore( a, b );
|
||||
else if ( a > b )
|
||||
a.parentNode.insertBefore( b, a );
|
||||
return ret;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
$.fn.reverse = function() {
|
||||
cur[0].parentNode.appendChild( cur[0] );
|
||||
for ( var i = 1; cur && i < cur.length; i++ )
|
||||
cur[i-1].parentNode.insertBefore( cur[i], cur[i-1] );
|
||||
cur = cur.reverse();
|
||||
return this;
|
||||
}
|
||||
|
||||
$.fn.genericSort = function(a,b,c) {
|
||||
if ( typeof a == "string" || typeof b == "string" ) {
|
||||
} else if ( c != null ) {
|
||||
a = sibling(a.firstChild)[c].innerText;
|
||||
b = sibling(b.firstChild)[c].innerText;
|
||||
} else {
|
||||
a = a.innerText;
|
||||
b = b.innerText;
|
||||
}
|
||||
|
||||
// Case insensitive
|
||||
a = a.toLowerCase();
|
||||
b = b.toLowerCase();
|
||||
|
||||
// Figure out if it's an American-style date
|
||||
var re = new RegExp( "^(\d{2}).(\d{2}).(\d{2,4})$" );
|
||||
var ma = re.exec(a);
|
||||
var mb = re.exec(b);
|
||||
|
||||
if ( ma.length && mb.length ) {
|
||||
a = ma.reverse().join('');
|
||||
b = mb.reverse().join('');
|
||||
}
|
||||
|
||||
// If it contains a number, sort on that only
|
||||
if ( a.match(/\d/) ) {
|
||||
var re = new RegExp("[^0-9.-]","ig");
|
||||
a = parseFloat( a.replace( re, "" ) );
|
||||
b = parseFloat( b.replace( re, "" ) );
|
||||
}
|
||||
|
||||
return ( a < b ? -1 : ( a > b ? 1 : 0 ) );
|
||||
}
|
108
tmpl/tmpl.js
108
tmpl/tmpl.js
@ -1,108 +0,0 @@
|
||||
// test commit
|
||||
|
||||
$.fn.get = function(i) {
|
||||
return i == null ?
|
||||
this.$$unclean ? $.sibling(this.$$unclean[0]) : this.cur :
|
||||
(this.get())[i];
|
||||
};
|
||||
|
||||
$.fn._get = function(i) {
|
||||
return i == null ? this.cur : this.cur[i];
|
||||
};
|
||||
|
||||
$.fn.set = function(a,b) {
|
||||
return this.each(function(){
|
||||
if ( b == null )
|
||||
for ( var j in a )
|
||||
this[$.attr(j)] = a[j];
|
||||
else {
|
||||
if ( b.constructor != String ) { // TODO: Fix this
|
||||
for ( var i in b ) {
|
||||
var c = $.Select(i,this);
|
||||
for ( var j in c )
|
||||
c[j][$.attr(a)] = b[i];
|
||||
}
|
||||
} else
|
||||
this[$.attr(a)] = b;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function $C(a) {
|
||||
if ( a.indexOf('<') >= 0 ) {
|
||||
if ( a.indexOf('<tr') >= 0 ) {
|
||||
var r = $C("table").html("<tbody>"+a+"</tbody>");
|
||||
r.$$unclean = r.get(0).childNodes[0].childNodes;
|
||||
} else {
|
||||
var r = $C("div").html(a);
|
||||
r.$$unclean = r.get(0).childNodes;
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
return $(document.createElement(a),document);
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.appendTo = function() {
|
||||
var self = this;
|
||||
var a = arguments;
|
||||
return this.each(function(){
|
||||
for ( var i = 0; i < a.length; i++ ) {
|
||||
if ( self.$$unclean )
|
||||
$(a[i]).append( self.get() );
|
||||
else
|
||||
$(a[i]).append( this );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.clean = function(a) {
|
||||
var r = [];
|
||||
for ( var i = 0; i < a.length; i++ ) {
|
||||
if ( a[i].constructor == String ) {
|
||||
// Cool, but has scary side-effects
|
||||
//a[i] = a[i].replace( /#([a-zA-Z0-9_-]+)/g, " id='$1' " );
|
||||
//a[i] = a[i].replace( /\.([a-zA-Z0-9_-]+)/g, " class='$1' " );
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = a[i];
|
||||
for ( var j = 0; j < div.childNodes.length; j++ )
|
||||
r[r.length] = div.childNodes[j];
|
||||
} else if ( a[i].length ) {
|
||||
for ( var j = 0; j < a[i].length; j++ )
|
||||
r[r.length] = a[i][j];
|
||||
} else {
|
||||
r[r.length] = a[i];
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
// Frequently-used Accessors
|
||||
window.cssQuery = $.Select;
|
||||
document.getElementsByClass = function(a){return $.Select("."+a)};
|
||||
document.getElementsBySelector = $.Select;
|
||||
|
||||
|
||||
// Make Xpath Axes Sane
|
||||
//var re = new RegExp( "/?descendant::", "i" );
|
||||
//t = t.replace( re, " " );
|
||||
//var re = new RegExp( "/?child::", "i" );
|
||||
//t = t.replace( re, "/" );
|
||||
// If only...
|
||||
//var re = new RegExp( "/?following-sibling::", "i" );
|
||||
//t = t.replace( re, " + " );
|
||||
//var re = new RegExp( "/?preceding-sibling::", "i" );
|
||||
//t = t.replace( re, " ~ " );
|
||||
//var re = new RegExp( "/?self::", "i" );
|
||||
//t = t.replace( re, "" );
|
||||
//var re = new RegExp( "/?parent::", "i" );
|
||||
//t = t.replace( re, " .. " );
|
||||
|
||||
// following
|
||||
// preceding
|
||||
// ancestor
|
||||
// ancestor-or-self
|
||||
// descendant-or-self
|
||||
|
||||
// Deprecated
|
||||
//style: function(a,b){ return this.css(a,b); },
|
Loading…
Reference in New Issue
Block a user