Skip to content
pstadler edited this page Jan 29, 2012 · 3 revisions

Add / modify menu entries

// myplugin/candy.js
Candy.View.Event.Roster.onContextMenu = function(args) {
	return {
		// add a new menu entry with key profile
		'profile': {
			requiredPermission: function(user, me) {
				// don't show if it's myself
				// this will also disable the entry in the room's context menu (where moderators can change the subject)
				return me.getNick() !== user.getNick();
			},
			'class' : 'profile',
			'label' : 'Show Profile',
			'callback' : function(e, roomJid, user) {
				// open profile in new window
				window.open('http://domain.tld/user/detail/' + user.getNick(), '');
			}
		}
	};
};
/* myplugin/candy.css */
#context-menu .profile {
	background-image: url('profile.png');
}

To modify existing menu entries use the following keys to overwrite them:

'private':  {... // private chat
'ignore':   {... // ignore a user
'unignore': {... // unignore a user
'ban':      {... // ban a user
'kick':     {... // kick a user
'subject':  {... // change the room's subject