2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
var runtil = /Until$/,
|
|
|
|
rparentsprev = /^(?:parents|prevUntil|prevAll)/,
|
|
|
|
// Note: This RegExp should be improved, or likely pulled from Sizzle
|
2010-03-23 16:12:16 +00:00
|
|
|
rmultiselector = /,/,
|
|
|
|
isSimple = /^.[^:#\[\.,]*$/,
|
2010-10-10 19:36:02 +00:00
|
|
|
slice = Array.prototype.slice,
|
2011-12-12 16:23:47 +00:00
|
|
|
POS = jQuery.expr.match.globalPOS,
|
2011-01-14 14:55:40 +00:00
|
|
|
// methods guaranteed to produce a unique set when starting from a unique set
|
|
|
|
guaranteedUnique = {
|
|
|
|
children: true,
|
|
|
|
contents: true,
|
|
|
|
next: true,
|
|
|
|
prev: true
|
|
|
|
};
|
2010-10-10 04:33:02 +00:00
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
find: function( selector ) {
|
2011-03-16 05:16:32 +00:00
|
|
|
var self = this,
|
2011-03-16 18:41:26 +00:00
|
|
|
i, l;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2011-03-16 05:16:32 +00:00
|
|
|
if ( typeof selector !== "string" ) {
|
|
|
|
return jQuery( selector ).filter(function() {
|
|
|
|
for ( i = 0, l = self.length; i < l; i++ ) {
|
|
|
|
if ( jQuery.contains( self[ i ], this ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-11-09 16:09:07 +00:00
|
|
|
var ret = this.pushStack( "", "find", selector ),
|
2011-03-16 18:41:26 +00:00
|
|
|
length, n, r;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2011-03-16 05:16:32 +00:00
|
|
|
for ( i = 0, l = this.length; i < l; i++ ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
length = ret.length;
|
|
|
|
jQuery.find( selector, this[i], ret );
|
|
|
|
|
|
|
|
if ( i > 0 ) {
|
|
|
|
// Make sure that the results are unique
|
2011-03-16 05:16:32 +00:00
|
|
|
for ( n = length; n < ret.length; n++ ) {
|
|
|
|
for ( r = 0; r < length; r++ ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
if ( ret[r] === ret[n] ) {
|
|
|
|
ret.splice(n--, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2009-12-09 20:43:13 +00:00
|
|
|
has: function( target ) {
|
2012-04-02 17:12:57 +00:00
|
|
|
var targets = jQuery( target, this );
|
2009-12-09 20:43:13 +00:00
|
|
|
return this.filter(function() {
|
|
|
|
for ( var i = 0, l = targets.length; i < l; i++ ) {
|
|
|
|
if ( jQuery.contains( this, targets[i] ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-07-16 07:32:11 +00:00
|
|
|
not: function( selector ) {
|
2009-09-15 00:35:35 +00:00
|
|
|
return this.pushStack( winnow(this, selector, false), "not", selector);
|
2009-07-16 07:32:11 +00:00
|
|
|
},
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
filter: function( selector ) {
|
2009-09-15 00:35:35 +00:00
|
|
|
return this.pushStack( winnow(this, selector, true), "filter", selector );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
is: function( selector ) {
|
2011-12-09 01:42:47 +00:00
|
|
|
return !!selector && (
|
2011-09-20 03:50:52 +00:00
|
|
|
typeof selector === "string" ?
|
|
|
|
// If this is a positional selector, check membership in the returned set
|
|
|
|
// so $("p:first").is("p:last") won't return true for a doc with two "p".
|
2011-12-09 01:42:47 +00:00
|
|
|
POS.test( selector ) ?
|
2011-09-20 03:50:52 +00:00
|
|
|
jQuery( selector, this.context ).index( this[0] ) >= 0 :
|
|
|
|
jQuery.filter( selector, this ).length > 0 :
|
|
|
|
this.filter( selector ).length > 0 );
|
2009-12-10 17:25:25 +00:00
|
|
|
},
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2009-12-03 00:05:51 +00:00
|
|
|
closest: function( selectors, context ) {
|
2010-10-10 19:42:56 +00:00
|
|
|
var ret = [], i, l, cur = this[0];
|
2011-12-09 01:42:47 +00:00
|
|
|
|
2011-09-23 13:11:02 +00:00
|
|
|
// Array (deprecated as of jQuery 1.7)
|
2009-12-03 00:05:51 +00:00
|
|
|
if ( jQuery.isArray( selectors ) ) {
|
2011-09-23 13:11:02 +00:00
|
|
|
var level = 1;
|
2009-12-03 00:05:51 +00:00
|
|
|
|
2011-09-23 13:11:02 +00:00
|
|
|
while ( cur && cur.ownerDocument && cur !== context ) {
|
|
|
|
for ( i = 0; i < selectors.length; i++ ) {
|
2009-12-03 16:05:12 +00:00
|
|
|
|
2011-09-23 13:11:02 +00:00
|
|
|
if ( jQuery( cur ).is( selectors[ i ] ) ) {
|
|
|
|
ret.push({ selector: selectors[ i ], elem: cur, level: level });
|
2009-12-03 00:05:51 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-23 13:11:02 +00:00
|
|
|
|
|
|
|
cur = cur.parentNode;
|
|
|
|
level++;
|
2009-12-03 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
2010-09-28 00:59:42 +00:00
|
|
|
return ret;
|
2009-12-03 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 00:59:20 +00:00
|
|
|
// String
|
|
|
|
var pos = POS.test( selectors ) || typeof selectors !== "string" ?
|
|
|
|
jQuery( selectors, context || this.context ) :
|
|
|
|
0;
|
2010-09-28 00:59:42 +00:00
|
|
|
|
2010-10-10 19:42:56 +00:00
|
|
|
for ( i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
cur = this[i];
|
2010-10-10 04:33:02 +00:00
|
|
|
|
2010-10-10 17:37:36 +00:00
|
|
|
while ( cur ) {
|
2010-10-10 19:36:02 +00:00
|
|
|
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
|
2010-10-10 04:33:02 +00:00
|
|
|
ret.push( cur );
|
2010-10-10 17:37:36 +00:00
|
|
|
break;
|
|
|
|
|
2010-10-10 04:33:02 +00:00
|
|
|
} else {
|
2010-10-10 17:37:36 +00:00
|
|
|
cur = cur.parentNode;
|
2011-03-31 03:39:19 +00:00
|
|
|
if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
|
2010-10-10 17:37:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-28 00:59:42 +00:00
|
|
|
|
2011-03-31 03:23:38 +00:00
|
|
|
ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-06-21 17:50:02 +00:00
|
|
|
return this.pushStack( ret, "closest", selectors );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
// Determine the position of an element within
|
|
|
|
// the matched set of elements
|
|
|
|
index: function( elem ) {
|
2011-06-15 04:38:36 +00:00
|
|
|
|
|
|
|
// No argument, return index in parent
|
|
|
|
if ( !elem ) {
|
|
|
|
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// index in selector
|
|
|
|
if ( typeof elem === "string" ) {
|
|
|
|
return jQuery.inArray( this[0], jQuery( elem ) );
|
2009-12-10 17:25:25 +00:00
|
|
|
}
|
2011-06-15 04:38:36 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
// Locate the position of the desired element
|
|
|
|
return jQuery.inArray(
|
|
|
|
// If it receives a jQuery object, the first element is used
|
|
|
|
elem.jquery ? elem[0] : elem, this );
|
|
|
|
},
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2009-11-07 15:43:31 +00:00
|
|
|
add: function( selector, context ) {
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
var set = typeof selector === "string" ?
|
2010-12-29 02:07:04 +00:00
|
|
|
jQuery( selector, context ) :
|
2011-04-17 17:51:24 +00:00
|
|
|
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
all = jQuery.merge( this.get(), set );
|
|
|
|
|
2010-01-13 05:12:18 +00:00
|
|
|
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
|
|
|
|
all :
|
|
|
|
jQuery.unique( all ) );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
andSelf: function() {
|
|
|
|
return this.add( this.prevObject );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-01-13 05:12:18 +00:00
|
|
|
// A painfully simple check to see if an element is disconnected
|
|
|
|
// from a document (should be improved, where feasible).
|
|
|
|
function isDisconnected( node ) {
|
|
|
|
return !node || !node.parentNode || node.parentNode.nodeType === 11;
|
|
|
|
}
|
|
|
|
|
2012-05-07 20:38:55 +00:00
|
|
|
function sibling( cur, dir ) {
|
2012-05-07 20:45:22 +00:00
|
|
|
cur = cur[ dir ];
|
2012-05-07 20:05:05 +00:00
|
|
|
|
2012-05-07 20:45:22 +00:00
|
|
|
while ( cur.nodeType !== 1 ) {
|
|
|
|
cur = cur[ dir ];
|
|
|
|
}
|
2012-05-07 20:05:05 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
jQuery.each({
|
2009-12-22 00:58:13 +00:00
|
|
|
parent: function( elem ) {
|
|
|
|
var parent = elem.parentNode;
|
|
|
|
return parent && parent.nodeType !== 11 ? parent : null;
|
|
|
|
},
|
|
|
|
parents: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "parentNode" );
|
|
|
|
},
|
|
|
|
parentsUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "parentNode", until );
|
|
|
|
},
|
|
|
|
next: function( elem ) {
|
2012-05-07 20:38:55 +00:00
|
|
|
return sibling( elem, "nextSibling" );
|
2009-12-22 00:58:13 +00:00
|
|
|
},
|
|
|
|
prev: function( elem ) {
|
2012-05-07 20:38:55 +00:00
|
|
|
return sibling( elem, "previousSibling" );
|
2009-12-22 00:58:13 +00:00
|
|
|
},
|
|
|
|
nextAll: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "nextSibling" );
|
|
|
|
},
|
|
|
|
prevAll: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "previousSibling" );
|
|
|
|
},
|
|
|
|
nextUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "nextSibling", until );
|
|
|
|
},
|
|
|
|
prevUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "previousSibling", until );
|
|
|
|
},
|
|
|
|
siblings: function( elem ) {
|
2012-02-22 05:21:18 +00:00
|
|
|
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
|
2009-12-22 00:58:13 +00:00
|
|
|
},
|
|
|
|
children: function( elem ) {
|
|
|
|
return jQuery.sibling( elem.firstChild );
|
|
|
|
},
|
|
|
|
contents: function( elem ) {
|
|
|
|
return jQuery.nodeName( elem, "iframe" ) ?
|
|
|
|
elem.contentDocument || elem.contentWindow.document :
|
|
|
|
jQuery.makeArray( elem.childNodes );
|
|
|
|
}
|
|
|
|
}, function( name, fn ) {
|
2009-12-04 17:28:47 +00:00
|
|
|
jQuery.fn[ name ] = function( until, selector ) {
|
2011-11-06 21:38:26 +00:00
|
|
|
var ret = jQuery.map( this, fn, until );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
if ( !runtil.test( name ) ) {
|
|
|
|
selector = until;
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
if ( selector && typeof selector === "string" ) {
|
2009-10-26 22:07:57 +00:00
|
|
|
ret = jQuery.filter( selector, ret );
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:55:40 +00:00
|
|
|
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 17:55:20 +00:00
|
|
|
ret = ret.reverse();
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2011-11-06 21:38:26 +00:00
|
|
|
return this.pushStack( ret, name, slice.call( arguments ).join(",") );
|
2009-03-18 21:15:38 +00:00
|
|
|
};
|
2009-07-25 21:31:59 +00:00
|
|
|
});
|
2009-10-26 22:07:57 +00:00
|
|
|
|
|
|
|
jQuery.extend({
|
|
|
|
filter: function( expr, elems, not ) {
|
|
|
|
if ( not ) {
|
|
|
|
expr = ":not(" + expr + ")";
|
|
|
|
}
|
|
|
|
|
2010-10-10 19:36:02 +00:00
|
|
|
return elems.length === 1 ?
|
|
|
|
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
|
|
|
|
jQuery.find.matches(expr, elems);
|
2009-10-26 22:07:57 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
dir: function( elem, dir, until ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var matched = [],
|
|
|
|
cur = elem[ dir ];
|
|
|
|
|
2010-01-21 01:10:34 +00:00
|
|
|
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
2009-10-26 22:07:57 +00:00
|
|
|
if ( cur.nodeType === 1 ) {
|
|
|
|
matched.push( cur );
|
|
|
|
}
|
|
|
|
cur = cur[dir];
|
|
|
|
}
|
|
|
|
return matched;
|
|
|
|
},
|
|
|
|
|
|
|
|
sibling: function( n, elem ) {
|
|
|
|
var r = [];
|
|
|
|
|
|
|
|
for ( ; n; n = n.nextSibling ) {
|
|
|
|
if ( n.nodeType === 1 && n !== elem ) {
|
|
|
|
r.push( n );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2009-11-07 15:43:31 +00:00
|
|
|
});
|
2010-03-23 16:12:16 +00:00
|
|
|
|
|
|
|
// Implement the identical functionality for filter and not
|
|
|
|
function winnow( elements, qualifier, keep ) {
|
2011-04-11 15:54:55 +00:00
|
|
|
|
|
|
|
// Can't pass null or undefined to indexOf in Firefox 4
|
|
|
|
// Set to 0 to skip string check
|
|
|
|
qualifier = qualifier || 0;
|
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
if ( jQuery.isFunction( qualifier ) ) {
|
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
|
|
|
var retVal = !!qualifier.call( elem, i, elem );
|
|
|
|
return retVal === keep;
|
|
|
|
});
|
|
|
|
|
2011-04-11 15:54:55 +00:00
|
|
|
} else if ( qualifier.nodeType ) {
|
2010-03-23 16:12:16 +00:00
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
2011-10-27 19:35:09 +00:00
|
|
|
return ( elem === qualifier ) === keep;
|
2010-03-23 16:12:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
} else if ( typeof qualifier === "string" ) {
|
|
|
|
var filtered = jQuery.grep(elements, function( elem ) {
|
|
|
|
return elem.nodeType === 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( isSimple.test( qualifier ) ) {
|
|
|
|
return jQuery.filter(qualifier, filtered, !keep);
|
|
|
|
} else {
|
|
|
|
qualifier = jQuery.filter( qualifier, filtered );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
2011-10-27 19:35:09 +00:00
|
|
|
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
|
2010-03-23 16:12:16 +00:00
|
|
|
});
|
2010-03-31 18:36:24 +00:00
|
|
|
}
|
2010-09-08 17:54:33 +00:00
|
|
|
|
|
|
|
})( jQuery );
|