Commit d6ffcbc8 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Update recentmenu extension

parent 8bb40fdf
......@@ -14,8 +14,8 @@
<url desc="Support">https://github.com/civicrm/org.civicrm.recentmenu</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2018-12-21</releaseDate>
<version>1.1</version>
<releaseDate>2019-02-28</releaseDate>
<version>1.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.8</ver>
......
(function($) {
$(document).on('crmLoad', '#civicrm-menu', function() {
$(document)
.on('crmLoad', '#civicrm-menu', function() {
if (CRM.vars && CRM.vars.recentmenu && !CRM.menubar.getItem('recent_items')) {
CRM.menubar.addItems(-1, null, [CRM.vars.recentmenu]);
}
})
.ajaxSuccess(function(event, xhr, settings) {
try {
if ((!settings.dataType || settings.dataType == 'json') && xhr.responseText) {
var response = $.parseJSON(xhr.responseText);
if (typeof(response.recentmenu_items) == 'object') {
CRM.vars.recentmenu = response.recentmenu_items;
CRM.menubar.updateItem(response.recentmenu_items);
}
}
}
// Ignore errors thrown by parseJSON and the menubar
catch (e) {}
});
})(CRM.$);
......@@ -134,11 +134,45 @@ function recentmenu_civicrm_entityTypes(&$entityTypes) {
_recentmenu_civix_civicrm_entityTypes($entityTypes);
}
/**
* Implements hook_civicrm_pageRun().
*/
function recentmenu_civicrm_pageRun(&$page) {
if (!empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], ['json', 6])) {
$page->ajaxResponse['recentmenu_items'] = _get_recentmenu_items();
}
}
/**
* Implements hook_civicrm_preProcess().
*/
function recentmenu_civicrm_preProcess($formName, &$form) {
if (!empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], ['json', 6])) {
$form->ajaxResponse['recentmenu_items'] = _get_recentmenu_items();
}
}
/**
* Implements hook_civicrm_postProcess().
*/
function recentmenu_civicrm_postProcess($formName, &$form) {
if (!empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], ['json', 6])) {
$form->ajaxResponse['recentmenu_items'] = _get_recentmenu_items();
}
}
/**
* Implements hook_civicrm_coreResourceList().
*/
function recentmenu_civicrm_coreResourceList(&$list, $region) {
if ($region == 'html-header' && CRM_Core_Permission::check('access CiviCRM')) {
Civi::resources()
->addScriptFile('org.civicrm.recentmenu', 'js/recentmenu.js', 0, 'html-header')
->addVars('recentmenu', _get_recentmenu_items());
}
}
function _get_recentmenu_items() {
$icons = [
'Individual' => 'fa-user',
'Household' => 'fa-home',
......@@ -193,8 +227,5 @@ function recentmenu_civicrm_coreResourceList(&$list, $region) {
}
$menu['child'][] = $node;
}
Civi::resources()
->addScriptFile('org.civicrm.recentmenu', 'js/recentmenu.js', 0, 'html-header')
->addVars('recentmenu', $menu);
}
return $menu;
}
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