Index: js/analyticdropdown.js --- /dev/null +++ js/analyticdropdown.js @@ -0,0 +1,38 @@ + +//Marinelli jQuery Drop Down Menu (uses hoverIntent jquery plugin (http://cherne.net/brian/resources/jquery.hoverIntent.html) + +Drupal.behaviors.analytic = function(context){ +// add some markup + +$('#primary-links-wrapper li.expanded > a').addClass("primoespanso"); +$('#primary-links-wrapper li.expanded ul li.expanded > a').addClass('espanso'); +$('#primary-links-wrapper li.expanded > ul').addClass('primosottolivello'); +$('#primary-links-wrapper li.expanded ul li a').removeClass('active'); +$('#primary-links-wrapper li.expanded ul li.expanded > ul').removeClass('primosottolivello').addClass('sottolivello'); + + +// show & hide functions + +function mostra(){ + $(this).children('.primosottolivello, .sottolivello').show(); + $(this).addClass('dropping-down'); + } + +function nascondi(){ + $(this).children('.primosottolivello, .sottolivello').hide(); + $(this).removeClass('dropping-down'); + } + +// set some options for the hover effect + +var config = { + sensitivity: 5, // number = sensitivity threshold (must be 1 or higher) + interval: 100, // number = milliseconds for onMouseOver polling interval + over: mostra, // function = onMouseOver callback (REQUIRED) + timeout: 200, // number = milliseconds delay before onMouseOut + out: nascondi // function = onMouseOut callback (REQUIRED) +}; + + + $('#primary-links-wrapper li.expanded').hoverIntent(config); +}; Index: dropdown.css --- /dev/null +++ dropdown.css @@ -0,0 +1,107 @@ +body div#body-main{ /* this for z-index issues */ + position: static; + z-index:1; +} + + +/* ## LI ## */ + +/* li containing sublevels */ +#primary-links-wrapper ul li.expanded{ + position:relative; +/* z-index:1;*/ +} + + +/* set li width */ +#primary-links-wrapper ul li.expanded ul li{ + font-size:100%; + line-height:135%; + width:160px; + z-index:100; + margin:0px; + padding:0px; + border-bottom:1px solid black; +} + + +/* ## UL ## */ + +/* Hide first sublevel */ +#primary-links-wrapper ul li.expanded ul{ + display:none; +} + +/* First Sublevel */ +#primary-links-wrapper ul.primosottolivello{ + margin:0px; + padding:0px 5px 5px 0px; /* padding for backgorund shadow */ + background: url(images/menushadow.png) no-repeat 3px 10%; + width:160px; + position:absolute; + left:0px; + top:30px; + z-index:100; + border-left: none; +} + + +/* Other Sublevels */ +#primary-links-wrapper ul.sottolivello{ + margin:0px; + padding:0px 5px 5px 0px; /* padding for backgorund shadow */ + background: url(images/menushadow.png) no-repeat 3px 10%; + width:160px; + position:absolute; + left:160px; + top:0px; + z-index:100; + border-left: none; +} + +/* ## Anchors ## */ + +#primary-links-wrapper ul li.expanded a{ + background:#23749E; +} + +body #primary-links-wrapper ul li.expanded a.active{ + background:#23749E url(images/expanded-drop.gif) no-repeat 4px 8px; +} + + +/* first level hover state*/ +#primary-links-wrapper ul li.expanded a.primoespanso:hover{ + background:#043860 url(images/expanded-drop.gif) no-repeat 4px 8px; +} + +/* sublevels hover state*/ +#primary-links-wrapper ul li ul li a:hover{ + font-weight:normal; + background:#043860; +} + + +/* expanded sublevels hover state */ +#primary-links-wrapper ul li ul li.expanded a.espanso:hover{ + font-weight:normal; + background:#043860 url(images/expanded-right.gif) no-repeat 95% 8px; +} + + +#primary-links-wrapper ul li.expanded a.primoespanso{ + background:#343434 url(images/expanded-drop.gif) no-repeat 4px 8px; + padding-left:23px; +} + +#primary-links-wrapper ul li.dropping-down a.primoespanso { + background-color: #23749E; +} + + +#primary-links-wrapper ul li.expanded a.espanso, +body #primary-links-wrapper ul li.expanded ul li a.espanso{ + background: #23749E url(images/expanded-right.gif) no-repeat 95% 8px; + padding-right:24px; + padding-left:10px; +} Index: jquery.hoverIntent.minified.js --- /dev/null +++ js/jquery.hoverIntent.minified.js @@ -0,0 +1,9 @@ +/** +* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+ +* +* +* @param f onMouseOver function || An object with configuration options +* @param g onMouseOut function || Nothing (use configuration options object) +* @author Brian Cherne +*/ +(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY)) - 'links primary-links')) ?> + Index: style.css --- style.css +++ style.css @@ -27,6 +27,14 @@ background-color:#f5f5f1; } +.clear +{ + clear: both; + font-size: 0px; + line-height: 0px; + visibility: collapse; +} + a{color:#8d6e00;} Index: template.php --- template.php +++ template.php @@ -4,7 +4,8 @@ function phptemplate_preprocess_page(&$vars) { $defaults = array( 'admin_left_column' => 1, - 'admin_right_column' => 0 + 'admin_right_column' => 0, + 'menutype' => 0, ); global $theme_key; @@ -73,4 +74,23 @@ return $output; } +function analytic_links($links, $attributes = array('class' => 'links')){ + if($attributes['class'] == 'links primary-links'){ + return menu_tree(variable_get('menu_primary_links_source', 'primary-links')); + } + return theme_links($links,$attributes); +} + + +$valore = theme_get_setting('menutype'); // if we choose dropdown + +if($valore == '1'){ + + drupal_add_js(drupal_get_path('theme','analytic').'/js/jquery.hoverIntent.minified.js'); // load the javascript + drupal_add_js(drupal_get_path('theme','analytic').'/js/analyticdropdown.js'); // load the javascript + drupal_add_css(drupal_get_path('theme','analytic').'/dropdown.css'); // load the css + +} + + ?> Index: theme-settings.php --- theme-settings.php +++ theme-settings.php @@ -12,7 +12,8 @@ function phptemplate_settings($saved_settings) { $defaults = array( 'admin_left_column' => 1, - 'admin_right_column' => 0 + 'admin_right_column' => 0, + 'menutype' => 0, ); $settings = array_merge($defaults, $saved_settings); @@ -38,7 +39,25 @@ '#title' => t('Show right column in admin section'), '#default_value' => $settings['admin_right_column'] ); - + + $form['dropdown_container'] = array( + '#type' => 'fieldset', + '#title' => t('Dropdown Menu Settings'), + '#description' => t('Check this if you want to enable dropdown menu functionality. This option is turned off by default to save loading unnecessary javascript files'), + '#collapsible' => FALSE, + ); + + + $form['dropdown_container']['menutype'] = array( + '#type' => 'select', + '#title' => t('Do you want to use static or drop down Primary Links ?'), + '#default_value' => $settings['menutype'], + '#options' => array( + 0 => 'static', + 1 => 'drop down', + ) + ); + // Return theme settings form return $form; }