Fix a bug notifications sidebar in client-side not being translated

This commit is contained in:
Hadi Nategh 2018-01-11 17:23:58 +01:00
parent 6f2f0c4a8d
commit 2bf7597647
3 changed files with 28 additions and 17 deletions

View File

@ -72,7 +72,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function()
_msg = _msg.toLowerCase(); _msg = _msg.toLowerCase();
// search apps in given order for a replacement // search apps in given order for a replacement
var apps = this.lang_order || ['custom', this.getAppName(), 'etemplate', 'common']; var apps = this.lang_order || ['custom', this.getAppName(), 'etemplate', 'common', 'notifications'];
for(var i = 0; i < apps.length; ++i) for(var i = 0; i < apps.length; ++i)
{ {
if (typeof lang_arr[apps[i]] != "undefined" && if (typeof lang_arr[apps[i]] != "undefined" &&

View File

@ -19,9 +19,16 @@ if ($GLOBALS['egw_info']['user']['apps']['notifications'])
{ {
$notification_config = Api\Config::read('notifications'); $notification_config = Api\Config::read('notifications');
Api\Translation::add_app('notifications'); Api\Translation::add_app('notifications');
$langRequire = array (
'app' => 'notifications',
'lang' => Api\Translation::$userlang,
'etag' => Api\Translation::etag('notifications', Api\Translation::$userlang)
);
$popup_poll_interval = empty($notification_config['popup_poll_interval']) ? 60 : $notification_config['popup_poll_interval']; $popup_poll_interval = empty($notification_config['popup_poll_interval']) ? 60 : $notification_config['popup_poll_interval'];
echo '<script src="'. $GLOBALS['egw_info']['server']['webserver_url']. '/notifications/js/notificationajaxpopup.js?'. echo '<script src="'. $GLOBALS['egw_info']['server']['webserver_url']. '/notifications/js/notificationajaxpopup.js?'.
filemtime(EGW_SERVER_ROOT.'/notifications/js/notificationajaxpopup.js'). '" type="text/javascript" id="notifications_script_id" data-poll-interval="'.$popup_poll_interval.'"></script>'; filemtime(EGW_SERVER_ROOT.'/notifications/js/notificationajaxpopup.js').
'" type="text/javascript" id="notifications_script_id" data-poll-interval="'.$popup_poll_interval.
'" data-langRequire="'. htmlspecialchars(json_encode($langRequire)).'"></script>';
echo ' echo '
<div id="egwpopup" style="display: none; z-index: 999;"> <div id="egwpopup" style="display: none; z-index: 999;">
<div id="egwpopup_header">'.lang('Notifications'). <div id="egwpopup_header">'.lang('Notifications').

View File

@ -559,20 +559,24 @@
var lab = egw_LAB || $LAB; var lab = egw_LAB || $LAB;
var self = notifications; var self = notifications;
lab.wait(function(){ lab.wait(function(){
if (typeof window.app == 'undefined') window.app = {}; var langRequire = jQuery('#notifications_script_id').attr('data-langRequire');
window.app.notifications = new self(); egw.langRequire(window, [JSON.parse(langRequire)], function()
// toggle notifications bar {
jQuery('.egwpopup_toggle').click(function(){window.app.notifications.toggle();}); if (typeof window.app == 'undefined') window.app = {};
jQuery('#egwpopup_fw_notifications').click(function(){window.app.notifications.toggle();}); window.app.notifications = new self();
jQuery(".egwpopup_deleteall", '#egwpopup').click(function(){ // toggle notifications bar
et2_dialog.show_dialog( function(_button){ jQuery('.egwpopup_toggle').click(function(){window.app.notifications.toggle();});
if (_button == 2) window.app.notifications.delete_all(); jQuery('#egwpopup_fw_notifications').click(function(){window.app.notifications.toggle();});
}, jQuery(".egwpopup_deleteall", '#egwpopup').click(function(){
egw.lang('Are you sure you want to delete all notifications?'), et2_dialog.show_dialog( function(_button){
egw.lang('Delete notifications'), if (_button == 2) window.app.notifications.delete_all();
null, et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw },
); egw.lang('Are you sure you want to delete all notifications?'),
}); egw.lang('Delete notifications'),
jQuery(".egwpopup_seenall", '#egwpopup').click(function(){window.app.notifications.mark_all_seen()}); null, et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw
);
});
jQuery(".egwpopup_seenall", '#egwpopup').click(function(){window.app.notifications.mark_all_seen()});
}, this);
}); });
})(); })();