diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-08 03:42:23 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-08 03:42:23 +0000 |
commit | aa011b14603ba807121c811399685895a9c75d67 (patch) | |
tree | 26a2916749929b34f5295fa55ee4c7d62126e17d /views | |
parent | 7682706a46a20e3e58a9afd8ba208d5b0c040499 (diff) | |
download | elgg-aa011b14603ba807121c811399685895a9c75d67.tar.gz elgg-aa011b14603ba807121c811399685895a9c75d67.tar.bz2 |
Added new submenu system.
Added elgg_http_url_is_identical().
Moved canvas_header/submenu* to navigation/submenu*.
Added UI test for submenu.
git-svn-id: http://code.elgg.org/elgg/trunk@5982 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views')
-rw-r--r-- | views/default/canvas_header/submenu_group.php | 19 | ||||
-rw-r--r-- | views/default/canvas_header/submenu_template.php | 24 | ||||
-rw-r--r-- | views/default/css.php | 10 | ||||
-rw-r--r-- | views/default/navigation/submenu_group.php | 42 | ||||
-rw-r--r-- | views/default/navigation/submenu_item.php | 41 | ||||
-rw-r--r-- | views/default/navigation/submenu_js.php | 31 |
6 files changed, 119 insertions, 48 deletions
diff --git a/views/default/canvas_header/submenu_group.php b/views/default/canvas_header/submenu_group.php deleted file mode 100644 index 8d23aed3f..000000000 --- a/views/default/canvas_header/submenu_group.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * Elgg default layout - * - * @package Elgg - * @subpackage Core - * @author Curverider Ltd - * @link http://elgg.org/ - */ -if (isset($vars['group_name'])) { - $groupname = $vars['group_name']; -} else { - $groupname = "main"; -} - -if (isset($vars['submenu'])) { - $submenu = "<ul class='submenu {$groupname}'>" . $vars['submenu'] . "</ul>"; - echo $submenu; -}
\ No newline at end of file diff --git a/views/default/canvas_header/submenu_template.php b/views/default/canvas_header/submenu_template.php deleted file mode 100644 index 0210e865f..000000000 --- a/views/default/canvas_header/submenu_template.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php -/** - * Elgg default layout - * - * @package Elgg - * @subpackage Core - * @author Curverider Ltd - * @link http://elgg.org/ - */ - -if (isset($vars['selected']) && $vars['selected'] == true) { - $selected = "class=\"selected\""; -} else { - $selected = ""; -} - -if (isset($vars['onclick']) && $vars['onclick'] == true) { - $onclick = "onclick=\"javascript:return confirm('". elgg_echo('deleteconfirm') . "')\""; -} else { - $onclick = ""; -} - -?> -<li <?php echo $selected; ?>><a href="<?php echo $vars['href']; ?>" <?php echo $onclick; ?>><?php echo $vars['label']; ?></a></li>
\ No newline at end of file diff --git a/views/default/css.php b/views/default/css.php index b81945eb4..bdef42982 100644 --- a/views/default/css.php +++ b/views/default/css.php @@ -684,6 +684,11 @@ li.navigation_more ul li { color:white; text-decoration:none; } +.submenu .child li a{ + margin-left:15px; + background-color:white; + color:#4690D6; +} @@ -1630,11 +1635,6 @@ form.admin_plugins_simpleview .submit_button { .admin_settings.menuitems li.custom_menuitem { margin-bottom:20px; } -.admin .child_submenu li a{ - margin-left: 15px; - background-color: white; - color: #4690D6; -} .admin_notices { padding-bottom: 15px; } diff --git a/views/default/navigation/submenu_group.php b/views/default/navigation/submenu_group.php new file mode 100644 index 000000000..08e417494 --- /dev/null +++ b/views/default/navigation/submenu_group.php @@ -0,0 +1,42 @@ +<?php +/** + * Elgg submenu group. Writes the <ul> for a submenu and passes items one by one + * to navigation/submenu_item + * + * @uses $vars['group_name'] + * @uses $vars['items'] + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$group = (isset($vars['group'])) ? $vars['group'] : 'default'; +$items = (isset($vars['items'])) ? $vars['items'] : array(); +$hidden = (isset($vars['hidden']) && $vars['hidden']) ? 'hidden' : ''; +$child = (isset($vars['child']) && $vars['child']) ? 'child' : ''; + +echo "<ul class='submenu $group $hidden $child'>\n"; + +foreach ($items as $item) { + $item_vars = array('item' => $item, 'group' => $group); + if (isset($item->vars) && is_array($item->vars)) { + $item_vars = array_merge($item->vars, $item_vars); + } + + if (isset($item->children)) { + $child_vars = array( + 'group' => $group, + 'items' => $item->children, + // if this menu item is selected, make sure to display the full tree + // ie, don't hide it. + 'hidden' => !$item->selected, + 'child' => TRUE + ); + $item_vars['children_html'] = elgg_view('navigation/submenu_group', $child_vars); + } + + echo elgg_view('navigation/submenu_item', $item_vars); +} + +echo "</ul>\n";
\ No newline at end of file diff --git a/views/default/navigation/submenu_item.php b/views/default/navigation/submenu_item.php new file mode 100644 index 000000000..c64f8a679 --- /dev/null +++ b/views/default/navigation/submenu_item.php @@ -0,0 +1,41 @@ +<?php +/** + * Elgg submenu item. Displays the <li> part of a submenu. + * + * @uses $vars['group'] + * @uses $vars['item'] + * @uses $vars['children_html'] + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$group = (isset($vars['group'])) ? $vars['group'] : 'default'; +$item = (isset($vars['item'])) ? $vars['item'] : FALSE; +$children_html = (isset($vars['children_html'])) ? $vars['children_html'] : FALSE; + + +if ($item) { + $has_children = (isset($item->children) && $item->children) ? TRUE : FALSE; + $selected = (isset($item->selected) && $item->selected == TRUE) ? 'class="selected"' : ''; + $js = (isset($vars['js'])) ? $vars['js'] : ''; + + $child_indicator = ''; + if ($has_children) { + if ($selected) { + $child_indicator = '<span class="close_child">-</span>'; + $child_indicator .= '<span class="hidden open_child">+</span>'; + } else { + $child_indicator = '<span class="hidden close_child">-</span>'; + $child_indicator .= '<span class="open_child">+</span>'; + } + + $child_indicator = "<span class=\"child_indicator\">$child_indicator </span>"; + } + + $url = htmlentities($item->url); + $text = $child_indicator . htmlentities($item->text); +} +?> +<li <?php echo $selected; ?>><a href="<?php echo $url; ?>" <?php echo $js; ?>><?php echo $text; ?></a><?php echo $children_html; ?></li> diff --git a/views/default/navigation/submenu_js.php b/views/default/navigation/submenu_js.php new file mode 100644 index 000000000..0f0c88888 --- /dev/null +++ b/views/default/navigation/submenu_js.php @@ -0,0 +1,31 @@ +<?php +/** + * Javascript to expand submenu items. + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ +?> + +<script type="text/javascript"> +$(document).ready(function() { + $('.submenu span.child_indicator').click(function() { + var submenu = $(this).parent().parent().find('ul.submenu.child:first'); + var closeChild = $($(this).find('.close_child')); + var openChild = $($(this).find('.open_child')); + + if (submenu.is(':visible')) { + closeChild.addClass('hidden'); + openChild.removeClass('hidden'); + } else { + closeChild.removeClass('hidden'); + openChild.addClass('hidden'); + } + + submenu.slideToggle(); + return false; + }); +}); +</script>
\ No newline at end of file |