source: trunk/jabberit_messenger/js/load.js @ 382

Revision 382, 8.5 KB checked in by niltonneto, 16 years ago (diff)

Inclusão do módulo JabberIt? Messenger, novo módulo de mensagens
instantâneas do Expresso. É uma customização do projeto original
Jeti, e foi desenvolvido em Java.

  • Property svn:executable set to *
Line 
1(function()
2{
3        var _conn   = new JITConnector(path_jabberit);
4        var _xtools = new JITXTools(path_jabberit);
5        var _showhidden = new ShowHidden(1500);
6        var myWindow      = '';
7        var flagMouseOver = '';
8   
9        //Sniffer Browser
10        var agt=navigator.userAgent.toLowerCase();
11    var is_major = parseInt(navigator.appVersion);
12    var is_minor = parseFloat(navigator.appVersion);   
13    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
14                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
15                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
16    var is_gecko = (agt.indexOf('gecko') != -1);
17    var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1);
18    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
19    var is_ie3    = (is_ie && (is_major < 4));
20    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
21    var is_ie4up  = (is_ie && (is_major >= 4));
22    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
23    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
24    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
25    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
26    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
27    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);   
28    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
29
30        if ( !(document.getElementById('jabberit_messenger_content')) )
31        {
32                var _jabberit_content = document.createElement('div');
33                _jabberit_content.setAttribute('id', 'jabberit_messenger_content');
34                _jabberit_content = document.body.appendChild(_jabberit_content);
35        }
36
37        var _window = new JITWindows(_xtools, _jabberit_content);
38        var _ldap       = new JITLdap( _conn, _xtools, _window);
39
40        function addIcon()
41        {
42               
43                var StatusBar = '';
44                if((StatusBar = document.getElementById('divStatusBar')))
45                {
46                        var _div = document.createElement('div');
47                        _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling));
48                        StatusBar.parentNode.insertBefore(_div,StatusBar);
49
50                        StatusBar.style.paddingLeft = '33px';
51
52                        var _status = top.document.createElement('div');
53                                _status.setAttribute('id', 'jabberit_status');
54                                _status.style.background = 'no-repeat';
55                                _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')';
56                                _status.style.float = 'left';
57                                _status.style.height = '15px';
58                                _status.style.left = '7px';
59                                _status.style.margin = '8 0 0 10px';
60                                _status.style.padding = '0px';
61                                _status.style.position = 'absolute';
62                                _status.style.width = '15px';
63                                _status.style.cursor = 'pointer';
64
65                        StatusBar.insertBefore(_status, StatusBar.firstChild);
66
67                        var _menu;
68                                _menu = top.document.createElement('span');
69                                _menu.setAttribute('id','fast_menu_jabberit');
70                                _menu.style.backgroundColor = 'cecece';
71                                _menu.style.display = 'none';
72                                _menu.style.margin = '20px 0 0 -15px';
73                                _menu.style.position = 'absolute';
74                                _menu.style.zIndex = '99999';
75                                _menu.style.border = '1px dashed #000';
76                        StatusBar.insertBefore(_menu, StatusBar.firstChild);
77
78                        var _menu_div = top.document.createElement('div');
79                                _menu_div.style.background = 'no-repeat';
80                                _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')';
81                                _menu_div.style.float = 'left';
82                                _menu_div.style.height = '18px';
83                                _menu_div.style.left = '19px';
84                                _menu_div.style.margin = '0 0 0 10px';
85                                _menu_div.style.padding = '0px';
86                                _menu_div.style.position = 'absolute';
87                                _menu_div.style.width = '18px';
88                                _menu_div.style.cursor = 'pointer';
89                       
90                        StatusBar.insertBefore(_menu_div, StatusBar.firstChild);
91                       
92                        configEvents(_menu_div,'onclick',showWindow);
93
94                        configEvents(
95                                _status,
96                                'onclick',
97                                function()
98                                {
99                                        var _options = [
100                                                ['Add Contacts',addContacts],
101                                                ['Help',helpJabberit]
102                                        ];
103
104                                        var _style_text = 'cursor: pointer; padding:2px 4px 2px 20px; background: no-repeat url(' + jabberit_group_close.src + ');';
105
106                                        var _xml = _xtools.xml('menu');
107                                        var _option;
108                                        var _item;
109                                        var _action;
110                                        var _style;
111
112                                        for ( var i in _options )
113                                        {
114                                                _option = _xml.createElement('option');
115
116                                                _item = _xml.createElement('item');
117                                                _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0])));
118                                               
119                                                _style = _xml.createElement('style');
120                                                _style.appendChild(_xml.createTextNode(_style_text));
121
122                                                _option.appendChild(_item);
123                                                _option.appendChild(_style);
124
125                                                _xml.documentElement.appendChild(_option);
126                                        }
127
128                                        _menu.innerHTML = _xtools.parse(_xml, 'options.xsl');
129                                        _showhidden.action('onmouseover', 'onmouseout', _menu);
130
131                                        _item = _menu.firstChild;
132
133                                        for ( var i in _options )
134                                        {
135                                                _item.childNodes[i].setAttribute('presence', _options[i]);
136                                                configEvents(
137                                                        _item.childNodes[i],
138                                                        'onclick',
139                                                        _options[i][1]
140                                                );
141                                        }
142                                }
143                        );
144                }
145        }
146
147        function addContacts()
148        {
149                _ldap.add();
150        }
151
152        function configEvents(pObj, pEvent, pHandler)
153        {
154                if ( typeof pObj == 'object' )
155                {
156                        if ( pEvent.substring(0, 2) == 'on' )
157                                pEvent = pEvent.substring(2, pEvent.length);
158
159                        if ( pObj.addEventListener )
160                                pObj.addEventListener(pEvent, pHandler, false);
161                        else if ( pObj.attachEvent )
162                                pObj.attachEvent('on' + pEvent, pHandler);
163                }
164        }
165
166        function closeWindow()
167        {
168                _conn.go('$this.ujabber.setWindow','window=closed');
169                myWindow = '';
170        }
171
172        function getFocus()
173        {
174                var pNewWindow = myWindow;
175                for( var i = 15 ; i > 0 ; i-- )
176                {
177                        pNewWindow.moveBy(i,0);
178                        pNewWindow.moveBy(-i,0);
179                }
180                pNewWindow.focus();
181        }
182
183        function helpJabberit()
184        {
185                var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes');
186        }
187
188        function keyPressSearch()
189        {
190                var ev = arguments[0];
191                var element = arguments[1];
192
193                if ( ev.keyCode == 13 )
194                        if( element.value.length >= 4 )
195                                _ldap.search( element.value ); 
196                        else
197                                alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
198        }
199
200        function openPopup()
201        {
202                _conn.go('$this.ujabber.statusWindow',
203                                function(data)
204                                {
205                                        if( !(data.indexOf('closed') < 0 ))
206                                        {
207                                                if( !myWindow )
208                                                {       
209                                                        myWindow = window.open( path_jabberit + 'client.php', 'JabberIM', 'width=215,height=400,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no');
210                                                        myWindow.blur();
211                                                        configEvents(myWindow,'onbeforeunload', closeWindow );
212                                                        _conn.go('$this.ujabber.setWindow','window=open');
213                                                }
214                                        }
215                                        else
216                                                alert('O Mensageiro já está aberto!');
217                                });
218        }
219
220        function openWindow()
221        {
222                var _win_contacts = _window.load('jabberit_contacts');
223                        _win_contacts.size(1,1);
224                        _win_contacts.position(50,50);
225
226                        _win_contacts.bc.style.display = "none";
227                        _win_contacts.bx.style.display = "none";
228
229                        if( _win_contacts.bz.removeEventListener )
230                                _win_contacts.bz.removeEventListener('click',_win_contacts.button, false);
231                        else
232                                _win_contacts.bz.detachEvent('onclick',_win_contacts.button);
233
234                configEvents(
235                        _win_contacts.bz,
236                        "onclick",
237                        function()
238                        {
239                                _win_contacts.size(1,1);
240                                _win_contacts.wm.style.visibility = 'hidden';
241                                _win_contacts.position(50,50);
242                                _win_contacts.title('');
243                        }
244                );
245
246                var _params = {'path' : path_jabberit};
247               
248                _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params));
249                _win_contacts.wm.style.visibility = "hidden";
250        }
251
252        function searchUser()
253        {
254                var element = arguments[0].previousSibling;
255               
256                if( element.value.length >= 4 )
257                        _ldap.search( element.value ); 
258                else
259                        alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
260        }
261
262        function showDiv()
263        {
264                var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ;
265                if( _element != null )
266                        _element.style.visibility = 'visible';
267        }
268
269        function showWindow()
270        {
271                var _win_contacts = _window.get('jabberit_contacts');
272                if( !is_ie )
273                {
274                        if ( _win_contacts )
275                        {
276                                _win_contacts.wm.style.visibility = "visible";
277                                _win_contacts.title('.:: Expresso - JMessenger ::.');
278                                _win_contacts.size(205,400);
279                        }
280                        else
281                                openWindow();
282                }
283                else
284                        openPopup();
285        }
286
287        function Load()
288        {
289                addIcon();
290                setTimeout('loadscript.showW();', 2000);
291        }
292
293        Load.prototype.keyPress = keyPressSearch;
294        Load.prototype.search = searchUser;
295        Load.prototype.show = showDiv;
296        Load.prototype.showW = showWindow;
297        Load.prototype.closeW = closeWindow;
298        window.loadscript = new Load;
299
300})();
Note: See TracBrowser for help on using the repository browser.