Skip to content

Commit

Permalink
Merge pull request #93 from misd-service-development/1.5
Browse files Browse the repository at this point in the history
1.5
  • Loading branch information
JeebsUK authored Jan 6, 2017
2 parents 386c205 + 922d5fe commit 530e62f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Changelog

Note: the theme contains the University's house style assets (CSS, images, JavaScript). For the sake of completeness, all updates to these are also listed below.

7.x-1.5

* Fixed a bug that stopped menu items being clickable if they had child pages
and were more than 2 levels deep in the navigation on the mobile view.

7.x-1.4
-------

Expand Down
2 changes: 1 addition & 1 deletion cambridge_theme.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = University of Cambridge
description = The University of Cambridge's house style.
core = 7.x
engine = phptemplate
version = 1.5-dev
version = 1.5

stylesheets[all][] = "css/full-stylesheet.css"
stylesheets[all][] = "css/drupal.css"
Expand Down
71 changes: 37 additions & 34 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ function cambridge_theme_menu_block_tree_alter(&$tree, &$config) {

$tree = _cambridge_theme_mark_active_item_in_tree($tree);

$tree = _cambridge_theme_add_horizontal_navigation_overview_items($tree);
_cambridge_theme_add_overview_items($tree);

}
}

Expand All @@ -322,51 +323,53 @@ function _cambridge_theme_mark_active_item_in_tree($tree) {
}

/**
* Mark the end of active trails as faux active.
* Add faux overview items in menu tree to allow clicking in mobile view
*/
function _cambridge_theme_mark_active_item($item) {
if (TRUE == $item['link']['in_active_trail'] && 0 === count($item['below']) && $_GET['q'] != $item['link']['href']) {
$item['link']['cambridge_theme_faux_active'] = TRUE;
}
function _cambridge_theme_add_overview_items(&$tree) {

foreach ($item['below'] as $key => $child) {
$item['below'][$key] = _cambridge_theme_mark_active_item($child);
}
foreach ($tree as $key => &$value) {

return $item;
}
// Ignore disabled menu items
if($value['link']['hidden'] == 0) {

/**
* Add in extra 'Overview' menu items as parents aren't clickable/tapable.
*/
function _cambridge_theme_add_horizontal_navigation_overview_items($items) {
foreach ($items as $i => $item) {
$has_children = FALSE;
// Ignore childless items
if($value['link']['has_children'] == 1) {

foreach ($item['below'] as $child) {
if (TRUE != $child['link']['hidden']) {
$has_children = TRUE;
break;
}
}
// now recursively check any children
_cambridge_theme_add_overview_items($tree[$key]['below']);

if (FALSE === $has_children) {
continue;
// add the overview except for firstchild items
if ('<firstchild>' !== $value['link']['link_path']) {

// create and overview page with same link data but nothing below
$overview = array('link' => $value['link'], 'below' => array());
//dpm('needs an overview page', $overview['link']['title']);
$overview['link']['title'] .= ' overview'; // append overview

// pre-pend it to existing tree
$temp = $value['below'];
$temp = array('overview' => $overview) + $temp;
$tree[$key]['below'] = $temp;
}
}
}
}
}

$items[$i]['below'] = _cambridge_theme_add_horizontal_navigation_overview_items($item['below']);

if ('<firstchild>' !== $item['link']['link_path']) {
$overview = array('link' => $item['link'], 'below' => array());
$overview['link']['title'] .= ' overview';
/**
* Mark the end of active trails as faux active.
*/
function _cambridge_theme_mark_active_item($item) {
if (TRUE == $item['link']['in_active_trail'] && 0 === count($item['below']) && $_GET['q'] != $item['link']['href']) {
$item['link']['cambridge_theme_faux_active'] = TRUE;
}

$temp = $item['below'];
$temp = array('overview' => $overview) + $temp;
$items[$i]['below'] = $temp;
}
foreach ($item['below'] as $key => $child) {
$item['below'][$key] = _cambridge_theme_mark_active_item($child);
}

return $items;
return $item;
}

/**
Expand Down

0 comments on commit 530e62f

Please sign in to comment.