forgot_password_modal.html 3.73 KB
Newer Older
1
<%! from django.utils.translation import ugettext as _ %>
2
<%! from microsite_configuration import microsite %>
3

4
<%! from django.core.urlresolvers import reverse %>
5
<section id="forgot-password-modal" class="modal" role="dialog" tabindex="-1" aria-label="${_('Password Reset')}">
6
  <div class="inner-wrapper">
7
    <button class="close-modal">
8
      <i class="icon fa fa-remove"></i>
9 10
      <span class="sr">
        ## Translators: this is a control to allow users to exit out of this modal interface (a menu or piece of UI that takes the full focus of the screen)
11
        ${_('Close')}
12 13
      </span>
    </button>
14

15 16
    <div id="password-reset">
      <header>
17
        <h2>${_("Password Reset")}</h2>
18 19
      </header>

20
      <div class="instructions">
21
        <p>${_("Please enter your e-mail address below, and we will e-mail instructions for setting a new password.")}</p>
22
      </div>
23 24

      <form id="pwd_reset_form" action="${reverse('password_reset')}" method="post" data-remote="true">
25
        <fieldset class="group group-form group-form-requiredinformation">
26 27
          <legend class="is-hidden">${_("Required Information")}</legend>

28
          <ol class="list-input">
29
            <li class="field required text" id="forgot-password-modal-field-email">
30
              <label for="pwd_reset_email">${_("Your E-mail Address")}</label>
31
              <input class="" id="pwd_reset_email" type="email" name="email" value="" placeholder="example: username@domain.com" aria-describedby="pwd_reset_email-tip" aria-required="true" />
32
              <span class="tip tip-input" id="pwd_reset_email-tip">${_("This is the e-mail address you used to register with {platform}").format(platform=microsite.get_value('platform_name', settings.PLATFORM_NAME))}</span>
33 34 35
            </li>
          </ol>
        </fieldset>
36

37
        <div class="form-actions">
38
          <button name="submit" type="submit" id="pwd_reset_button" class="action action-primary action-update">${_("Reset My Password")}</button>
39
        </div>
40 41 42 43 44 45 46
      </form>
    </div>
  </div>
</section>

<script type="text/javascript">
  (function() {
47 48 49 50 51 52 53 54 55 56
    $(document).delegate('#pwd_reset_form', 'ajax:success', function(data, json, xhr) {
      if(json.success) {
        $("#password-reset").html(json.value);
      } else {
        if($('#pwd_error').length == 0) {
          $('#pwd_reset_form').prepend('<div id="pwd_error" class="modal-form-error">${_("Email is incorrect.")}</div>');
        }
        $('#pwd_error').stop().css("display", "block");
      }
    });
57

58 59 60 61
    // removing close link's default behavior
    $('#login-modal .close-modal').click(function(e) {
     e.preventDefault();
    });
62

63 64 65
    var onModalClose = function() {
      $("#forgot-password-modal").attr("aria-hidden", "true");
      $("#forgot-password-link").focus();
66
    };
67

68 69 70
    var cycle_modal_tab = function(from_element_name, to_element_name) {
      $(from_element_name).on('keydown', function(e) {
          var keyCode = e.keyCode || e.which;
Adam Palay committed
71 72
          var TAB_KEY = 9;  // 9 corresponds to the tab key
          if (keyCode === TAB_KEY) {
73 74 75 76 77
              e.preventDefault();
              $(to_element_name).focus();
          }
      });
    };
78
    $("#forgot-password-modal .close-modal").click(onModalClose);
79 80 81
    cycle_modal_tab("#forgot-password-modal .close-modal", "#pwd_reset_email");
    cycle_modal_tab("#pwd_reset_email", "#pwd_reset_button");
    cycle_modal_tab("#pwd_reset_button", "#forgot-password-modal .close-modal");
82

83 84 85 86 87 88 89 90 91 92
    // Hitting the ESC key will exit the modal
    $("#forgot-password-modal").on("keydown", function(e) {
        var keyCode = e.keyCode || e.which;
        // 27 is the ESC key
        if (keyCode === 27) {
            e.preventDefault();
            $("#forgot-password-modal .close-modal").click();
        }
    });

93 94
  })(this)
</script>