Guest User

Untitled

a guest
Jun 21st, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. jQuery popup/popout menus usability - hide on document click
  2. <div class="toolbar">
  3. <div class="popout-wrap">
  4. <div class="button">
  5. </div>
  6. <div class="popout">
  7. blah blah blah
  8. </div>
  9. </div>
  10. <div class="popout-wrap">
  11. <div class="button">
  12. </div>
  13. <div class="popout">
  14. blah blah blah
  15. </div>
  16. </div>
  17. ...
  18.  
  19. $(".popout-wrap .button").click(function () {
  20. var menu = $(this).siblings(".popout");
  21. if (menu.is(":hidden")) {
  22. $(".popout").not(":hidden").fadeOut("fast");
  23. menu.css("top", -1 * (menu.outerHeight() + 8) + "px");
  24. menu.fadeIn("fast");
  25. } else {
  26. menu.fadeOut("fast");
  27. }
  28. return false;
  29. });
  30.  
  31. $(".popout-wrap .button").blur(function () {
  32. $(this).siblings(".popout").fadeOut("fast");
  33. return false;
  34. });
  35.  
  36. //to prevent hiding when clicking on popup but it is not necessary
  37. //$(".popout-wrap .popout").click()(function(){return false});
  38.  
  39. $(document).click(function(){
  40. var menu = $(".popout-wrap .popout");
  41. if (!menu.is(":hidden")) {
  42. menu.fadeOut("fast");
  43. }
  44. return false;
  45. });
Advertisement
Add Comment
Please, Sign In to add comment