From 8960d9b994132446a85ecd6bf71ee5a6bc0083da Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 16 Jan 2014 21:30:26 -0800 Subject: [PATCH] CRM-13817 - Move logout menu item and add CRM.status() --- CRM/Core/BAO/Navigation.php | 22 ++++++++++++++-------- css/civicrm.css | 25 ++++++++++++++++++++++--- js/Common.js | 27 +++++++++++++++++++++++++++ templates/CRM/common/Navigation.tpl | 8 ++++++++ 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 3ad5ca88c8..61ace95999 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -577,12 +577,11 @@ ORDER BY parent_id, weight"; //add additional navigation items $logoutURL = CRM_Utils_System::url('civicrm/logout', 'reset=1'); - $appendString = "
  • " . ts('Logout') . "
  • "; // get home menu from db $homeParams = array('name' => 'Home'); $homeNav = array(); - $homeIcon = ''; + $homeIcon = ''; self::retrieve($homeParams, $homeNav); if ($homeNav) { list($path, $q) = explode('&', $homeNav['url']); @@ -597,25 +596,32 @@ ORDER BY parent_id, weight"; $homeURL = CRM_Utils_System::url('civicrm/dashboard', 'reset=1'); $homeLabel = ts('CiviCRM Home'); } - + // Link to hide the menubar if ( ($config->userSystem->is_drupal) && ((module_exists('toolbar') && user_access('access toolbar')) || module_exists('admin_menu') && user_access('access administration menu') ) ) { - $prepandString = '
  • ' . $homeIcon . ""; + $hideLabel = ts('Hide Menu'); } - $navigation = $prepandString . $navigation . $appendString; + $prepandString = " +
  • tag doesn't need to be closed } - return $navigation; + return $prepandString . $navigation; } /** diff --git a/css/civicrm.css b/css/civicrm.css index 5408d0b449..5d5c0c9d9c 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2826,9 +2826,28 @@ div.grippie { padding: 2px 16px 3px 2px; } -#civicrm-menu #menu-logout { - float: right; - border-left: 1px solid #5D5D5D; +/* Status message bar */ +#civicrm-menu .crm-menubar-status-container { + position: absolute; + right: 2px; + top: 0; + border-top: 1px solid #1B1B1B; +} + +#civicrm-menu .crm-menubar-status-progressbar { + padding: 3px 14px; + font-size: 14px !important; + font-weight: bold; + background: rgba(142, 136, 0, 0.9); + text-align: center; +} + +#civicrm-menu .status-busy { + background: #F8FF03 url("../packages/jquery/jquery-ui/css/black-tie/images/animated-overlay.gif"); +} + +#civicrm-menu .status-done .crm-menubar-status-progressbar { + background: rgba(41, 152, 32, 0.7); } /* Pop-up help icon - eliminate forced line break */ diff --git a/js/Common.js b/js/Common.js index ed859b2816..c85d38cb4a 100644 --- a/js/Common.js +++ b/js/Common.js @@ -579,6 +579,33 @@ CRM.validate = CRM.validate || { } ); }; + /** + * @param startMsg string + * @param endMsg string|function + * @param deferred optional jQuery deferred object + * @return jQuery deferred object - if not supplied a new one will be created + */ + var fadeOut; + CRM.status = function(startMsg, endMsg, deferred) { + var $bar = $('#civicrm-menu'); + if (!$bar.length) { + console && console.log && console.log('CRM.status called on a page with no menubar'); + return; + } + $('.crm-menubar-status-container', $bar).remove(); + fadeOut && window.clearTimeout(fadeOut); + $bar.append('
  • ' + startMsg + '
  • '); + $('.crm-menubar-status-container', $bar).css('min-width', $('.crm-menubar-status-container', $bar).width()); + deferred || (deferred = new $.Deferred()); + deferred.done(function(data) { + var msg = typeof(endMsg) === 'function' ? endMsg(data) : endMsg; + $('.crm-menubar-status-container', $bar).removeClass('status-busy').addClass('status-done').find('.crm-menubar-status-msg').html(msg); + fadeOut = window.setTimeout(function() { + $('.crm-menubar-status-container', $bar).fadeOut('slow'); + }, 2000); + }); + return deferred; + }; /** * @param string text Displayable message diff --git a/templates/CRM/common/Navigation.tpl b/templates/CRM/common/Navigation.tpl index 36aa47ebdb..265215a9bf 100644 --- a/templates/CRM/common/Navigation.tpl +++ b/templates/CRM/common/Navigation.tpl @@ -114,6 +114,14 @@ $('#civicrm-menu').ready(function() { $('.crm-hidemenu').click(function() { $.Menu.closeAll(); $('#civicrm-menu').slideUp(); + var alert = CRM.alert({/literal}'{ts escape='js'}Restore Menu{/ts}', "{ts escape='js'}CiviCRM Menu Hidden{/ts}"{literal}); + $('#crm-notification-container') + .off('.hideMenu') + .on('click.hideMenu', '#crm-restore-menu', function() { + alert.close(); + $('#civicrm-menu').slideDown(); + return false; + }); return false; }); $('.crm-quickSearchField').click(function() { -- 2.25.1