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

Revision 1801, 22.9 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #612 - Adequando as preferências do JMessenger para o padrao Expresso.

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