Guest User

Untitled

a guest
Jun 19th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. $(function()
  2. {
  3. var cal;
  4. var $this;
  5.  
  6. var checkForMouseout = function(event)
  7. {
  8. var el = event.target;
  9.  
  10. while (true){
  11. if (el == cal) {
  12. return true;
  13. } else if (el == document) {
  14. $this.dpClose();
  15. return false;
  16. } else {
  17. el = $(el).parent()[0];
  18. }
  19. }
  20. };
  21.  
  22. $('.date-pick')
  23. .datePicker()
  24. .bind(
  25. 'dpDisplayed',
  26. function(event, datePickerDiv)
  27. {
  28. cal = datePickerDiv;
  29. $this = $(this);
  30. $(document).bind(
  31. 'mouseover',
  32. checkForMouseout
  33. );
  34. }
  35. ).bind(
  36. 'dpClosed',
  37. function(event, selected)
  38. {
  39. $(document).unbind(
  40. 'mouseover',
  41. checkForMouseout
  42. );
  43. }
  44. );
  45.  
  46. });
  47.  
  48. //el is set above or below, call is set globally in the document.ready
  49. while (true){ //this will loop forever until a return
  50. if (el == cal) { //is the receiving element the calender
  51. return true; //we return true (no ideo why true and not null or 'yaadada'
  52. } else if (el == document) { //we check if the target el is the document
  53. $this.dpClose(); //close the element
  54. return false; //return to leave loop
  55. } else { //el is neither the call or the document
  56. el = $(el).parent()[0]; //set el to the imidiate parent of the current el and reloop
  57. }
  58. }
  59.  
  60. $('.date-pick')
  61. .datePicker()
  62. .bind(
  63. 'dpDisplayed',
  64. function(event, datePickerDiv)
  65. {
  66. cal = datePickerDiv; //datepickerdiv should somehow hold the the datpicker div , something like: $('.date-pick')[0];
  67. $this = $(this);
  68. $(cal).mouseleave( function() { $(this).dpClose(); });
  69. }
  70. }
Add Comment
Please, Sign In to add comment