1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
create: function(options){
options = $merge({
'bind': this,
'arguments': null,
'delay': false,
'periodical': false,
'attempt': false,
'event': false
}, options);
return this.create2(options.bind, options.arguments, options.delay, options.periodical, options.attempt, options.event);
},
create2: function(bind, args, delay, periodical, attempt, event){
var self = this;
return function(e){
args = $splat(args) || arguments;
if (event) args = [e || window.event].extend(args);
var returns = function(){
return self.apply($pick(bind, self), args);
};
if (delay) return setTimeout(returns, delay);
if (periodical) return setInterval(returns, periodical);
if (attempt) return $try(returns);
return returns();
};
},
bind2: function(bind, args, evt){
return this.create2(bind, args, false, false, false, evt);
},
|