/branches/jsdoc_tk_gui/setup/workingDirectory/Webeo/gui/window/Wait.js

http://jsdoc-toolkit.googlecode.com/ · JavaScript · 86 lines · 39 code · 12 blank · 35 comment · 5 complexity · f8a8e072541a331e0025a0928b99474d MD5 · raw file

  1. ek.require("gui.tools.Dom");
  2. ek.register("gui.window.Wait");
  3. ek.requireCSS("css.gui.window.Wait", "wait.Wait");
  4. /**
  5. *@displayName Affiche une fenetre d'attente
  6. *@src wait.js
  7. *@env Client
  8. *@hint Permet de bloquer l ecran pendant une operation synchrone
  9. *@version 1.0
  10. */
  11. function Wait (dom, message, cssClass, timeToShow, timeToHide, offsetLeft, offsetTop){
  12. this.hideTimer = undefined;
  13. this.showTimer = undefined;
  14. //PARAMETRAGE
  15. this.cssClass = (cssClass != undefined)? cssClass : 'wait';
  16. this.timeToShow = (timeToShow != undefined)? timeToShow : 0;
  17. this.timeToHide = (timeToHide != undefined)? timeToHide : 1000;
  18. this.offsetLeft = (offsetLeft != undefined)? offsetLeft : 0;
  19. this.offsetTop = (offsetTop != undefined)? offsetTop : 0;
  20. //Fin PARAMETRAGE
  21. this.parentDom = Dom.getElement(dom);
  22. this.divNameWait = dom.id + '_WAIT' ;
  23. this.drawWait(message, this.cssClass);
  24. this.isShown = false;
  25. this.hide();
  26. //Positionnement par rapport ? l'élément parent
  27. //if(this.parentDom.style.position=="")
  28. // this.parentDom.style.position = "relative";
  29. }
  30. /**
  31. * Ecrit la fen?tre d'attente dans le document
  32. * @param content : the text content of the wait div
  33. */
  34. Wait.prototype.drawWait = function (content){
  35. //Create the wait div
  36. this.domWait = Dom.createHTMLDivElement(content, this.cssClass, this.divNameWait);
  37. //Save the component for event handler
  38. this.domWait.waitModel = this;
  39. //Append wait element to the parent node
  40. this.parentDom.appendChild(this.domWait);
  41. }
  42. /**
  43. * Affiche la fenetre d'attente
  44. */
  45. Wait.prototype.show = function (){
  46. this.domWait.style.display = '';
  47. this.domWait.style.left = this.parentDom.offsetLeft + this.parentDom.offsetWidth / 2 - this.domWait.offsetWidth / 2 + this.offsetLeft ;
  48. this.domWait.style.top = this.parentDom.offsetTop + this.parentDom.offsetHeight / 2 - this.domWait.offsetHeight / 2 + this.offsetTop ;
  49. this.isShown = true;
  50. }
  51. /**
  52. *
  53. */
  54. Wait.prototype.hide = function(){
  55. this.domWait.style.display = 'none';
  56. this.isShown = false;
  57. }
  58. /**
  59. * On affiche la fen?tre au bout de quelques millisecondes
  60. */
  61. Wait.prototype.mayShow = function (){
  62. //On affiche un tooltip apr?s l'avoir survolé pendant au moins 1000ms
  63. this.showTimer = window.setTimeout("document.getElementById('" + this.divNameWait + "').waitModel.show()", this.timeToShow);
  64. }
  65. /**
  66. * Lors d'un survol du tooltip on le montre
  67. */
  68. Wait.prototype.mayHide = function (){
  69. //On annule le timeout destiné ? affiché le tooltip
  70. //window.clearTimeout(this.showTimer);
  71. this.showTimer = undefined;
  72. //if(this.isShown)
  73. this.hideTimer = window.setTimeout("document.getElementById('" + this.divNameWait + "').waitModel.hide()", this.timeToHide);
  74. }