try to recover from non existing this.et2

This commit is contained in:
Klaus Leithoff 2014-07-17 14:47:12 +00:00
parent 344c2f2064
commit 1f9b7689e5

View File

@ -86,6 +86,26 @@ app.classes.mail = AppJS.extend(
this._super.apply(this, arguments); this._super.apply(this, arguments);
}, },
/**
* check and try to reinitialize et2 of module
*/
checkET2: function()
{
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer
if (!this.et2) // if not defined try this in order to recover
{
try
{
this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
}
catch(e)
{
return false;
}
}
return true;
},
/** /**
* This function is called when the etemplate2 object is loaded * This function is called when the etemplate2 object is loaded
* and ready. If you must store a reference to the et2 object, * and ready. If you must store a reference to the et2 object,
@ -877,18 +897,7 @@ app.classes.mail = AppJS.extend(
*/ */
mail_setQuotaDisplay: function(_data) mail_setQuotaDisplay: function(_data)
{ {
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer if (!this.et2 && !this.checkET2()) return;
if (!this.et2)
{
try
{
this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
}
catch(e)
{
return;
}
}
var quotabox = this.et2.getWidgetById(this.nm_index+'[quotainpercent]'); var quotabox = this.et2.getWidgetById(this.nm_index+'[quotainpercent]');
@ -921,21 +930,7 @@ app.classes.mail = AppJS.extend(
*/ */
mail_refreshVacationNotice: function(_data) mail_refreshVacationNotice: function(_data)
{ {
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer if (!this.et2 && !this.checkET2()) return;
//var vacationnotice = this.et2.getWidgetById(this.nm_index+'[vacationnotice]');
//var vacationrange = this.et2.getWidgetById(this.nm_index+'[vacationrange]');
//try to set it via set_value and set label
if (!this.et2)
{
try
{
this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
}
catch(e)
{
return;
}
}
if (_data == null) if (_data == null)
{ {
this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value(''); this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value('');
@ -958,17 +953,8 @@ app.classes.mail = AppJS.extend(
{ {
//alert('mail_refreshFilter2Options'); //alert('mail_refreshFilter2Options');
if (_data == null) return; if (_data == null) return;
if (!this.et2) if (!this.et2 && !this.checkET2()) return;
{
try
{
this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
}
catch(e)
{
return;
}
}
var filter2 = this.et2.getWidgetById('filter2'); var filter2 = this.et2.getWidgetById('filter2');
var current = filter2.value; var current = filter2.value;
var currentexists=false; var currentexists=false;
@ -990,17 +976,8 @@ app.classes.mail = AppJS.extend(
{ {
//alert('mail_refreshFilterOptions'); //alert('mail_refreshFilterOptions');
if (_data == null) return; if (_data == null) return;
if (!this.et2) if (!this.et2 && !this.checkET2()) return;
{
try
{
this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
}
catch(e)
{
return;
}
}
var filter = this.et2.getWidgetById('filter'); var filter = this.et2.getWidgetById('filter');
var current = filter.value; var current = filter.value;
var currentexists=false; var currentexists=false;
@ -1098,6 +1075,7 @@ app.classes.mail = AppJS.extend(
* @param {array} _status * @param {array} _status
*/ */
mail_setFolderStatus: function(_status) { mail_setFolderStatus: function(_status) {
if (!this.et2 && !this.checkET2()) return;
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
for (var i in _status) { for (var i in _status) {
ftree.setLabel(i,_status[i]); ftree.setLabel(i,_status[i]);