45f14ba7c2f34aad04b3c9b8117b5980ef94a5bb
[ldapsaisie.git] / public_html / includes / js / LSformElement_maildir_field.js
1 var LSformElement_maildir_field = new Class({
2     initialize: function(name,input){
3       this.name = name;
4       this.input = input;
5       this.params = varLSdefault.getParams(this.name);
6       this.initialiseLSformElement_maildir_field();
7     },
8     
9     initialiseLSformElement_maildir_field: function() {
10       if (!$type(varLSform.idform)) {
11         return true;
12       }
13       if ($type(this.params.LSform[varLSform.idform])) {
14         this.doBtn = new Element('img');
15         this.doBtn.addClass('btn');
16         this.doBtn.addEvent('click',this.onDoBtnClick.bind(this));
17         this.doInput = new Element('input');
18         this.doInput.setProperties({
19           name: 'LSformElement_maildir_' + this.name + '_do',
20           type: 'hidden'
21         });
22         if (this.params.LSform[varLSform.idform]) {
23           this.doInput.value = 1;
24           this.doBtn.src = varLSdefault.imagePath('maildir_do.png');
25           varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','do');
26         }  
27         else {
28           this.doInput.value = 0;
29           this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png');
30           varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','nodo');
31         }
32         this.doBtn.injectAfter(this.input);
33         this.doInput.injectAfter(this.doBtn);
34       }
35     },
36     
37     onDoBtnClick: function() {
38       if (this.doInput.value==0) {
39         this.doInput.value = 1;
40         this.doBtn.src = varLSdefault.imagePath('maildir_do.png');
41         varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','do');
42       }
43       else {
44         this.doInput.value = 0;
45         this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png');
46         varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','nodo');
47       }
48     }
49     
50 });