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

Revision 751, 26.0 KB checked in by niltonneto, 15 years ago (diff)

Resolve tickets #461, #462 e #472.

  • Property svn:executable set to *
Line 
1(function()
2{
3        var _autoStatusTime = 60000; // 1 minuto
4        var _autoStatus;
5        var _conn   = new JITConnector(path_jabberit);
6        var _xtools = new JITXTools(path_jabberit);
7        var _showhidden = new ShowHidden(300);
8        var myWindow      = '';
9        var flagMouseOver = '';
10        var flagOpenIM    = '';
11        var flagOpenPopup = '';
12        var flagAwayIM    = '';
13        var itensSubMenu  = [];
14   
15        // Sniffer Browser
16        var agt=navigator.userAgent.toLowerCase();
17    var is_major = parseInt(navigator.appVersion);
18    var is_minor = parseFloat(navigator.appVersion);   
19    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
20                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
21                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
22    var is_gecko = (agt.indexOf('gecko') != -1);
23    var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1);
24    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
25    var is_ie3    = (is_ie && (is_major < 4));
26    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
27    var is_ie4up  = (is_ie && (is_major >= 4));
28    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
29    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
30    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
31    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
32    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
33    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);   
34    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
35
36        if ( !(document.getElementById('jabberit_messenger_content')) )
37        {
38                var _jabberit_content = document.createElement('div');
39                _jabberit_content.setAttribute('id', 'jabberit_messenger_content');
40                _jabberit_content = document.body.appendChild(_jabberit_content);
41        }
42
43        var _window = new JITWindows(_xtools, _jabberit_content);
44        var _ldap       = new JITLdap( _conn, _xtools, _window);
45
46        function addContacts()
47        {
48                _ldap.add();
49        }
50
51        function addIcon()
52        {
53               
54                var StatusBar = document.getElementById('divStatusBar');
55
56                /**
57                 * @quando estiver habilitada a opção fora de escritório nos filtros.
58                 */
59               
60                if( div_write_msg = document.getElementById('em_div_write_msg') )
61                {               
62                        var StatusBarIM = document.getElementById('JabberMessenger');
63                        div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg);
64                        StatusBarIM.style.paddingLeft = '33px';
65                        return;                 
66                }
67               
68                if( StatusBar )
69                {
70                        StatusBar.style.paddingLeft = '33px';
71                       
72                        var _div = document.createElement('div');
73                        _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling));
74                        StatusBar.parentNode.insertBefore(_div,StatusBar);
75                       
76                        var divJabber = document.createElement('div');
77                                divJabber.setAttribute('id', 'JabberMessenger');
78                       
79                        var _status = top.document.createElement('div');
80                                _status.setAttribute('id', 'jabberit_login');
81                                _status.style.background = 'no-repeat';
82                                _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')';
83                                _status.style.float = 'left';
84                                _status.style.height = '15px';
85                                _status.style.left = '7px';
86                                _status.style.margin = '8 0 0 10px';
87                                _status.style.padding = '0px';
88                                _status.style.position = 'absolute';
89                                _status.style.width = '15px';
90                                _status.style.cursor = 'pointer';
91
92                        divJabber.insertBefore(_status,divJabber.firstChild);
93
94                        var _menu;
95                                _menu = top.document.createElement('div');
96                                _menu.setAttribute('id','fast_menu_jabberit');
97                                _menu.style.backgroundColor = 'cecece';
98                                _menu.style.border = '1px dashed #000';
99                                _menu.style.display = 'none';
100                                _menu.style.margin = '20px 5px 0px -15px';
101                                _menu.style.position = 'absolute';
102                                _menu.style.zIndex = '99999';
103                                _menu.onmouseout = function(){ _showhidden.hiddenObject(false); };
104                                _menu.onmouseover = function(){ _showhidden.hiddenObject(true); };
105                               
106                        divJabber.insertBefore(_menu, divJabber.firstChild);
107
108                        var _menu_div = top.document.createElement('div');
109                                _menu_div.setAttribute('id','status_Jabber_Expresso');
110                                _menu_div.style.background = 'no-repeat';
111                                _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')';
112                                _menu_div.style.float = 'left';
113                                _menu_div.style.height = '18px';
114                                _menu_div.style.left = '19px';
115                                _menu_div.style.margin = '0 0 0 10px';
116                                _menu_div.style.padding = '0px';
117                                _menu_div.style.position = 'absolute';
118                                _menu_div.style.width = '18px';
119                                _menu_div.style.cursor = 'pointer';
120                                _menu_div.style.zindex = '99999999';
121                       
122                        statusJabberExpresso = _menu_div;
123                       
124                        divJabber.insertBefore(_menu_div, divJabber.firstChild);
125                        StatusBar.insertBefore(divJabber, StatusBar.firstChild);                       
126                       
127                        configEvents(_menu_div,'onclick',showWindow);
128
129                        configEvents(
130                                _status,
131                                'onclick',
132                                function()
133                                {
134                                        var _options = [
135                                                ['Add Contacts',addContacts],
136                                                ['Help',helpJabberit],
137                                                ['Preferences', preferences],
138                                                ['Change Status', subMenuChangeStatus]
139                                        ];
140
141                                        var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; border-bottom:1px solid #dedede; background: no-repeat url(' + jabberit_group_close.src + ');';                                   
142
143                                        var _xml = _xtools.xml('menu');
144                                        var _option;
145                                        var _item;
146                                        var _action;
147                                        var _style;
148
149                                        for ( var i in _options )
150                                        {
151                                                _option = _xml.createElement('option');
152
153                                                _item = _xml.createElement('item');
154                                                _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0])));
155                                               
156                                                _style = _xml.createElement('style');
157                                                _style.appendChild(_xml.createTextNode(_style_text));
158
159                                                _option.appendChild(_item);
160                                                _option.appendChild(_style);
161
162                                                _xml.documentElement.appendChild(_option);
163                                        }
164
165                                        _menu.innerHTML = _xtools.parse(_xml, 'options.xsl');
166                                        _showhidden.action('onmouseover', 'onmouseout', _menu);
167
168                                        _item = _menu.firstChild;
169
170                                        for ( var i in _options )
171                                        {
172                                                _item.childNodes[i].setAttribute('presence', _options[i]);
173                                                configEvents(
174                                                        _item.childNodes[i],
175                                                        'onclick',
176                                                        _options[i][1]
177                                                );
178                                        }
179                                });
180                }
181        }
182
183        function autoStatus()
184        {
185               
186                if ( _autoStatus )
187                        clearTimeout(_autoStatus);
188
189                var _div_status = document.getElementById('status_Jabber_Expresso');
190                if ( _div_status )
191                {
192                        var _status = _div_status.style.backgroundImage;
193                        _status = _status.substr(_status.lastIndexOf('/') + 1);
194                        _status = _status.substr(0, _status.indexOf('.'));
195                        if ( _status == 'xa' && _div_status.getAttribute('autoStatus') )
196                        {
197                                _div_status.removeAttribute('autoStatus');
198                                changeStatusJava("2");
199                        }
200                }
201
202                var TimeStatus = flagAwayIM.split(':');
203
204                if( TimeStatus[1] )
205                        _autoStatus = setTimeout(autoStatusHandler, parseInt(TimeStatus[1])*_autoStatusTime);
206                else
207                        _autoStatus = setTimeout(autoStatusHandler, parseInt(_autoStatusTime));
208        }
209
210        function autoStatusHandler()
211        {
212                var _div_status = document.getElementById('status_Jabber_Expresso');
213                if ( _div_status )
214                {
215                        var _status = _div_status.style.backgroundImage;
216                        _status = _status.substr(_status.lastIndexOf('/') + 1);
217                        _status = _status.substr(0, _status.indexOf('.'));
218                        if ( _status == 'available' )
219                        {
220                                _div_status.setAttribute('autoStatus','true');
221                                changeStatusJava("5");
222                        }
223                }
224        }
225
226        function changeLabel()
227        {
228                if( arguments.length > 0 )
229                {
230                        var element = arguments[0].parentNode.parentNode.firstChild;
231
232                        if(arguments[0].checked)
233                                element.innerHTML = "<span style='color:red;'>Digite o Email .: </span>";
234                        else
235                                element.innerHTML = "Nome do Contato .: ";
236                }
237        }
238
239        function changeStatusJava()
240        {
241                if(arguments.length > 0 )
242                {
243                        try
244                        {
245                                var status      = arguments[0];
246                                var msg         = ( arguments[1] ) ? arguments[1] : "";
247                       
248//                              alert("Mensagem Jabber : " + msg);
249                               
250                                // If Layer;
251                                if( elementIframe = document.getElementById('iframe_applet_jabberit') )
252                                {
253                                        if( !is_ie )
254                                                elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg);
255                                        else
256                                                elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg);
257                                }
258                                else // If Pop-Up
259                                {
260                                        myWindow.document.applets[0].changeStatusfromExpresso(status, msg);
261                                }
262                               
263                        }
264                        catch(e)
265                        {
266                                if( confirm('Deseja conectar o IM ?') )
267                                        showWindow();
268                        }
269                }               
270        }
271
272        function configEvents(pObj, pEvent, pHandler)
273        {
274                if ( typeof pObj == 'object' )
275                {
276                        if ( pEvent.substring(0, 2) == 'on' )
277                                pEvent = pEvent.substring(2, pEvent.length);
278
279                        if ( pObj.addEventListener )
280                                pObj.addEventListener(pEvent, pHandler, false);
281                        else if ( pObj.attachEvent )
282                                pObj.attachEvent('on' + pEvent, pHandler);
283                }
284        }
285
286        function closeWindow()
287        {
288                myWindow = '';
289        }
290
291        function getElementStatus()
292        {
293                return document.getElementById('status_Jabber_Expresso');
294        }
295
296        function getPreferences()
297        {
298                if( flagOpenIM == '' )
299                {
300                        _conn.go("$this.db_im.getPreferences",
301                                                function(data)
302                                                {
303                                                        var autoConnect = '';
304                                                        flagOpenIM = data;
305
306                                                        if( data.indexOf(';') != -1)
307                                                        {
308                                                                var temp = data.split(';');
309                                                                autoConnect = flagOpenIM = temp[0];
310                                                               
311                                                                // Open as Pop-Up
312                                                                flagOpenPopup = 'openWindowJabberitPopUp:false';
313                                                               
314                                                                if( temp[1] )
315                                                                {
316                                                                        if( temp[1] == 'openWindowJabberitPopUp:true' || temp[1] == 'openWindowJabberitPopUp:false')
317                                                                                flagOpenPopup = temp[1];
318                                                                }
319                                                               
320                                                                // Away
321                                                                flagAwayIM = 'flagAwayIM:5';
322                                                               
323                                                                if( temp[2] )
324                                                                {
325                                                                        flagAwayIM = temp[2];
326                                                                }
327                                                        }
328                                                        else
329                                                        {
330                                                                autoConnect = flagOpenIM;
331                                                        }
332                                                       
333                                                        if( autoConnect == 'openWindowJabberit:true' )
334                                                        {
335                                                                setTimeout('loadscript.showW();', 2500);
336                                                        }
337                                                });
338                }
339
340        }
341
342        function helpJabberit()
343        {
344                var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes');
345        }
346
347        function keyPressSearch()
348        {
349                var ev = arguments[0];
350                var element = arguments[1];
351
352                if ( ev.keyCode == 13 )
353                        if( element.value.length >= 4 )
354                                _ldap.search( element.value ); 
355                        else
356                                alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
357        }
358
359        function openPopup()
360        {
361                var widPopup = '220';
362
363                if( is_ie )
364                        widPopup = '250';
365
366                try{
367
368                        if(!myWindow )
369                        {       
370                                myWindow = window.open('','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
371                                myWindow.close();
372                                myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
373                                myWindow.blur();
374                                configEvents(myWindow,'onbeforeunload', closeWindow );
375                        }
376                        else
377                        {
378                                for( var i = 15 ; i > 0 ; i-- )
379                                {
380                                        myWindow.moveBy(i,0); myWindow.moveBy(-i,0);
381                                }
382                                myWindow.focus();
383                        }
384                }
385                catch(e)
386                {
387                        delete myWindow;
388                        myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
389                        myWindow.blur();
390                        configEvents(myWindow,'onbeforeunload', closeWindow );
391                }
392        }
393
394        function openWindow()
395        {
396                var _win_contacts = _window.load('jabberit_contacts');
397
398                var flagOpenAux = '';
399               
400                if( flagOpenIM.indexOf(';') != -1 )
401                {
402                        var aux = flagOpenIM.split(';');
403                        flagOpenAux = aux[0];
404                }
405                else
406                        flagOpenAux = flagOpenIM;
407
408                if( flagOpenAux == 'openWindowJabberit:false' )
409                {
410                        if( !is_ie )
411                                _win_contacts.size(220,400);
412                        else   
413                                _win_contacts.size(250,400);
414                }                                       
415                else
416                {
417                        if( !is_ie )
418                        {
419                                _win_contacts.size(1,1);
420                                _win_contacts.wm.style.visibility = 'hidden';
421                        }
422                        else
423                        {
424                                _win_contacts.size(0,0);
425                        }
426                }
427
428                _win_contacts.bc.style.display = "none";
429                _win_contacts.bx.style.display = "none";
430
431                if( _win_contacts.bz.removeEventListener )
432                        _win_contacts.bz.removeEventListener('click',_win_contacts.button, false);
433                else
434                        _win_contacts.bz.detachEvent('onclick',_win_contacts.button);
435
436                configEvents(
437                        _win_contacts.bz,
438                        "onclick",
439                        function()
440                        {
441                                _win_contacts.size(1,1);
442                                _win_contacts.wm.style.visibility = 'hidden';
443                                _win_contacts.position(50,50);
444                                _win_contacts.title('');
445                        }
446                );
447
448                var _params = {'path' : path_jabberit};
449                _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params));
450
451                if( flagOpenAux == 'openWindowJabberit:false' )
452                {
453                        if( !is_ie )
454                        {
455                                _win_contacts.wm.style.visibility = "visible";
456                                _win_contacts.size(220,400);
457                                _win_contacts.title('.:: Expresso - JMessenger ::.');
458                        }
459                        else
460                        {
461                                _win_contacts.size(250,400);
462                                _win_contacts.title('.:: Expresso - JMessenger ::.');
463                        }
464                        _win_contacts.position(50,50);
465                }
466                else
467                {
468                        if( !is_ie )
469                                _win_contacts.wm.style.visibility = "hidden";
470                }
471        }
472
473        function openWindowParticipantsExternal()
474        {
475                if( arguments.length > 0)
476                {
477                        var element = arguments[0];
478                        var orgPartExternal = externalParticipantsJabberit.split(",");
479                       
480                        var _splash = top.document.createElement('span');
481                                _splash.setAttribute('id','fast_splash_jabberit');
482                                _splash.style.backgroundColor = 'dedede';
483                                _splash.style.position = 'absolute';
484                                _splash.style.display = 'block';
485                                _splash.style.width = '200px';
486                                _splash.style.height = 'auto';
487                                _splash.style.margin = ( !is_ie ) ? '0px 5px 0px 130px' : '20px 0px 0px 0px';
488                                _splash.style.zIndex = '99999';
489                                _splash.style.border = '2px outset #000';
490                                _splash.onmouseout = function(){ _showhidden.hiddenObject(false); };
491                                _splash.onmouseover = function(){ _showhidden.hiddenObject(true); };
492                       
493                                for(var i = 0; i < orgPartExternal.length; i++)
494                                        _splash.innerHTML += '<div style="margin:5px;border-bottom:1px dashed #000;cursor:default !important;">' + (i + 1) + " - " + orgPartExternal[i] + '</div>';     
495                               
496                        _showhidden.action('onmouseover', 'onmouseout', _splash);
497                        element.appendChild(_splash);
498                }
499        }
500
501        function preferences()
502        {
503                if( !(_window.get('jabberit_preferences')) )
504                {
505                        var _win_preferences = _window.load('jabberit_preferences');
506                                _win_preferences.size(400,310);                         
507                                _win_preferences.position(150,100);
508                                _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
509                                _win_preferences.bc.style.display = "none";
510                                _win_preferences.bx.style.display = "none";
511                                _win_preferences.wc.style.padding = "5px";                                                             
512
513                        if( _win_preferences.bz.removeEventListener )
514                                _win_preferences.bz.removeEventListener('click',_win_preferences.button, false);
515                        else
516                                _win_preferences.bz.detachEvent('onclick',_win_preferences.button);
517                               
518                        configEvents(
519                                _win_preferences.bz,
520                                "onclick",
521                                function()
522                                {
523                                        _win_preferences.size(1,1);
524                                        _win_preferences.wm.style.visibility = 'hidden';
525                                        _win_preferences.position(50,50);
526                                        _win_preferences.title('');
527                                });
528
529                        var _params = {'path'  : path_jabberit,
530                                                   'lang1' : jabberitGetLang('Your Preferences'),
531                                                   'lang2' : jabberitGetLang('Connection'),     
532                                                   'lang3' : jabberitGetLang('Enable Auto Login IM'),
533                                                   'lang4' : jabberitGetLang('Users OffLine'),
534                                                   'lang5' : jabberitGetLang('Show friends Offline'),
535                                                   'lang6' : jabberitGetLang('Save'),
536                                                   'lang7' : jabberitGetLang('Cancel'),
537                                                   'lang8' : jabberitGetLang('Window'),
538                                                   'lang9' : jabberitGetLang('Open as Pop-Up Window'),
539                                                   'lang10' : jabberitGetLang('Away Presence'),
540                                                   'lang11' : jabberitGetLang('Set status to away after'),
541                                                   'lang12' : jabberitGetLang('minutes'),                                                 
542                                                   'langYes': jabberitGetLang('Yes'),
543                                                   'langNo' : jabberitGetLang('No')                                                                                       
544                                                  };
545                        _win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params));
546                        _win_preferences.wc.lastChild.lastChild.onclick = _win_preferences.close;
547                }
548                else
549                {
550                        var _win_preferences = _window.get('jabberit_preferences');
551                        _win_preferences.wm.style.visibility = "visible";
552                        _win_preferences.position(150,100);                                                     
553                        _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
554                        _win_preferences.size(320,250);
555                }
556               
557                // Element openWindowJabberit
558                var value1 = flagOpenIM.split(':');
559                var element1 = document.getElementById(value1[0]);
560                var valueSelect1 = value1[1];
561               
562                for(var i = 0; i < element1.options.length; i++)
563                        if( element1.options[i].value == valueSelect1 )
564                                element1.options[i].selected = true;
565
566               
567                // Element openWindowJabberitPopUp
568                var value2 = flagOpenPopup.split(':');
569                var element2 = document.getElementById(value2[0]);
570                var valueSelect2 = value2[1];
571                       
572                for(var i = 0; i < element2.options.length; i++)
573                        if( element2.options[i].value == valueSelect2 )
574                                element2.options[i].selected = true;
575                               
576                // Element flagAwayIM
577                var value3 = flagAwayIM.split(':');
578                var element3 = document.getElementById(value3[0]);
579                element3.value = value3[1];
580               
581        }
582
583        function searchUser()
584        {
585                var element = arguments[0].previousSibling;
586               
587                if( element.value.length >= 4 )
588                        _ldap.search( element.value ); 
589                else
590                        alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
591        }
592
593        function setItensStatusMenu()
594        {
595                if( arguments.length > 0 )
596                {
597                        var key = parseInt(arguments[0].substring(0, arguments[0].indexOf('-')));
598                        var value = arguments[0].substring(arguments[0].indexOf('-') + 1 );
599                       
600                        itensSubMenu[key] = value.toString();   
601                }
602        }
603       
604        function setPreferences()
605        {
606                // Element openWindowJabberit
607                var elementOpenW = document.getElementById('openWindowJabberit');
608                var value = '';
609                var flagReload = false;
610               
611                for(var i = 0 ; i < elementOpenW.options.length; i++)
612                        if( elementOpenW.options[i].selected == true)
613                        {
614                                value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value;
615                                flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value;
616                        }
617
618                // Element openWindowJabberitPopUp
619                var elementOpenPop = document.getElementById('openWindowJabberitPopUp');       
620
621                for(var i = 0; i < elementOpenPop.options.length; i++ )
622                        if( elementOpenPop.options[i].selected ==  true )
623                        {
624                                value += '&preferences2=openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
625                               
626                                if( flagOpenPopup != 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value)
627                                        flagReload = true;
628                                       
629                                flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
630                        }
631               
632                // Element flagAwayIM
633                var elementFlagIM = document.getElementById('flagAwayIM');
634               
635                if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 )
636                {
637                        flagAwayIM = 'flagAwayIM:' + elementFlagIM.value;
638                        value += '&preferences3=flagAwayIM:' + elementFlagIM.value;
639                }
640                else
641                {
642                        alert(jabberitGetLang('Enter a value greater than or equal to 1!'));
643                        return false;
644                }
645
646                _conn.go('$this.db_im.setPreferences',
647                                 function(data)
648                                 {
649                                        if(data == 'true')
650                                        {
651                                                if( flagReload )
652                                                {
653                                                        window.location.reload();
654                                                        myWindow.close();                                                       
655                                                }
656                                        }
657                                        else{ alert(jabberitGetLang('Error saving your preferences!')); }
658                                                                               
659                                        var _win_preferences = _window.get('jabberit_preferences');
660                                                _win_preferences.close();
661                                 },
662                                 value);
663        }
664       
665        function showDiv()
666        {
667                var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ;
668                if( _element != null )
669                        _element.style.visibility = 'visible';
670        }
671
672        function showWindow()
673        {
674                var _win_contacts = _window.get('jabberit_contacts');
675               
676                if( flagOpenPopup === 'openWindowJabberitPopUp:true' )
677                {
678                        openPopup();                                   
679                }
680                else
681                {
682                        if ( _win_contacts )
683                        {       
684                                _win_contacts.wm.style.visibility = "visible";
685                                _win_contacts.title('.:: Expresso - JMessenger ::.');
686       
687                                if( !is_ie )
688                                        _win_contacts.size(220,400);
689                                else
690                                        _win_contacts.size(250,400);
691       
692                                _win_contacts.position(60,60);
693                        }
694                        else
695                                openWindow();
696                }
697        }
698
699        function subMenuChangeStatus()
700        {
701                if(document.getElementById('subMenu_Change_Status_JabberIt') == null )
702                {
703                        var _itens  = [
704                                                                ['Online', 'loadscript.subMnChStIt("2",this);', 'available_jabberit.src','jabberit_group_close_black.src'],
705                                                                ['Free For Chat', 'loadscript.subMnChStIt("1",this);', 'chat_jabberit.src','jabberit_group_close_black.src'],
706                                                                ['Xa', 'loadscript.subMnChStIt("3",this);','xa_jabberit.src','jabberit_group_close_black.src'],
707                                                                ['Dnd', 'loadscript.subMnChStIt("4",this);','dnd_jabberit.src','jabberit_group_close_black.src'],
708                                                                ['Away', 'loadscript.subMnChStIt("5",this);','away_jabberit.src','jabberit_group_close_black.src'],
709                                                                ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src']
710                                                  ];
711       
712                        var _itensMenu = "<dl style='margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
713                       
714                        for(var i in _itens)
715                        {
716                                _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;';
717                                if ( i != _itens.length - 1 )
718                                        _itensMenu += 'border-bottom:1px solid #dedede;';
719                                _itensMenu += '">';
720
721                                _itensMenu += "<div ";
722                                if( _itens[i][3] )
723                                        _itensMenu += "style='background: url(" + eval(_itens[i][3]) + ") no-repeat center right'";
724                                _itensMenu += "onclick="+_itens[i][1] +"><img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</div></dt>";
725                        }
726
727                        _itensMenu += "</dl>";
728       
729                        var _subMenu_div = document.createElement("div");
730                                _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt');
731                                _subMenu_div.style.margin = '-10px 5px 0px 0px';
732                                _subMenu_div.style.background = '#cecece';
733                                _subMenu_div.style.border = '1px dashed #000';
734                                _subMenu_div.style.float = 'left';
735                                _subMenu_div.style.position = 'absolute';
736                                _subMenu_div.style.left = '55px';
737                                _subMenu_div.style.width = ( is_ie ) ? '160px': '140px';;
738                                _subMenu_div.style.zindex = '99999';
739                                _subMenu_div.innerHTML = _itensMenu;
740       
741                        var elementParent = document.getElementById('fast_menu_jabberit');
742                        elementParent.appendChild(_subMenu_div);
743                }
744        }
745       
746        function subMenuChangeStatusItens()
747        {
748                if( arguments.length > 0 )
749                {
750                        var status      = arguments[0];
751                        var element     = arguments[1];
752                        var msg         = "";
753
754                        if( itensSubMenu.length > 0 )
755                        {
756                                var string = "";
757                                for( var i = 0; i < itensSubMenu.length ; i++ )
758                                {
759                                        if( itensSubMenu[i] != undefined )
760                                        {
761                                                string = itensSubMenu[i].substring(1);
762                                                string = string.substring(0, string.indexOf("]")).toString();
763
764                                                if( string != "" )
765                                                {
766                                                        if( status == i )
767                                                        {
768                                                                if ( ! ( string.indexOf( ',' ) < 0 ) )
769                                                                {
770                                                                        var phases = string.split(',');
771                                                                        var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
772                                                                        for ( var m = 0; m < phases.length; m++ )
773                                                                        {
774                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;border-bottom:1px solid #dedede;'>";
775                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+phases[m]+"\")'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + phases[m] + "</div></dt>";     
776                                                                        }
777                                                                        _itensMenu += "</dl>";
778                                                                }
779                                                                else
780                                                                {
781                                                                        var _itensMenu  = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
782                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>";                                                             
783                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+string+"\");'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + string + "</div></dt>";
784                                                                                _itensMenu += "</dl>";
785                                                                }
786                                                        }
787
788                                                        for( var j = 0 ; j < 6 ; j++ )
789                                                        {
790                                                                if( document.getElementById('ItemSubMenuJabberd_' + j) != null )
791                                                                {
792                                                                        var ElementItem = document.getElementById('ItemSubMenuJabberd_' + j);
793                                                                                ElementItem.parentNode.removeChild(ElementItem);
794                                                                }
795                                                        }
796                                                }
797                                        }
798                                }
799                               
800                                if( _itensMenu )
801                                {
802                                        var _subMenuItem_div = document.createElement("div");
803                                        _subMenuItem_div.setAttribute('id','ItemSubMenuJabberd_' + status);
804                                        _subMenuItem_div.style.margin = ( is_ie ) ? '-3px 5px 0px 0px' : '-20px 5px 0px 0px';
805                                        _subMenuItem_div.style.background = '#cecece';
806                                        _subMenuItem_div.style.border = '1px dashed #000';
807                                        _subMenuItem_div.style.float = 'left';
808                                        _subMenuItem_div.style.position = 'absolute';
809                                        _subMenuItem_div.style.left = ( is_ie ) ? '157px' : '140px';
810                                        _subMenuItem_div.style.width = ( is_ie ) ? '180px': '160px';
811                                        _subMenuItem_div.style.zindex = '99999';
812                                        _subMenuItem_div.innerHTML = _itensMenu;
813                                       
814                                        element.appendChild( _subMenuItem_div );
815                                }else
816                                        changeStatusJava(status,"");
817                        }
818                }
819        }
820
821        function Load()
822        {
823                addIcon();
824                getPreferences();
825               
826                // AutoStatus Away             
827                autoStatus();
828                configEvents(document, 'onmousemove', autoStatus);
829                configEvents(document, 'onkeypress', autoStatus);
830        }
831
832        Load.prototype.adIcon                   = addIcon;
833        Load.prototype.autoStatusIM             = autoStatus;
834        Load.prototype.chgStatusJava    = changeStatusJava;
835        Load.prototype.closeW                   = closeWindow;
836        Load.prototype.cLabel                   = changeLabel;
837        Load.prototype.getElement               = getElementStatus;
838        Load.prototype.keyPress                 = keyPressSearch;
839        Load.prototype.openWinParExt    = openWindowParticipantsExternal;
840        Load.prototype.search                   = searchUser;
841        Load.prototype.setItensStatus   = setItensStatusMenu;
842        Load.prototype.setPrefe                 = setPreferences;
843        Load.prototype.show                             = showDiv;
844        Load.prototype.showW                    = showWindow;
845        Load.prototype.subMnChStIt              = subMenuChangeStatusItens;
846       
847        window.loadscript = new Load;
848
849})();
850
851// Functions OnMouseOver e OnMouseOut
852
853function elementOnMouseOut()
854{
855        if( arguments.length > 0 )
856        {
857                var _element = arguments[0];
858                        _element.style.backgroundColor = '';
859                        _element.style.border = '';
860                        if( !arguments[1] )
861                                _element.style.borderBottom = '1px solid #dedede';
862        }
863}
864
865function elementOnMouseOver()
866{
867        if( arguments.length > 0 )
868        {
869                var _element = arguments[0];
870                        _element.style.backgroundColor = 'white';
871                        _element.style.border = '1px solid black';
872        }
873}
874
Note: See TracBrowser for help on using the repository browser.