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

Revision 1569, 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 *
RevLine 
[382]1(function()
2{
[697]3        var _autoStatusTime = 60000; // 1 minuto
4        var _autoStatus;
[1530]5        var _conn               = new JITConnector(path_jabberit);
6        var Xtools              = new JITXtools(path_jabberit);
[751]7        var _showhidden = new ShowHidden(300);
[1530]8        var _win_contacts = null;
[382]9        var myWindow      = '';
10        var flagMouseOver = '';
[417]11        var flagOpenIM    = '';
[622]12        var flagOpenPopup = '';
[697]13        var flagAwayIM    = '';
[751]14        var itensSubMenu  = [];
[382]15   
[417]16        // Sniffer Browser
[1530]17        var agt = navigator.userAgent.toLowerCase();
[382]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');
[1530]40                        _jabberit_content.setAttribute('id', 'jabberit_messenger_content');
41                        _jabberit_content = document.body.appendChild(_jabberit_content);
[382]42        }
43
[1530]44        var _ldap = new JITLdap( _conn, Xtools, is_ie );
[382]45
[697]46        function addContacts()
47        {
[1530]48                _ldap.load(myWindow);
[697]49        }
50
[382]51        function addIcon()
52        {
[622]53               
54                var StatusBar = document.getElementById('divStatusBar');
55
[439]56                /**
[622]57                 * @quando estiver habilitada a opção fora de escritório nos filtros.
[439]58                 */
59               
[622]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                }
[439]67               
[622]68                if( StatusBar )
[382]69                {
70                        StatusBar.style.paddingLeft = '33px';
[439]71                       
[622]72                        var _div = document.createElement('div');
73                        _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling));
74                        StatusBar.parentNode.insertBefore(_div,StatusBar);
75                       
[439]76                        var divJabber = document.createElement('div');
77                                divJabber.setAttribute('id', 'JabberMessenger');
78                       
[382]79                        var _status = top.document.createElement('div');
[439]80                                _status.setAttribute('id', 'jabberit_login');
[382]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
[439]92                        divJabber.insertBefore(_status,divJabber.firstChild);
[382]93
94                        var _menu;
[697]95                                _menu = top.document.createElement('div');
[382]96                                _menu.setAttribute('id','fast_menu_jabberit');
[1530]97                                _menu.className = "x-menu";
[382]98                                _menu.style.zIndex = '99999';
[697]99                                _menu.onmouseout = function(){ _showhidden.hiddenObject(false); };
100                                _menu.onmouseover = function(){ _showhidden.hiddenObject(true); };
[439]101                               
102                        divJabber.insertBefore(_menu, divJabber.firstChild);
[382]103
104                        var _menu_div = top.document.createElement('div');
[622]105                                _menu_div.setAttribute('id','status_Jabber_Expresso');
[382]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';
[1569]116                                _menu_div.style.zindex = '999999';
[382]117                       
[622]118                        statusJabberExpresso = _menu_div;
119                       
[439]120                        divJabber.insertBefore(_menu_div, divJabber.firstChild);
121                        StatusBar.insertBefore(divJabber, StatusBar.firstChild);                       
[382]122                       
[1530]123                        configEvents(_menu_div,'onclick', windowShow);
[382]124
125                        configEvents(
126                                _status,
127                                'onclick',
128                                function()
129                                {
130                                        var _options = [
[1530]131                                                ['Add Contact', addContacts],
132                                                ['Help', helpJabberit],
[697]133                                                ['Preferences', preferences],
134                                                ['Change Status', subMenuChangeStatus]
[382]135                                        ];
136
[1530]137                                        var _style_text = 'cursor: pointer;' +
138                                                                          'padding:2px 2px 2px 15px;' +
139                                                                          'background: no-repeat url(' + jabberit_group_close.src + ');';                                       
[382]140
[1530]141                                        var _xml = Xtools.xml('menu');
[382]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
[1530]163                                        _menu.innerHTML = Xtools.parse(_xml, 'options.xsl');
[382]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]);
[1530]171                                                configEvents( _item.childNodes[i], 'onclick', _options[i][1] );
[382]172                                        }
[697]173                                });
174                }
175        }
[622]176
[1530]177        function addUser()
178        {
179                _ldap.addUser();
180        }
181       
[697]182        function autoStatus()
183        {
184                if ( _autoStatus )
185                        clearTimeout(_autoStatus);
[622]186
[697]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                }
[622]199
[697]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));
[382]206        }
207
[697]208        function autoStatusHandler()
[382]209        {
[697]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                }
[382]222        }
223
[551]224        function changeLabel()
225        {
226                if( arguments.length > 0 )
227                {
228                        var element = arguments[0].parentNode.parentNode.firstChild;
229
230                        if(arguments[0].checked)
[560]231                                element.innerHTML = "<span style='color:red;'>Digite o Email .: </span>";
[551]232                        else
[560]233                                element.innerHTML = "Nome do Contato .: ";
[551]234                }
235        }
236
[697]237        function changeStatusJava()
238        {
239                if(arguments.length > 0 )
240                {
241                        try
242                        {
[751]243                                var status      = arguments[0];
244                                var msg         = ( arguments[1] ) ? arguments[1] : "";
245                       
[697]246                                // If Layer;
247                                if( elementIframe = document.getElementById('iframe_applet_jabberit') )
248                                {
249                                        if( !is_ie )
[751]250                                                elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg);
[697]251                                        else
[751]252                                                elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg);
[697]253                                }
254                                else // If Pop-Up
255                                {
[751]256                                        myWindow.document.applets[0].changeStatusfromExpresso(status, msg);
[697]257                                }
[751]258                               
[697]259                        }
260                        catch(e)
261                        {
262                                if( confirm('Deseja conectar o IM ?') )
[1530]263                                        windowShow();
[697]264                        }
265                }               
266        }
267
[382]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
[622]287        function getElementStatus()
[382]288        {
[622]289                return document.getElementById('status_Jabber_Expresso');
290        }
291
292        function getPreferences()
293        {
294                if( flagOpenIM == '' )
[382]295                {
[622]296                        _conn.go("$this.db_im.getPreferences",
297                                                function(data)
298                                                {
299                                                        var autoConnect = '';
300                                                        flagOpenIM = data;
[697]301
[622]302                                                        if( data.indexOf(';') != -1)
303                                                        {
304                                                                var temp = data.split(';');
305                                                                autoConnect = flagOpenIM = temp[0];
[697]306                                                               
307                                                                // Open as Pop-Up
[622]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                                                                }
[697]315                                                               
316                                                                // Away
317                                                                flagAwayIM = 'flagAwayIM:5';
318                                                               
319                                                                if( temp[2] )
320                                                                {
321                                                                        flagAwayIM = temp[2];
322                                                                }
[622]323                                                        }
324                                                        else
325                                                        {
326                                                                autoConnect = flagOpenIM;
327                                                        }
[697]328                                                       
[622]329                                                        if( autoConnect == 'openWindowJabberit:true' )
330                                                        {
[1530]331                                                                setTimeout('loadscript.windowHidden();', 2500);
[622]332                                                        }
333                                                });
[382]334                }
[622]335
[382]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        {
[622]357                var widPopup = '220';
358
359                if( is_ie )
360                        widPopup = '250';
361
[417]362                try{
[624]363
[622]364                        if(!myWindow )
[417]365                        {       
[624]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();
[622]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');
[417]369                                myWindow.blur();
370                                configEvents(myWindow,'onbeforeunload', closeWindow );
[622]371                        }
372                        else
373                        {
374                                for( var i = 15 ; i > 0 ; i-- )
375                                {
376                                        myWindow.moveBy(i,0); myWindow.moveBy(-i,0);
377                                }
[417]378                                myWindow.focus();
[622]379                        }
[417]380                }
381                catch(e)
382                {
383                        delete myWindow;
[622]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');
[417]385                        myWindow.blur();
[1530]386                        configEvents( myWindow, 'onbeforeunload', closeWindow );
[417]387                }
[382]388        }
389
390        function openWindow()
391        {
[1530]392                if( document.getElementById(_win_contacts.id_window + "__content") == null )
[417]393                {
[1530]394                        var contacts = function()
[622]395                        {
[1530]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});
[622]399                        }
[1530]400               
401                        winBuild( _win_contacts );
402                        setTimeout( function(){ contacts(); }, 250);
[551]403                }
[417]404        }
405
406        function preferences()
407        {
[1530]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                                                                };
[417]421
[1530]422                var _preferences = function()
423                {
424                       
425                        var _params = {
426                                                   'path'  : path_jabberit,
[560]427                                                   'lang1' : jabberitGetLang('Your Preferences'),
[622]428                                                   'lang2' : jabberitGetLang('Connection'),     
[560]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'),
[622]434                                                   'lang8' : jabberitGetLang('Window'),
[697]435                                                   'lang9' : jabberitGetLang('Open as Pop-Up Window'),
[1530]436                                                   'lang10' : jabberitGetLang('Away'),
[697]437                                                   'lang11' : jabberitGetLang('Set status to away after'),
438                                                   'lang12' : jabberitGetLang('minutes'),                                                 
[560]439                                                   'langYes': jabberitGetLang('Yes'),
[697]440                                                   'langNo' : jabberitGetLang('No')                                                                                       
[1530]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);
[417]453
[1530]454                        // Element openWindowJabberit
455                        var value1 = flagOpenIM.split(':');
456                        var element1 = document.getElementById(value1[0]);
457                        var valueSelect1 = value1[1];
[560]458                       
[1530]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];
[697]468                               
[1530]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);
[622]480               
[1530]481                setTimeout(function(){ _preferences();}, 250);
[417]482        }
483
[382]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        }
[751]493
494        function setItensStatusMenu()
495        {
[1435]496                var applet = "";
497               
498                try
[751]499                {
[1435]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                        }
[751]512                       
[1435]513                        for( i = 1; i < 6; i++ )
514                                itensSubMenu[i] = applet.getStatusMessages(i);
515                       
516                }catch(e){}
[751]517        }
[417]518       
519        function setPreferences()
520        {
[560]521                // Element openWindowJabberit
522                var elementOpenW = document.getElementById('openWindowJabberit');
523                var value = '';
[622]524                var flagReload = false;
[417]525               
[560]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;
[622]530                                flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value;
[560]531                        }
532
[622]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 )
[560]538                        {
[622]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                        }
[697]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
[417]561                _conn.go('$this.db_im.setPreferences',
562                                 function(data)
563                                 {
564                                        if(data == 'true')
565                                        {
[622]566                                                if( flagReload )
567                                                {
568                                                        window.location.reload();
[624]569                                                        myWindow.close();                                                       
[622]570                                                }
[417]571                                        }
[622]572                                        else{ alert(jabberitGetLang('Error saving your preferences!')); }
[1530]573
574                                        winBuild('jabberit_preferences', 'remove');
[417]575                                 },
[622]576                                 value);
[417]577        }
578       
[1530]579        function windowHidden()
[382]580        {
[1530]581                if( _win_contacts == null )
[382]582                {
[1530]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();
[622]603                }
604                else
[1530]605                        winBuild( _win_contacts.id_window , "display" );
606               
607        }
[622]608       
[1530]609        function windowShow()
610        {
611                if( _win_contacts == null )
612                {
613                        if( !is_ie )
614                                var sizeW = { w : 234, h : 432 };
[382]615                        else
[1530]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();                       
[382]633                }
[1530]634                else
635                        winBuild( _win_contacts.id_window , "display" );
[382]636        }
[1530]637       
638        function windowContacts()
639        {
640                if( flagOpenPopup === 'openWindowJabberitPopUp:true' )
641                        openPopup();                                   
642                else
643                        openWindow();
644        }
[382]645
[697]646        function subMenuChangeStatus()
647        {
648                if(document.getElementById('subMenu_Change_Status_JabberIt') == null )
649                {
650                        var _itens  = [
[1530]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'],
[751]656                                                                ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src']
[697]657                                                  ];
658       
[1530]659                        var _itensMenu = "<dl style='margin:2px 2px !important; font-size:8pt !important;'>";
[697]660                       
661                        for(var i in _itens)
662                        {
[1530]663                                _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;">';
[751]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>";
[697]668                        }
669
670                        _itensMenu += "</dl>";
671       
672                        var _subMenu_div = document.createElement("div");
673                                _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt');
[1530]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;
[697]679       
680                        var elementParent = document.getElementById('fast_menu_jabberit');
681                        elementParent.appendChild(_subMenu_div);
[1435]682                       
683                        setItensStatusMenu();
[697]684                }
685        }
[751]686       
687        function subMenuChangeStatusItens()
688        {
689                if( arguments.length > 0 )
690                {
691                        var status      = arguments[0];
692                        var element     = arguments[1];
693                        var msg         = "";
[697]694
[751]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(',');
[1530]712                                                                        var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;'>";
[751]713                                                                        for ( var m = 0; m < phases.length; m++ )
714                                                                        {
[1530]715                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>";
[751]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                                                                {
[1530]722                                                                        var _itensMenu  = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;'>";
[751]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);
[1530]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]751                                       
752                                        element.appendChild( _subMenuItem_div );
[1530]753                                       
[751]754                                }else
755                                        changeStatusJava(status,"");
756                        }
757                }
758        }
759
[382]760        function Load()
761        {
762                addIcon();
[417]763                getPreferences();
[697]764               
765                // AutoStatus Away             
766                autoStatus();
767                configEvents(document, 'onmousemove', autoStatus);
768                configEvents(document, 'onkeypress', autoStatus);
[382]769        }
770
[751]771        Load.prototype.adIcon                   = addIcon;
[1530]772        Load.prototype.addUser                  = addUser;
[751]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;
[1530]782        Load.prototype.windowHidden             = windowHidden;
[697]783       
[1530]784        configEvents(window, 'onload', function(){ window.loadscript = new Load; });
[382]785
[697]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] )
[1530]798                                _element.className = '';
[697]799        }
800}
801
802function elementOnMouseOver()
803{
804        if( arguments.length > 0 )
805        {
806                var _element = arguments[0];
[1530]807                        _element.className = 'x-menuOnMouseOver';
[697]808        }
[1530]809}
Note: See TracBrowser for help on using the repository browser.