1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
/**
* Navigation menu for a user's or a group's pages
*
* @uses $vars['page'] Page object if manually setting selected item
*/
// add the jquery treeview files for navigation
elgg_load_js('jquery-treeview');
elgg_load_css('jquery-treeview');
$entity = elgg_extract('entity', $vars, false);
if (elgg_instanceof($entity, 'object', 'task') && ($list = get_entity($entity->list_guid))) {
$url = $list->getURL();
} elseif ($entity) {
$url = $entity->getURL();
}
$title = elgg_echo('tasks:navigation');
tasks_register_navigation_tree(elgg_get_page_owner_entity());
$content = elgg_view_menu('tasks_nav', array('class' => 'tasks-nav'));
if (!$content) {
$content = '<p>' . elgg_echo('tasks:none') . '</p>';
}
echo elgg_view_module('aside', $title, $content);
?><?php //@todo JS 1.8: no ?>
<script type="text/javascript">
$(document).ready(function() {
$(".tasks-nav").treeview({
persist: "location",
collapsed: true,
unique: true
});
<?php
if ($entity) {
// if on a history page, we need to manually select the correct menu item
// code taken from the jquery.treeview library
?>
var current = $(".tasks-nav a[href='<?php echo $url; ?>']");
var items = current.addClass("selected").parents("ul, li").add( current.next() ).show();
var CLASSES = $.treeview.classes;
items.filter("li")
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea );
<?php
}
?>
});
</script>
|