From 7eed4524498d0335c66c8c8cedbe1887aa65ac6f Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 13 Jul 2018 10:55:02 +0530 Subject: [PATCH] dev/core#237 : Hide Drupal8 Administer Menu bar on CiviCRM pages --- CRM/Utils/System/Drupal.php | 9 +++++++ CRM/Utils/System/Drupal8.php | 9 +++++++ CRM/Utils/System/DrupalBase.php | 9 ------- js/{crm.drupal.js => crm.drupal7.js} | 7 +----- js/crm.drupal8.js | 14 +++++++++++ js/crm.wordpress.js | 5 +++- templates/CRM/common/navigation.js.tpl | 35 +++++++++++++------------- 7 files changed, 55 insertions(+), 33 deletions(-) rename js/{crm.drupal.js => crm.drupal7.js} (64%) create mode 100644 js/crm.drupal8.js diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index 4a677da3f6..0d6bf7e68f 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -861,4 +861,13 @@ AND u.status = 1 } } + /** + * Append Drupal7 js to coreResourcesList. + * + * @param array $list + */ + public function appendCoreResources(&$list) { + $list[] = 'js/crm.drupal7.js'; + } + } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 1413f2bd7b..b535b0a841 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -664,4 +664,13 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return \Drupal::languageManager()->getCurrentLanguage()->getId(); } + /** + * Append Drupal8 js to coreResourcesList. + * + * @param array $list + */ + public function appendCoreResources(&$list) { + $list[] = 'js/crm.drupal8.js'; + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 6c1eebcd6b..4f81b304ea 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -300,15 +300,6 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { _drupal_flush_css_js(); } - /** - * Append Drupal js to coreResourcesList. - * - * @param array $list - */ - public function appendCoreResources(&$list) { - $list[] = 'js/crm.drupal.js'; - } - /** * @inheritDoc */ diff --git a/js/crm.drupal.js b/js/crm.drupal7.js similarity index 64% rename from js/crm.drupal.js rename to js/crm.drupal7.js index 7ed33666e2..72a6d461d7 100644 --- a/js/crm.drupal.js +++ b/js/crm.drupal7.js @@ -11,12 +11,7 @@ CRM.$(function($) { $('#toolbar').css('z-index', ''); } }) - // d8 Hack to hide title when it should be (CRM-19960) .ready(function() { - var pageTitle = $('.page-title'); - var title = $('.page-title').text(); - if ('' == title) { - pageTitle.hide(); - } + $('#civicrm-menu').css({position: "fixed", top: "0px", 'width': '97%'}); }); }); diff --git a/js/crm.drupal8.js b/js/crm.drupal8.js new file mode 100644 index 0000000000..b35656b415 --- /dev/null +++ b/js/crm.drupal8.js @@ -0,0 +1,14 @@ +// http://civicrm.org/licensing +CRM.$(function($) { + // d8 Hack to hide title when it should be (CRM-19960) + $(document).ready(function() { + var pageTitle = $('.page-title'); + if ('' == pageTitle.text()) { + pageTitle.hide(); + } + + $('#civicrm-menu').css({position: "fixed", top: "0px", height: "29px"}); + + $('#toolbar-bar').hide(); + }); +}); diff --git a/js/crm.wordpress.js b/js/crm.wordpress.js index 774b24a35f..e9667e6d12 100644 --- a/js/crm.wordpress.js +++ b/js/crm.wordpress.js @@ -17,5 +17,8 @@ CRM.$(function($) { $('#wpadminbar').toggle(e.data === 2); }); } - }); + }) + .ready(function() { + $('#civicrm-menu').css({position: "fixed", top: "0px"}); + }); }); diff --git a/templates/CRM/common/navigation.js.tpl b/templates/CRM/common/navigation.js.tpl index 69151673f3..2b26596a74 100644 --- a/templates/CRM/common/navigation.js.tpl +++ b/templates/CRM/common/navigation.js.tpl @@ -54,30 +54,25 @@ {/strip}{/capture}//