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

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