source: trunk/instant_messenger/js/build_win.js @ 287

Revision 287, 5.6 KB checked in by niltonneto, 16 years ago (diff)

Verificar Wiki/Trac? do módulo.

Line 
1/**
2* @AUTHOR: Alexandre Correia - alexandrecorreia [.at.] celepar [.dot.] pr [.dot.] gov [.dot.] br
3* @AUTHOR: Rodrigo Souza - rodrigosouzadossantos [.at.] gmail [.dot.] com
4* @COPYLEFT: GPL - http://www.gnu.org/copyleft/gpl.html
5* @DATE: 07/11/2007
6* @LAST CHANGE:
7* @BRIEF:
8**/
9
10function build_win()
11{
12        this.window     = [];
13        this.position   = {"x":100, "y":10};
14        this.focus              = 100;
15        this.xtools             = new XTools();
16}
17
18build_win.prototype = {
19
20        "elementB" : function(pId)
21        {
22                return document.getElementById(pId + '__window_body');
23        },
24
25        "elementC" : function(pId)
26        {
27                return document.getElementById(pId + '__window_body_content');
28        },
29
30        "elementM" : function(pId)
31        {
32                return document.getElementById(pId + '__window_master');
33        },
34       
35        "load" :  function(pId, pParentId, pXml, pXsl, pWidth, pButMin, pButMax, pButClose )
36        {
37                try{
38                        if( document.getElementById(pId + '__window_master') == null)
39                        {
40                                pXml  = '<window>' + pXml ;
41                                pXml += '<name>' + pId + '</name>';
42                                pXml += (pWidth) ? '<width>' + pWidth + 'px</width>' : '<width>200px</width>' ;
43                                pXml += (pButMin) ? '<pButMin>block</pButMin>' : '<pButMin>none</pButMin>';
44                                pXml += (pButMax) ? '<pButMax>block</pButMax>' : '<pButMax>none</pButMax>';
45                                pXml += (pButClose) ? '<pButClose>block</pButClose>' : '<pButClose>none</pButClose>';
46                                pXml += '</window>';
47                               
48                                var div = document.createElement("div");
49                                div.innerHTML = this.xtools.parse(pXml,pXsl);
50                                div.style.display = "none";
51                                document.getElementById(pParentId).appendChild(div);
52                               
53                                if( pId == '__contacts_im_' )
54                                {
55                                        this.elementM(pId).style.right = "0px";
56                                        this.elementM(pId).style.top  = parseInt( this.position.y += 10 ) + "px";
57                                }
58                                else
59                                        this.window_position(pId, this.elementM(pId));
60                                this.window_state(pId, 'nm');
61                                this.window_focus(document.getElementById(pId + '__window_master'));
62
63                                // Janela __contacts_im_ minimizada;
64                                if( pId == '__contacts_im_' )
65                                        im_window.window_minimize('__contacts_im_');
66                                       
67                                div.style.display = "block";
68                        }
69                        else
70                        {
71                                this.window_visible(pId);
72                                this.window_state(pId, 'nm');
73                        }
74                }
75                catch(e)
76                {
77                        alert("Error - : \n\n" + e + "\n\n" + e.description);
78                }
79        },
80
81        "window_close" :  function(pId)
82        {
83                this.window_state(pId, 'cl');
84                this.elementM(pId).parentNode.removeChild(this.elementM(pId));
85        },
86
87        "window_focus" :  function(pElement)
88        {
89                if (! templates.dontFocus)
90                        pElement.style.zIndex = ++this.focus;
91                else
92                        templates.dontFocus = false;
93        },
94
95        "window_maximize" : function(pId)
96        {
97                this.window_state(pId, 'max');
98
99                // _button_maximize
100                var button_maximize = document.getElementById(pId + '__button_maximize');
101                button_maximize.onclick = function(){im_window.window_normal(button_maximize, pId, 'window_maximize');};
102
103                // _window_master
104                this.elementM(pId).style.top = "0px";
105                this.elementM(pId).style.left = "0px";
106                this.elementM(pId).style.width = window.screen.availWidth - 24;
107                this.elementM(pId).style.height = window.screen.availHeight - 60;
108               
109
110                // _window_body
111                this.elementB(pId).style.width = 'auto';
112                this.elementB(pId).style.height =  '100%';
113
114                // _window_body_content
115                this.elementC(pId).style.height = '100%';
116                var windowType = this.elementC(pId).firstChild.firstChild.className;
117
118                if (windowType == 'history') // message window
119                {
120                        this.elementC(pId).firstChild.childNodes[0].style.height = '60%';
121                        this.elementC(pId).firstChild.childNodes[0].style.width = '100%';
122                        this.elementC(pId).firstChild.childNodes[1].style.width = '100%';
123                        this.elementC(pId).firstChild.childNodes[2].firstChild.style.width = '100%';
124                }
125                else if (windowType == 'font_menu') // contacts window
126                {
127                        this.elementC(pId).childNodes[1].style.height = '70%';
128                }
129
130        },
131
132        "window_minimize" :  function(pId)
133        {
134                this.window_state(pId, 'min');
135
136                // _window_master
137                this.elementM(pId).style.display = 'none';
138               
139                // Caso especial para iframes;
140                if(func.byId('iframe_' + pId) != null)
141                        func.byId('iframe_' + pId).parentNode.removeChild(func.byId('iframe_' + pId));
142        },
143
144        "window_normal" : function(pButton, pId, pFunction)
145        {
146                this.elementM(pId).style.top = this.window[pId].y;
147                this.elementM(pId).style.left = this.window[pId].x;
148                this.elementM(pId).style.width = this.window[pId].w;
149                this.elementM(pId).style.height = 'auto';
150                pButton.onclick = function(){eval('im_window.' + pFunction + '("' + pId + '")');};
151                this.window_state(pId, 'max');
152        },
153
154        "window_object" : function( pId, pState)
155        {
156                this.window[pId] = {
157                        "x": this.elementM(pId).offsetLeft,
158                        "y": this.elementM(pId).offsetTop,
159                        "w": this.elementM(pId).clientWidth,
160                        "h": this.elementM(pId).clientHeight,
161                        "s": pState
162                };
163        },
164
165        "window_position" : function( pId, pElement )
166        {
167                pElement.style.position = 'absolute';
168
169                if ( this.window[pId] )
170                {
171                        pElement.style.left = this.window[pId].x + "px";
172                        pElement.style.top  = this.window[pId].y + "px";
173                }
174                else
175                {
176                        pElement.style.left = parseInt( this.position.x += 10 ) + "px";
177                        pElement.style.top  = parseInt( this.position.y += 10 ) + "px";
178                }
179        },
180
181        "window_state" : function(pId, pState)
182        {
183
184                if(this.window[pId])
185                {
186                        if(pState == 'max')
187                        {
188                                if(this.window[pId].s == 'max')
189                                        this.window_object( pId, pState);
190                                else
191                                        this.window_object( pId, pState);
192                        }
193                        else if( pState == 'cl')
194                                this.window_object( pId, pState);
195                }
196                else
197                        this.window_object( pId, pState);
198        },
199
200        "window_visible" : function(pId)
201        {
202                if ( this.elementM(pId).style.display == 'none' )
203                                this.elementM(pId).style.display = 'block';
204        },
205       
206        "visible" : function(pId, pDisplay)
207        {
208                document.getElementById('div_im_load_contacts_initial_' + pId).style.display = pDisplay;
209        }
210};
211
212var im_window = new build_win();
Note: See TracBrowser for help on using the repository browser.