summaryrefslogtreecommitdiff
path: root/modules/user/js/user.js
blob: fe7adf7726a8a37da693880259fbee43d11234cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * @todo preventDefault() not working in IE 6 and 7
 * @todo Close link should be reusable
 */

$("document").ready(function() {
  $("#gLoginLink").click(function(event) {
    var url = $("#gLoginLink a").attr("href");
    $.get(url, function(data) {
	    $('#gLoginLink').hide();
	    $("#gLoginMenu").append('<li><a href="#">X</a></li>');
	    $("#gLoginMenu li:last").addClass("gClose").show();
	    $("#gLoginMenu .gClose a").click(function() {
	      $("#gLoginForm").remove();
	      $("#gLoginMenu .gClose").remove();
	      $("#gLoginFormContainer").hide();
	      $("#gLoginLink").show();
	      $("input#gUsername").val("");
	      $("input#gPassword").val("");
	    });
      $("#gLoginFormContainer").html(data).hide().fadeIn();
      ajaxify_login_form();
    });
    return false;
  });
});

function ajaxify_login_form() {
  $("#gLoginForm").ajaxForm({
    target: "#gLoginFormContainer",
    success: function(responseText, statusText) {
      if (!responseText) {
        window.location.reload();
      } else {
        ajaxify_login_form();
      }
    }
  });
}