Fixed some bugs, improved the quality of some of the variables.
This commit is contained in:
parent
874e4f65ee
commit
ccf9d44062
|
@ -17,7 +17,7 @@ $(document).ready(function(){
|
||||||
}).ToolTipDemo('#fff');
|
}).ToolTipDemo('#fff');
|
||||||
|
|
||||||
$("a.name").click(function(){
|
$("a.name").click(function(){
|
||||||
$("div.more,div.short",this.parentNode.parentNode).toggle().find("div.desc",function(){
|
$("div.more,div.short",this.parentNode.parentNode).toggle('slow').find("div.desc",function(){
|
||||||
$(this).html( $(this).html().replace(/\n\n/g, "<br/><br/>") );
|
$(this).html( $(this).html().replace(/\n\n/g, "<br/><br/>") );
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -485,7 +485,8 @@ jQuery.extend({
|
||||||
z.el.orig[prop] + "px" : z.el.orig[prop];
|
z.el.orig[prop] + "px" : z.el.orig[prop];
|
||||||
|
|
||||||
// set its height and/or width to auto
|
// set its height and/or width to auto
|
||||||
jQuery.setAuto( z.el, prop );
|
if ( prop == 'height' || prop == 'width' )
|
||||||
|
jQuery.setAuto( z.el, prop );
|
||||||
|
|
||||||
// If a callback was provided, execute it
|
// If a callback was provided, execute it
|
||||||
if( z.o.complete && z.o.complete.constructor == Function )
|
if( z.o.complete && z.o.complete.constructor == Function )
|
||||||
|
|
120
src/jquery/jquery.js
vendored
120
src/jquery/jquery.js
vendored
|
@ -233,6 +233,14 @@ jQuery.fn = jQuery.prototype = {
|
||||||
return jQuery.each( this, fn, args );
|
return jQuery.each( this, fn, args );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
index: function( obj ) {
|
||||||
|
var pos = -1;
|
||||||
|
this.each(function(i){
|
||||||
|
if ( this == obj ) pos = i;
|
||||||
|
});
|
||||||
|
return pos;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access a property on the first matched element.
|
* Access a property on the first matched element.
|
||||||
* This method makes it easy to retreive a property value
|
* This method makes it easy to retreive a property value
|
||||||
|
@ -895,7 +903,7 @@ jQuery.extend({
|
||||||
new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
|
new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
|
||||||
},
|
},
|
||||||
has: function(e,a) {
|
has: function(e,a) {
|
||||||
if ( e.className )
|
if ( e.className != undefined )
|
||||||
e = e.className;
|
e = e.className;
|
||||||
return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
|
return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
|
||||||
}
|
}
|
||||||
|
@ -1364,14 +1372,14 @@ jQuery.extend({
|
||||||
* @type Array<Element>
|
* @type Array<Element>
|
||||||
* @param Element elem The element to find the ancestors of.
|
* @param Element elem The element to find the ancestors of.
|
||||||
*/
|
*/
|
||||||
parents: function(a){
|
parents: function( elem ){
|
||||||
var b = [];
|
var matched = [];
|
||||||
var c = a.parentNode;
|
var cur = elem.parentNode;
|
||||||
while ( c && c != document ) {
|
while ( cur && cur != document ) {
|
||||||
b.push( c );
|
matched.push( cur );
|
||||||
c = c.parentNode;
|
cur = cur.parentNode;
|
||||||
}
|
}
|
||||||
return b;
|
return matched;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1382,23 +1390,25 @@ jQuery.extend({
|
||||||
* @type Array
|
* @type Array
|
||||||
* @param Element elem The element to find all the siblings of (including itself).
|
* @param Element elem The element to find all the siblings of (including itself).
|
||||||
*/
|
*/
|
||||||
sibling: function(a,n) {
|
sibling: function(elem, pos, not) {
|
||||||
var type = [];
|
var elems = [];
|
||||||
var tmp = a.parentNode.childNodes;
|
|
||||||
for ( var i = 0; i < tmp.length; i++ ) {
|
var siblings = elem.parentNode.childNodes;
|
||||||
if ( tmp[i].nodeType == 1 )
|
for ( var i = 0; i < siblings.length; i++ ) {
|
||||||
type.push( tmp[i] );
|
if ( not === true && siblings[i] == elem ) continue;
|
||||||
if ( tmp[i] == a )
|
|
||||||
type.n = type.length - 1;
|
if ( siblings[i].nodeType == 1 )
|
||||||
|
elems.push( siblings[i] );
|
||||||
|
if ( siblings[i] == elem )
|
||||||
|
elems.n = elems.length - 1;
|
||||||
}
|
}
|
||||||
type.last = type.n == type.length - 1;
|
|
||||||
type.cur =
|
return jQuery.extend( elems, {
|
||||||
n == "even" && type.n % 2 == 0 ||
|
last: elems.n == elems.length - 1,
|
||||||
n == "odd" && type.n % 2 ||
|
cur: n == "even" && elems.n % 2 == 0 || n == "odd" && elems.n % 2 || elems[pos] == a,
|
||||||
type[n] == a;
|
prev: elems[elems.n - 1],
|
||||||
type.prev = type[type.n - 1];
|
next: elems[elems.n + 1]
|
||||||
type.next = type[type.n + 1];
|
});
|
||||||
return type;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1410,30 +1420,30 @@ jQuery.extend({
|
||||||
* @param Array a The first array to merge.
|
* @param Array a The first array to merge.
|
||||||
* @param Array b The second array to merge.
|
* @param Array b The second array to merge.
|
||||||
*/
|
*/
|
||||||
merge: function(a,b) {
|
merge: function(first, second) {
|
||||||
var d = [];
|
var result = [];
|
||||||
|
|
||||||
// Move b over to the new array (this helps to avoid
|
// Move b over to the new array (this helps to avoid
|
||||||
// StaticNodeList instances)
|
// StaticNodeList instances)
|
||||||
for ( var k = 0; k < a.length; k++ )
|
for ( var k = 0; k < first.length; k++ )
|
||||||
d[k] = a[k];
|
result[k] = second[k];
|
||||||
|
|
||||||
// Now check for duplicates between a and b and only
|
// Now check for duplicates between a and b and only
|
||||||
// add the unique items
|
// add the unique items
|
||||||
for ( var i = 0; i < b.length; i++ ) {
|
for ( var i = 0; i < second.length; i++ ) {
|
||||||
var c = true;
|
var noCollision = true;
|
||||||
|
|
||||||
// The collision-checking process
|
// The collision-checking process
|
||||||
for ( var j = 0; j < a.length; j++ )
|
for ( var j = 0; j < first.length; j++ )
|
||||||
if ( b[i] == a[j] )
|
if ( second[i] == first[j] )
|
||||||
c = false;
|
noCollision = false;
|
||||||
|
|
||||||
// If the item is unique, add it
|
// If the item is unique, add it
|
||||||
if ( c )
|
if ( noCollision )
|
||||||
d.push( b[i] );
|
result.push( second[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1448,21 +1458,21 @@ jQuery.extend({
|
||||||
* @param Function fn The function to process each item against.
|
* @param Function fn The function to process each item against.
|
||||||
* @param Boolean inv Invert the selection - select the opposite of the function.
|
* @param Boolean inv Invert the selection - select the opposite of the function.
|
||||||
*/
|
*/
|
||||||
grep: function(a,f,s) {
|
grep: function(elems, fn, inv) {
|
||||||
// If a string is passed in for the function, make a function
|
// If a string is passed in for the function, make a function
|
||||||
// for it (a handy shortcut)
|
// for it (a handy shortcut)
|
||||||
if ( f.constructor == String )
|
if ( fn.constructor == String )
|
||||||
f = new Function("a","i","return " + f);
|
fn = new Function("a","i","return " + fn);
|
||||||
|
|
||||||
var r = [];
|
var result = [];
|
||||||
|
|
||||||
// Go through the array, only saving the items
|
// Go through the array, only saving the items
|
||||||
// that pass the validator function
|
// that pass the validator function
|
||||||
for ( var i = 0; i < a.length; i++ )
|
for ( var i = 0; i < elems.length; i++ )
|
||||||
if ( !s && f(a[i],i) || s && !f(a[i],i) )
|
if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
|
||||||
r.push( a[i] );
|
result.push( elems[i] );
|
||||||
|
|
||||||
return r;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1479,24 +1489,26 @@ jQuery.extend({
|
||||||
* @param Array array The Array to translate.
|
* @param Array array The Array to translate.
|
||||||
* @param Function fn The function to process each item against.
|
* @param Function fn The function to process each item against.
|
||||||
*/
|
*/
|
||||||
map: function(a,f) {
|
map: function(elems, fn) {
|
||||||
// If a string is passed in for the function, make a function
|
// If a string is passed in for the function, make a function
|
||||||
// for it (a handy shortcut)
|
// for it (a handy shortcut)
|
||||||
if ( f.constructor == String )
|
if ( fn.constructor == String )
|
||||||
f = new Function("a","return " + f);
|
fn = new Function("a","return " + fn);
|
||||||
|
|
||||||
var r = [];
|
var result = [];
|
||||||
|
|
||||||
// Go through the array, translating each of the items to their
|
// Go through the array, translating each of the items to their
|
||||||
// new value (or values).
|
// new value (or values).
|
||||||
for ( var i = 0; i < a.length; i++ ) {
|
for ( var i = 0; i < elems.length; i++ ) {
|
||||||
var t = f(a[i],i);
|
var val = fn(elems[i],i);
|
||||||
if ( t !== null && t != undefined ) {
|
|
||||||
if ( t.constructor != Array ) t = [t];
|
if ( val !== null && val != undefined ) {
|
||||||
r = jQuery.merge( r, t );
|
if ( val.constructor != Array ) val = [val];
|
||||||
|
result = jQuery.merge( result, val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue