summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/web/js/edituser_menu.js
blob: 4f6d6ec694c66f854f6b8796c13c812c13fd36b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var usermenu_widget;

YAHOO.util.Event.onDOMReady(function() {
  usermenu_widget = new YAHOO.widget.Menu('usermenu_widget', { position : 'dynamic' });
  usermenu_widget.addItems([
    { text: 'Activity', url: '#', target: '_blank' },
    { text: 'Mail',     url: '#', target: '_blank' },
    { text: 'Edit',     url: '#', target: '_blank' }
  ]);
  usermenu_widget.render(document.body);
});

function show_usermenu(event, id, email, show_edit) {
  if (!usermenu_widget)
    return true;
  if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
    return true;
  usermenu_widget.getItem(0).cfg.setProperty('url',
    'page.cgi?id=user_activity.html&action=run' +
    '&from=' + YAHOO.util.Date.format(new Date(new Date() - (1000 * 60 * 60 * 24 * 14)), {format: '%Y-%m-%d'}) +
    '&to=' + YAHOO.util.Date.format(new Date(), {format: '%Y-%m-%d'}) +
    '&who=' + encodeURIComponent(email));
  usermenu_widget.getItem(1).cfg.setProperty('url', 'mailto:' + encodeURIComponent(email));
  if (show_edit) {
    usermenu_widget.getItem(2).cfg.setProperty('url', 'editusers.cgi?action=edit&userid=' + id);
  } else {
    usermenu_widget.removeItem(2);
  }
  usermenu_widget.cfg.setProperty('xy', YAHOO.util.Event.getXY(event));
  usermenu_widget.show();
  return false;
}