c5169e0e
Renato De Donato
a new hope
|
1
|
define([
|
74249687
Luigi Serra
Cross browser con...
|
2
3
4
5
6
|
"../core"
], function( jQuery ) {
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
|
c5169e0e
Renato De Donato
a new hope
|
7
|
var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
74249687
Luigi Serra
Cross browser con...
|
8
9
10
11
12
13
14
15
|
var i = 0,
len = elems.length,
bulk = key == null;
// Sets many values
if ( jQuery.type( key ) === "object" ) {
chainable = true;
for ( i in key ) {
|
c5169e0e
Renato De Donato
a new hope
|
16
|
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
|
74249687
Luigi Serra
Cross browser con...
|
17
18
19
20
21
22
23
24
25
26
27
|
}
// Sets one value
} else if ( value !== undefined ) {
chainable = true;
if ( !jQuery.isFunction( value ) ) {
raw = true;
}
if ( bulk ) {
|
74249687
Luigi Serra
Cross browser con...
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Bulk operations run against the entire set
if ( raw ) {
fn.call( elems, value );
fn = null;
// ...except when executing function values
} else {
bulk = fn;
fn = function( elem, key, value ) {
return bulk.call( jQuery( elem ), value );
};
}
}
if ( fn ) {
for ( ; i < len; i++ ) {
|
c5169e0e
Renato De Donato
a new hope
|
44
|
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
|
74249687
Luigi Serra
Cross browser con...
|
45
46
47
48
49
50
51
52
53
54
|
}
}
}
return chainable ?
elems :
// Gets
bulk ?
fn.call( elems ) :
|
c5169e0e
Renato De Donato
a new hope
|
55
|
len ? fn( elems[0], key ) : emptyGet;
|
74249687
Luigi Serra
Cross browser con...
|
56
57
58
59
|
};
return access;
|
c5169e0e
Renato De Donato
a new hope
|
60
|
});
|