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

Revision 235, 4.9 KB checked in by niltonneto, 16 years ago (diff)
  • Property svn:executable set to *
  • Property svn:mime-type set to application/octet-stream
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(this.elementM(pId));
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                pElement.style.zIndex = ++this.focus;
90        },
91
92        "window_maximize" : function(pId)
93        {
94                this.window_state(pId, 'max');
95
96                // _button_maximize
97                var button_maximize = document.getElementById(pId + '_button_maximize');
98                button_maximize.onclick = function(){im_window.window_normal(button_maximize, pId, 'window_maximize');};
99
100                // _window_master
101                this.elementM(pId).style.top = "0px";
102                this.elementM(pId).style.left = "0px";
103                this.elementM(pId).style.width = window.screen.availWidth - 24;
104                this.elementM(pId).style.height = window.screen.availHeight - 60;
105
106                // _window_body
107                this.elementB(pId).style.width = 'auto';
108                this.elementB(pId).style.height =  '100%';
109
110                // _window_body_content
111                this.elementC(pId).style.height = '100%';
112        },
113
114        "window_minimize" :  function(pId)
115        {
116                this.window_state(pId, 'min');
117
118                // _window_master
119                this.elementM(pId).style.display = 'none';
120               
121                // Caso especial para iframes;
122                if(func.byId('iframe_' + pId) != null)
123                        func.byId('iframe_' + pId).parentNode.removeChild(func.byId('iframe_' + pId));
124        },
125
126        "window_normal" : function(pButton, pId, pFunction)
127        {
128                this.elementM(pId).style.top = this.window[pId].y;
129                this.elementM(pId).style.left = this.window[pId].x;
130                this.elementM(pId).style.width = this.window[pId].w;
131                this.elementM(pId).style.height = 'auto';
132                pButton.onclick = function(){eval('im_window.' + pFunction + '("' + pId + '")');};
133                this.window_state(pId, 'max');
134        },
135
136        "window_object" : function( pId, pState)
137        {
138                this.window[pId] = {
139                        "x": this.elementM(pId).offsetLeft,
140                        "y": this.elementM(pId).offsetTop,
141                        "w": this.elementM(pId).clientWidth,
142                        "h": this.elementM(pId).clientHeight,
143                        "s": pState
144                };
145        },
146
147        "window_position" : function( pId, pElement )
148        {
149                pElement.style.position = 'absolute';
150
151                if ( this.window[pId] )
152                {
153                        pElement.style.left = this.window[pId].x + "px";
154                        pElement.style.top  = this.window[pId].y + "px";
155                }
156                else
157                {
158                        pElement.style.left = parseInt( this.position.x += 10 ) + "px";
159                        pElement.style.top  = parseInt( this.position.y += 10 ) + "px";
160                }
161        },
162
163        "window_state" : function(pId, pState)
164        {
165
166                if(this.window[pId])
167                {
168                        if(pState == 'max')
169                        {
170                                if(this.window[pId].s == 'max')
171                                        this.window_object( pId, pState);
172                                else
173                                        this.window_object( pId, pState);
174                        }
175                        else if( pState == 'cl')
176                                this.window_object( pId, pState);
177                }
178                else
179                        this.window_object( pId, pState);
180        },
181
182        "window_visible" : function(pId)
183        {
184                if ( this.elementM(pId).style.display == 'none' )
185                                this.elementM(pId).style.display = 'block';
186        },
187       
188        "visible" : function(pId, pDisplay)
189        {
190                document.getElementById('div_im_load_contacts_initial_' + pId).style.display = pDisplay;
191        }
192};
193
194var im_window = new build_win();
Note: See TracBrowser for help on using the repository browser.