a1a3bc73
Luigi Serra
graphs updates
|
1
|
define( [
|
74249687
Luigi Serra
Cross browser con...
|
2
3
|
"./core",
"./var/indexOf",
|
a1a3bc73
Luigi Serra
graphs updates
|
4
5
|
"./traversing/var/dir",
"./traversing/var/siblings",
|
74249687
Luigi Serra
Cross browser con...
|
6
7
8
9
|
"./traversing/var/rneedsContext",
"./core/init",
"./traversing/findFilter",
"./selector"
|
a1a3bc73
Luigi Serra
graphs updates
|
10
|
], function( jQuery, indexOf, dir, siblings, rneedsContext ) {
|
74249687
Luigi Serra
Cross browser con...
|
11
12
|
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
a1a3bc73
Luigi Serra
graphs updates
|
13
|
|
74249687
Luigi Serra
Cross browser con...
|
14
15
16
17
18
19
20
21
|
// Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
contents: true,
next: true,
prev: true
};
|
a1a3bc73
Luigi Serra
graphs updates
|
22
|
jQuery.fn.extend( {
|
74249687
Luigi Serra
Cross browser con...
|
23
24
25
26
|
has: function( target ) {
var targets = jQuery( target, this ),
l = targets.length;
|
a1a3bc73
Luigi Serra
graphs updates
|
27
|
return this.filter( function() {
|
74249687
Luigi Serra
Cross browser con...
|
28
29
|
var i = 0;
for ( ; i < l; i++ ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
30
|
if ( jQuery.contains( this, targets[ i ] ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
31
32
33
|
return true;
}
}
|
a1a3bc73
Luigi Serra
graphs updates
|
34
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
35
36
37
38
39
40
41
42
43
44
45
46
|
},
closest: function( selectors, context ) {
var cur,
i = 0,
l = this.length,
matched = [],
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
jQuery( selectors, context || this.context ) :
0;
for ( ; i < l; i++ ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
47
48
|
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
|
74249687
Luigi Serra
Cross browser con...
|
49
|
// Always skip document fragments
|
a1a3bc73
Luigi Serra
graphs updates
|
50
51
|
if ( cur.nodeType < 11 && ( pos ?
pos.index( cur ) > -1 :
|
74249687
Luigi Serra
Cross browser con...
|
52
53
54
|
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
|
a1a3bc73
Luigi Serra
graphs updates
|
55
|
jQuery.find.matchesSelector( cur, selectors ) ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
56
57
58
59
60
61
62
|
matched.push( cur );
break;
}
}
}
|
a1a3bc73
Luigi Serra
graphs updates
|
63
|
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
|
74249687
Luigi Serra
Cross browser con...
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
},
// Determine the position of an element within the set
index: function( elem ) {
// No argument, return index in parent
if ( !elem ) {
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
}
// Index in selector
if ( typeof elem === "string" ) {
return indexOf.call( jQuery( elem ), this[ 0 ] );
}
// Locate the position of the desired element
return indexOf.call( this,
// If it receives a jQuery object, the first element is used
elem.jquery ? elem[ 0 ] : elem
);
},
add: function( selector, context ) {
return this.pushStack(
|
a1a3bc73
Luigi Serra
graphs updates
|
89
|
jQuery.uniqueSort(
|
74249687
Luigi Serra
Cross browser con...
|
90
91
92
93
94
95
96
|
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
},
addBack: function( selector ) {
return this.add( selector == null ?
|
a1a3bc73
Luigi Serra
graphs updates
|
97
|
this.prevObject : this.prevObject.filter( selector )
|
74249687
Luigi Serra
Cross browser con...
|
98
99
|
);
}
|
a1a3bc73
Luigi Serra
graphs updates
|
100
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
101
102
|
function sibling( cur, dir ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
103
|
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
|
74249687
Luigi Serra
Cross browser con...
|
104
105
106
|
return cur;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
107
|
jQuery.each( {
|
74249687
Luigi Serra
Cross browser con...
|
108
109
110
111
112
|
parent: function( elem ) {
var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null;
},
parents: function( elem ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
113
|
return dir( elem, "parentNode" );
|
74249687
Luigi Serra
Cross browser con...
|
114
115
|
},
parentsUntil: function( elem, i, until ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
116
|
return dir( elem, "parentNode", until );
|
74249687
Luigi Serra
Cross browser con...
|
117
118
119
120
121
122
123
124
|
},
next: function( elem ) {
return sibling( elem, "nextSibling" );
},
prev: function( elem ) {
return sibling( elem, "previousSibling" );
},
nextAll: function( elem ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
125
|
return dir( elem, "nextSibling" );
|
74249687
Luigi Serra
Cross browser con...
|
126
127
|
},
prevAll: function( elem ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
128
|
return dir( elem, "previousSibling" );
|
74249687
Luigi Serra
Cross browser con...
|
129
130
|
},
nextUntil: function( elem, i, until ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
131
|
return dir( elem, "nextSibling", until );
|
74249687
Luigi Serra
Cross browser con...
|
132
133
|
},
prevUntil: function( elem, i, until ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
134
|
return dir( elem, "previousSibling", until );
|
74249687
Luigi Serra
Cross browser con...
|
135
136
|
},
siblings: function( elem ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
137
|
return siblings( ( elem.parentNode || {} ).firstChild, elem );
|
74249687
Luigi Serra
Cross browser con...
|
138
139
|
},
children: function( elem ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
140
|
return siblings( elem.firstChild );
|
74249687
Luigi Serra
Cross browser con...
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
},
contents: function( elem ) {
return elem.contentDocument || jQuery.merge( [], elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
var matched = jQuery.map( this, fn, until );
if ( name.slice( -5 ) !== "Until" ) {
selector = until;
}
if ( selector && typeof selector === "string" ) {
matched = jQuery.filter( selector, matched );
}
if ( this.length > 1 ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
158
|
|
74249687
Luigi Serra
Cross browser con...
|
159
160
|
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
161
|
jQuery.uniqueSort( matched );
|
74249687
Luigi Serra
Cross browser con...
|
162
163
164
165
166
167
168
169
170
171
|
}
// Reverse order for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) {
matched.reverse();
}
}
return this.pushStack( matched );
};
|
a1a3bc73
Luigi Serra
graphs updates
|
172
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
173
174
|
return jQuery;
|
a1a3bc73
Luigi Serra
graphs updates
|
175
|
} );
|