c5169e0e
Renato De Donato
a new hope
|
1
|
define([
|
74249687
Luigi Serra
Cross browser con...
|
2
|
"./core",
|
c5169e0e
Renato De Donato
a new hope
|
3
|
"./data/var/data_priv",
|
74249687
Luigi Serra
Cross browser con...
|
4
5
|
"./deferred",
"./callbacks"
|
c5169e0e
Renato De Donato
a new hope
|
6
|
], function( jQuery, data_priv ) {
|
74249687
Luigi Serra
Cross browser con...
|
7
|
|
c5169e0e
Renato De Donato
a new hope
|
8
|
jQuery.extend({
|
74249687
Luigi Serra
Cross browser con...
|
9
10
11
12
13
|
queue: function( elem, type, data ) {
var queue;
if ( elem ) {
type = ( type || "fx" ) + "queue";
|
c5169e0e
Renato De Donato
a new hope
|
14
|
queue = data_priv.get( elem, type );
|
74249687
Luigi Serra
Cross browser con...
|
15
16
17
18
|
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !queue || jQuery.isArray( data ) ) {
|
c5169e0e
Renato De Donato
a new hope
|
19
|
queue = data_priv.access( elem, type, jQuery.makeArray(data) );
|
74249687
Luigi Serra
Cross browser con...
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
} else {
queue.push( data );
}
}
return queue || [];
}
},
dequeue: function( elem, type ) {
type = type || "fx";
var queue = jQuery.queue( elem, type ),
startLength = queue.length,
fn = queue.shift(),
hooks = jQuery._queueHooks( elem, type ),
next = function() {
jQuery.dequeue( elem, type );
};
// If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) {
fn = queue.shift();
startLength--;
}
if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if ( type === "fx" ) {
queue.unshift( "inprogress" );
}
// Clear up the last queue stop function
delete hooks.stop;
fn.call( elem, next, hooks );
}
if ( !startLength && hooks ) {
hooks.empty.fire();
}
},
// Not public - generate a queueHooks object, or return the current one
_queueHooks: function( elem, type ) {
var key = type + "queueHooks";
|
c5169e0e
Renato De Donato
a new hope
|
66
67
68
69
70
|
return data_priv.get( elem, key ) || data_priv.access( elem, key, {
empty: jQuery.Callbacks("once memory").add(function() {
data_priv.remove( elem, [ type + "queue", key ] );
})
});
|
74249687
Luigi Serra
Cross browser con...
|
71
|
}
|
c5169e0e
Renato De Donato
a new hope
|
72
|
});
|
74249687
Luigi Serra
Cross browser con...
|
73
|
|
c5169e0e
Renato De Donato
a new hope
|
74
|
jQuery.fn.extend({
|
74249687
Luigi Serra
Cross browser con...
|
75
76
77
78
79
80
81
82
83
84
|
queue: function( type, data ) {
var setter = 2;
if ( typeof type !== "string" ) {
data = type;
type = "fx";
setter--;
}
if ( arguments.length < setter ) {
|
c5169e0e
Renato De Donato
a new hope
|
85
|
return jQuery.queue( this[0], type );
|
74249687
Luigi Serra
Cross browser con...
|
86
87
88
89
|
}
return data === undefined ?
this :
|
c5169e0e
Renato De Donato
a new hope
|
90
|
this.each(function() {
|
74249687
Luigi Serra
Cross browser con...
|
91
92
93
94
95
|
var queue = jQuery.queue( this, type, data );
// Ensure a hooks for this queue
jQuery._queueHooks( this, type );
|
c5169e0e
Renato De Donato
a new hope
|
96
|
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
74249687
Luigi Serra
Cross browser con...
|
97
98
|
jQuery.dequeue( this, type );
}
|
c5169e0e
Renato De Donato
a new hope
|
99
|
});
|
74249687
Luigi Serra
Cross browser con...
|
100
101
|
},
dequeue: function( type ) {
|
c5169e0e
Renato De Donato
a new hope
|
102
|
return this.each(function() {
|
74249687
Luigi Serra
Cross browser con...
|
103
|
jQuery.dequeue( this, type );
|
c5169e0e
Renato De Donato
a new hope
|
104
|
});
|
74249687
Luigi Serra
Cross browser con...
|
105
106
107
108
|
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
|
74249687
Luigi Serra
Cross browser con...
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, obj ) {
var tmp,
count = 1,
defer = jQuery.Deferred(),
elements = this,
i = this.length,
resolve = function() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
}
};
if ( typeof type !== "string" ) {
obj = type;
type = undefined;
}
type = type || "fx";
while ( i-- ) {
|
c5169e0e
Renato De Donato
a new hope
|
130
|
tmp = data_priv.get( elements[ i ], type + "queueHooks" );
|
74249687
Luigi Serra
Cross browser con...
|
131
132
133
134
135
136
137
138
|
if ( tmp && tmp.empty ) {
count++;
tmp.empty.add( resolve );
}
}
resolve();
return defer.promise( obj );
}
|
c5169e0e
Renato De Donato
a new hope
|
139
|
});
|
74249687
Luigi Serra
Cross browser con...
|
140
141
|
return jQuery;
|
c5169e0e
Renato De Donato
a new hope
|
142
|
});
|