I'm trying to create a Postbox addon (Postbox is a mail client based on Thunderbird) and I'm having a small problem. I'm far from being a Javascript expert and I can't understand the problem behind this...
I'm trying to extend some object function from the Postbox code. The code is quite big, so I tried to create a small example to demonstrate my problem. The following code is a sample of the original Postbox code structure:
FolderTreeView.prototype = {
init: function FTV__init() {
alert("init");
},
_ensureValidRow: function FTV__ensureValidRow(aRow) {
alert("_ensureValidRow");
},
getCellProperties: function FTV_getCellProperties(aRow, aColumn, aProperties) {
this._ensureValidRow(aRow);
}
}
function FolderTreeView() {
this._tree = null;
this.init();
}
var gFolderView = new FolderTreeView();
I cannot change this code cause when Postbox gets updated, the code would revert to the original source and it would be a pain to maintain that.
The following is my own code, trying to extend the getCellProperties function:
MyExtension = {
init: function() {
MyExtension.FolderIcon.load();
},
FolderIcon: {
load: function() {
var oGetCellProperties = gFolderView.getCellProperties;
gFolderView.getCellProperties = function FTV_getCellProperties(aRow, aColumn, aProperties) {
oGetCellProperties(aRow, aColumn, aProperties);
}
gFolderView.getCellProperties(null, null, null);
}
}
}
Now, oGetCellProperties is calling the original function, which in turn tries to call this._ensureValidRow but it fails. The error console reports that:
this._ensureValidRow is not a function