mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 23:29:31 +01:00
global method egw_message(_msg, _type) to display success-, warning- or error-messages in app-header
This commit is contained in:
parent
30d16c491f
commit
1f8e0e9e41
@ -537,7 +537,7 @@ etemplate2.prototype.getValues = function(_root)
|
||||
* If there's a message provided, we try to find where it goes and set it directly. Then
|
||||
* we look for a nextmatch widget, and tell it to refresh its data based on that ID.
|
||||
*
|
||||
* @param msg String Message to try to display. eg: "Entry added"
|
||||
* @param msg String Message to try to display. eg: "Entry added" (not used anymore, handeled by egw_refresh and egw_message)
|
||||
* @param id String|null Application specific entry ID to try to refresh
|
||||
* @param type String|null Type of change. One of 'edit', 'delete', 'add' or null
|
||||
*
|
||||
@ -546,22 +546,6 @@ etemplate2.prototype.getValues = function(_root)
|
||||
*/
|
||||
etemplate2.prototype.refresh = function(msg, app, id, type)
|
||||
{
|
||||
// We use et2_baseWidget in case the app uses something like HTML instead of label
|
||||
var msg_widget = this.widgetContainer.getWidgetById("msg");
|
||||
if(msg_widget)
|
||||
{
|
||||
if(typeof msg != "string")
|
||||
{
|
||||
msg = "";
|
||||
}
|
||||
msg_widget.set_value(msg);
|
||||
msg_widget.set_disabled(msg.trim().length == 0);
|
||||
|
||||
// In case parent(s) have been disabled, just show it all
|
||||
// TODO: Fix this so messages go in a single, well defined place that don't get disabled
|
||||
$j(msg_widget.getDOMNode()).parents().show();
|
||||
}
|
||||
|
||||
// Refresh nextmatches
|
||||
this.widgetContainer.iterateOver(function(_widget) {
|
||||
// Trigger refresh
|
||||
|
@ -218,12 +218,15 @@ function egw_getAppName()
|
||||
* @param string _targetapp which app's window should be refreshed, default current
|
||||
* @param string|RegExp _replace regular expression to replace in url
|
||||
* @param string _with
|
||||
* @param string _msg_type 'error', 'warning' or 'success' (default)
|
||||
*/
|
||||
function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with)
|
||||
function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
||||
{
|
||||
//alert("egw_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
|
||||
var win = typeof _targetapp != 'undefined' ? egw_appWindow(_targetapp) : window;
|
||||
|
||||
win.egw_message(_msg, _msg_type);
|
||||
|
||||
// if window registered an app_refresh method or overwritten app_refresh, just call it
|
||||
if(typeof win.app_refresh == "function" && typeof win.app_refresh.registered == "undefined" ||
|
||||
typeof win.app_refresh != "undefined" && win.app_refresh.registered(_app))
|
||||
@ -262,6 +265,42 @@ function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with)
|
||||
win.location.href = href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an error or regular message
|
||||
*
|
||||
* @param string _msg message to show
|
||||
* @param string _type 'error', 'warning' or 'success' (default)
|
||||
*/
|
||||
function egw_message(_msg, _type)
|
||||
{
|
||||
if (typeof _type == 'undefined')
|
||||
_type = _msg.match(/error/i) ? 'error' : 'success';
|
||||
|
||||
var framework = egw_getFramework();
|
||||
if (framework)
|
||||
{
|
||||
framework.setMessage.call(window.framework, _msg, _type);
|
||||
return;
|
||||
}
|
||||
|
||||
// handle message display for non-framework templates, eg. idots or jerryr
|
||||
if (window.egw_message_timer)
|
||||
{
|
||||
window.clearTimeout(window.egw_message_timer);
|
||||
delete window.egw_message_timer;
|
||||
}
|
||||
|
||||
$j('div#divAppboxHeader div').remove();
|
||||
$j('div#divAppboxHeader').prepend($j(document.createElement('div')).text(_msg).addClass(_type+'_message').css('position', 'absolute'));
|
||||
|
||||
if (_type != 'error') // clear message again after some time, if no error
|
||||
{
|
||||
window.egw_message_timer = window.setTimeout(function() {
|
||||
$j('div#divAppboxHeader').text(document.title.replace(/^.*\[(.*)\]$/, '$1'));
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* View an EGroupware entry: opens a popup of correct size or redirects window.location to requested url
|
||||
*
|
||||
|
@ -870,3 +870,25 @@ td.lettersearch {
|
||||
border-bottom: 1px solid silver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Styles for different egw_message-types
|
||||
*/
|
||||
.success_message, .warning_message, .error_message {
|
||||
color: red;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
text-align: left;
|
||||
margin-left: 5px;
|
||||
padding-left: 20px;
|
||||
background-image: url(../../default/images/check.png);
|
||||
background-position: left;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
}
|
||||
.warning_message {
|
||||
background-image: url(../../default/images/dialog_warning.png);
|
||||
}
|
||||
.error_message {
|
||||
font-weight: bold;
|
||||
background-image: url(../../default/images/dialog_error.png);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user