Projet

Général

Profil

Paste
Télécharger (1,71 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / cas / cas.js @ a5572547

1
(function ($) {
2
Drupal.behaviors.cas = {
3
  attach: function (context) {
4
    var loginElements = $('.form-item-name, .form-item-pass, li.cas-link, ul.openid-links');
5
    var casElements = $('#edit-cas-login-redirection-message, li.user-link, li.uncas-link');
6

    
7
    $(".form-item-cas-identifier").hide();
8
    if($("#edit-cas-identifier").attr("checked")) {
9
      loginElements.hide();
10
      // Use .css("display", "block") instead of .show() to be Konqueror friendly.
11
      casElements.css("display", "block");
12
    }
13
    else
14
    {
15
      loginElements.css("display", "block");
16
      // Use .css("display", "block") instead of .show() to be Konqueror friendly.
17
      casElements.hide();
18
    }
19

    
20
    $("li.cas-link", context)
21
      .click( function() {
22
        loginElements.hide();
23
        casElements.css("display", "block");
24
        $("#edit-cas-identifier").attr("checked", true);
25
        // Remove possible error message.
26
        $("#edit-name, #edit-pass").removeClass("error");
27
        $("div.messages.error").hide();
28
        return false;
29
      });
30
    $("li.uncas-link", context)
31
      .click(function() {
32
        loginElements.css("display", "block");
33
        casElements.hide();
34
        $("#edit-cas-identifier").attr("checked", false);
35
        // Clear cas Identifier field and remove possible error message.
36
        $("div.messages.error").css("display", "block");
37
        // Set focus on username field.
38
        $("#edit-name")[0].focus();
39
        return false;
40
      });
41
    // OpenID Compatibility
42
    $("li.openid-link", context)
43
      .click( function() {
44
        $("li.cas-link").hide();
45
      });
46
    $("li.user-link", context)
47
      .click( function() {
48
        $("li.cas-link").css("display", "block");
49
      });
50
    }
51
  };
52
})(jQuery);