Commit 632071d5 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Update KAM extension to 1.0

parent 039df6a6
......@@ -82,6 +82,7 @@ class CRM_Kam_Page_AJAX {
if (CRM_Utils_Array::value('name', $item['attributes']) === 'Home') {
unset($item['attributes']['label'], $item['attributes']['url']);
$item['attributes']['icon'] = 'crm-logo-sm';
$item['attributes']['attr']['accesskey'] = 'm';
$item['child'] = [
[
'attributes' => [
......
......@@ -36,7 +36,7 @@
border-bottom: 1px solid #bbb;
}
#civicrm-menu li:not(.crm-menu-border-bottom) + li.crm-menu-border-top {
border-top: 2px solid #bbb;
border-top: 1px solid #bbb;
}
#civicrm-menu li a:focus,
#civicrm-menu li a:hover,
......
......@@ -2,7 +2,7 @@
<extension key="uk.squiffle.kam" type="module">
<file>kam</file>
<name>Keyboard Accessible Menu</name>
<description>This module replaces the default admin menu with an accessible, responsive one using the SmartMenus jQuery menu plugin (smartmenus.org)</description>
<description>Replaces the default admin menu with an accessible, responsive one using the SmartMenus jQuery menu plugin (smartmenus.org)</description>
<license>AGPL-3.0</license>
<maintainer>
<author>Aidan Saunders</author>
......@@ -14,8 +14,8 @@
<url desc="Support">https://github.com/aydun/uk.squiffle.kam</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2018-12-20</releaseDate>
<version>1.0.beta3</version>
<releaseDate>2019-01-17</releaseDate>
<version>1.0</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.8</ver>
......
......@@ -2,7 +2,8 @@
(function($, _) {
"use strict";
var templates, initialized,
ENTER_KEY = 13;
ENTER_KEY = 13,
SPACE_KEY = 32;
CRM.menubar = _.extend({
data: null,
settings: {collapsibleBehavior: 'accordion'},
......@@ -10,14 +11,14 @@
attachTo: (CRM.menubar && CRM.menubar.position === 'above-crm-container') ? '#crm-container' : 'body',
initialize: function() {
var cache = CRM.cache.get('menubar');
if (cache && cache.code === CRM.config.menuCacheCode && cache.lang === CRM.config.lcMessages && localStorage.civiMenubar) {
if (cache && cache.code === CRM.config.menuCacheCode && cache.locale === CRM.config.locale && localStorage.civiMenubar) {
CRM.menubar.data = cache.data;
insert(localStorage.civiMenubar);
} else {
$.getJSON(CRM.url('civicrm/ajax/navmenu', {c: CRM.config.menuCacheCode, l: CRM.config.lcMessages}))
$.getJSON(CRM.url('civicrm/ajax/navmenu', {c: CRM.config.menuCacheCode, l: CRM.config.locale}))
.done(function(data) {
var markup = getTpl('tree')(data);
CRM.cache.set('menubar', {code: CRM.config.menuCacheCode, lang: CRM.config.lcMessages, data: data});
CRM.cache.set('menubar', {code: CRM.config.menuCacheCode, locale: CRM.config.locale, data: data});
CRM.menubar.data = data;
localStorage.setItem('civiMenubar', markup);
insert(markup);
......@@ -58,6 +59,16 @@
e.preventDefault();
CRM.menubar.hide(250, true);
})
.on('keyup', 'a', function(e) {
// Simulate a click when spacebar key is pressed
if (e.which == SPACE_KEY) {
$(e.currentTarget)[0].click();
}
})
.on('show.smapi', function(e, menu) {
// Focus menu when opened with an accesskey
$(menu).siblings('a[accesskey]:not(:hover)').focus();
})
.smartmenus(CRM.menubar.settings);
initialized = true;
CRM.menubar.initializeResponsive();
......@@ -153,7 +164,7 @@
list = CRM.menubar.data.menu;
}
if (position < 0) {
position = list.length + 1 - position;
position = list.length + 1 + position;
}
if (position >= list.length) {
list.push.apply(list, items);
......@@ -169,9 +180,12 @@
CRM.menubar.refresh();
},
removeItem: function(itemName) {
traverse(CRM.menubar.data.menu, itemName, 'delete');
$('li[data-name="' + itemName + '"]', '#civicrm-menu').remove();
CRM.menubar.refresh();
var item = traverse(CRM.menubar.data.menu, itemName, 'delete');
if (item) {
$('li[data-name="' + itemName + '"]', '#civicrm-menu').remove();
CRM.menubar.refresh();
}
return item;
},
updateItem: function(item) {
if (!item.name) {
......@@ -363,7 +377,7 @@
'<a href="#"> ' +
'<form action="<%= CRM.url(\'civicrm/contact/search/advanced\') %>" name="search_block" method="post">' +
'<div>' +
'<input type="text" id="crm-qsearch-input" name="sort_name" placeholder="\uf002" />' +
'<input type="text" id="crm-qsearch-input" name="sort_name" placeholder="\uf002" accesskey="q" />' +
'<input type="hidden" name="hidden_location" value="1" />' +
'<input type="hidden" name="hidden_custom" value="1" />' +
'<input type="hidden" name="qfKey" value="<%= CRM.menubar.qfKey %>" />' +
......@@ -379,8 +393,8 @@
'</li>',
branchTpl:
'<% _.forEach(items, function(item) { %>' +
'<li <%= attr(item) %>>' +
'<a href="<%= item.url || "#" %>">' +
'<li <%= attr("li", item) %>>' +
'<a <%= attr("a", item) %>>' +
'<% if (item.icon) { %>' +
'<i class="<%- item.icon %>"></i>' +
'<% } %>' +
......@@ -434,11 +448,17 @@
return found;
}
function attr(item) {
var ret = [], attr = _.cloneDeep(item.attr || {});
attr['data-name'] = item.name;
if (item.separator) {
attr.class = (attr.class ? attr.class + ' ' : '') + 'crm-menu-border-' + item.separator;
function attr(el, item) {
var ret = [], attr = _.cloneDeep(item.attr || {}), a = ['rel', 'accesskey'];
if (el === 'a') {
attr = _.pick(attr, a);
attr.href = item.url || "#";
} else {
attr = _.omit(attr, a);
attr['data-name'] = item.name;
if (item.separator) {
attr.class = (attr.class ? attr.class + ' ' : '') + 'crm-menu-border-' + item.separator;
}
}
_.each(attr, function(val, name) {
ret.push(name + '="' + val + '"');
......
......@@ -38,6 +38,7 @@ function kam_civicrm_coreResourceList(&$list, $region) {
->addScriptFile('uk.squiffle.kam', $path . 'addons/keyboard/jquery.smartmenus.keyboard.js', -98, 'html-header')
->addScriptFile('uk.squiffle.kam', 'js/crm.menubar.js', -97, 'html-header');
$list[] = [
'config' => ['locale' => CRM_Core_I18n::getLocale()],
'menubar' => [
'position' => $position,
'qfKey' => CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE),
......
{*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{htxt id="accesskeys-title"}
{ts}Access Keys{/ts}
{/htxt}
{htxt id="accesskeys"}
{php}
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strstr($ua, 'mac')) {
$key = '<span>CTRL</span>+<span>ALT</span>';
}
else {
$key = strstr($ua, 'firefox') ? '<span>ALT</span>+<span>SHIFT</span>' : '<span>ALT</span>';
}
$this->assign('accessKey', $key);
{/php}
<p></p>
<ul id="crmAccessKeyList">
<li>{$accessKey}+<span>E</span> - {ts}Edit Contact (View Contact Summary Page){/ts}</li>
<li>{$accessKey}+<span>S</span> - {ts}Save Button{/ts}</li>
<li>{$accessKey}+<span>N</span> - {ts}Add a new record in each tab (Activities, Tags,..etc){/ts}</li>
<li>{$accessKey}+<span>M</span> - {ts}Open the CiviCRM menubar{/ts}</li>
<li>{$accessKey}+<span>Q</span> - {ts}Quicksearch{/ts}</li>
</ul>
{literal}<style type="text/css">
#crmAccessKeyList li {
margin-top: 5px;
}
#crmAccessKeyList span {
display: inline-block;
background: grey;
font-size: 80%;
border: 2px groove #eee;
padding: 0 4px;
}
</style>{/literal}
{/htxt}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment