自己动手实现jQuery Callbacks完整功能代码详解(8)

this.disable = function ()
                {
                    _disabled = true;
                    return this;
                };

this.disabled = function ()
                {
                    return _disabled;
                };

this.fired = function ()
                {
                    return firedTimes > 0;
                };

function _fire( context, args )
                {
                    if ( _disabled || ops.once && firedTimes > 0 || _locked )
                    {
                        return;
                    }

if ( ar.length > 0 )
                    {
                        var r;

for ( var i = 0; i < ar.length; i++ )
                        {
                            r = ar[i].call( context, args );

if ( ops.stopOnFalse && r === false )
                            {
                                break;
                            }
                        }
                    }

firedTimes++;

if ( ops.memory )
                    {
                        lastArgs = args;
                    }

};

this.fireWith = function ( context, args )
                {
                    context = context || this;
                    _fire( context, args );
                    return this;
                };

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwxwp.html