use createDelegate rather than bind, saving implementing our own method of setting a functions scope

This commit is contained in:
Damien Churchill 2010-01-26 17:31:32 +00:00
parent dc764b2ad5
commit 4afcae325a
4 changed files with 3 additions and 13 deletions

View File

@ -74,7 +74,7 @@ Copyright:
Ext.each(this.toRegister, function(eventName) {
Deluge.Client.web.register_event_listener(eventName);
});
this.poll = this.poll.bind(this);
this.poll = this.poll.createDelegate(this);
this.running = setInterval(this.poll, 2000);
this.poll();
},

View File

@ -96,7 +96,7 @@ Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
}
item.setText(str);
}.bind(this);
}.createDelegate(this);
updateStat('connections', {
value: {value: stats.num_connections},

View File

@ -84,7 +84,7 @@ Deluge.UI = {
Deluge.Login.show();
}, this, {single: true});
this.update = this.update.bind(this);
this.update = this.update.createDelegate(this);
},
update: function() {

View File

@ -38,16 +38,6 @@ Ext.namespace('Ext.deluge');
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
(function() {
/* Add some helper functions to Ext */
Ext.apply(Function.prototype, {
bind: function(scope) {
var self = this;
return function() {
return self.apply(scope, arguments);
}
}
});
Ext.apply(Ext, {
escapeHTML: function(text) {
text = String(text).replace('<', '&lt;').replace('>', '&gt;');