source: trunk/instant_messenger/bkp/instant_messenger_32/js/build_win.js @ 151

Revision 151, 4.2 KB checked in by niltonneto, 16 years ago (diff)

Commit da nova versão do módulo, usando agente em C.
Vide Página do módulo do Trac:
http://www.expressolivre.org/dev/wiki/messenger

A versão anterior encontra-se na subpasta bkp (32/64).

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