Changeset 2975


Ignore:
Timestamp:
06/28/10 12:13:37 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #1116 - Melhorar a visualizacao/avisos de novos contatos e pedidos de autorizacao no modulo.

Location:
trunk/jmessenger/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/jmessenger/js/jscode/loadIM.js

    r2969 r2975  
    5757                        var _element    = ( e.target ) ? e.target : e.srcElement; 
    5858                        var jid         = arguments[1]; 
    59                         var index       = arguments[2]; 
    6059                        var coord       = null; 
    6160 
     
    7978                        { 
    8079                                if( e.button > 1 ) 
    81                                         optionsItensContact( jid, index, coord ); 
     80                                        optionsItensContact( jid, coord ); 
    8281                                else 
    8382                                        TrophyIM.rosterClick(jid); 
     
    8685                        { 
    8786                                if( e.which > 1 ) 
    88                                         optionsItensContact( jid, index, coord ); 
     87                                        optionsItensContact( jid, coord ); 
    8988                                else 
    9089                                        if( e.target.id ) 
     
    281280                } 
    282281        } 
    283          
     282 
     283        function disabledNotificationNewUsers() 
     284        { 
     285                var _notification       = getElement('notification_new_users_jabber') ; 
     286                var _statusJabber       = getElement('status_jabber_expresso'); 
     287 
     288                _notification.style.display = 'none'; 
     289                 
     290                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
     291                 
     292                if( _timeOutNotification ) 
     293                        clearTimeout(_timeOutNotification ); 
     294                 
     295                TrophyIM.controll.notificationNewUsers = 0; 
     296        } 
     297         
     298        function enabledNotificationNewUsers() 
     299        { 
     300                var _notification       = getElement('notification_new_users_jabber') ; 
     301                var _statusJabber       = getElement('status_jabber_expresso'); 
     302         
     303                if( _notification && _statusJabber ) 
     304                {        
     305                        if ( _notification.style.display == 'none' ) 
     306                        { 
     307                                _notification.style.display = 'block'; 
     308                                 
     309                                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat"; 
     310                                 
     311                                if( _timeOutNotification ) 
     312                                        clearTimeout(_timeOutNotification ); 
     313 
     314                                _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 2000 ); 
     315                        } 
     316                        else 
     317                        { 
     318                                _notification.style.display = 'none'; 
     319                                 
     320                                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
     321                                 
     322                                if( _timeOutNotification ) 
     323                                        clearTimeout(_timeOutNotification ); 
     324 
     325                                _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 800 ); 
     326                        } 
     327                } 
     328        } 
     329 
    284330        function fastMenu() 
    285331        { 
     
    579625                { 
    580626                        var jid         = arguments[0]; 
    581                         var index       = arguments[1]; 
    582                         var coord       = arguments[2]; 
    583                         var element = getElement('itenContact_' + jid + '_' + index ); 
     627                        var coord       = arguments[1]; 
     628                        var element = getElement('itenContact_' + jid ); 
    584629                        var action      = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar";      
    585630                         
     
    588633 
    589634                        var _options = [ 
    590                                                 [ action , 'loadscript.setAutorization(\''+jid+'\',\''+index+'\')'], 
    591                                                 ['Remover' , 'loadscript.removeContact(\''+jid+'\',\''+index+'\')'], 
    592                                                 ['Renomear' , 'loadscript.renameContact(\''+jid+'\',\''+index+'\')'], 
    593                                                 ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\',\''+index+'\')'] 
     635                                                [ action , 'loadscript.setAutorization(\''+jid+'\')'], 
     636                                                ['Remover' , 'loadscript.removeContact(\''+jid+'\')'], 
     637                                                ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'], 
     638                                                ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')'] 
    594639                                                   ]; 
    595640 
     
    709754        } 
    710755         
    711         function removeContact(jid, index) 
    712         { 
    713                 setTimeout(function() 
    714                 { 
    715                         TrophyIM.removeContact(jid, index); 
    716                          
    717                 },300); 
     756        function removeContact( jid ) 
     757        { 
     758                TrophyIM.removeContact( jid ); 
    718759        } 
    719760         
     
    742783                { 
    743784                        var _jid        = arguments[0]; 
    744                         var _index      = arguments[1]; 
    745                          
    746                         TrophyIM.renameContact( _jid, _index ); 
     785                         
     786                        TrophyIM.renameContact( _jid ); 
    747787                } 
    748788        } 
     
    753793                { 
    754794                        var _jid        = arguments[0]; 
    755                         var _index      = arguments[1]; 
    756                          
    757                         TrophyIM.renameGroup( _jid , _index ); 
     795                         
     796                        TrophyIM.renameGroup( _jid ); 
    758797                } 
    759798        } 
     
    815854        } 
    816855         
    817         function setAutorization(jidTo, indexTo) 
    818         { 
    819         var divItenContact = null; 
    820          
    821         if( ( divItenContact = getElement('itenContact_' + jidTo + '_' + indexTo ))) 
     856        function setAutorization() 
     857        { 
     858                var divItenContact = null; 
     859                 
     860                if( arguments.length > 0 ) 
     861                { 
     862                        var jidTo = arguments[0]; 
     863                 
     864                        if( getElement('itenContact_' + jidTo) ) 
     865                                divItenContact = getElement('itenContact_' + jidTo ); 
     866                } 
     867                 
     868        if( divItenContact ) 
    822869        {        
    823870                var subscription = divItenContact.getAttribute('subscription'); 
    824                  
     871 
    825872                switch(subscription) 
    826873                { 
     
    845892                                        if( ( _add = confirm("Deseja adicionar o usuario!")) )           
    846893                                        { 
    847                                                 addUser.add( jidTo, indexTo ); 
     894                                                addUser.add( jidTo ); 
    848895                                        } 
    849896                                         
     
    863910                                         
    864911                                default : 
     912                                        alert( "SEM PARAMETRO DEFINIDO : " + subscription ); 
    865913                                         
    866                                         alert( "DEFAULT : " + subscription ); 
    867914                } 
    868         }        
     915        } 
     916         
     917        setTimeout(function() 
     918        { 
     919                        if( getElement('itenContactNotification_' + jidTo ) ) 
     920                                loadscript.removeElement( getElement('itenContactNotification_' + jidTo ) ); 
     921        },500); 
     922     
    869923        } 
    870924         
     
    11701224                                        var _user       = _users.createElement('user'); 
    11711225                                        var _jid        = _users.createElement('jid'); 
    1172                                         var _index      = _users.createElement('index'); 
     1226                                        var _status     = _users.createElement('status'); 
    11731227                                        _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) ); 
    1174                                         _index.appendChild( _users.createTextNode("0")); 
     1228                                        _status.appendChild( _users.createTextNode( _subscription ) ); 
    11751229                                        _user.appendChild( _jid ); 
    1176                                         _user.appendChild( _index ); 
     1230                                        _user.appendChild( _status ); 
    11771231                                        _users.documentElement.appendChild( _user ); 
    11781232                                } 
     
    12061260                _winBuild( winNotification ); 
    12071261        } 
    1208          
    1209         function teste_new() 
    1210         { 
    1211                 var _notification       = getElement('notification_new_users_jabber') ; 
    1212                 var _statusJabber       = getElement('status_jabber_expresso'); 
    1213          
    1214                 if( _notification && _statusJabber ) 
    1215                 {        
    1216                         if ( _notification.style.display == 'none' ) 
    1217                         { 
    1218                                 _notification.style.display = 'block'; 
    1219                                  
    1220                                 _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat"; 
    1221                                  
    1222                                 if( _timeOutNotification ) 
    1223                                         clearTimeout(_timeOutNotification ); 
    1224  
    1225                                 _timeOutNotification = setTimeout( function(){ teste_new(); }, 2000 ); 
    1226                         } 
    1227                         else 
    1228                         { 
    1229                                 _notification.style.display = 'none'; 
    1230                                  
    1231                                 _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
    1232                                  
    1233                                 if( _timeOutNotification ) 
    1234                                         clearTimeout(_timeOutNotification ); 
    1235  
    1236                                 _timeOutNotification = setTimeout( function(){ teste_new(); }, 800 ); 
    1237                         } 
    1238                 } 
    1239         } 
    1240          
    1241          
    1242         loadIM.prototype.teste_new = teste_new; 
    1243          
    1244          
     1262 
    12451263        function loadIM() 
    12461264        { 
     
    13201338        loadIM.prototype.clrAllContacts         = clrAllContacts; 
    13211339        loadIM.prototype.configEvents           = configEvents; 
     1340        loadIM.prototype.disabledNotificationNewUsers   = disabledNotificationNewUsers; 
     1341        loadIM.prototype.enabledNotificationNewUsers    = enabledNotificationNewUsers;   
    13221342        loadIM.prototype.getIsIE                        = getIsIE; 
    13231343        loadIM.prototype.getPhotoUser           = getPhotoUser; 
  • trunk/jmessenger/js/trophyim.js

    r2971 r2975  
    308308                TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    309309                TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
    310                 Strophe.log = TrophyIM.log; 
     310                //Strophe.log = TrophyIM.log; 
    311311                Strophe.info('Attempting Strophe attach.'); 
    312312                TrophyIM.connection.attach(xids[0], xids[1], xids[2], TrophyIM.onConnect); 
     
    397397        TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    398398        TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
    399         Strophe.log                                     = TrophyIM.log; 
     399        //Strophe.log                                   = TrophyIM.log; 
    400400         
    401401                if ( arguments.length > 0 ) 
     
    10421042        var divItenContact       = null; 
    10431043        var spanShow             = null; 
    1044          
     1044 
    10451045        if( ( divItenContact = document.getElementById('itenContact_' + jidTo ))) 
    10461046        {        
     
    10521052                 
    10531053                divItenContact.parentNode.removeChild(divItenContact); 
    1054  
    1055                 // Remove Contact 
    1056                         var _id = TrophyIM.connection.getUniqueId();     
    1057                 var delContact  = $iq({type: 'set', id: _id}) 
    1058                         delContact      = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    1059                         delContact      = delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree(); 
    1060  
    1061                 TrophyIM.connection.send( delContact );                  
     1054                 
     1055                // Remove Contact 
     1056                var _id = TrophyIM.connection.getUniqueId();     
     1057                var delContact  = $iq({type: 'set', id: _id}) 
     1058                        delContact      = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
     1059                        delContact      = delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree(); 
     1060 
     1061                TrophyIM.connection.send( delContact );                  
    10621062        } 
    10631063    }, 
     
    12401240                                                                status          = " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) "; 
    12411241                                                                statusColor     = "orange"; 
    1242                                                                  
    1243                                                                 if ( TrophyIM.controll.notificationNewUsers == 0 ) 
    1244                                                                 { 
    1245                                                                         loadscript.enabledNotificationNewUsers(); 
    1246                                                                         TrophyIM.controll.notificationNewUsers++; 
    1247                                                                 } 
    1248                                                                  
    12491242                                                                break; 
    12501243         
     
    12651258                                                                status          = " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) "; 
    12661259                                                                statusColor     = "orange";      
    1267                                                                  
    1268                                                                 if ( TrophyIM.controll.notificationNewUsers == 0 ) 
    1269                                                                 { 
    1270                                                                         loadscript.enabledNotificationNewUsers(); 
    1271                                                                         TrophyIM.controll.notificationNewUsers++; 
    1272                                                                 } 
    1273  
    12741260                                                                break; 
    12751261                                                                 
     
    12821268                                }; 
    12831269 
    1284                                 var itensJid    = document.getElementById( "itenContact_" + objContact.contact.jid ); 
    1285  
    1286                                 if( itensJid == null ) 
     1270                                if( objContact.contact.subscription != "remove") 
    12871271                                { 
    1288                                         // Name 
    1289                                         var nameContact = "";                                    
     1272                                        var itensJid    = document.getElementById( "itenContact_" + objContact.contact.jid ); 
    12901273                                         
    1291                                         if ( objContact.contact.name )  
    1292                                                 nameContact = objContact.contact.name; 
     1274                                        if( itensJid == null ) 
     1275                                        { 
     1276                                                // Name 
     1277                                                var nameContact = "";                                    
     1278                                                 
     1279                                                if ( objContact.contact.name )  
     1280                                                        nameContact = objContact.contact.name; 
     1281                                                else 
     1282                                                { 
     1283                                                        nameContact = objContact.contact.jid; 
     1284                                                        nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
     1285                                                } 
     1286                                                 
     1287                                                // Get Presence 
     1288                                                _presence(objContact); 
     1289                                                 
     1290                                                var paramsContact = 
     1291                                                { 
     1292                                                        divDisplay              : "block",  
     1293                                                        id                              : 'itenContact_' + objContact.contact.jid , 
     1294                                                        jid                             : objContact.contact.jid, 
     1295                                                        nameContact     : nameContact, 
     1296                                                        path_jabberit   : path_jabberit, 
     1297                                                        presence                : presence, 
     1298                                                        spanDisplay             : statusDisplay, 
     1299                                                        status                  : status, 
     1300                                                        statusColor             : "black", 
     1301                                                        subscription    : objContact.contact.subscription, 
     1302                                                        resource                : _resource 
     1303                                                } 
     1304                                                 
     1305                                                // Get Authorization 
     1306                                                _subscription( objContact ); 
     1307                                                 
     1308                                                if( group != "") 
     1309                                                { 
     1310                                                        var _NodeChild          = element.firstChild; 
     1311                                                         
     1312                                                        while( _NodeChild ) 
     1313                                                        { 
     1314                                                                if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1315                                                                { 
     1316                                                                        if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
     1317                                                                        { 
     1318                                                                                _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
     1319                                                                        } 
     1320                                                                } 
     1321         
     1322                                                                _NodeChild = _NodeChild.nextSibling; 
     1323                                                        } 
     1324                                                }        
     1325                                        } 
    12931326                                        else 
    12941327                                        { 
    1295                                                 nameContact = objContact.contact.jid; 
    1296                                                 nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
    1297                                         } 
    1298                                          
    1299                                         // Get Presence 
    1300                                         _presence(objContact); 
    1301                                          
    1302                                         var paramsContact = 
    1303                                         { 
    1304                                                 divDisplay              : "block",  
    1305                                                 id                              : 'itenContact_' + objContact.contact.jid , 
    1306                                                 jid                             : objContact.contact.jid, 
    1307                                                 nameContact     : nameContact, 
    1308                                                 path_jabberit   : path_jabberit, 
    1309                                                 presence                : presence, 
    1310                                                 spanDisplay             : statusDisplay, 
    1311                                                 status                  : status, 
    1312                                                 statusColor             : "black", 
    1313                                                 subscription    : objContact.contact.subscription, 
    1314                                                 resource                : _resource 
    1315                                         } 
    1316                                          
    1317                                         // Get Authorization 
    1318                                         _subscription( objContact ); 
    1319                                          
    1320                                         if( group != "") 
    1321                                         { 
    1322                                                 var _NodeChild          = element.firstChild; 
     1328                                                // Get Presence 
     1329                                                _presence(objContact); 
     1330         
     1331                                                var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
     1332                                                        is_open = is_open.indexOf("arrow_down.gif"); 
     1333         
     1334                                                // Get Authorization 
     1335                                                _subscription( objContact ); 
    13231336                                                 
    1324                                                 while( _NodeChild ) 
     1337                                                // Set subscription 
     1338                                                itensJid.setAttribute('subscription', objContact.contact.subscription ); 
     1339                                                 
     1340                                                with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
    13251341                                                { 
    1326                                                         if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1342                                                        if( presence == "unavailable" && !showOffline ) 
    13271343                                                        { 
    1328                                                                 if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
     1344                                                                style.display = "none"; 
     1345                                                        } 
     1346                                                        else 
     1347                                                        { 
     1348                                                                if( is_open > 0 ) 
    13291349                                                                { 
    1330                                                                         _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
     1350                                                                        style.display   = statusDisplay; 
     1351                                                                        style.color             = statusColor; 
     1352                                                                        innerHTML               = status; 
    13311353                                                                } 
    13321354                                                        } 
    1333  
    1334                                                         _NodeChild = _NodeChild.nextSibling; 
    13351355                                                } 
    1336                                         }        
    1337                                 } 
    1338                                 else 
    1339                                 { 
    1340                                         // Get Presence 
    1341                                         _presence(objContact); 
    1342  
    1343                                         var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
    1344                                                 is_open = is_open.indexOf("arrow_down.gif"); 
    1345                                          
    1346                                         // Get Authorization 
    1347                                         _subscription( objContact ); 
    1348                                          
    1349                                         // Set subscription 
    1350                                         itensJid.setAttribute('subscription', objContact.contact.subscription ); 
    1351                                          
    1352                                         with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
    1353                                         { 
     1356                                                 
    13541357                                                if( presence == "unavailable" && !showOffline ) 
    13551358                                                { 
    1356                                                         style.display = "none"; 
     1359                                                        itensJid.style.display = "none"; 
    13571360                                                } 
    13581361                                                else 
     
    13601363                                                        if( is_open > 0 ) 
    13611364                                                        { 
    1362                                                                 style.display   = statusDisplay; 
    1363                                                                 style.color             = statusColor; 
    1364                                                                 innerHTML               = status; 
     1365                                                                itensJid.style.display = "block"; 
     1366                                                        } 
     1367                                                } 
     1368                                                 
     1369                                                itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
     1370                                                 
     1371                                        } 
     1372         
     1373                                        // Contact OffLine 
     1374                                        if( !objContact.presence && !showOffline ) 
     1375                                        { 
     1376                                                if( objContact.contact.subscription != "remove" ) 
     1377                                                { 
     1378                                                        with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
     1379                                                        { 
     1380                                                                style.display   = "none"; 
     1381                                                        } 
     1382                 
     1383                                                        with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
     1384                                                        { 
     1385                                                                style.display   = "none"; 
    13651386                                                        } 
    13661387                                                } 
    13671388                                        } 
    1368                                          
    1369                                         if( presence == "unavailable" && !showOffline ) 
    1370                                         { 
    1371                                                 itensJid.style.display = "none"; 
    1372                                         } 
    1373                                         else 
    1374                                         { 
    1375                                                 if( is_open > 0 ) 
    1376                                                 { 
    1377                                                         itensJid.style.display = "block"; 
    1378                                                 } 
    1379                                         } 
    1380                                          
    1381                                         itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
    13821389                                } 
    1383  
    1384                                 // Contact OffLine 
    1385                                 if( !objContact.presence && !showOffline ) 
     1390                        } 
     1391                }; 
     1392                 
     1393                var flag = false; 
     1394                 
     1395                for( var i = 0 ; i < users.length; i++ ) 
     1396                { 
     1397                        if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
     1398                        { 
     1399                                var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription; 
     1400                                 
     1401                                if( _subscription == "to" || _subscription == "not-in-roster") 
    13861402                                { 
    1387                                         with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
    1388                                         { 
    1389                                                 style.display   = "none"; 
    1390                                         } 
    1391  
    1392                                         with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
    1393                                         { 
    1394                                                 style.display   = "none"; 
    1395                                         } 
     1403                                        flag = true; 
    13961404                                } 
    1397                         } 
    1398                 }; 
    1399                  
    1400                 for( var i = 0 ; i < users.length; i++ ) 
    1401                 { 
    1402                         if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
    1403                         { 
     1405                                 
    14041406                                if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
    14051407                                { 
     
    14231425                                } 
    14241426                        } 
     1427                } 
     1428                 
     1429                if( flag ) 
     1430                { 
     1431                        if ( TrophyIM.controll.notificationNewUsers == 0 ) 
     1432                        { 
     1433                                loadscript.enabledNotificationNewUsers(); 
     1434                                TrophyIM.controll.notificationNewUsers++; 
     1435                        } 
     1436                } 
     1437                else 
     1438                { 
     1439                        loadscript.disabledNotificationNewUsers(); 
     1440                        TrophyIM.controll.notificationNewUsers = 0; 
    14251441                } 
    14261442        }, 
     
    16821698        this.addContact = function(jid, subscription, name, groups ) 
    16831699        { 
    1684         if( subscription !== "remove" ) 
     1700                if( subscription === "remove" || subscription == "remove") 
    16851701        { 
    1686                 var contact             = { jid:jid, subscription:subscription, name:name, groups:groups } 
     1702                        this.removeContact(jid); 
     1703        } 
     1704        else 
     1705        { 
     1706                        var contact             = { jid:jid, subscription:subscription, name:name, groups:groups } 
    16871707                var jid_lower   = jid.toLowerCase(); 
    16881708         
     
    17071727                                this.groups[groups[g]][jid_lower] = jid_lower; 
    17081728                } 
    1709         } 
    1710         else 
    1711         { 
    1712                 this.removeContact(jid); 
    17131729        } 
    17141730    } 
Note: See TracChangeset for help on using the changeset viewer.