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.

105 lines
3.5 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. function handleLogin(){
  22. Accounts.login(Ext.fly('login_field_username').getValue(), Ext.fly('login_field_password').getValue(),
  23. function(provider, response){
  24. if( response.result.success ){
  25. window.location.reload();
  26. }
  27. else{
  28. Ext.Msg.show({
  29. title: gettext("Login error"),
  30. msg: gettext("Unable to log in."),
  31. icon: Ext.MessageBox.ERROR,
  32. buttons: Ext.MessageBox.OK
  33. });
  34. }
  35. });
  36. }
  37. Ext.ux.ButtonLogin = Ext.extend(Ext.Button, {
  38. text: gettext('Login'),
  39. enableToggle: true,
  40. toggleHandler: function(button, state){
  41. if( !this.wnd ){
  42. this.wnd = new Ext.Window({
  43. title: gettext('Login'),
  44. closable: false,
  45. width: 300,
  46. height: 130,
  47. layout: 'fit',
  48. items: {
  49. id: 'login_form',
  50. layout: 'form',
  51. border: false,
  52. defaults: { anchor: '-20px' },
  53. buttons: [{
  54. text: gettext('Submit'),
  55. handler: handleLogin
  56. }],
  57. items: [{
  58. id: 'login_field_username',
  59. xtype: "textfield",
  60. width: 50,
  61. fieldLabel: gettext("User name"),
  62. name: "username",
  63. listeners: {
  64. specialkey: function( f, e ){
  65. if( e.getKey() == e.ENTER )
  66. Ext.fly('login_field_password').focus();
  67. }
  68. }
  69. }, {
  70. id: 'login_field_password',
  71. xtype: 'textfield',
  72. fieldLabel: gettext("Password"),
  73. inputType: "password",
  74. name: "password",
  75. listeners: {
  76. specialkey: function( f, e ){
  77. if( e.getKey() == e.ENTER )
  78. handleLogin();
  79. }
  80. }
  81. }],
  82. },
  83. });
  84. }
  85. if( state ){
  86. this.wnd.show();
  87. mypos = this.getPosition();
  88. mysize = this.getSize();
  89. winsize = this.wnd.getSize();
  90. this.wnd.setPosition(
  91. mypos[0] + mysize.width - winsize.width,
  92. mypos[1] - winsize.height
  93. );
  94. (function(){
  95. Ext.fly('login_field_username').focus();
  96. }).defer(250);
  97. }
  98. else
  99. this.wnd.hide();
  100. }
  101. });