| 3167 | |
| 3168 | // Fire callbacks |
| 3169 | fire = function() { |
| 3170 | |
| 3171 | // Enforce single-firing |
| 3172 | locked = options.once; |
| 3173 | |
| 3174 | // Execute callbacks for all pending executions, |
| 3175 | // respecting firingIndex overrides and runtime changes |
| 3176 | fired = firing = true; |
| 3177 | for ( ; queue.length; firingIndex = -1 ) { |
| 3178 | memory = queue.shift(); |
| 3179 | while ( ++firingIndex < list.length ) { |
| 3180 | |
| 3181 | // Run callback and check for early termination |
| 3182 | if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
| 3183 | options.stopOnFalse ) { |
| 3184 | |
| 3185 | // Jump to end and forget the data so .add doesn't re-fire |
| 3186 | firingIndex = list.length; |
| 3187 | memory = false; |
| 3188 | } |
| 3189 | } |
| 3190 | } |
| 3191 | |
| 3192 | // Forget the data if we're done with it |
| 3193 | if ( !options.memory ) { |
| 3194 | memory = false; |
| 3195 | } |
| 3196 | |
| 3197 | firing = false; |
| 3198 | |
| 3199 | // Clean up if we're done firing for good |
| 3200 | if ( locked ) { |
| 3201 | |
| 3202 | // Keep an empty list if we have data for future add calls |
| 3203 | if ( memory ) { |
| 3204 | list = []; |
| 3205 | |
| 3206 | // Otherwise, this object is spent |
| 3207 | } else { |
| 3208 | list = ""; |
| 3209 | } |
| 3210 | } |
| 3211 | }, |
| 3212 | |
| 3213 | // Actual Callbacks object |
| 3214 | self = { |