PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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