Commit 43bd54d7 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Add uk.squiffle.kam

parent 8b2a9959
<?php
class CRM_Kam_Page_AJAX {
public static function navMenu() {
if (CRM_Core_Session::singleton()->get('userID')) {
$menu = CRM_Core_BAO_Navigation::buildNavigationTree();
self::buildHomeMenu($menu);
CRM_Utils_Hook::navigationMenu($menu);
CRM_Core_BAO_Navigation::fixNavigationMenu($menu);
CRM_Core_BAO_Navigation::orderByWeight($menu);
self::filterByPermission($menu);
self::formatMenuItems($menu);
$output = [
'menu' => $menu,
'search' => CRM_Utils_Array::makeNonAssociative(CRM_Admin_Page_AJAX::getSearchOptions()),
];
// Encourage browsers to cache for a long time - 1 year
$ttl = 60 * 60 * 24 * 364;
CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
CRM_Utils_System::setHttpHeader('Cache-Control', "max-age=$ttl, public");
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
print (json_encode($output));
}
CRM_Utils_System::civiExit();
}
/**
* Unset menu items for disabled components and non-permissioned users
*
* @param $menu
*/
public static function filterByPermission(&$menu) {
foreach ($menu as $key => $item) {
if (
(array_key_exists('active', $item['attributes']) && !$item['attributes']['active']) ||
!CRM_Core_BAO_Navigation::checkPermission($item['attributes'])
) {
unset($menu[$key]);
continue;
}
if (!empty($item['child'])) {
self::filterByPermission($menu[$key]['child']);
}
}
}
public static function formatMenuItems(&$menu) {
foreach ($menu as $key => &$item) {
$props = $item['attributes'];
unset($item['attributes']);
if (!empty($props['separator'])) {
$item['separator'] = ($props['separator'] == 1 ? 'bottom' : 'top');
}
if (!empty($props['icon'])) {
$item['icon'] = $props['icon'];
}
if (!empty($props['attr'])) {
$item['attr'] = $props['attr'];
}
if (!empty($props['url'])) {
$item['url'] = CRM_Utils_System::evalUrl(CRM_Core_BAO_Navigation::makeFullyFormedUrl($props['url']));
}
if (!empty($props['label'])) {
$item['label'] = ts($props['label'], ['context' => 'menu']);
}
$item['name'] = !empty($props['name']) ? $props['name'] : CRM_Utils_String::munge(CRM_Utils_Array::value('label', $props));
if (!empty($item['child'])) {
self::formatMenuItems($item['child']);
}
}
$menu = array_values($menu);
}
/**
* @param array $menu
*/
public static function buildHomeMenu(&$menu) {
foreach ($menu as &$item) {
if (CRM_Utils_Array::value('name', $item['attributes']) === 'Home') {
unset($item['attributes']['label'], $item['attributes']['url']);
$item['attributes']['icon'] = 'crm-logo-sm';
$item['child'] = [
[
'attributes' => [
'label' => 'CiviCRM Home',
'name' => 'CiviCRM Home',
'url' => 'civicrm/dashboard?reset=1',
'weight' => 1,
]
],
[
'attributes' => [
'label' => 'Hide Menu',
'name' => 'Hide Menu',
'url' => '#hidemenu',
'weight' => 2,
]
],
[
'attributes' => [
'label' => 'Log out',
'name' => 'Log out',
'url' => 'civicrm/logout?reset=1',
'weight' => 3,
]
],
];
return;
}
}
}
}
This diff is collapsed.
# KAM - Keyboard Accessible Menus
This module uses the SmartMenus jQuery plugin to add a responsive, accessible, configurable menu to CiviCRM.
![Screencast](images/Wordpress-menubar.gif)
## Requirements
Requires CiviCRM 5.8 or later.
## Installation
Install as a normal CiviCRM extension; then optionally visit **Administer -> Customize Data & Screens -> Display Preferences** to choose menubar placement.
## Roadmap
This extension will be merged into CiviCRM core in the near future. See https://lab.civicrm.org/dev/core/issues/487
## Configuration
Menubar placement can be configured at **Administer -> Customize Data & Screens -> Display Preferences**. The options control where the menubar appears on desktop screens (on mobile screens it will always be collapsed regardless of this setting).
By default the bar will appear at the top of the screen with a toggle arrow to move it below the CMS menu.
## API
*Provides a clientside api for working with the menubar (adding/removing/updating menu items, etc.)*
#### Events
| Event | Description | Example |
| ------ | ----------- | ------- |
| `crmMenuLoad` | Triggered on the page body after menu data loads but *before* the menu is rendered in the dom.<br />This is a good time to add/remove items if you already know what they are at page load. | `$(document).on('crmMenuLoad', function() {` <br /> ` CRM.menubar.addItems(-1, 'Search', myItems);` <br /> `});` |
| `crmLoad` | Triggered on the `#civicrm-menu` element after menu is rendered in the dom. | `$(document).on('crmLoad', '#civicrm-menu', function() {` <br /> ` // Do something now that the menu is rendered` <br /> `});` |
#### Properties
| Property | Type | Description |
| ------ | ----------- | ------- |
| `attachTo` | String | jQuery selector of page element to attach menubar to. |
| `position` | String | E.g. 'over-cms-menu', 'below-cms-menu', 'above-crm-container'. |
| `settings` | Object | Settings to pass to SmartMenus during initialize. |
#### Methods
| Method | Description | Example |
| ------ | ----------- | ------- |
| `addItems( position, targetName, items )` | `position`: can be "before" or "after" to create siblings of the target, or an integer to specify index to place as child of the target (negative numbers will start from the end). <br /> `targetName`: name of the menu item to place the new items before/after/within. If using an index for position, specify `null` for placing top-level menu items. <br /> `items`: An array of one or more menu items. | `CRM.menubar.addItems('before', 'Search', [{name: 'foo', label: 'Foo', child: [{name: 'bar', label: 'Bar'}]}]);` |
| `close( )` | Close any open menus. | `CRM.menubar.close();` |
| `destroy( )` | Remove the menubar from the dom (although the menu data is still retained in `CRM.menubar.data` for use by `initialize()`). | `CRM.menubar.destroy();` |
| `hide( [speed], [showMessage] )` | Hides the menubar.<br />`speed`: if a number is given, a slideup animation is used.<br />`showMessage`: if `true`, a restore button will be shown. | `CRM.menubar.hide(250, true);` |
| `obj getItem( itemName )` | Returns the object defining a particular menu item. Includes children. | `CRM.menubar.getItem('New Individual');` |
| `initialize( )` | Build the menu from scratch. Called internally when the page loads. | `CRM.menubar.initialize();` |
| `bool isOpen( itemName )` | Checks if a given menu tree is open (will always return false if called on items that do not have children). | `var isOpen = CRM.menubar.isOpen('Search');` |
| `open( itemName )` | Opens the menu and gives focus to the named item. | `CRM.menubar.open('New Individual');` |
| `removeItem( itemName )` | Deletes an item from the menu (and all its children).<br />`itemName`: name of item to remove. | `CRM.menubar.removeItem('New Household');` |
| `show( [speed] )` | Shows the menubar if hidden.<br />`speed`: if a number is given, a slidedown animation is used. | `CRM.menubar.show(250);` |
| `spin( [spin] )` | Spins the icon in the home menu.<br />`spin`: pass a boolean to start or stop the spinning, or pass no arguments to toggle. | `CRM.menubar.spin(true); // start` <br /> `CRM.menubar.spin(false); // stop` |
| `togglePosition()` | Toggles between 'over-cms-menu' and 'below-cms-menu'. | `CRM.menubar.togglePosition();` |
| `updateItem( item )` | Updates the properties of a menu item (label, url, separator, icon, etc.<br />`item`: object with at least a `name` plus properties to update. | `CRM.menubar.updateItem({name: 'Search', label: 'Find'});` |
Tip: Try pasting those examples into your browser console.
#### CSS classes
*The following css classes are added to the page body*
* `crm-menubar-visible` When the menubar is present and visible.
* `crm-menubar-hidden` When the menubar is present but hidden via `CRM.menubar.hide()`.
* `crm-menubar-wrapped` When the menu items have wrapped to a second line and the menubar is twice as tall.
* Depending on which option is selected, the body will also have one of: `crm-menubar-over-cms-menu`, `crm-menubar-below-cms-menu`, `crm-menubar-above-crm-container`.
#### Hooks
Your custom code can alter the list of menubar placement options via [hook_civicrm_alterSettingsMetaData](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsMetaData/) - modify the `options` array in the setting `menubar_position`.
E.g. adding a new option named "foo" will add class `crm-menubar-foo` to the page body when selected which can be targeted from your stylesheet.
## Acknowledgements
- The SmartMenus jQuery plugin was written by Vasil Dinkov - smartmenus.org
- Based on com.aghstrategies.slicknav that provides a responsive menu on mobile devices. This module changes the menu on both mobile and desktop displays.
- Nic Wistreich - customising CSS to blend smartmenus with CiviCRM
/* joomla.css: Joomla-specific css directives for CiviCRM. */
/*
** HTML elements
*/
div#toolbar-box .icon-48-generic {
display: none;
}
div#toolbar-box {
height: 26px;
}
fieldset {
margin-bottom: 1em;
padding: .5em;
}
form {
margin: 0;
padding: 0;
}
hr {
height: 1px;
border: 1px solid gray;
}
img {
border: 0;
}
/* Added in CiviCRM 2.0 to alleviate tiny font issues. */
#crm-container tr, #crm-container tr td {
font-size: 1em;
}
/* Added in CiviCRM 2.1 to overwrite tiny font in TinyMCE editor. */
#crm-container #content table.mceLayout td {
font-size: 0em;
}
th {
text-align: left;
padding-right: 1em;
border-bottom: 3px solid #ccc;
white-space: nowrap;
}
th.active img {
display: inline;
}
tr.dark, tr.light {
background-color: #eee;
border-bottom: 1px solid #ccc;
padding: 0.1em 0.6em;
}
td.active {
background-color: #ddd;
}
td.label {
background: none;
color: #3e3e3e;
display: table-cell;
}
/*
** Other common styles
*/
.breadcrumb {
padding-bottom: .5em
}
.block ul {
margin: 0;
padding: 0 0 0.25em 1em;
}
br.clear {
clear: both;
height: 0px;
}
.container-inline div {
display: inline;
}
.container-inline .crm-form-submit {
margin: 0;
}
.item-list .icon {
color: #555;
float: right;
padding-left: 0.25em;
clear: right;
}
.item-list .icon a {
color: #000;
text-decoration: none;
}
.item-list .icon a:hover {
color: #000;
text-decoration: none;
}
.item-list .title {
font-weight: bold;
}
.item-list ul {
margin: 0 0 0.75em 0;
padding: 0;
}
.item-list ul li {
margin: 0 0 0.25em 1.5em;
padding: 0;
list-style: disc;
}
/* Override .9em field help size from civicrm.css - CiviCRM 2.0 */
#crm-container div.description, #crm-container span.description, #crm-container dd.description {
font-size: 1em;
}
#crm-container div.description, #crm-container span.description {
margin: 2px 0 15px 0;
display: block;
}
.form-item label {
font-weight: bold;
}
.form-item label.option {
font-weight: normal;
}
.crm-form-submit {
margin: 0.5em 0;
}
.marker, .form-required {
color: #f00;
}
.more-link {
text-align: right;
}
#pager {
clear: both;
text-align: center;
}
#pager div {
padding: 0.5em;
}
.tips {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
font-size: 0.9em;
}
.more-help-link {
font-size: 0.85em;
text-align: right;
}
/*
** Page layout blocks / IDs
*/
#header, #content {
width: 100%;
}
#header {
background-color: #69c;
}
#logo {
vertical-align: middle;
border: 0;
}
#logo img {
float: left;
padding: 0em 1.0em 0em 1em;
border: 0;
}
#menu {
padding: 0 0 0 0;
vertical-align: middle;
}
#primary {
font-size: 1.0em;
padding: 0em 0.8em 0.5em 0;
color: #9cf;
}
#primary a {
font-weight: bold;
color: #fff;
}
#secondary {
padding: 0 1em 0.5em 0;
font-size: 0.8em;
color: #9cf;
}
#secondary a {
font-weight: bold;
color: #9cf;
}
#search .form-text, #search .crm-form-submit {
border: 1px solid #369;
font-size: 1.1em;
}
#search .form-text {
width: 8em;
height: 1.4em;
padding: 0 0.5em 0 0.5em;
margin: 0 0 0.5em 0;
}
#search .crm-form-submit {
height: 1.5em;
}
#main {
/* padding in px not ex because IE messes up 100% width tables otherwise */
padding: 10px;
}
#help {
font-size: 1em;
margin-bottom: 1em;
}
.breadcrumb {
margin-bottom: .5em;
}
.messages {
background-color: #eee;
border: 1px solid #ccc;
padding: 0.3em;
margin-bottom: 1em;
}
.error {
border-color: red;
color: red;
}
#sidebar-left, #sidebar-right {
background-color: #ddd;
width: 16em;
/* padding in px not ex because IE messes up 100% width tables otherwise */
padding: 20px;
vertical-align: top;
}
#content-right {
background-color: #FFFFFF;
}
#footer {
padding: 1em;
font-size: 0.8em;
}
/*
** Common declarations for child classes of node, comment, block, box, etc.
** If you want any of them styled differently for a specific parent, add
** additional rules /with only the differing properties!/ to .parent .class.
** See .comment .title for an example.
*/
.title, .title a {
font-weight: normal;
font-size: 1.6em;
color: #666;
margin: 0 auto 0 auto; /* decrease default margins for h<x>.title */
}
.block-civicrm #recently-viewed .crm-icon, .crm-icon {
margin-top: 0 !important;
}
.submitted {
color: #999;
font-size: 0.8em;
}
.links {
color: #999;
}
.links a {
font-weight: bold;
}
.block, .box {
padding: 0 0 1.5em 0;
}
.block {
min-height: 25px;
border-bottom: 1px solid #bbb;
padding-bottom: 0.75em;
margin-bottom: 1.5em;
}
.block .title {
margin-bottom: .25em;
}
.box .title {
font-size: 1.1em;
}
#module-status, .version {
font-size:11px;
}
#module-status a {
font-weight: normal;
}
.main {
text-align:left;
}
/* Joomla Admin Menu alterations */
/* Moved from civicrm.css in v3.2 */
div#toolbar-box div.m {
padding: 0px !important;
min-height: 0;
border: 0;
margin-top: 8px;
}
div#toolbar-box, div#toolbar-box div.m{
height: auto;
}
.crm-tab-button,
.ui-tabs .ui-tabs-nav li {
border: 1px;
font-size: 110%;
}
.ui-tabs .ui-tabs-nav {
padding: 0.2em 3px 1px;
}
#mainTabContainer li.crm-tab-button {
margin:0 3px 3px 0;
border: 1px solid #F5F6F1 !important;
}
#mainTabContainer li.crm-tab-button.ui-tabs-selected {
padding-bottom: 0;
border: 1px solid #999 !important;
}
#crm-container {
font-size: 11px;
}
#crm-container .col1 {
margin: 0;
}
#crm-container .footer {
font-size: 1em;
}
.ac_results .ac_odd {
background-color: #444;
}
#crm-notification-container {
top: 100px;
}
.crm-container textarea,
.crm-container input,
.crm-container select {
font-size: 12px;
margin-bottom: auto;
margin-right: 4px;
width: auto;
padding: 2px 4px;
}
.crm-container .select2-search input {
width: 100%;
}
.crm-container textarea,
.crm-container input {
height: auto;
}
.crm-container input[type=submit] {
height: auto;
}
.crm-container .disabled {
font-weight: normal;
}
#crm-container .form-layout td.label,
.crm-container .form-layout td.label {
width: inherit;
}
#crm-container .crm-event-form-fee-block .label {
background-color: inherit;
width: inherit;
display: block;
}
/* Remove Joomla subhead toolbar & whitespace border */
body.admin.com_civicrm .subhead-collapse {
display:none;
}
body.admin.com_civicrm .container-fluid.container-main {
padding: 0;
border-top: 1px solid #787878;
}
body.admin.com_civicrm #content-right {
padding: 12px;
}
\ No newline at end of file
/* CiviCRM navigation menu stylesheet */
#civicrm-menu-nav {
line-height: 0;
text-align: left;
font-size: 13px;
}
#civicrm-menu {
background-color: #f2f2f2;
width: 100%;
z-index: 500;
height: auto;
margin: 0;
}
#civicrm-menu i {
margin-right: 3px;
}
#civicrm-menu li {
border: none;
padding: 0;
}
#civicrm-menu li a {
padding: 12px 8px;
text-decoration: none;
color: #333;
box-shadow: none;
border: none;
}
#civicrm-menu li a[href="#"] {
cursor: default;
}
#civicrm-menu li li a {
padding: 6px 36px 6px 10px;
}
#civicrm-menu li.crm-menu-border-bottom:not(:last-child) {
border-bottom: 1px solid #bbb;
}
#civicrm-menu li:not(.crm-menu-border-bottom) + li.crm-menu-border-top {
border-top: 2px solid #bbb;
}
#civicrm-menu li a:focus,
#civicrm-menu li a:hover,
#civicrm-menu li a.highlighted {
text-decoration: none;
background-color: #fff;
}
#civicrm-menu li li .sub-arrow:before {
content: "\f0da";
font-family: 'FontAwesome';
color: #666;
float: right;
margin-right: -25px;
}
/* x icon */
#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon {
height: 0;
background: transparent;
}
#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon:before {
top: 0;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon:after {
top: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
/* hide menu state checkbox (keep it visible to screen readers) */
#civicrm-menu-nav #crm-menubar-state {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
overflow: hidden;
clip: rect(1px,1px,1px,1px);
}
#civicrm-menu-nav .crm-menubar-toggle-btn {
position: relative;
display: inline-block;
width: 57px;
height: 28px;
text-indent: 28px;
white-space: nowrap;
overflow: hidden;
cursor: pointer;
color: transparent;
-webkit-tap-highlight-color: rgba(0,0,0,0);
background-color: #333;
}
/* responsive icon */
#civicrm-menu-nav .crm-menubar-toggle-btn-icon,
#civicrm-menu-nav .crm-menubar-toggle-btn-icon:before,
#civicrm-menu-nav .crm-menubar-toggle-btn-icon:after {
position: absolute;
top: 50%;
left: 27px;
height: 2px;
width: 24px;
background: #bbb;
-webkit-transition: all 0.25s;
transition: all 0.25s;
}
#civicrm-menu-nav .crm-menubar-toggle-btn-icon:before {
content: '';
top: -7px;
left: 0;
}
#civicrm-menu-nav .crm-menubar-toggle-btn-icon:after {
content: '';
top: 7px