login.template 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <form id="form" class="table outline ui-corner-all">
  2. <div class="row">
  3. <span class="cell align-right">
  4. <label from="login" for="login-username">
  5. Username:
  6. </label>
  7. </span>
  8. <span class="cell">
  9. <input name="username" id="login-username" type="text"/>
  10. </span>
  11. </div>
  12. <div class="row">
  13. <span class="cell align-right">
  14. <label from="login" for="login-password">
  15. Password:
  16. </label>
  17. </span>
  18. <span class="cell">
  19. <input id="login-password" name="password" type="password"/>
  20. </span>
  21. </div>
  22. <div class="row">
  23. <div class="cell align-right">
  24. <input type="submit" value="login"/>
  25. </div>
  26. <div class="cell">
  27. <input type="button" value="cancel" class="cancel"/>
  28. </div>
  29. </div>
  30. </form>
  31. <script>
  32. {{#if key}}
  33. History.back();
  34. {{else}}
  35. $('form#form').submit(function(){
  36. var data = $(this).serializeObject(),
  37. State = History.getState();
  38. for(var i in State.data){
  39. data[i] = State.data;
  40. }
  41. data.type = 'action';
  42. data.id = 'login';
  43. apiCall(data,function(d){
  44. if(!d.error){
  45. setKey(d.key);
  46. History.go(-1);
  47. }else{
  48. setKey(null);
  49. $('#loading').hide();
  50. }
  51. return false;
  52. });
  53. return false;
  54. }).children('.cancel').click(function(){
  55. History.back();
  56. return false;
  57. });
  58. {{/if}}
  59. </script>