diff --git a/phpgwapi/js/jsapi/egw_message.js b/phpgwapi/js/jsapi/egw_message.js index bb6a3dd576..924cff4ea1 100644 --- a/phpgwapi/js/jsapi/egw_message.js +++ b/phpgwapi/js/jsapi/egw_message.js @@ -59,8 +59,9 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) * * @param {string} _msg message to show or empty to remove previous message * @param {string} _type 'help', 'info', 'error', 'warning' or 'success' (default) + * @param {boolean} _discard if true, it will show a checkbox in order to discard the message, default is false */ - message: function(_msg, _type) + message: function(_msg, _type, _discard) { var jQuery = _wnd.jQuery; @@ -95,15 +96,74 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) { // replace p and br-tags with newlines _msg = _msg.replace(new_line_reg, "\n"); - + var msg_div = jQuery(_wnd.document.createElement('div')) .attr('id','egw_message') .text(_msg) .addClass(_type+'_message') - .click(function() {$j(this).remove();}) + .click(function() { + //check if the messeage should be discarded forever + if (_type == 'info' && _discard + && msg_chkbox && msg_chkbox.is(':checked')) + { + var discarded = egw.getLocalStorageItem(egw.app_name(),'discardedMsgs'); + + if (!isDiscarded(_msg)) + { + if (!discarded) + { + discarded = [_msg]; + } + else + { + if (jQuery.isArray(JSON.parse(discarded))) discarded.push(_msg); + } + egw.setLocalStorageItem(egw.app_name(),'discardedMsgs',JSON.stringify(discarded)); + } + } + $j(this).remove(); + }) .css('position', 'absolute'); + + // discard checkbox implementation + if (_discard && _type === 'info') + { + // helper function to check if the messaege is discarded + var isDiscarded = function (_msg) + { + var discarded = JSON.parse(egw.getLocalStorageItem(egw.app_name(),'discardedMsgs')); + + if (jQuery.isArray(discarded)) + { + for(var i=0; i< discarded.length; i++) + { + if (discarded[i] === _msg) return true; + } + } + return false; + }; + + //discard div container + var msg_discard =jQuery(_wnd.document.createElement('div')).addClass('discard'); + + // checkbox + var msg_chkbox = jQuery(_wnd.document.createElement('input')) + .attr({type:"checkbox",name:"msgChkbox"}) + .click(function(e){e.stopImmediatePropagation();}) + .appendTo(msg_discard); + // Label + jQuery(_wnd.document.createElement('label')) + .text(egw.lang("Don't show this again")) + .css({"font-weight":"bold"}) + .attr({for:'msgChkbox'}) + .appendTo(msg_discard); + + if (isDiscarded(_msg)) return; + msg_div.append(msg_discard); + } + parent.prepend(msg_div); - + // replace simple a href (NO other attribute, to gard agains XSS!) var matches = a_href_reg.exec(_msg); if (matches) diff --git a/phpgwapi/lang/egw_de.lang b/phpgwapi/lang/egw_de.lang index ccf087bb8b..42be1647a3 100644 --- a/phpgwapi/lang/egw_de.lang +++ b/phpgwapi/lang/egw_de.lang @@ -263,6 +263,7 @@ domain name for mail-address, eg. "%1" common de Domainname für E-Mail Adresse, domestic common de Inland dominica common de DOMINICA dominican republic common de DOMINIKANISCHE REPUBLIK +don't show this again common de Text nicht mehr anzeigen done common de Fertig dos international common de DOS International download common de Herunterladen diff --git a/phpgwapi/lang/egw_en.lang b/phpgwapi/lang/egw_en.lang index 0a44c45f59..14fbec58a9 100644 --- a/phpgwapi/lang/egw_en.lang +++ b/phpgwapi/lang/egw_en.lang @@ -263,6 +263,7 @@ domain name for mail-address, eg. "%1" common en Domain name for mail address, e domestic common en Domestic dominica common en DOMINICA dominican republic common en DOMINICAN REPUBLIC +don't show this again common en Don't show this again done common en Done dos international common en DOS International download common en Download diff --git a/phpgwapi/templates/idots/css/traditional.css b/phpgwapi/templates/idots/css/traditional.css index 775a29fd7a..e7f8eb3beb 100755 --- a/phpgwapi/templates/idots/css/traditional.css +++ b/phpgwapi/templates/idots/css/traditional.css @@ -961,6 +961,10 @@ td.lettersearch { .help_message { background-image: url(../../default/images/dialog_help.png); } +.info_message .discard { + float:right; + margin-top: 4px; +} /** * Message in popup */ diff --git a/pixelegg/css/mobile.css b/pixelegg/css/mobile.css index ace1bdf13b..fa69918be0 100644 --- a/pixelegg/css/mobile.css +++ b/pixelegg/css/mobile.css @@ -3798,6 +3798,10 @@ div.admin-config form > table td b { font-weight: bold; background-image: url(../images/dialog_error.png); } +.info_message .discard { + float:right; + margin-top: 4px; +} /** * Message in popup */ diff --git a/pixelegg/css/pixelegg.css b/pixelegg/css/pixelegg.css index 0dafb2144d..8d47b88dbb 100644 --- a/pixelegg/css/pixelegg.css +++ b/pixelegg/css/pixelegg.css @@ -3784,6 +3784,10 @@ div.admin-config form > table td b { font-weight: bold; background-image: url(../images/dialog_error.png); } +.info_message .discard { + float:right; + margin-top: 4px; +} /** * Message in popup */ diff --git a/pixelegg/less/layout_dialog.less b/pixelegg/less/layout_dialog.less index 9870323d6d..35a7db8ea0 100755 --- a/pixelegg/less/layout_dialog.less +++ b/pixelegg/less/layout_dialog.less @@ -487,7 +487,10 @@ div.admin-config form > table { font-weight: bold; background-image: url(../images/dialog_error.png); } - +.info_message .discard { + float:right; + margin-top: 4px; +} /** * Message in popup */