From d90faa7dcc0b327bc7d9b384e3fc986bb8389e00 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 7 Feb 2014 09:11:30 +0000 Subject: [PATCH] fixed app-header show in wrong tab, caused by framework object being created AFTER egw --- phpgwapi/js/jsapi/egw.js | 2 +- phpgwapi/js/jsapi/egw_message.js | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 850da0ccb6..5380125fca 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -233,7 +233,7 @@ // set app-header if (window.framework && egw_script.getAttribute('data-app-header')) { - egw(window).app_header(egw_script.getAttribute('data-app-header')); + egw(window).app_header(egw_script.getAttribute('data-app-header'), appname); } // display a message if (egw_script.getAttribute('data-message')) diff --git a/phpgwapi/js/jsapi/egw_message.js b/phpgwapi/js/jsapi/egw_message.js index 6e1ef4e3ae..c0a7c4cedb 100644 --- a/phpgwapi/js/jsapi/egw_message.js +++ b/phpgwapi/js/jsapi/egw_message.js @@ -27,8 +27,6 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) _app; // not used, but required by function signature var message_timer; var jQuery = _wnd.jQuery; - var framework = _wnd.framework; - var is_popup = !framework || _wnd.opener; var error_reg_exp; // install handler to remove message on click @@ -36,6 +34,16 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) jQuery('div#egw_message').remove(); }); + /** + * Are we running in a popup + * + * @returns {boolean} true: popup, false: main window + */ + function is_popup() + { + return !_wnd.framework || _wnd.opener; + } + return { /** * Display an error or regular message @@ -45,6 +53,8 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) */ message: function(_msg, _type) { + var framework = _wnd.framework; + if (_msg && typeof _type == 'undefined') { if (typeof error_reg_exp == 'undefined') error_reg_exp = new RegExp('(error|'+egw.lang('error')+')', 'i'); @@ -53,7 +63,7 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) } // if we are NOT in a popup and have a framwork --> let it deal with it - if (!is_popup && typeof framework.setMessage != 'undefined') + if (!is_popup() && typeof framework.setMessage != 'undefined') { // currently not using framework, but top windows message //framework.setMessage.call(framework, _msg, _type); @@ -94,6 +104,16 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) } }, + /** + * Active app independent if we are using a framed template-set or not + * + * @returns {string} + */ + app_name: function() + { + return !is_popup() && _wnd.framework ? _wnd.framework.activeApp.appName : _wnd.egw_appName; + }, + /** * Update app-header and website-title * @@ -102,12 +122,12 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) */ app_header: function(_header,_app) { - if (!is_popup) // not for popups + if (!is_popup()) // not for popups { - var app = _app || egw_getAppName(); + var app = _app || this.app_name(); var title = _wnd.document.title.replace(/[.*]$/, '['+_header+']'); - framework.setWebsiteTitle.call(window.framework, app, title, _header); + _wnd.framework.setWebsiteTitle.call(_wnd.framework, app, title, _header); return; } jQuery('div#divAppboxHeader').text(_header);