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

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