| 2949 | |
| 2950 | // Fire callbacks |
| 2951 | fire = function() { |
| 2952 | |
| 2953 | // Enforce single-firing |
| 2954 | locked = locked || options.once; |
| 2955 | |
| 2956 | // Execute callbacks for all pending executions, |
| 2957 | // respecting firingIndex overrides and runtime changes |
| 2958 | fired = firing = true; |
| 2959 | for ( ; queue.length; firingIndex = -1 ) { |
| 2960 | memory = queue.shift(); |
| 2961 | while ( ++firingIndex < list.length ) { |
| 2962 | |
| 2963 | // Run callback and check for early termination |
| 2964 | if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
| 2965 | options.stopOnFalse ) { |
| 2966 | |
| 2967 | // Jump to end and forget the data so .add doesn't re-fire |
| 2968 | firingIndex = list.length; |
| 2969 | memory = false; |
| 2970 | } |
| 2971 | } |
| 2972 | } |
| 2973 | |
| 2974 | // Forget the data if we're done with it |
| 2975 | if ( !options.memory ) { |
| 2976 | memory = false; |
| 2977 | } |
| 2978 | |
| 2979 | firing = false; |
| 2980 | |
| 2981 | // Clean up if we're done firing for good |
| 2982 | if ( locked ) { |
| 2983 | |
| 2984 | // Keep an empty list if we have data for future add calls |
| 2985 | if ( memory ) { |
| 2986 | list = []; |
| 2987 | |
| 2988 | // Otherwise, this object is spent |
| 2989 | } else { |
| 2990 | list = ""; |
| 2991 | } |
| 2992 | } |
| 2993 | }, |
| 2994 | |
| 2995 | // Actual Callbacks object |
| 2996 | self = { |