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