slider.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Set the initial height
  2. var sliderHeight = "80px";
  3. // Set the initial slider state
  4. var slider_state = "close";
  5. function sliderAction()
  6. {
  7. if (slider_state == "close") {
  8. sliderOpen();
  9. slider_state = "open"
  10. $(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_out.png"></a>');
  11. } else if (slider_state == "open") {
  12. sliderClose();
  13. slider_state = "close";
  14. $(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_in.png"></a>');
  15. }
  16. return false;
  17. }
  18. function sliderOpen()
  19. {
  20. var open_height = $(".slider").attr("box_h") + "px";
  21. $(".slider").animate({"height": open_height}, {duration: "slow" });
  22. }
  23. function sliderClose()
  24. {
  25. $(".slider").animate({"height": "0px"}, {duration: "fast" });
  26. $(".slider").animate({"height": sliderHeight}, {duration: "fast" });
  27. }
  28. $(function() {
  29. // Show the slider content
  30. $('.slider').show();
  31. $('.slider').each(function () {
  32. var current = $(this);
  33. current.attr("box_h", current.height());
  34. });
  35. $(".slider").css("height", sliderHeight);
  36. });