| 3217 | |
| 3218 | // Fire callbacks |
| 3219 | fire = function() { |
| 3220 | |
| 3221 | // Enforce single-firing |
| 3222 | locked = options.once; |
| 3223 | |
| 3224 | // Execute callbacks for all pending executions, |
| 3225 | // respecting firingIndex overrides and runtime changes |
| 3226 | fired = firing = true; |
| 3227 | for ( ; queue.length; firingIndex = -1 ) { |
| 3228 | memory = queue.shift(); |
| 3229 | while ( ++firingIndex < list.length ) { |
| 3230 | |
| 3231 | // Run callback and check for early termination |
| 3232 | if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
| 3233 | options.stopOnFalse ) { |
| 3234 | |
| 3235 | // Jump to end and forget the data so .add doesn't re-fire |
| 3236 | firingIndex = list.length; |
| 3237 | memory = false; |
| 3238 | } |
| 3239 | } |
| 3240 | } |
| 3241 | |
| 3242 | // Forget the data if we're done with it |
| 3243 | if ( !options.memory ) { |
| 3244 | memory = false; |
| 3245 | } |
| 3246 | |
| 3247 | firing = false; |
| 3248 | |
| 3249 | // Clean up if we're done firing for good |
| 3250 | if ( locked ) { |
| 3251 | |
| 3252 | // Keep an empty list if we have data for future add calls |
| 3253 | if ( memory ) { |
| 3254 | list = []; |
| 3255 | |
| 3256 | // Otherwise, this object is spent |
| 3257 | } else { |
| 3258 | list = ""; |
| 3259 | } |
| 3260 | } |
| 3261 | }, |
| 3262 | |
| 3263 | // Actual Callbacks object |
| 3264 | self = { |