From ebb1ab6ce15b99d7cb460632445f0b03900cad51 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 22 Nov 2007 04:43:47 +0000 Subject: [PATCH] ability to set new themes now --- README.txt | 3 +- down-green.gif | Bin 179 -> 0 bytes left-green.gif | Bin 895 -> 0 bytes right-green.gif | Bin 893 -> 0 bytes simplemenu.css | 118 +++++++++++++--------------------------------- simplemenu.js | 10 ++-- simplemenu.module | 63 +++++++++++++++---------- 7 files changed, 78 insertions(+), 116 deletions(-) delete mode 100644 down-green.gif delete mode 100644 left-green.gif delete mode 100644 right-green.gif diff --git a/README.txt b/README.txt index be25bebc..4bd47195 100644 --- a/README.txt +++ b/README.txt @@ -35,4 +35,5 @@ jQuery Superfish: http://users.tpg.com.au/j_birch/plugins/superfish/ - new CHANGELOG to keep track of changes - #156256 upgrade to SuperFish 1.3 - upgrade to bgIframe 2.1.1 (for IE6 compatibility with forms) -- remove RTL option; this conflicts with other changes and is properly implemented in Drupal 6 \ No newline at end of file +- remove RTL option; this conflicts with other changes and is properly implemented in Drupal 6 +- new option to select which theme to style SimpleMenu with, or provide a custom one \ No newline at end of file diff --git a/down-green.gif b/down-green.gif deleted file mode 100644 index 215ecc33b5ee70fa925caf59e06d4d0eeff2bac4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 179 zcmZ?wbhEHb6krfwI3mH&w8SZUx=!glhyCYQ%-L32KG&#ZuJN)xHI)l&j$T@oJV~p6 zb@0*4>(?LZ&z)hg{!s7Ct;OZ@oTqNeSbwN(`j&z%C#J97-?{nt)c^ngGhhRXKUo+V z7$g{UK$0Lk8CVSz)cR5~=Vh!~m$TZ6O^AgxVLn%=>9wgo3?VE=6$X6VQyUBvSi+e+ P4~iBFuB6plyu>5eRPme_GROMN_${SX=MNZax`u0KAZ2f85 zvpd)L@4mQb>zTPr54O~+~Gp&T+E8x|aF<`CA3iTJ?8)u!dgl5yaILld90p2>p` z7Zz{|$*GkHI7~`%FuB6plyu>5eRPme_GROMN_${SX=MNZax`u0KAZ2f85 zvpd)L@4mQb>zTPr54O~;Amp&T+E8x|aF<`CA3i4Zu-+QuZ!Vlh#GwVh4eti&UM zA(5F;!P@78!=WPwxtZ*01QHKAb+C)@@V!tt*v!tR=%HZo!lAj5i=Rv8#?Asp4jzGE OhK3VcG> a -{ - background:url(right-green.gif) no-repeat 97%; - padding-right:2em; -} - -#simplemenu li.root > a -{ - font-weight:700; - background:url(down-green.gif) no-repeat 97%; -} - -#simplemenu li ul -{ - float:none; - top:-999em; +#simplemenu ul { position:absolute; - margin:0; - padding:0; - z-index:9999; + top:-999em; width:14em; - background:#ddd; - border:1px solid #999; } - -#simplemenu li:hover,#simplemenu li.sfHover,#simplemenu a:focus,#simplemenu a:hover,#simplemenu a:active -{ - background:#3875d7; - color:#fff; +#simplemenu ul li, +#simplemenu a { + width: 100%; } - -#simplemenu li:hover ul,#simplemenu li.sfHover ul -{ - left:-1px; - top:20px; +#simplemenu li { + float:left; + position:relative; + z-index:99; } - -#simplemenu li:hover li ul,#simplemenu li.sfHover li ul -{ +#simplemenu a { + display:block; +} +#simplemenu li:hover ul, +ul#simplemenu li.sfHover ul { + left:0px; + top:21px; +} +#simplemenu li:hover li ul, +#simplemenu li.sfHover li ul { top:-999em; } - -#simplemenu li li:hover ul,#simplemenu li li.sfHover ul -{ +#simplemenu li li:hover ul, +ul#simplemenu li li.sfHover ul { left:14em; top:-1px; - width:14em; } - -#simplemenu li li -{ - background:#ddd; - float:none; - border:none; +.superfish li:hover ul, +.superfish li li:hover ul { + top: -999em; } - -#simplemenu li li a -{ - float:none; - padding-right:0; -} \ No newline at end of file diff --git a/simplemenu.js b/simplemenu.js index 7baf121c..92cae848 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -24,15 +24,15 @@ $(document).ready(function() { // Build menu $('#simplemenu') .append(simplemenu) - .superfish() - .find(">li[ul]") + .superfish( { speed: 'fast' } ) + .find(">li:has(ul)") .mouseover(function(){ - $("ul", this).bgiframe({opacity:false}); + $("ul", this).bgIframe({opacity:false}); }) .find("a") .focus(function(){ - $("ul", $("#simplemenu>li[ul]")).bgiframe({opacity:false}); - }); + $("ul", $(".nav>li:has(ul)")).bgIframe({opacity:false}); + }); $('#simplemenu').children('li.expanded').addClass('root'); }); diff --git a/simplemenu.module b/simplemenu.module index 7300b117..02ed6414 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -12,7 +12,7 @@ function simplemenu_menu($may_cache) { $items = array(); - if ($may_cache) { + if ($may_cache) { $items[] = array( 'path' => 'admin/settings/simplemenu', 'title' => t('SimpleMenu'), @@ -35,16 +35,21 @@ function simplemenu_footer() { if (user_access('view simplemenu') && !$exclusions[$theme]) { global $theme, $custom_theme; $path = drupal_get_path('module', 'simplemenu'); + $simplemenu_theme = variable_get('simplemenu_theme', 'original'); drupal_add_css($path .'/simplemenu.css'); - - $settings = array( + + if ($theme != 'custom') { + drupal_add_css($path .'/themes/'. $simplemenu_theme .'/'. $simplemenu_theme .'.css'); + } + + $settings = array( // pass in base path to the JS file // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off 'basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='), 'placement' => variable_get('simplemenu_element_method', 'prepend'), 'element' => variable_get('simplemenu_element', 'body') ); - + drupal_add_js(array('simplemenu' => $settings), 'setting'); drupal_add_js('var simplemenu = '. drupal_to_js(simplemenu_get_menu()) .';', 'inline'); drupal_add_js($path .'/simplemenu.js'); @@ -69,21 +74,29 @@ function simplemenu_admin_settings() { '#default_value' => variable_get('simplemenu_menu', 1), '#description' => t('Select the menu to display.') ); - + $form['default_menu']['simplemenu_devel'] = array( '#type' => 'checkbox', '#title' => t('Add devel module links'), '#default_value' => variable_get('simplemenu_devel', 0), '#description' => t('Add devel module links for those users that can access the devel module.') - ); - + ); + + $form['default_menu']['simplemenu_theme'] = array( + '#type' => 'select', + '#title' => t('Theme'), + '#options' => drupal_map_assoc(array('original', 'custom')), + '#default_value' => variable_get('simplemenu_theme', 'original'), + '#description' => t('Select which theme to use. If you specify custom, you need to define CSS in your theme.') + ); + $form['default_menu']['advanced'] = array( - '#type' => 'fieldset', + '#type' => 'fieldset', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => TRUE ); - + $form['default_menu']['advanced']['simplemenu_element'] = array( '#type' => 'textfield', '#title' => t('CSS selector to attach menu to'), @@ -91,24 +104,24 @@ function simplemenu_admin_settings() { '#description' => t('A valid CSS selector to attach the menu to. Example: body, #primary, div.my-class'), '#required' => TRUE ); - + $form['default_menu']['advanced']['simplemenu_element_method'] = array( '#type' => 'radios', - '#title' => 'Attach method', + '#title' => 'Attach method', '#options' => drupal_map_assoc(array('prepend', 'append', 'replace')), '#default_value' => variable_get('simplemenu_element_method', 'prepend'), '#description' => t('Choose how the menu should be attached to the above selector.'), '#required' => TRUE ); - + $form['default_menu']['advanced']['simplemenu_exclusions'] = array( '#type' => 'checkboxes', - '#title' => 'Theme exclusions', + '#title' => 'Theme exclusions', '#options' => drupal_map_assoc(array_keys(list_themes())), '#default_value' => variable_get('simplemenu_exclusions', array()), '#description' => t('Select which themes to not display the menu. Use this when you have a theme that displays its own admin navigation.'), - ); - + ); + return system_settings_form($form); } @@ -117,18 +130,18 @@ function simplemenu_admin_settings() { */ function simplemenu_get_menu() { $output = ''; - + $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1)); - + if (!$menu) { $menu = '
  • '. t('No menu items found. Try a different menu as the default.') .'
  • '; } - + $output .= simplemenu_get_devel(); $output .= $menu; - + return $output; -} +} /** * Custom implementation of menu_tree(). @@ -148,7 +161,7 @@ function simplemenu_menu_tree($pid = 1) { } return $output; -} +} /** * Custom implementation of theme_menu_tree() to call our custom menu above. @@ -157,7 +170,7 @@ function simplemenu_theme_menu_tree($pid = 1) { if ($tree = simplemenu_menu_tree($pid)) { return '
      '. $tree .'
    '; } -} +} /** * Return a list of devel module links if the module is enabled @@ -165,7 +178,7 @@ function simplemenu_theme_menu_tree($pid = 1) { */ function simplemenu_get_devel() { $output = ''; - + if (variable_get('simplemenu_devel', 0) && module_exists('devel')) { if (user_access('access devel information')) { $links[] = l('Devel settings', 'admin/settings/devel', array('title' => t('Adjust module settings for devel module'))); @@ -181,12 +194,12 @@ function simplemenu_get_devel() { // True only if devel_node_access enabled. $links[] = l('Node access summary', 'devel/node_access/summary'); } - + $output = '
  • '. t('Devel module') .'
      '; $output .= '
    • '. implode($links, '
    • ') .'
    • '; $output .= '
  • '; } } - + return $output; } \ No newline at end of file