+
Index: sandbox/jabberit_messenger/trophy_expresso/inc/jabberit_acl.inc.php
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/inc/jabberit_acl.inc.php (revision 2397)
+++ sandbox/jabberit_messenger/trophy_expresso/inc/jabberit_acl.inc.php (revision 2437)
@@ -54,5 +54,5 @@
// User
$fullName = $_SESSION['phpgw_info']['jabberit_messenger']['fullname'];
- $userJabber = $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']."@ecelepar10612.celepar.parana";
+ $userJabber = $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']."@".$_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'];
$password = $_SESSION['phpgw_info']['jabberit_messenger']['passwd'];
Index: sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js (revision 2421)
+++ sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js (revision 2437)
@@ -4,8 +4,9 @@
var path = "";
var addUser = null;
- var conn = null
+ var conn = null;
+ var selectEditable = null;
var showhidden = null;
+ var userCurrent = null;
var Xtools = null;
- var userCurrent = null;
var zIndex = 9001;
@@ -42,5 +43,5 @@
}
- function addContacts()
+ function addContact()
{
if( arguments.length > 0 )
@@ -145,5 +146,5 @@
var _options = [
- ['Adicionar Contato', 'loadIM.addContacts();' ],
+ ['Adicionar Contato', 'loadIM.addContact();' ],
['Ajuda', 'alert("2")' ],
['PreferĂȘncias', 'alert("3")'],
@@ -309,6 +310,6 @@
var _options = [
- ['Autorizar', 'TrophyIM.setAutorization(\''+jid+'\')' ],
- ['Remover', 'Remover : ' + jid ],
+ ['Autorizar', 'TrophyIM.setAutorization(\''+jid+'\')'],
+ ['Remover', 'loadIM.removeContact(\''+jid+'\')'],
['Renomear', 'Renomear : ' + jid],
['Trocar grupo', 'Trocar grupo : ' + jid],
@@ -332,4 +333,5 @@
showhidden.action('onmouseover', 'onmouseout', _optionsItens);
+ element.parentNode.onclick = function(){ showhidden.hiddenObject(false); };
element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); };
element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); };
@@ -346,4 +348,9 @@
if( arguments.length === 3 )
return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] );
+ }
+
+ function removeContact(jid)
+ {
+ TrophyIM.removeContact(jid);
}
@@ -385,4 +392,10 @@
}
+ function setSelectEditable(element)
+ {
+ if( document.getElementById('selectBox0') == null )
+ selectEditable.create(element);
+ }
+
function setPresence()
{
@@ -458,6 +471,8 @@
path_jabberit + 'js/trophyim.js',
path_jabberit + 'js/AddUser.js',
+ path_jabberit + 'js/SelectEditable.js',
path_jabberit + 'templates/default/css/button.css',
path_jabberit + 'templates/default/css/common.css',
+ path_jabberit + 'templates/default/css/selectEditableStyle.css',
path_jabberit + 'templates/default/css/' + theme_jabberit
];
@@ -484,4 +499,9 @@
addUser = new addUserIM(Xtools, conn);
+
+ // Object SelectEditable
+ if( selectEditable == null )
+ selectEditable = new SelectEditable();
+
// Add Jabber in StatusBar;
addIcon();
@@ -492,5 +512,5 @@
loadIM.prototype.actionButton = actionButton;
- loadIM.prototype.addContacts = addContacts;
+ loadIM.prototype.addContact = addContact;
loadIM.prototype.configEvents = configEvents;
loadIM.prototype.getUserCurrent = getUserCurrent;
@@ -501,7 +521,9 @@
loadIM.prototype.loginPage = loginPage;
loadIM.prototype.parse = parse;
+ loadIM.prototype.searchUser = searchUser
loadIM.prototype.setPresence = setPresence;
- loadIM.prototype.searchUser = searchUser
loadIM.prototype.setStatusJabber = setStatusJabber;
+ loadIM.prototype.setSelectEditable = setSelectEditable;
+ loadIM.prototype.removeContact = removeContact;
loadIM.prototype.rosterDiv = rosterDiv;
Index: sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js (revision 2421)
+++ sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js (revision 2437)
@@ -4,5 +4,5 @@
var conn = null;
- function addContacts()
+ function addContact()
{
var jidFrom = loadIM.getUserCurrent().jid;
@@ -11,8 +11,7 @@
var group = document.getElementById('user_group_jabberIM').value;
- alert( jidFrom + "\n" + jidTo + "\n" + name + "\n" + group );
-
- //TrophyIM.addContacts( jidFrom, jidTo, name, group );
-
+ TrophyIM.addContact( jidFrom, jidTo, name, group );
+
+ _winBuild('add_user_info','remove');
}
@@ -74,4 +73,5 @@
var element = ( Element.target ) ? Element.target : Element.srcElement;
var infoUser = null;
+ var img = document.createElement('img');
if( element.getAttribute('value') )
@@ -85,4 +85,6 @@
'group' : element.getAttribute('ou'),
'name' : element.getAttribute('name').substring( 0, element.getAttribute('name').indexOf(' ')),
+ 'ou' : element.getAttribute('ou'),
+ 'selectBoxOptions' : "grupo1; grupo2; grupo3",
'uid' : element.getAttribute('value').substring( element.getAttribute('value').indexOf(';') + 1 )
};
@@ -97,5 +99,7 @@
'lang_name_contact' : "Contato",
'group' : element.parentNode.getAttribute('ou'),
- 'name' : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')),
+ 'name' : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')),
+ 'ou' : element.parentNode.getAttribute('ou'),
+ 'selectBoxOptions' : "grupo1; grupo2; grupo3",
'uid' : element.parentNode.getAttribute('value').substring( element.parentNode.getAttribute('value').indexOf(';') + 1)
};
@@ -105,5 +109,5 @@
{
id_window : "add_user_info",
- width : 355,
+ width : 370,
height : 190,
top : 85,
@@ -126,8 +130,42 @@
'lang2' : 'Fechar',
'onclickClose' : '_winBuild("' + winAddUser.id_window + '","remove");',
- 'onclickSubmit' : 'loadIM.addContacts(this);'
+ 'onclickSubmit' : 'loadIM.addContact(this);'
};
- document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
+ // Add Buttons
+ document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
+
+ // Select Editable
+ loadIM.setSelectEditable(document.getElementById('user_group_jabberIM'));
+
+ if( element.style.backgroundImage )
+ {
+ var _img = element.cloneNode( false );
+ _img.style.width = '60px';
+ _img.style.height = '80px';
+ _img.style.display = 'block';
+ _img.style.backgroundRepeat = 'no-repeat';
+
+ }
+ else
+ {
+ var _img = document.createElement("img");
+ _img.style.width = '60px';
+ _img.style.height = '80px';
+ _img.style.display = 'block';
+ _img.src = path_jabberit + "templates/default/images/photo.png";
+ }
+
+ with ( document.getElementById('photo_user_ldap_jabber') )
+ {
+ if( hasChildNodes( ) )
+ while( hasChildNodes( ) )
+ {
+ removeNode( firstChild );
+ }
+
+ appendChild( _img );
+ }
+
}
@@ -160,4 +198,5 @@
_winBuild( windAddUser );
+
}
@@ -171,5 +210,5 @@
}
- loadAddUser.prototype.add = addContacts;
+ loadAddUser.prototype.add = addContact;
loadAddUser.prototype.search = search;
loadAddUser.prototype.show = showForm;
Index: sandbox/jabberit_messenger/trophy_expresso/js/SelectEditable.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/SelectEditable.js (revision 2437)
+++ sandbox/jabberit_messenger/trophy_expresso/js/SelectEditable.js (revision 2437)
@@ -0,0 +1,186 @@
+(function()
+{
+ //Load Images
+ var arrowImage = path_jabberit + 'templates/default/images/select_arrow.gif'; // Regular arrow
+ var arrowImageOver = path_jabberit + 'templates/default/images/select_arrow_over.gif'; // Mouse over
+ var arrowImageDown = path_jabberit + 'templates/default/images/select_arrow_down.gif'; // Mouse down
+
+ var activeOption;
+ var selectBoxIds = 0;
+ var currentlyOpenedOptionBox = false;
+ var editableSelect_activeArrow = false;
+
+ function configEvents(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function createEditableSelect()
+ {
+ if( arguments.length > 0 )
+ dest = arguments[0];
+ else
+ return false;
+
+ dest.className='selectBoxInput';
+
+ var div = document.createElement('DIV');
+ div.id = 'selectBox' + selectBoxIds;
+ div.style.left = '155px';
+ div.style.width = dest.offsetWidth;
+ div.style.position = 'absolute';
+ div.style.styleFloat = 'left';
+
+ var parent = dest.parentNode;
+ parent.insertBefore(div,dest);
+
+ div.appendChild(dest);
+ div.className='selectBox';
+
+ var img = document.createElement('IMG');
+ img.src = arrowImage;
+ img.className = 'selectBoxArrow';
+
+ img.onclick = selectBox_showOptions;
+ img.id = 'arrowSelectBox' + selectBoxIds;
+
+ div.appendChild(img);
+
+ var optionDiv = document.createElement('DIV');
+ optionDiv.id = 'selectBoxOptions' + selectBoxIds;
+ optionDiv.className='selectBoxOptionContainer';
+ optionDiv.style.width = div.offsetWidth-2 + 'px';
+
+ div.appendChild(optionDiv);
+
+ if(dest.getAttribute('selectBoxOptions'))
+ {
+ var options = dest.getAttribute('selectBoxOptions').split(';');
+ var optionsTotalHeight = 0;
+ var optionArray = new Array();
+ for(var no = 0 ; no < options.length ; no++)
+ {
+ var anOption = document.createElement('DIV');
+ anOption.innerHTML = options[no];
+ anOption.className='selectBoxAnOption';
+ anOption.onclick = selectOptionValue;
+ anOption.style.width = optionDiv.style.width.replace('px','') - 2 + 'px';
+ anOption.onmouseover = highlightSelectBoxOption;
+
+
+ optionDiv.appendChild(anOption);
+ optionsTotalHeight = optionsTotalHeight + anOption.offsetHeight;
+ optionArray.push(anOption);
+ }
+
+ if(optionsTotalHeight > optionDiv.offsetHeight)
+ {
+ for(var no = 0; no < optionArray.length ; no++)
+ {
+ optionArray[no].style.width = optionDiv.style.width.replace('px','') - 22 + 'px';
+ }
+ }
+
+ optionDiv.style.display = 'none';
+ optionDiv.style.visibility = 'visible';
+ optionDiv.style.zIndex = loadIM.getZIndex();
+ }
+
+ configEvents(dest,
+ 'onkeydown',
+ function(e)
+ {
+ switch(e.keyCode)
+ {
+ case 13:
+ case 27:
+ dest.value = dest.value;
+ dest.focus();
+ dest.select();
+ break;
+ }
+ });
+
+ configEvents(dest,
+ 'onclick',
+ function(e)
+ {
+ dest.value = dest.value;
+ dest.focus();
+ dest.select();
+ document.getElementById('selectBoxOptions0').style.display='none';
+ document.getElementById('arrowSelectBox0').src = arrowImageOver;
+ });
+ }
+
+ function highlightSelectBoxOption()
+ {
+ if( this.style.backgroundColor == '#316AC5' )
+ {
+ this.style.backgroundColor = '';
+ this.style.color = '';
+ }
+ else
+ {
+ this.style.backgroundColor = '#316AC5';
+ this.style.color = '#FFF';
+ }
+
+ if( activeOption )
+ {
+ activeOption.style.backgroundColor='';
+ activeOption.style.color='';
+ }
+ activeOption = this;
+ }
+
+ function selectOptionValue()
+ {
+ var parentNode = this.parentNode.parentNode;
+ var textInput = parentNode.getElementsByTagName('INPUT')[0];
+ textInput.value = this.innerHTML;
+ this.parentNode.style.display='none';
+ document.getElementById('arrowSelectBox' + parentNode.id.replace(/[^\d]/g,'')).src = arrowImageOver;
+ }
+
+ function selectBox_showOptions()
+ {
+ if( editableSelect_activeArrow && editableSelect_activeArrow!=this )
+ editableSelect_activeArrow.src = arrowImage;
+
+ editableSelect_activeArrow = this;
+
+ var numId = this.id.replace(/[^\d]/g,'');
+ var optionDiv = document.getElementById('selectBoxOptions' + numId);
+ if(optionDiv.style.display=='block')
+ {
+ optionDiv.style.display='none';
+ this.src = arrowImageOver;
+ }
+ else
+ {
+ optionDiv.style.display='block';
+ this.src = arrowImageDown;
+
+ if( currentlyOpenedOptionBox && currentlyOpenedOptionBox!=optionDiv)
+ currentlyOpenedOptionBox.style.display='none';
+
+ currentlyOpenedOptionBox= optionDiv;
+ }
+ }
+
+ function SelectEditable(){}
+
+ SelectEditable.prototype.create = createEditableSelect;
+ window.SelectEditable = SelectEditable;
+
+})();
Index: sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js (revision 2397)
+++ sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js (revision 2437)
@@ -6,5 +6,5 @@
*/
-var TROPHYIM_BOSH_SERVICE = "/proxy/xmpp-httpbind"; //Change to suit
+var TROPHYIM_BOSH_SERVICE = "/proxy/ejabberd"; //Change to suit
var TROPHYIM_LOG_LINES = 200;
@@ -651,18 +651,21 @@
*
* Parameters:
- * (string) jid
+ * (string) jidFrom
+ * (string) jidTo
* (string) name
* (string) group
*/
- addContacts : function( jidFrom, jidTo, name, group )
- {
- var newPresence = $pres({from: jidFrom, to: jidTo, type: 'subscribe'}).tree();
-
+ addContact : function( jidFrom, jidTo, name, group )
+ {
+ // Set Presence
+ var newPresence = $pres({from: jidFrom, to: jidTo, type: 'subscribe'}).tree();
+
TrophyIM.connection.send(newPresence);
-
- var newContact = $iq({type: 'set', id: 'set1'});
+
+ // Add Contact
+ var newContact = $iq({type: 'set', id: 'setAddContact'});
newContact = newContact.c('query').attrs({xmlns : 'jabber:iq:roster'});
- newContact = newContact.c('item').attrs({jid: jid, name: name, ask:'subscribe', subscription :'none'});
+ newContact = newContact.c('item').attrs({jid: jidTo, name:name, ask:'subscribe', subscription:'to'});
newContact = newContact.c('group').t(group).tree();
@@ -689,4 +692,39 @@
},
+ /** Function: removeContact
+ *
+ * Parameters:
+ * (string) jidTo
+ */
+
+ removeContact : function(jidTo)
+ {
+ var divItenContact = null;
+
+ if( ( divItenContact = document.getElementById('itenContact_' + jidTo)))
+ {
+ divItenContact.parentNode.removeChild(divItenContact);
+
+ // Delete Object groups
+ for( var nameGroup in TrophyIM.rosterObj.groups )
+ for(var Jid in TrophyIM.rosterObj.groups[nameGroup])
+ if(TrophyIM.rosterObj.groups[nameGroup][Jid] == jidTo )
+ delete TrophyIM.rosterObj.groups[nameGroup][Jid];
+
+ // Delete Object roster
+ if( TrophyIM.rosterObj.roster[jidTo] )
+ delete TrophyIM.rosterObj.roster[jidTo];
+
+ TrophyIM.rosterObj.save();
+
+ // Remove Contact
+ var delContact = $iq({type: 'set', id: Date.parse( new Date )})
+ delContact = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'});
+ delContact = delContact.c('item').attrs({jid: jidTo, subscription:'remove'});//.tree();
+
+ TrophyIM.connection.send(delContact);
+ }
+ },
+
/** Function: renderRoster
*
@@ -911,7 +949,4 @@
setAutorization : function( jid )
{
- //
- //var _autorization = $pres( ).attrs( {to: jid, from: loadIM.getUserCurrent(), type:'subscribed'}).tree();
-
TrophyIM.connection.send($pres( ).attrs( {to: jid, from: loadIM.getUserCurrent().jid, type:'subscribed'}).tree());
},
Index: sandbox/jabberit_messenger/trophy_expresso/templates/default/css/selectEditableStyle.css
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/templates/default/css/selectEditableStyle.css (revision 2437)
+++ sandbox/jabberit_messenger/trophy_expresso/templates/default/css/selectEditableStyle.css (revision 2437)
@@ -0,0 +1,49 @@
+ .selectBoxArrow
+ {
+ margin-top:1px;
+ float:left;
+ position:absolute;
+ right:1px;
+
+ }
+
+ .selectBoxInput
+ {
+ font-family: Verdana, Helvetica, sans;
+ font-size: 11px !important;
+ border:0px !important;
+ padding-left:1px;
+ height:16px;
+ position:absolute;
+ bottom:0px;
+ left:0px;
+ }
+
+ .selectBox
+ {
+ border:1px solid #cecece !important;
+ height:20px;
+ }
+
+ .selectBoxOptionContainer
+ {
+ position:absolute;
+ border:1px solid #cecece !important;
+ font-size:12px;
+ background-color:#FFF;
+ left:-1px;
+ top:20px;
+ visibility:hidden;
+ height: 100px;
+ overflow-y:auto;
+ }
+
+ .selectBoxAnOption
+ {
+ font-family: Verdana, Helvetica, sans;
+ font-size:12px;
+ cursor:default;
+ margin:1px;
+ overflow:hidden;
+ white-space:nowrap;
+ }