scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | define( [ |
1 | define([ |
|
2 | "../core" |
2 | "../core" |
|
3 | ], function( jQuery ) { |
3 | ], function( jQuery ) { |
|
Line 4... | Line -... | |||
4 | |
- | ||
5 | "use strict"; |
- | ||
6 | |
4 | |
|
7 | // Multifunctional method to get and set values of a collection |
5 | // Multifunctional method to get and set values of a collection |
|
8 | // The value/s can optionally be executed if it's a function |
6 | // The value/s can optionally be executed if it's a function |
|
9 | var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
7 | var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
|
10 | var i = 0, |
8 | var i = 0, |
|
11 | len = elems.length, |
9 | len = elems.length, |
|
Line 12... | Line 10... | |||
12 | bulk = key == null; |
10 | bulk = key == null; |
|
13 | |
11 | |
|
14 | // Sets many values |
12 | // Sets many values |
|
15 | if ( jQuery.type( key ) === "object" ) { |
13 | if ( jQuery.type( key ) === "object" ) { |
|
16 | chainable = true; |
14 | chainable = true; |
|
17 | for ( i in key ) { |
15 | for ( i in key ) { |
|
Line 18... | Line 16... | |||
18 | access( elems, fn, i, key[ i ], true, emptyGet, raw ); |
16 | jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); |
|
19 | } |
17 | } |
|
20 | |
18 | |
|
Line 25... | Line 23... | |||
25 | if ( !jQuery.isFunction( value ) ) { |
23 | if ( !jQuery.isFunction( value ) ) { |
|
26 | raw = true; |
24 | raw = true; |
|
27 | } |
25 | } |
|
Line 28... | Line 26... | |||
28 | |
26 | |
|
29 | if ( bulk ) { |
- | ||
30 | |
27 | if ( bulk ) { |
|
31 | // Bulk operations run against the entire set |
28 | // Bulk operations run against the entire set |
|
32 | if ( raw ) { |
29 | if ( raw ) { |
|
33 | fn.call( elems, value ); |
30 | fn.call( elems, value ); |
|
Line 42... | Line 39... | |||
42 | } |
39 | } |
|
43 | } |
40 | } |
|
Line 44... | Line 41... | |||
44 | |
41 | |
|
45 | if ( fn ) { |
42 | if ( fn ) { |
|
46 | for ( ; i < len; i++ ) { |
- | ||
47 | fn( |
- | ||
48 | elems[ i ], key, raw ? |
- | ||
49 | value : |
43 | for ( ; i < len; i++ ) { |
|
50 | value.call( elems[ i ], i, fn( elems[ i ], key ) ) |
- | ||
51 | ); |
44 | fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); |
|
52 | } |
45 | } |
|
53 | } |
46 | } |
|
Line 54... | Line 47... | |||
54 | } |
47 | } |
|
55 | |
48 | |
|
56 | if ( chainable ) { |
- | ||
57 | return elems; |
- | ||
58 | } |
- | ||
59 | |
- | ||
60 | // Gets |
- | ||
61 | if ( bulk ) { |
- | ||
Line -... | Line 49... | |||
- | 49 | return chainable ? |
||
- | 50 | elems : |
||
- | 51 | |
||
62 | return fn.call( elems ); |
52 | // Gets |
|
63 | } |
53 | bulk ? |
|
Line 64... | Line 54... | |||
64 | |
54 | fn.call( elems ) : |
|
Line 65... | Line 55... | |||
65 | return len ? fn( elems[ 0 ], key ) : emptyGet; |
55 | len ? fn( elems[0], key ) : emptyGet; |