diff --git a/fg.menu.js b/fg.menu.js index d8d584f..bb86a17 100755 --- a/fg.menu.js +++ b/fg.menu.js @@ -38,7 +38,7 @@ function Menu(caller, options){ this.menuOpen = false; this.menuExists = false; - var options = jQuery.extend({ + var options = jQuery.extend(true,{ content: null, width: 180, // width of menu container, must be set or passed in to calculate widths of child menus maxHeight: 180, // max height of menu (if a drilldown: height does not include breadcrumb) @@ -67,7 +67,11 @@ function Menu(caller, options){ flyOutOnState: 'ui-state-default', nextMenuLink: 'ui-icon-triangle-1-e', // class to style the link (specifically, a span within the link) used in the multi-level menu to show the next level topLinkText: 'All', - nextCrumbLink: 'ui-icon-carat-1-e' + nextCrumbLink: 'ui-icon-carat-1-e', + itemClickEvent: function( item ){ + $('#menuSelection').text($(item).text()); + location.href = $(item).attr('href'); + } }, options); var killAllMenus = function(){ @@ -76,6 +80,12 @@ function Menu(caller, options){ }); }; + + var checkMenuHeight = function(el){ + if (el.height() > options.maxHeight) { el.addClass('fg-menu-scroll') }; + el.css({ height: options.maxHeight }); + }; + this.kill = function(){ caller .removeClass(options.loadingState) @@ -206,7 +216,8 @@ function Menu(caller, options){ else { menu.drilldown(container, options); } } else { - container.find('a').click(function(){ + container.find('a').click(function( e ){ + e.preventDefault(); menu.chooseItem(this); return false; }); @@ -235,7 +246,9 @@ function Menu(caller, options){ }, function(){ $(this).removeClass(options.linkHoverSecondary); } ); - }; + }; + + checkMenuHeight( container ); menu.setPosition(container, caller, options); menu.menuExists = true; @@ -299,7 +312,8 @@ Menu.prototype.flyout = function(container, options) { ); }); - container.find('a').click(function(){ + container.find('a').click(function( e ){ + e.preventDefault(); menu.chooseItem(this); return false; });