Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

232 lines
9.6 KiB

15 years ago
  1. // kate: space-indent on; indent-width 4; replace-tabs on;
  2. Ext.namespace('Ext.ux');
  3. Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, {
  4. clickHandler: function( node, ev ){
  5. if( typeof node.attributes.userdata != "undefined" ){
  6. this.activate(node.attributes.userdata);
  7. }
  8. },
  9. init: function( tree ){
  10. this.tree = tree;
  11. tree.on("click", this.clickHandler, this);
  12. },
  13. activate: function( userdata ){
  14. if( !this.wnd ){
  15. this.userdata = userdata;
  16. this.wnd = new Ext.Window({
  17. title: this.windowTitle || gettext("User details"),
  18. layout: 'fit',
  19. items: [{
  20. xtype: "tabpanel",
  21. activeTab: 0,
  22. border: false,
  23. items: [{
  24. xtype: "form",
  25. border: false,
  26. title: gettext("User comment"),
  27. items: [{
  28. xtype: "htmleditor",
  29. fieldLabel: 'x',
  30. hideLabel: true,
  31. name: "comment",
  32. value: userdata.comment,
  33. }],
  34. }, {
  35. title: gettext("Avatar"),
  36. scope: this,
  37. listeners: {
  38. afterrender: function( panel ){
  39. Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){
  40. if( response.result.has ){
  41. panel.el.dom.children[0].children[0].innerHTML = String.format(
  42. '<img src="{0}" alt="avatar" />', response.result.url
  43. );
  44. }
  45. else{
  46. panel.el.dom.children[0].children[0].innerHTML =
  47. gettext("This user does not have an Avatar.");
  48. }
  49. } );
  50. }
  51. },
  52. html: gettext("Loading..."),
  53. }, {
  54. title: gettext("Infos"),
  55. html: "<ul><li>admin: yes</li><li>registered: maybe</li></ul>",
  56. }, {
  57. xtype: "form",
  58. border: false,
  59. title: gettext("Administration"),
  60. items: [{
  61. xtype: "checkbox",
  62. fieldLabel: gettext("Ban"),
  63. name: "ban"
  64. }, {
  65. xtype: "numberfield",
  66. fieldLabel: gettext("Ban duration"),
  67. value: 3600,
  68. name: "duration"
  69. }, {
  70. xtype: "label",
  71. text: gettext("Only if banning. Set to 0 for permanent ban, any other value for the ban duration in seconds."),
  72. cls: "form_hint_label",
  73. }, {
  74. xtype: "textfield",
  75. fieldLabel: gettext("Reason"),
  76. name: "reason"
  77. }],
  78. fbar: [{
  79. scope: this,
  80. text: gettext("Kick"),
  81. handler: function(btn){
  82. f = btn.ownerCt.ownerCt.getForm().getValues();
  83. Mumble.kickUser(
  84. this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration)
  85. );
  86. }
  87. }, {
  88. text: gettext("Mute"),
  89. enableToggle: true,
  90. scope: this,
  91. ref: '../mutebutton',
  92. pressed: this.userdata.mute,
  93. disabled: this.userdata.deaf,
  94. toggleHandler: function(btn, state){
  95. Mumble.muteUser(this.serverid, this.userdata.session, state);
  96. }
  97. }, {
  98. text: gettext("Deafen"),
  99. enableToggle: true,
  100. scope: this,
  101. ref: '../deafenbutton',
  102. pressed: this.userdata.deaf,
  103. toggleHandler: function(btn, state){
  104. Mumble.deafenUser(this.serverid, this.userdata.session, state);
  105. if( state )
  106. btn.refOwner.mutebutton.toggle(true, true);
  107. btn.refOwner.mutebutton.setDisabled(state);
  108. }
  109. }],
  110. }],
  111. }],
  112. width: 500,
  113. height: 300,
  114. scope: this,
  115. listeners: {
  116. beforeclose: function(){
  117. this.owner.wnd = null;
  118. }
  119. },
  120. });
  121. this.wnd.owner = this;
  122. }
  123. if( !this.wnd.isVisible() ){
  124. this.wnd.show();
  125. mypos = this.tree.getPosition();
  126. mysize = this.tree.getSize();
  127. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  128. }
  129. else{
  130. this.wnd.close();
  131. }
  132. },
  133. } );
  134. Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
  135. clickHandler: function( node, ev ){
  136. if( typeof node.attributes.chandata != "undefined" ){
  137. this.activate(node.attributes.chandata);
  138. }
  139. },
  140. init: function( tree ){
  141. this.tree = tree;
  142. tree.on("click", this.clickHandler, this);
  143. },
  144. activate: function( chandata ){
  145. if( !this.wnd ){
  146. this.chandata = chandata;
  147. this.wnd = new Ext.Window({
  148. title: this.windowTitle || gettext("Channel details"),
  149. layout: 'fit',
  150. items: [{
  151. xtype: "tabpanel",
  152. activeTab: 0,
  153. items: [{
  154. xtype: "form",
  155. border: false,
  156. title: gettext("Channel description"),
  157. defaults: { "anchor": "-20px" },
  158. items: [{
  159. xtype: "textfield",
  160. fieldLabel: "x",
  161. hideLabel: true,
  162. name: "name",
  163. value: chandata.name
  164. }, {
  165. xtype: "htmleditor",
  166. fieldLabel: 'x',
  167. hideLabel: true,
  168. name: "description",
  169. value: chandata.description
  170. }],
  171. fbar: [{
  172. text: gettext('Add subchannel...'),
  173. scope: this,
  174. handler: function(btn){
  175. Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
  176. if (btn == 'ok'){
  177. Mumble.addChannel( this.serverid, text, this.chandata.id );
  178. }
  179. }, this);
  180. }
  181. }, {
  182. scope: this,
  183. text: gettext("Submit name/description"),
  184. handler: function(btn){
  185. f = btn.ownerCt.ownerCt.getForm().getValues();
  186. Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description);
  187. }
  188. }, {
  189. text: gettext('Delete channel'),
  190. scope: this,
  191. handler: function(btn){
  192. Ext.Msg.confirm(
  193. gettext('Confirm channel deletion'),
  194. interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
  195. function(btn){
  196. if( btn == 'yes' ){
  197. Mumble.removeChannel( this.serverid, this.chandata.id );
  198. }
  199. }, this);
  200. }
  201. }]
  202. }],
  203. }],
  204. width: 500,
  205. height: 300,
  206. scope: this,
  207. listeners: {
  208. beforeclose: function(){
  209. this.owner.wnd = null;
  210. }
  211. },
  212. });
  213. this.wnd.owner = this;
  214. }
  215. if( !this.wnd.isVisible() ){
  216. this.wnd.show();
  217. mypos = this.tree.getPosition();
  218. mysize = this.tree.getSize();
  219. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  220. }
  221. else{
  222. this.wnd.close();
  223. }
  224. },
  225. } );