From c4c3e79730cadc82eab4b5695e64261a985f0bce Mon Sep 17 00:00:00 2001 From: silvio Date: Thu, 15 Oct 2009 12:36:19 -0300 Subject: Initial import; partially working --- .gitignore | 3 + README.txt | 10 +++ jquery_drawer.info | 6 ++ jquery_drawer.module | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 58 +++++++++++++ 5 files changed, 309 insertions(+) create mode 100644 .gitignore create mode 100644 README.txt create mode 100644 jquery_drawer.info create mode 100644 jquery_drawer.module create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be78ec6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Ignore any vim temp file +*.swp +jquery_drawer/* diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..5065ae6 --- /dev/null +++ b/README.txt @@ -0,0 +1,10 @@ +jQuery.drawer +============= + +This module implements the jQuery.drawer navigation menu +from http://lib.metatype.jp/jquery_drawer/sample.html + +The code is mostly an adaptation from Dynamic Persistent +Menu found at http://drupal.org/project/dynamic_persistent_menu + +Additional code by Silvio - s1lv10 at uol.com.br. diff --git a/jquery_drawer.info b/jquery_drawer.info new file mode 100644 index 0000000..9a55330 --- /dev/null +++ b/jquery_drawer.info @@ -0,0 +1,6 @@ +; $Id$ +name = jQuery Drawer +description = Show menu with jQuery.drawer functionality. +core = 6.x +version = "6.x-0.1" +dependencies[] = menu diff --git a/jquery_drawer.module b/jquery_drawer.module new file mode 100644 index 0000000..2dcb707 --- /dev/null +++ b/jquery_drawer.module @@ -0,0 +1,232 @@ + 'select', + '#title' => t('Select the menu to list'), + '#default_value' => variable_get('jquery_drawer', 'navigation:0'), + '#options' => menu_parent_options(menu_get_menus(), 0), + ); + return $form; + + case 'save': + variable_set('jquery_drawer', $edit['jquery_drawer']); + break; + + case 'view': + $menu = explode(':', variable_get('jquery_drawer', 'navigation:0')); + $block['content'] = theme('jquery_drawer', $menu[0], $menu[1]); + return $block; + } +} + +/** + * Implementation of hook_theme(); + */ +function jquery_drawer_theme() { + return array( + 'jquery_drawer' => array( + 'arguments' => array( + 'menu' => NULL, + 'parent' => NULL, + ), + ), + 'jquery_drawer_javascript' => array( + 'arguments' => array(), + ), + 'jquery_drawer_css' => array( + 'arguments' => array(), + ), + 'jquery_drawer_link' => array( + 'arguments' => array(), + ), + ); +} + +/** + * Generate the menu. + */ +function theme_jquery_drawer($menu_name, $mlid) { + $item_class = "jquery-drawer-menu-item"; + $sub_item_class = "jquery-drawer-sub-menu-item"; + + // Find menu item in the menu tree + + $menu_tree = menu_tree_all_data($menu_name); + $menu_link = menu_link_load($mlid); + + if ($mlid != 0) { + for ($i=1; $i<10; $i++) { + foreach ($menu_tree as $menu_item) { + if ($menu_item["link"]['mlid'] == $mlid) { + $menu = $menu_item['below']; + break 2; + } + else { + if ($menu_item["link"]['mlid'] == $menu_link['p'. $i]) { + $menu_tree = $menu_item['below']; + break; + } + } + } + } + } + else { + $menu = $menu_tree; + } + + // Don't display anything if the selected menu has no children + + if (!$menu) { + return; + } + + // Backup active menu trail and set a new one + + $active_menu_name = menu_get_active_menu_name(); + menu_set_active_menu_name($menu_name); + + // Build table of mlid in the active trail + + foreach (menu_set_active_trail() as $value) { + if ($value['mlid']) { + $trail[] = $value['mlid']; + } + } + + // Restore active menu trail + + menu_set_active_menu_name($active_menu_name); + + // Build the menus + + $output = jquery_drawer_build($menu); + $output .= ''; // TODO: remove this + $output .= '
'; + $output .= '
'; + + return $output; +} + +/** + * Recursively build the menu. + * + * @ingroup themeable + */ +function jquery_drawer_build($menu) { + + global $_jquery_drawer_id; + + if ($_jquery_drawer_id == NULL) { + $output = '