diff --git a/api/js/framework/fw_base.js b/api/js/framework/fw_base.js index 0357c6a865..a200dc114d 100644 --- a/api/js/framework/fw_base.js +++ b/api/js/framework/fw_base.js @@ -1164,5 +1164,39 @@ var fw_base = (function(){ "use strict"; return Class.extend( } } } + }, + + /** + * Set a notification message for topmenu info item + * + * @param {string} _id id of topmenu info item with its prefix + * @param {string} _message message that should be displayed + * @param {string} _tooltip hint text as tooltip + */ + topmenu_info_notify: function(_id, _switch, _message, _tooltip) { + var $items = jQuery('#egw_fw_topmenu_info_items').children(); + var prefix = "topmenu_info_"; + + $items.each(function(i,item){ + if (item.id == prefix+_id || item.id == _id) + { + var $notify = jQuery(item).find('.egw_fw_topmenu_info_notify'); + if (_switch) + { + if ($notify.length == 0) + { + $notify = jQuery(document.createElement('div')) + .addClass('egw_fw_topmenu_info_notify') + .prop('title', _tooltip) + .appendTo(item); + } + $notify.prop('title', _tooltip).text(_message); + } + else + { + $notify.remove(); + } + } + }); } });}).call(this); diff --git a/api/src/Framework.php b/api/src/Framework.php index 233f4f9c27..f2c73f263c 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -1121,52 +1121,70 @@ abstract class Framework extends Framework\Extra */ function topmenu(array $vars,array $apps) { - $this->_add_topmenu_info_item($this->_user_avatar_menu(), 'user_avatar'); + // array of topmenu info items (orders of the items matter) + $topmenu_info_items = [ + 'user_avatar' => $this->_user_avatar_menu(), + 'logout' => (Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'fw_mobile') ? self::_logout_menu() : null, + 'update' => ($update = Framework\Updates::notification()) ? $update : null, + 'notifications' => ($GLOBALS['egw_info']['user']['apps']['notifications']) ? self::_get_notification_bell() : null, + 'quick_add' => $vars['quick_add'], + 'print_title' => $this->_print_menu() + ]; + + // array of topmenu items (orders of the items matter) + $topmenu_items = [ + 0 => (is_array(($current_user = $this->_current_users()))) ? $current_user : null, + ]; + + // Home should be at the top before preferences if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home'])) { $this->_add_topmenu_item($apps['home']); } + // array of topmenu preferences items (orders of the items matter) + $topmenu_preferences = ['prefs', 'acl', 'cats', 'security']; + + // set topmenu preferences items if($GLOBALS['egw_info']['user']['apps']['preferences']) { - $this->add_preferences_topmenu('prefs'); - $this->add_preferences_topmenu('acl'); - $this->add_preferences_topmenu('cats'); - $this->add_preferences_topmenu('security'); + foreach ($topmenu_preferences as $prefs) + { + $this->add_preferences_topmenu($prefs); + } } - /* disable help until content is reworked - if($GLOBALS['egw_info']['user']['apps']['manual'] && isset($apps['manual'])) - { - $this->_add_topmenu_item(array_merge($apps['manual'],array('title' => lang('Help')))); - }*/ - + // call topmenu info items hooks Hooks::process('topmenu_info',array(),true); - if (($update = Framework\Updates::notification())) - { - $this->_add_topmenu_info_item($update, 'update'); - } - if($GLOBALS['egw_info']['user']['apps']['notifications']) - { - $this->_add_topmenu_info_item(self::_get_notification_bell(), 'notifications'); - } - - if (is_array(($current_user = $this->_current_users()))) $this->_add_topmenu_item($current_user); - $this->_add_topmenu_info_item($vars['quick_add'], 'quick_add'); - $this->_add_topmenu_info_item($this->_print_menu(), 'print_title'); // Add extra items added by hooks foreach(self::$top_menu_extra as $extra_item) { if ($extra_item['name'] == 'search') { - $this->_add_topmenu_info_item('', 'search'); + $topmenu_info_items['search'] = ''; } else { - $this->_add_topmenu_item($extra_item); + array_push($topmenu_items, $extra_item); } } - $this->_add_topmenu_item($apps['logout']); + // push logout as the last item in topmenu items list + array_push($topmenu_items, $apps['logout']); + + // set topmenu info items + foreach ($topmenu_info_items as $id => $content) + { + if (!$content || (in_array($id, ['search', 'quick_add', 'update']) && (Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'fw_mobile'))) + { + continue; + } + $this->_add_topmenu_info_item($content, $id); + } + // set topmenu items + foreach ($topmenu_items as $item) + { + if ($item) $this->_add_topmenu_item($item); + } } /** diff --git a/pixelegg/css/mobile.css b/pixelegg/css/mobile.css index 37c998e23a..fb9ca76f22 100644 --- a/pixelegg/css/mobile.css +++ b/pixelegg/css/mobile.css @@ -6982,6 +6982,8 @@ span.egw_tutorial_title { body .sidebar-toggle #egw_fw_top_toolbar div#egw_fw_menu { background-image: url(../images/topmenu_items/mobile/menu.png); } + body .sidebar-toggle #egw_fw_top_toolbar #egw_fw_topmenu_info_items, + body .sidebar-toggle #egw_fw_top_toolbar #egw_fw_topmenu, body .sidebar-toggle #egw_fw_top_toolbar #egw_fw_userinfo, body .sidebar-toggle #egw_fw_top_toolbar .egw_fw_logout, body .sidebar-toggle #egw_fw_top_toolbar #egw_fw_appsToggle { diff --git a/pixelegg/css/mobile.less b/pixelegg/css/mobile.less index 62c3a396ca..d55c42132e 100644 --- a/pixelegg/css/mobile.less +++ b/pixelegg/css/mobile.less @@ -680,7 +680,7 @@ .sidebar-toggle{ #egw_fw_top_toolbar { div#egw_fw_menu {background-image: url(../images/topmenu_items/mobile/menu.png);} - #egw_fw_userinfo, .egw_fw_logout, #egw_fw_appsToggle {display: none !important;} + #egw_fw_topmenu_info_items, #egw_fw_topmenu, #egw_fw_userinfo, .egw_fw_logout, #egw_fw_appsToggle {display: none !important;} } #egw_fw_sidebar{ top: 70px; diff --git a/pixelegg/head_mobile.tpl b/pixelegg/head_mobile.tpl index 1482db52c4..eef9116689 100644 --- a/pixelegg/head_mobile.tpl +++ b/pixelegg/head_mobile.tpl @@ -32,25 +32,29 @@ {hook_after_navbar}