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

Revision 1530, 23.4 KB checked in by alexandrecorreia, 15 years ago (diff)

Ticket #370 - Melhoria do layout das janelas, para criação de preferencia(on/offline).

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