This is my code. How can I make this menu always be popped out, not just when you click on '#projects'? Change the .click function to what?
$(document).ready(function($) {
$.fn.longDropdown = function(options) { var opts = $.extend({}, $.fn.longDropdown.defaults, options);
// Weird bug to show the correct number of items
opts.visible = (opts.visible + 1);
return this.each(function() {
// Add down arrow only to menu items with submenus
// $(".dropdown > li:has('ul')").each(function() {
// $(this).find("a:first").append("<img src='images/down-arrow.png' />");
// });
$(".dropdown > li").click(function() {
var $container = $(this),
$list = $container.find('ul'),
$anchor = $container.find('a'),
height = $list.height() * 1.0,
totalHeight = $container.height() * opts.visible,
containerOffset = $container.offset().top + $container.height(),
windowHeight = $(window).height(),
maxHeight = windowHeight - containerOffset;
if( totalHeight > maxHeight ) {
while( $container.height() * opts.visible > maxHeight ) {
opts.visible = (opts.visible - 1);
}
totalHeight = $container.height() * (opts.visible + 1);
}
var multiplier = height / totalHeight;
// need to save height here so it can revert on mouseout
$container.data("origHeight", $container.height());
// so it can retain it's rollover color all the while the dropdown is open
$anchor.addClass("hover");
// make sure dropdown appears directly below parent list item
$list
.show()
.css({
paddingTop: $container.data("origHeight")
});
// don't do any animation if list shorter than max
if (multiplier > 1) {
$container
.css({
height: totalHeight,
overflow: "hidden"
})
.mousemove(function(e) {
var offset = $container.offset();
var relativeY = ((e.pageY - offset.top) * (multiplier)) - ($container.data("origHeight") * multiplier);
if (relativeY > $container.data("origHeight")) {
$list.css("top", -relativeY + $container.data("origHeight"));
};
});
}
}, function() {
var $el = $(this);
// put things back to normal
$el
.height($(this).data("origHeight"))
.find("ul")
.css({ top: 0 })
.hide()
.end()
.find("a")
.removeClass("hover");
opts.visible = (opts.visible + 1);
})
.filter(':has(ul)')
.each(function() {
$(this).find("a:first").append("<img src='" + opts.image + "' />");
});
});
};
// default options $.fn.longDropdown.defaults = { visible: 4, image: 'images/down-arrow.png' };
})(jQuery);
Thank you.