a1a3bc73
Luigi Serra
graphs updates
|
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
|
a1a3bc73
Luigi Serra
graphs updates
|
7
|
var 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 ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
16
|
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 ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
28
|
|
74249687
Luigi Serra
Cross browser con...
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// 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++ ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
45
46
47
48
49
|
fn(
elems[ i ], key, raw ?
value :
value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
|
74249687
Luigi Serra
Cross browser con...
|
50
51
52
53
54
55
56
57
58
59
|
}
}
}
return chainable ?
elems :
// Gets
bulk ?
fn.call( elems ) :
|
a1a3bc73
Luigi Serra
graphs updates
|
60
|
len ? fn( elems[ 0 ], key ) : emptyGet;
|
74249687
Luigi Serra
Cross browser con...
|
61
62
63
64
|
};
return access;
|
a1a3bc73
Luigi Serra
graphs updates
|
65
|
} );
|