aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsilvio <silvio@gota.(none)>2009-10-15 12:36:19 -0300
committersilvio <silvio@gota.(none)>2009-10-15 12:36:19 -0300
commitc4c3e79730cadc82eab4b5695e64261a985f0bce (patch)
treeffa416b2e2c501fbc247ab54c13b18e736a3be97
downloadjquery_drawer-c4c3e79730cadc82eab4b5695e64261a985f0bce.tar.gz
jquery_drawer-c4c3e79730cadc82eab4b5695e64261a985f0bce.tar.bz2
Initial import; partially working
-rw-r--r--.gitignore3
-rw-r--r--README.txt10
-rw-r--r--jquery_drawer.info6
-rw-r--r--jquery_drawer.module232
-rw-r--r--style.css58
5 files changed, 309 insertions, 0 deletions
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 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Implementation of a Finder Dropdown Menu.
+ *
+ * This module implements the Finder Dropdown menu described
+ * at http://www.alistapart.com/articles/complexdynamiclists.
+ */
+
+/**
+ * Implementation of hook_uninstall();
+ */
+function jquery_drawer_uninstall() {
+ variable_del('jquery_drawer');
+}
+
+/**
+ * Implementation of hook_init();
+ */
+function jquery_drawer_init() {
+ theme('jquery_drawer_css');
+ theme('jquery_drawer_javascript');
+}
+
+/**
+ * Implementation of hook_block();
+ */
+function jquery_drawer_block($op = 'list', $delta = 0, $edit = array()) {
+ switch ($op) {
+ case 'list':
+ $blocks[0]['info'] = t('jQuery Drawer');
+ $blocks[0]['cache'] = BLOCK_NO_CACHE;
+ return $blocks;
+
+ case 'configure':
+ $form['jquery_drawer'] = array(
+ '#type' => '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 .= '</ul>'; // TODO: remove this
+ $output .= '<div id="drw">';
+ $output .= '</div>';
+
+ return $output;
+}
+
+/**
+ * Recursively build the menu.
+ *
+ * @ingroup themeable
+ */
+function jquery_drawer_build($menu) {
+
+ global $_jquery_drawer_id;
+
+ if ($_jquery_drawer_id == NULL) {
+ $output = '<ul id="drw_tabs">';
+ $output .= implode((array) module_invoke_all('jquery_drawer_build'));
+ $_jquery_drawer_id = 0;
+ }
+ else {
+ //$output = '<ul id="drw[ul]['. $_jquery_drawer_id .']" class="hidden">';
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ $output .= '<li>';
+ if ($menu_item['below'] !== FALSE && jquery_drawer_has_unhidden_submenu($menu_item['below'])) {
+ $output .= $menu_item['link']['title'];
+ $_jquery_drawer_id++;
+ $output .= jquery_drawer_build($menu_item['below']);
+ }
+ else {
+ $output .= theme('jquery_drawer_link', $menu_item['link']);
+ }
+ $output .= '</li>';
+ }
+ }
+
+ //$output .= '</ul>';
+ return $output;
+
+}
+
+/**
+ * Check whether a menu has at least one unhidden submenu.
+ */
+function jquery_drawer_has_unhidden_submenu($menu = FALSE) {
+
+ if ($menu == FALSE) {
+ return FALSE;
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * jQuery Drawer Javascript theme function.
+ *
+ * @ingroup themeable
+ */
+function theme_jquery_drawer_javascript() {
+ drupal_add_js(drupal_get_path('module', 'jquery_drawer') .'/jquery_drawer/drw/scripts.js');
+}
+
+/**
+ * jQuery Drawer CSS theme function.
+ *
+ * @ingroup themeable
+ */
+function theme_jquery_drawer_css() {
+ drupal_add_css(drupal_get_path('module', 'jquery_drawer') .'/style.css');
+ drupal_add_css(drupal_get_path('module', 'jquery_drawer') .'/jquery_drawer/drw/styles.css');
+}
+
+/**
+ * jQuery Drawer Link theme function.
+ *
+ * @ingroup themeable
+ */
+function theme_jquery_drawer_link($link) {
+ if (empty($link['localized_options'])) {
+ $link['localized_options'] = array();
+ }
+
+ $link['attributes']['rel'] = 'drw';
+ return l($link['title'], $link['href'], array('attributes' => array('rel' => 'drw')));
+}
diff --git a/style.css b/style.css
new file mode 100644
index 0000000..2d02061
--- /dev/null
+++ b/style.css
@@ -0,0 +1,58 @@
+div#content {
+ color : #ffffff;
+ background : #000000;
+}
+
+div#info {
+ padding : 0 30px 30px 30px;
+}
+
+div#info h1 {
+ font-size : 36px;
+ font-weight : bold;
+ padding : 30px 0 0 0;
+ margin : 0;
+}
+
+div#info h2 {
+ font-size : 20px;
+ font-weight : bold;
+ border-top : 1px solid #111111;
+ padding : 30px 0 0 0;
+ margin : 30px 0 0 0;
+}
+
+div#info p {
+ font-size : 12px;
+ line-height : 1.6;
+ padding : 10px 0 0 0;
+ margin : 0;
+}
+
+div#info a {
+ color : #ffffff;
+}
+
+div#info pre {
+ font-size : 11px;
+ font-family : "Courier New", monospace;
+ line-height : 1.4;
+ color : #99ff99;
+ background : #222222;
+ padding : 10px;
+ margin : 10px 0;
+}
+
+div#info em {
+ font-style : normal;
+ color : #ff0099;
+}
+
+div.sample p {
+ font-size : 24px;
+ font-weight : bold;
+ line-height : 1.6;
+ color : #ffff00;
+ padding : 20px;
+ margin : 0;
+}