From 1f9b7689e598652563f35eba387f2e94f3473664 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 17 Jul 2014 14:47:12 +0000 Subject: [PATCH] try to recover from non existing this.et2 --- mail/js/app.js | 76 ++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/mail/js/app.js b/mail/js/app.js index 4657cffd09..c34cd9bdfa 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -86,6 +86,26 @@ app.classes.mail = AppJS.extend( 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 * 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) { - //this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer - if (!this.et2) - { - try - { - this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer; - } - catch(e) - { - return; - } - } + if (!this.et2 && !this.checkET2()) return; var quotabox = this.et2.getWidgetById(this.nm_index+'[quotainpercent]'); @@ -921,21 +930,7 @@ app.classes.mail = AppJS.extend( */ mail_refreshVacationNotice: function(_data) { - //this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer - //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 (!this.et2 && !this.checkET2()) return; if (_data == null) { this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value(''); @@ -958,17 +953,8 @@ app.classes.mail = AppJS.extend( { //alert('mail_refreshFilter2Options'); if (_data == null) return; - if (!this.et2) - { - try - { - this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer; - } - catch(e) - { - return; - } - } + if (!this.et2 && !this.checkET2()) return; + var filter2 = this.et2.getWidgetById('filter2'); var current = filter2.value; var currentexists=false; @@ -990,17 +976,8 @@ app.classes.mail = AppJS.extend( { //alert('mail_refreshFilterOptions'); if (_data == null) return; - if (!this.et2) - { - try - { - this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer; - } - catch(e) - { - return; - } - } + if (!this.et2 && !this.checkET2()) return; + var filter = this.et2.getWidgetById('filter'); var current = filter.value; var currentexists=false; @@ -1098,6 +1075,7 @@ app.classes.mail = AppJS.extend( * @param {array} _status */ mail_setFolderStatus: function(_status) { + if (!this.et2 && !this.checkET2()) return; var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); for (var i in _status) { ftree.setLabel(i,_status[i]);