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.

194 lines
7.6 KiB

  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.wnd = new Ext.Window({
  147. title: this.windowTitle || gettext("Channel details"),
  148. layout: 'fit',
  149. items: [{
  150. xtype: "tabpanel",
  151. activeTab: 0,
  152. items: [{
  153. xtype: "form",
  154. border: false,
  155. title: gettext("Channel description"),
  156. defaults: { "anchor": "-20px" },
  157. items: [{
  158. xtype: "htmleditor",
  159. fieldLabel: 'x',
  160. hideLabel: true,
  161. name: "description",
  162. value: chandata.description,
  163. }],
  164. }],
  165. }],
  166. width: 500,
  167. height: 300,
  168. scope: this,
  169. listeners: {
  170. beforeclose: function(){
  171. this.owner.wnd = null;
  172. }
  173. },
  174. });
  175. this.wnd.owner = this;
  176. }
  177. if( !this.wnd.isVisible() ){
  178. this.wnd.show();
  179. mypos = this.tree.getPosition();
  180. mysize = this.tree.getSize();
  181. this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
  182. }
  183. else{
  184. this.wnd.close();
  185. }
  186. },
  187. } );