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.

86 lines
3.1 KiB

  1. // kate: space-indent on; indent-width 4; replace-tabs on;
  2. Ext.namespace('Ext.ux');
  3. Ext.ux.ButtonLogout = Ext.extend(Ext.Button, {
  4. text: gettext('Logout'),
  5. handler: function(){
  6. Accounts.logout( function(provider, response){
  7. if( response.result.success ){
  8. window.location.reload();
  9. }
  10. else{
  11. Ext.Msg.show({
  12. title: gettext("Login error"),
  13. msg: gettext("Unable to log out."),
  14. icon: Ext.MessageBox.ERROR,
  15. buttons: Ext.MessageBox.OK
  16. });
  17. }
  18. } );
  19. }
  20. });
  21. Ext.ux.ButtonLogin = Ext.extend(Ext.Button, {
  22. text: gettext('Login'),
  23. enableToggle: true,
  24. toggleHandler: function(button, state){
  25. if( !this.wnd ){
  26. this.wnd = new Ext.Window({
  27. title: gettext('Login'),
  28. closable: false,
  29. width: 300,
  30. height: 130,
  31. layout: 'fit',
  32. items: {
  33. layout: 'form',
  34. border: false,
  35. defaults: { anchor: '-20px' },
  36. buttons: [{
  37. text: gettext('Submit'),
  38. handler: function(){
  39. form = this.ownerCt.ownerCt.items.items;
  40. Accounts.login(form[0].getValue(), form[1].getValue(),
  41. function(provider, response){
  42. if( response.result.success ){
  43. window.location.reload();
  44. }
  45. else{
  46. Ext.Msg.show({
  47. title: gettext("Login error"),
  48. msg: gettext("Unable to log in."),
  49. icon: Ext.MessageBox.ERROR,
  50. buttons: Ext.MessageBox.OK
  51. });
  52. }
  53. });
  54. }
  55. }],
  56. items: [{
  57. xtype: "textfield",
  58. width: 50,
  59. fieldLabel: gettext("User name"),
  60. name: "username"
  61. }, {
  62. xtype: 'textfield',
  63. fieldLabel: gettext("Password"),
  64. inputType: "password",
  65. name: "password"
  66. }],
  67. },
  68. });
  69. }
  70. if( state ){
  71. this.wnd.show();
  72. mypos = this.getPosition();
  73. mysize = this.getSize();
  74. winsize = this.wnd.getSize();
  75. this.wnd.setPosition(
  76. mypos[0] + mysize.width - winsize.width,
  77. mypos[1] - winsize.height
  78. );
  79. }
  80. else
  81. this.wnd.hide();
  82. }
  83. });