Lang file : Update lang french file
[ldapsaisie.git] / trunk / includes / js / LSview.js
1 var LSview = new Class({
2     initialize: function(){
3       this.labels = varLSdefault.LSjsConfig['LSview_labels'];
4       if (!$type(this.labels)) {
5         this.labels = {
6           delete_confirm_text:      "Do you really want to delete",
7           delete_confirm_title:     "Caution",
8           delete_confirm_validate:  "Delete"
9         };
10       }
11       
12       $$('td.LSobject-list-names').each(function(el) {
13         el.addEvent('click',this.onTdLSobjectListNamesClick.bind(this,el));
14       }, this);
15       $$('td.LSobject-list-names').each(function(el) {
16         el.addEvent('mouseenter',this.onTdLSobjectListNamesOver.bind(this,el));
17       }, this);
18       $$('td.LSobject-list-names').each(function(el) {
19         el.addEvent('mouseleave',this.onTdLSobjectListNamesOut.bind(this,el));
20       }, this);
21       $$('a.LSobject-list-actions').each(function(el) {
22         var checkRemove = /remove\.php.*/;
23         if (checkRemove.exec(el.href)) {
24           el.addEvent('click',this.onRemoveListBtnClick.bindWithEvent(this,el));
25         }
26       }, this);
27       $$('a.LSview-actions').each(function(el) {
28         var checkRemove = /remove\.php.*/;
29         if (checkRemove.exec(el.href)) {
30           el.addEvent('click',this.onRemoveViewBtnClick.bindWithEvent(this,el));
31         }
32       }, this);
33     },
34
35     onTdLSobjectListNamesClick: function(td) {
36       window.location=td.getFirst().href;
37     },
38
39     onTdLSobjectListNamesOver: function(td){
40       td.imgEdit = new Element('img');
41       td.imgEdit.src = varLSdefault.imagePath('view.png');
42       td.imgEdit.injectInside(td);
43     },
44     
45     onTdLSobjectListNamesOut: function(td) {
46       if(td.imgEdit)
47         td.imgEdit.destroy();
48     },
49     
50     onRemoveListBtnClick: function(event,a) {
51       Event(event).stop();
52       if (!this._confirmBoxOpen) {
53         this._confirmBoxOpen = 1;
54         var name = a.getParent().getParent().getFirst('td').getElement('a').innerHTML;
55         this.confirmBox = new LSconfirmBox({
56           text:         this.labels.delete_confirm_text + ' "'+name+'" ?', 
57           startElement: a,
58           onConfirm:    this.removeFromA.bind(this,a),
59           onClose:      this.onConfirmBoxClose.bind(this)
60         });
61       }
62     },
63     
64     onRemoveViewBtnClick: function(event,a) {
65       Event(event).stop();
66       if (!this._confirmBoxOpen) {
67         this._confirmBoxOpen = 1;
68         var name = $('LSview_title').innerHTML;
69         this.confirmBox = new LSconfirmBox({
70           text:           this.labels.delete_confirm_text + ' "'+name+'" ?',
71           title:          this.labels.delete_confirm_title,
72           validate_label: this.labels.delete_confirm_yes_btn,
73           startElement:   a,
74           onConfirm:      this.removeFromA.bind(this,a),
75           onClose:        this.onConfirmBoxClose.bind(this)
76         });
77       }
78     },
79     
80     onConfirmBoxClose: function() {
81       this._confirmBoxOpen = 0;
82     },
83     
84     removeFromA: function(a) {
85       document.location = a.href+'&valid';
86     }
87
88 });
89 window.addEvent(window.ie ? 'load' : 'domready', function() {
90   varLSview = new LSview();
91 });