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

Revision 227, 4.8 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                                this.window_position(pId, this.elementM(pId));
54                                this.window_state(pId, 'nm');
55                                this.window_focus(this.elementM(pId));
56
57                                // Começa com a Janela : _contacts_im_, minimizada
58                                if( pId == '_contacts_im_' )
59                                        im_window.window_minimize('_contacts_im_');
60                                       
61                                div.style.display = "block";
62                        }
63                        else
64                        {
65                                this.window_visible(pId);
66                                this.window_state(pId, 'nm');
67                        }
68                }
69                catch(e)
70                {
71                        alert("Error : \n\n" + e + "\n\n" + e.description);
72                }
73        },
74
75        "window_close" :  function(pId)
76        {
77                this.window_state(pId, 'cl');
78                this.elementM(pId).parentNode.removeChild(this.elementM(pId));
79        },
80
81        "window_focus" :  function(pElement)
82        {
83                pElement.style.zIndex = ++this.focus;
84        },
85
86        "window_maximize" : function(pId)
87        {
88                this.window_state(pId, 'max');
89
90                // _button_maximize
91                var button_maximize = document.getElementById(pId + '_button_maximize');
92                button_maximize.onclick = function(){im_window.window_normal(button_maximize, pId, 'window_maximize');};
93
94                // _window_master
95                this.elementM(pId).style.top = "0px";
96                this.elementM(pId).style.left = "0px";
97                this.elementM(pId).style.width = window.screen.availWidth - 24;
98                this.elementM(pId).style.height = window.screen.availHeight - 60;
99
100                // _window_body
101                this.elementB(pId).style.width = 'auto';
102                this.elementB(pId).style.height =  '100%';
103
104                // _window_body_content
105                this.elementC(pId).style.height = '100%';
106        },
107
108        "window_minimize" :  function(pId)
109        {
110                this.window_state(pId, 'min');
111
112                // _window_master
113                this.elementM(pId).style.display = 'none';
114               
115                // Caso especial para iframes;
116                if(func.byId('iframe_' + pId) != null)
117                        func.byId('iframe_' + pId).parentNode.removeChild(func.byId('iframe_' + pId));
118        },
119
120        "window_normal" : function(pButton, pId, pFunction)
121        {
122                this.elementM(pId).style.top = this.window[pId].y;
123                this.elementM(pId).style.left = this.window[pId].x;
124                this.elementM(pId).style.width = this.window[pId].w;
125                this.elementM(pId).style.height = 'auto';
126                pButton.onclick = function(){eval('im_window.' + pFunction + '("' + pId + '")');};
127                this.window_state(pId, 'max');
128        },
129
130        "window_object" : function( pId, pState)
131        {
132                this.window[pId] = {
133                        "x": this.elementM(pId).offsetLeft,
134                        "y": this.elementM(pId).offsetTop,
135                        "w": this.elementM(pId).clientWidth,
136                        "h": this.elementM(pId).clientHeight,
137                        "s": pState
138                };
139        },
140
141        "window_position" : function( pId, pElement )
142        {
143                pElement.style.position = 'absolute';
144
145                if ( this.window[pId] )
146                {
147                        pElement.style.left = this.window[pId].x + "px";
148                        pElement.style.top  = this.window[pId].y + "px";
149                }
150                else
151                {
152                        pElement.style.left = parseInt( this.position.x += 10 ) + "px";
153                        pElement.style.top  = parseInt( this.position.y += 10 ) + "px";
154                }
155        },
156
157        "window_state" : function(pId, pState)
158        {
159
160                if(this.window[pId])
161                {
162                        if(pState == 'max')
163                        {
164                                if(this.window[pId].s == 'max')
165                                        this.window_object( pId, pState);
166                                else
167                                        this.window_object( pId, pState);
168                        }
169                        else if( pState == 'cl')
170                                this.window_object( pId, pState);
171                }
172                else
173                        this.window_object( pId, pState);
174        },
175
176        "window_visible" : function(pId)
177        {
178                if ( this.elementM(pId).style.display == 'none' )
179                                this.elementM(pId).style.display = 'block';
180        },
181       
182        "visible" : function(pId, pDisplay)
183        {
184                document.getElementById('div_im_load_contacts_initial_' + pId).style.display = pDisplay;
185        }
186};
187
188var im_window = new build_win();
Note: See TracBrowser for help on using the repository browser.