cburschka / cadence

A strophe.js-powered XMPP web client for chatrooms.
6 stars 2 forks source link

Customize context menu #335

Open cburschka opened 8 years ago

cburschka commented 8 years ago

custom.js could support adding items to the context menu.

https://github.com/cburschka/cadence/blob/master/js/core/ui.js#L446

Maybe check config.ui.whatever and add those items at the end of the menu below a separator.

Format:

      ping: {
        name: labels.ping,
        icon: 'ping',
        disabled: !c('ping'),
        callback: function() { chat.commands.ping(nick || jid); }
      }
      msg: {
        name: labels.msg,
        icon: 'msg',
        disabled: !c('msg') || !nick || !roster[nick], // disabled if user is not room occupant.
        callback: function() { chat.prefixMsg(nick); }
      },

This would allow eg. bot commands etc.

cburschka commented 8 years ago

Note: This is somewhat complicated by the fact that the items must be generated for a specific user, so the config key wouldn't be an object but a function that receives a user object and returns an items object.

Considering how much code is actually involved (access control, accessing string labels etc.), this is way beyond what should conceivably be a config key, and is more of a job for a plugin system.

cburschka commented 8 years ago

347 would make this much cleaner.