Lang file : Update lang french file
[ldapsaisie.git] / trunk / includes / js / LSsession_login.js
1 var LSsession_login = new Class({
2     initialize: function(){
3       this.select_ldapserver = $('LSsession_ldapserver');
4       if ( ! this.select_ldapserver ) 
5         return;
6       this.loading_zone = $('loading_zone');
7       this.recoverPasswordElements = $$('.LSsession_recoverPassword');
8       this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
9       this.onLdapServerChanged();
10     },
11
12     disableInput: function() {
13       $$('input').each(function(el) {
14         el.setProperty('disabled','1');
15       });
16     },
17
18     enableInput: function() {
19       $$('input').each(function(el) {
20         el.setProperty('disabled','');
21       });
22     },
23
24     onLdapServerChanged: function(){
25       this.disableInput();
26       var imgload = varLSdefault.loadingImgDisplay(this.loading_zone,'inside','big');
27       var server = this.select_ldapserver.value;
28       var data = {
29         noLSsession:  1,
30         template:     'LSsession',
31         action:       'onLdapServerChangedLogin',
32         server:       server,
33         imgload:      imgload
34       };
35       new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
36     },
37
38     onLdapServerChangedComplete: function(responseText, responseXML){
39       varLSdefault.loadingImgHide();
40       var data = JSON.decode(responseText);
41       LSdebug(data);
42       if ( varLSdefault.checkAjaxReturn(data) ) {
43         if (data.list_topDn) {
44           $('LSsession_topDn').getParent().set('html',data.list_topDn);
45           LSdebug($('LSsession_topDn').innerHTML);
46           $('LSsession_topDn_label').set('html',data.subDnLabel);
47           $$('.loginform-level').each(function(el) {
48             el.setStyle('display','block');
49           });
50         }
51         else {
52           this.loginformLevelHide();
53         }
54         if (data.recoverPassword) {
55           this.recoverPasswordElements.each(function(el) {
56             el.removeClass('LSsession_recoverPassword_hidden');
57           },this);
58         }
59         else {
60           this.recoverPasswordElements.each(function(el) {
61             el.addClass('LSsession_recoverPassword_hidden');
62           },this);
63         }
64       }
65       else {
66         this.loginformLevelHide();
67       }
68       this.enableInput();
69     },
70     
71     loginformLevelHide: function(){
72       $$('.loginform-level').each(function(el) {
73         el.setStyle('display','none');
74       });
75       $('LSsession_topDn').empty();
76     }
77 });
78 window.addEvent(window.ie ? 'load' : 'domready', function() {
79   varLSsession_login = new LSsession_login();
80 });