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

Revision 868, 26.0 KB checked in by alexandrecorreia, 15 years ago (diff)

Ticket #513 - Problemas no cadastro de participantes externos.O cadastro de participantes externos, sendo habilitado e não informado uma organização, aparece item em branco para o usuário.

  • 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, is_ie );
45
46        function addContacts()
47        {
48                _ldap.add(myWindow);
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                                // If Layer;
249                                if( elementIframe = document.getElementById('iframe_applet_jabberit') )
250                                {
251                                        if( !is_ie )
252                                                elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg);
253                                        else
254                                                elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg);
255                                }
256                                else // If Pop-Up
257                                {
258                                        myWindow.document.applets[0].changeStatusfromExpresso(status, msg);
259                                }
260                               
261                        }
262                        catch(e)
263                        {
264                                if( confirm('Deseja conectar o IM ?') )
265                                        showWindow();
266                        }
267                }               
268        }
269
270        function configEvents(pObj, pEvent, pHandler)
271        {
272                if ( typeof pObj == 'object' )
273                {
274                        if ( pEvent.substring(0, 2) == 'on' )
275                                pEvent = pEvent.substring(2, pEvent.length);
276
277                        if ( pObj.addEventListener )
278                                pObj.addEventListener(pEvent, pHandler, false);
279                        else if ( pObj.attachEvent )
280                                pObj.attachEvent('on' + pEvent, pHandler);
281                }
282        }
283
284        function closeWindow()
285        {
286                myWindow = '';
287        }
288
289        function getElementStatus()
290        {
291                return document.getElementById('status_Jabber_Expresso');
292        }
293
294        function getPreferences()
295        {
296                if( flagOpenIM == '' )
297                {
298                        _conn.go("$this.db_im.getPreferences",
299                                                function(data)
300                                                {
301                                                        var autoConnect = '';
302                                                        flagOpenIM = data;
303
304                                                        if( data.indexOf(';') != -1)
305                                                        {
306                                                                var temp = data.split(';');
307                                                                autoConnect = flagOpenIM = temp[0];
308                                                               
309                                                                // Open as Pop-Up
310                                                                flagOpenPopup = 'openWindowJabberitPopUp:false';
311                                                               
312                                                                if( temp[1] )
313                                                                {
314                                                                        if( temp[1] == 'openWindowJabberitPopUp:true' || temp[1] == 'openWindowJabberitPopUp:false')
315                                                                                flagOpenPopup = temp[1];
316                                                                }
317                                                               
318                                                                // Away
319                                                                flagAwayIM = 'flagAwayIM:5';
320                                                               
321                                                                if( temp[2] )
322                                                                {
323                                                                        flagAwayIM = temp[2];
324                                                                }
325                                                        }
326                                                        else
327                                                        {
328                                                                autoConnect = flagOpenIM;
329                                                        }
330                                                       
331                                                        if( autoConnect == 'openWindowJabberit:true' )
332                                                        {
333                                                                setTimeout('loadscript.showW();', 2500);
334                                                        }
335                                                });
336                }
337
338        }
339
340        function helpJabberit()
341        {
342                var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes');
343        }
344
345        function keyPressSearch()
346        {
347                var ev = arguments[0];
348                var element = arguments[1];
349
350                if ( ev.keyCode == 13 )
351                        if( element.value.length >= 4 )
352                                _ldap.search( element.value ); 
353                        else
354                                alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
355        }
356
357        function openPopup()
358        {
359                var widPopup = '220';
360
361                if( is_ie )
362                        widPopup = '250';
363
364                try{
365
366                        if(!myWindow )
367                        {       
368                                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');
369                                myWindow.close();
370                                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');
371                                myWindow.blur();
372                                configEvents(myWindow,'onbeforeunload', closeWindow );
373                        }
374                        else
375                        {
376                                for( var i = 15 ; i > 0 ; i-- )
377                                {
378                                        myWindow.moveBy(i,0); myWindow.moveBy(-i,0);
379                                }
380                                myWindow.focus();
381                        }
382                }
383                catch(e)
384                {
385                        delete myWindow;
386                        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');
387                        myWindow.blur();
388                        configEvents(myWindow,'onbeforeunload', closeWindow );
389                }
390        }
391
392        function openWindow()
393        {
394                var _win_contacts = _window.load('jabberit_contacts');
395
396                var flagOpenAux = '';
397               
398                if( flagOpenIM.indexOf(';') != -1 )
399                {
400                        var aux = flagOpenIM.split(';');
401                        flagOpenAux = aux[0];
402                }
403                else
404                        flagOpenAux = flagOpenIM;
405
406                if( flagOpenAux == 'openWindowJabberit:false' )
407                {
408                        if( !is_ie )
409                                _win_contacts.size(220,400);
410                        else   
411                                _win_contacts.size(250,400);
412                }                                       
413                else
414                {
415                        if( !is_ie )
416                        {
417                                _win_contacts.size(1,1);
418                                _win_contacts.wm.style.visibility = 'hidden';
419                        }
420                        else
421                        {
422                                _win_contacts.size(0,0);
423                        }
424                }
425
426                _win_contacts.bc.style.display = "none";
427                _win_contacts.bx.style.display = "none";
428
429                if( _win_contacts.bz.removeEventListener )
430                        _win_contacts.bz.removeEventListener('click',_win_contacts.button, false);
431                else
432                        _win_contacts.bz.detachEvent('onclick',_win_contacts.button);
433
434                configEvents(
435                        _win_contacts.bz,
436                        "onclick",
437                        function()
438                        {
439                                _win_contacts.size(1,1);
440                                _win_contacts.wm.style.visibility = 'hidden';
441                                _win_contacts.position(50,50);
442                                _win_contacts.title('');
443                        }
444                );
445
446                var _params = {'path' : path_jabberit};
447                _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params));
448
449                if( flagOpenAux == 'openWindowJabberit:false' )
450                {
451                        if( !is_ie )
452                        {
453                                _win_contacts.wm.style.visibility = "visible";
454                                _win_contacts.size(220,400);
455                                _win_contacts.title('.:: Expresso - JMessenger ::.');
456                        }
457                        else
458                        {
459                                _win_contacts.size(250,400);
460                                _win_contacts.title('.:: Expresso - JMessenger ::.');
461                        }
462                        _win_contacts.position(50,50);
463                }
464                else
465                {
466                        if( !is_ie )
467                                _win_contacts.wm.style.visibility = "hidden";
468                }
469        }
470
471        function openWindowParticipantsExternal()
472        {
473                if( arguments.length > 0)
474                {
475                        var element = arguments[0];
476
477                        if( externalParticipantsJabberit != "" )
478                        {                       
479                                var orgPartExternal = externalParticipantsJabberit.split(",");
480                               
481                                var _splash = top.document.createElement('span');
482                                        _splash.setAttribute('id','fast_splash_jabberit');
483                                        _splash.style.backgroundColor = 'dedede';
484                                        _splash.style.position = 'absolute';
485                                        _splash.style.display = 'block';
486                                        _splash.style.width = '200px';
487                                        _splash.style.height = 'auto';
488                                        _splash.style.margin = ( !is_ie ) ? '0px 5px 0px 130px' : '20px 0px 0px 0px';
489                                        _splash.style.zIndex = '99999';
490                                        _splash.style.border = '2px outset #000';
491                                        _splash.onmouseout = function(){ _showhidden.hiddenObject(false); };
492                                        _splash.onmouseover = function(){ _showhidden.hiddenObject(true); };
493                               
494                                        for(var i = 0; i < orgPartExternal.length; i++)
495                                                _splash.innerHTML += '<div style="margin:5px;border-bottom:1px dashed #000;cursor:default !important;">' + (i + 1) + " - " + orgPartExternal[i] + '</div>';     
496                                       
497                                _showhidden.action('onmouseover', 'onmouseout', _splash);
498                                element.appendChild(_splash);
499                        }
500                }
501        }
502
503        function preferences()
504        {
505                if( !(_window.get('jabberit_preferences')) )
506                {
507                        var _win_preferences = _window.load('jabberit_preferences');
508                                _win_preferences.size(400,310);                         
509                                _win_preferences.position(150,100);
510                                _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
511                                _win_preferences.bc.style.display = "none";
512                                _win_preferences.bx.style.display = "none";
513                                _win_preferences.wc.style.padding = "5px";                                                             
514
515                        if( _win_preferences.bz.removeEventListener )
516                                _win_preferences.bz.removeEventListener('click',_win_preferences.button, false);
517                        else
518                                _win_preferences.bz.detachEvent('onclick',_win_preferences.button);
519                               
520                        configEvents(
521                                _win_preferences.bz,
522                                "onclick",
523                                function()
524                                {
525                                        _win_preferences.size(1,1);
526                                        _win_preferences.wm.style.visibility = 'hidden';
527                                        _win_preferences.position(50,50);
528                                        _win_preferences.title('');
529                                });
530
531                        var _params = {'path'  : path_jabberit,
532                                                   'lang1' : jabberitGetLang('Your Preferences'),
533                                                   'lang2' : jabberitGetLang('Connection'),     
534                                                   'lang3' : jabberitGetLang('Enable Auto Login IM'),
535                                                   'lang4' : jabberitGetLang('Users OffLine'),
536                                                   'lang5' : jabberitGetLang('Show friends Offline'),
537                                                   'lang6' : jabberitGetLang('Save'),
538                                                   'lang7' : jabberitGetLang('Cancel'),
539                                                   'lang8' : jabberitGetLang('Window'),
540                                                   'lang9' : jabberitGetLang('Open as Pop-Up Window'),
541                                                   'lang10' : jabberitGetLang('Away Presence'),
542                                                   'lang11' : jabberitGetLang('Set status to away after'),
543                                                   'lang12' : jabberitGetLang('minutes'),                                                 
544                                                   'langYes': jabberitGetLang('Yes'),
545                                                   'langNo' : jabberitGetLang('No')                                                                                       
546                                                  };
547                        _win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params));
548                        _win_preferences.wc.lastChild.lastChild.onclick = _win_preferences.close;
549                }
550                else
551                {
552                        var _win_preferences = _window.get('jabberit_preferences');
553                        _win_preferences.wm.style.visibility = "visible";
554                        _win_preferences.position(150,100);                                                     
555                        _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
556                        _win_preferences.size(320,250);
557                }
558               
559                // Element openWindowJabberit
560                var value1 = flagOpenIM.split(':');
561                var element1 = document.getElementById(value1[0]);
562                var valueSelect1 = value1[1];
563               
564                for(var i = 0; i < element1.options.length; i++)
565                        if( element1.options[i].value == valueSelect1 )
566                                element1.options[i].selected = true;
567
568               
569                // Element openWindowJabberitPopUp
570                var value2 = flagOpenPopup.split(':');
571                var element2 = document.getElementById(value2[0]);
572                var valueSelect2 = value2[1];
573                       
574                for(var i = 0; i < element2.options.length; i++)
575                        if( element2.options[i].value == valueSelect2 )
576                                element2.options[i].selected = true;
577                               
578                // Element flagAwayIM
579                var value3 = flagAwayIM.split(':');
580                var element3 = document.getElementById(value3[0]);
581                element3.value = value3[1];
582               
583        }
584
585        function searchUser()
586        {
587                var element = arguments[0].previousSibling;
588               
589                if( element.value.length >= 4 )
590                        _ldap.search( element.value ); 
591                else
592                        alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
593        }
594
595        function setItensStatusMenu()
596        {
597                if( arguments.length > 0 )
598                {
599                        var key = parseInt(arguments[0].substring(0, arguments[0].indexOf('-')));
600                        var value = arguments[0].substring(arguments[0].indexOf('-') + 1 );
601                       
602                        itensSubMenu[key] = value.toString();   
603                }
604        }
605       
606        function setPreferences()
607        {
608                // Element openWindowJabberit
609                var elementOpenW = document.getElementById('openWindowJabberit');
610                var value = '';
611                var flagReload = false;
612               
613                for(var i = 0 ; i < elementOpenW.options.length; i++)
614                        if( elementOpenW.options[i].selected == true)
615                        {
616                                value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value;
617                                flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value;
618                        }
619
620                // Element openWindowJabberitPopUp
621                var elementOpenPop = document.getElementById('openWindowJabberitPopUp');       
622
623                for(var i = 0; i < elementOpenPop.options.length; i++ )
624                        if( elementOpenPop.options[i].selected ==  true )
625                        {
626                                value += '&preferences2=openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
627                               
628                                if( flagOpenPopup != 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value)
629                                        flagReload = true;
630                                       
631                                flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
632                        }
633               
634                // Element flagAwayIM
635                var elementFlagIM = document.getElementById('flagAwayIM');
636               
637                if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 )
638                {
639                        flagAwayIM = 'flagAwayIM:' + elementFlagIM.value;
640                        value += '&preferences3=flagAwayIM:' + elementFlagIM.value;
641                }
642                else
643                {
644                        alert(jabberitGetLang('Enter a value greater than or equal to 1!'));
645                        return false;
646                }
647
648                _conn.go('$this.db_im.setPreferences',
649                                 function(data)
650                                 {
651                                        if(data == 'true')
652                                        {
653                                                if( flagReload )
654                                                {
655                                                        window.location.reload();
656                                                        myWindow.close();                                                       
657                                                }
658                                        }
659                                        else{ alert(jabberitGetLang('Error saving your preferences!')); }
660                                                                               
661                                        var _win_preferences = _window.get('jabberit_preferences');
662                                                _win_preferences.close();
663                                 },
664                                 value);
665        }
666       
667        function showDiv()
668        {
669                var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ;
670                if( _element != null )
671                        _element.style.visibility = 'visible';
672        }
673
674        function showWindow()
675        {
676                var _win_contacts = _window.get('jabberit_contacts');
677               
678                if( flagOpenPopup === 'openWindowJabberitPopUp:true' )
679                {
680                        openPopup();                                   
681                }
682                else
683                {
684                        if ( _win_contacts )
685                        {       
686                                _win_contacts.wm.style.visibility = "visible";
687                                _win_contacts.title('.:: Expresso - JMessenger ::.');
688       
689                                if( !is_ie )
690                                        _win_contacts.size(220,400);
691                                else
692                                        _win_contacts.size(250,400);
693       
694                                _win_contacts.position(60,60);
695                        }
696                        else
697                                openWindow();
698                }
699        }
700
701        function subMenuChangeStatus()
702        {
703                if(document.getElementById('subMenu_Change_Status_JabberIt') == null )
704                {
705                        var _itens  = [
706                                                                ['Online', 'loadscript.subMnChStIt("2",this);', 'available_jabberit.src','jabberit_group_close_black.src'],
707                                                                ['Free For Chat', 'loadscript.subMnChStIt("1",this);', 'chat_jabberit.src','jabberit_group_close_black.src'],
708                                                                ['Xa', 'loadscript.subMnChStIt("3",this);','xa_jabberit.src','jabberit_group_close_black.src'],
709                                                                ['Dnd', 'loadscript.subMnChStIt("4",this);','dnd_jabberit.src','jabberit_group_close_black.src'],
710                                                                ['Away', 'loadscript.subMnChStIt("5",this);','away_jabberit.src','jabberit_group_close_black.src'],
711                                                                ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src']
712                                                  ];
713       
714                        var _itensMenu = "<dl style='margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
715                       
716                        for(var i in _itens)
717                        {
718                                _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;';
719                                if ( i != _itens.length - 1 )
720                                        _itensMenu += 'border-bottom:1px solid #dedede;';
721                                _itensMenu += '">';
722
723                                _itensMenu += "<div ";
724                                if( _itens[i][3] )
725                                        _itensMenu += "style='background: url(" + eval(_itens[i][3]) + ") no-repeat center right'";
726                                _itensMenu += "onclick="+_itens[i][1] +"><img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</div></dt>";
727                        }
728
729                        _itensMenu += "</dl>";
730       
731                        var _subMenu_div = document.createElement("div");
732                                _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt');
733                                _subMenu_div.style.margin = '-10px 5px 0px 0px';
734                                _subMenu_div.style.background = '#cecece';
735                                _subMenu_div.style.border = '1px dashed #000';
736                                _subMenu_div.style.float = 'left';
737                                _subMenu_div.style.position = 'absolute';
738                                _subMenu_div.style.left = '55px';
739                                _subMenu_div.style.width = ( is_ie ) ? '160px': '140px';;
740                                _subMenu_div.style.zindex = '99999';
741                                _subMenu_div.innerHTML = _itensMenu;
742       
743                        var elementParent = document.getElementById('fast_menu_jabberit');
744                        elementParent.appendChild(_subMenu_div);
745                }
746        }
747       
748        function subMenuChangeStatusItens()
749        {
750                if( arguments.length > 0 )
751                {
752                        var status      = arguments[0];
753                        var element     = arguments[1];
754                        var msg         = "";
755
756                        if( itensSubMenu.length > 0 )
757                        {
758                                var string = "";
759                                for( var i = 0; i < itensSubMenu.length ; i++ )
760                                {
761                                        if( itensSubMenu[i] != undefined )
762                                        {
763                                                string = itensSubMenu[i].substring(1);
764                                                string = string.substring(0, string.indexOf("]")).toString();
765
766                                                if( string != "" )
767                                                {
768                                                        if( status == i )
769                                                        {
770                                                                if ( ! ( string.indexOf( ',' ) < 0 ) )
771                                                                {
772                                                                        var phases = string.split(',');
773                                                                        var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
774                                                                        for ( var m = 0; m < phases.length; m++ )
775                                                                        {
776                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;border-bottom:1px solid #dedede;'>";
777                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+phases[m]+"\")'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + phases[m] + "</div></dt>";     
778                                                                        }
779                                                                        _itensMenu += "</dl>";
780                                                                }
781                                                                else
782                                                                {
783                                                                        var _itensMenu  = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
784                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>";                                                             
785                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+string+"\");'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + string + "</div></dt>";
786                                                                                _itensMenu += "</dl>";
787                                                                }
788                                                        }
789
790                                                        for( var j = 0 ; j < 6 ; j++ )
791                                                        {
792                                                                if( document.getElementById('ItemSubMenuJabberd_' + j) != null )
793                                                                {
794                                                                        var ElementItem = document.getElementById('ItemSubMenuJabberd_' + j);
795                                                                                ElementItem.parentNode.removeChild(ElementItem);
796                                                                }
797                                                        }
798                                                }
799                                        }
800                                }
801                               
802                                if( _itensMenu )
803                                {
804                                        var _subMenuItem_div = document.createElement("div");
805                                        _subMenuItem_div.setAttribute('id','ItemSubMenuJabberd_' + status);
806                                        _subMenuItem_div.style.margin = ( is_ie ) ? '-3px 5px 0px 0px' : '-20px 5px 0px 0px';
807                                        _subMenuItem_div.style.background = '#cecece';
808                                        _subMenuItem_div.style.border = '1px dashed #000';
809                                        _subMenuItem_div.style.float = 'left';
810                                        _subMenuItem_div.style.position = 'absolute';
811                                        _subMenuItem_div.style.left = ( is_ie ) ? '157px' : '140px';
812                                        _subMenuItem_div.style.width = ( is_ie ) ? '180px': '160px';
813                                        _subMenuItem_div.style.zindex = '99999';
814                                        _subMenuItem_div.innerHTML = _itensMenu;
815                                       
816                                        element.appendChild( _subMenuItem_div );
817                                }else
818                                        changeStatusJava(status,"");
819                        }
820                }
821        }
822
823        function Load()
824        {
825                addIcon();
826                getPreferences();
827               
828                // AutoStatus Away             
829                autoStatus();
830                configEvents(document, 'onmousemove', autoStatus);
831                configEvents(document, 'onkeypress', autoStatus);
832        }
833
834        Load.prototype.adIcon                   = addIcon;
835        Load.prototype.autoStatusIM             = autoStatus;
836        Load.prototype.chgStatusJava    = changeStatusJava;
837        Load.prototype.closeW                   = closeWindow;
838        Load.prototype.cLabel                   = changeLabel;
839        Load.prototype.getElement               = getElementStatus;
840        Load.prototype.keyPress                 = keyPressSearch;
841        Load.prototype.openWinParExt    = openWindowParticipantsExternal;
842        Load.prototype.search                   = searchUser;
843        Load.prototype.setItensStatus   = setItensStatusMenu;
844        Load.prototype.setPrefe                 = setPreferences;
845        Load.prototype.show                             = showDiv;
846        Load.prototype.showW                    = showWindow;
847        Load.prototype.subMnChStIt              = subMenuChangeStatusItens;
848       
849        window.loadscript = new Load;
850
851})();
852
853// Functions OnMouseOver e OnMouseOut
854
855function elementOnMouseOut()
856{
857        if( arguments.length > 0 )
858        {
859                var _element = arguments[0];
860                        _element.style.backgroundColor = '';
861                        _element.style.border = '';
862                        if( !arguments[1] )
863                                _element.style.borderBottom = '1px solid #dedede';
864        }
865}
866
867function elementOnMouseOver()
868{
869        if( arguments.length > 0 )
870        {
871                var _element = arguments[0];
872                        _element.style.backgroundColor = 'white';
873                        _element.style.border = '1px solid black';
874        }
875}
876
Note: See TracBrowser for help on using the repository browser.