slider.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Set the initial height
  2. var sliderHeight = "80px";
  3. $(document).ready(function(){
  4. // Show the slider content
  5. $('.slider').show();
  6. $('.slider').each(function () {
  7. var current = $(this);
  8. current.attr("box_h", current.height());
  9. });
  10. $(".slider").css("height", sliderHeight);
  11. });
  12. function sliderGetHeight(foo_var)
  13. {
  14. var current = $(foo_var);
  15. if (current.height() <= 80){
  16. return current.height()+30;
  17. }
  18. else {
  19. return current.height();
  20. }
  21. }
  22. function sliderSetHeight(foo_var, foo_height)
  23. {
  24. $(foo_var).each(function () {
  25. var current = $(this);
  26. current.attr("box_h", foo_height);
  27. });
  28. }
  29. function controlSliderMenu(foo_height_a)
  30. {
  31. if (foo_height_a <= 80){
  32. sliderOpen();
  33. slider_state = "open"
  34. $(".slider_menu").empty();
  35. }
  36. }
  37. // Set the initial slider state
  38. var slider_state = "close";
  39. function getSliderState()
  40. {
  41. return slider_state;
  42. }
  43. function setSliderState(foo_slider_state)
  44. {
  45. slider_state = foo_slider_state;
  46. }
  47. function sliderAction()
  48. {
  49. if (slider_state == "close")
  50. {
  51. sliderOpen();
  52. slider_state = "open"
  53. $(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_out.png"></a>');
  54. }
  55. else if (slider_state == "open")
  56. {
  57. sliderClose();
  58. slider_state = "close";
  59. $(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_in.png"></a>');
  60. }
  61. return false;
  62. }
  63. function sliderOpen()
  64. {
  65. var open_height = $(".slider").attr("box_h") + "px";
  66. $(".slider").animate({"height": open_height}, {duration: "slow" });
  67. }
  68. function sliderClose()
  69. {
  70. $(".slider").animate({"height": "0px"}, {duration: "fast" });
  71. $(".slider").animate({"height": sliderHeight}, {duration: "fast" });
  72. }