Hi
I have a status message box (div box) positioned at the bottom of a web page using position: fixed; and bottom: 0;. Its height is initially 11px.
I want to allow users to double click it when there are more status messages than what can fit within the default hight, make it grow. If they double click it again or move the mouse away from the box, it should shrink again.
I am completely new to javascript and jquery, so bare with me. I manage to get this working exactly as I want, but it seems to me that it should be possible to write this more elegantly:
<script type="text/javascript">
$(document).ready(function() {
$("#footer").dblclick(showStatusBar);
});
function showStatusBar() {
var footer = $("#footer");
footer.unbind('dblclick', showStatusBar);
footer.animate({ height: "100px" }, 200);
footer.dblclick(hideStatusBar);
footer.bind('mouseleave', hideStatusBar);
}
function hideStatusBar() {
var footer = $("#footer");
footer.unbind('mouseleave', hideStatusBar);
footer.unbind('dblclick', hideStatusBar);
footer.animate({ height: "11px" }, 200);
footer.dblclick(showStatusBar);
}
</script>
I played around with the toggle event, but was unable to get it working. Input will be much appreciated.
Best regards, Egil.