Show
Ignore:
Timestamp:
12/21/07 07:21:32 (13 months ago)
Author:
cho45
Message:

lang/javascript/jsdeferred/trunk/jsdeferred.mini.js,
lang/javascript/jsdeferred/trunk/jsdeferred.jquery.js,
lang/javascript/jsdeferred/trunk/jsdeferred.js,
lang/javascript/jsdeferred/trunk/jsdeferred.nodoc.js,
lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js:

cancel の伝播
最初の deferred の cancel() をよぶことで以降すべてのキャンセルも起動するように

Location:
lang/javascript/jsdeferred/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/jsdeferred/trunk/jsdeferred.jquery.js

    r3224 r3386  
    1313fail:function(err){return this._fire("ng",err)}, 
    1414cancel:function(){ 
    15 (this.canceller || function(){})();return this.init();}, 
     15(this.canceller || function(){})();if(this._next)this._next.cancel();return this.init();}, 
    1616_post:function(okng,fun){ 
    1717this._next=new Deferred();this._next.callback[okng]=fun;return this._next;}, 
     
    3434}).error(function(e){ 
    3535ret.fail(e);});num++;})(dl[i],i);} 
    36 if(!num)Deferred.next(function(){ret.call()});return ret;};Deferred.wait=function(n){ 
     36if(!num)Deferred.next(function(){ret.call()});ret.canceller=function(){ 
     37for(var i in dl){ 
     38if(!dl.hasOwnProperty(i))continue;dl[i].cancel();} 
     39};return ret;};Deferred.wait=function(n){ 
    3740var d=new Deferred(),t=new Date();var id=setTimeout(function(){ 
    3841clearTimeout(id);d.call((new Date).getTime()-t.getTime());},n*1000) 
  • lang/javascript/jsdeferred/trunk/jsdeferred.js

    r3224 r3386  
    9999        cancel : function () { 
    100100                (this.canceller || function () {})(); 
     101                if (this._next) this._next.cancel(); 
    101102                return this.init(); 
    102103        }, 
     
    170171        } 
    171172        if (!num) Deferred.next(function () { ret.call() }); 
     173        ret.canceller = function () { 
     174                for (var i in dl) { 
     175                        if (!dl.hasOwnProperty(i)) continue; 
     176                        dl[i].cancel(); 
     177                } 
     178        }; 
    172179        return ret; 
    173180}; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.mini.js

    r3224 r3386  
    1313fail:function(err){return this._fire("ng",err)}, 
    1414cancel:function(){ 
    15 (this.canceller || function(){})();return this.init();}, 
     15(this.canceller || function(){})();if(this._next)this._next.cancel();return this.init();}, 
    1616_post:function(okng,fun){ 
    1717this._next=new Deferred();this._next.callback[okng]=fun;return this._next;}, 
     
    3434}).error(function(e){ 
    3535ret.fail(e);});num++;})(dl[i],i);} 
    36 if(!num)Deferred.next(function(){ret.call()});return ret;};Deferred.wait=function(n){ 
     36if(!num)Deferred.next(function(){ret.call()});ret.canceller=function(){ 
     37for(var i in dl){ 
     38if(!dl.hasOwnProperty(i))continue;dl[i].cancel();} 
     39};return ret;};Deferred.wait=function(n){ 
    3740var d=new Deferred(),t=new Date();var id=setTimeout(function(){ 
    3841clearTimeout(id);d.call((new Date).getTime()-t.getTime());},n*1000) 
  • lang/javascript/jsdeferred/trunk/jsdeferred.nodoc.js

    r3224 r3386  
    1919        cancel : function () { 
    2020                (this.canceller || function () {})(); 
     21                if (this._next) this._next.cancel(); 
    2122                return this.init(); 
    2223        }, 
     
    6667        } 
    6768        if (!num) Deferred.next(function () { ret.call() }); 
     69        ret.canceller = function () { 
     70                for (var i in dl) { 
     71                        if (!dl.hasOwnProperty(i)) continue; 
     72                        dl[i].cancel(); 
     73                } 
     74        }; 
    6875        return ret; 
    6976}; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js

    r3224 r3386  
    2323        cancel : function () { 
    2424                (this.canceller || function () {})(); 
     25                if (this._next) this._next.cancel(); 
    2526                return this.init(); 
    2627        }, 
     
    7071        } 
    7172        if (!num) Deferred.next(function () { ret.call() }); 
     73        ret.canceller = function () { 
     74                for (var i in dl) { 
     75                        if (!dl.hasOwnProperty(i)) continue; 
     76                        dl[i].cancel(); 
     77                } 
     78        }; 
    7279        return ret; 
    7380};