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