LSsearch : added predefined filters parameters
[ldapsaisie.git] / public_html / 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       this.LSsearchForm = $('LSsearch_form');
35       this.LSsearchPredefinedFilter = $('LSview_search_predefinedFilter');
36       if($type(this.LSsearchPredefinedFilter) && $type('LSsearch_form')) {
37         this.LSsearchPredefinedFilter.addEvent('change',this.onLSsearchPredefinedFilterChange.bind(this));
38       }
39     },
40     
41     onLSsearchPredefinedFilterChange: function() {
42       if (this.LSsearchForm) {
43         this.LSsearchForm.submit();
44       }
45     },
46
47     onTdLSobjectListNamesClick: function(td) {
48       window.location=td.getFirst().href;
49     },
50
51     onTdLSobjectListNamesOver: function(td){
52       td.imgEdit = new Element('img');
53       td.imgEdit.src = varLSdefault.imagePath('view.png');
54       td.imgEdit.injectInside(td);
55     },
56     
57     onTdLSobjectListNamesOut: function(td) {
58       if(td.imgEdit)
59         td.imgEdit.destroy();
60     },
61     
62     onRemoveListBtnClick: function(event,a) {
63       Event(event).stop();
64       if (!this._confirmBoxOpen) {
65         this._confirmBoxOpen = 1;
66         var name = a.getParent().getParent().getFirst('td').getElement('a').innerHTML;
67         this.confirmBox = new LSconfirmBox({
68           text:         this.labels.delete_confirm_text + ' "'+name+'" ?', 
69           startElement: a,
70           onConfirm:    this.removeFromA.bind(this,a),
71           onClose:      this.onConfirmBoxClose.bind(this)
72         });
73       }
74     },
75     
76     onRemoveViewBtnClick: function(event,a) {
77       Event(event).stop();
78       if (!this._confirmBoxOpen) {
79         this._confirmBoxOpen = 1;
80         var name = $('LSview_title').innerHTML;
81         this.confirmBox = new LSconfirmBox({
82           text:           this.labels.delete_confirm_text + ' "'+name+'" ?',
83           title:          this.labels.delete_confirm_title,
84           validate_label: this.labels.delete_confirm_yes_btn,
85           startElement:   a,
86           onConfirm:      this.removeFromA.bind(this,a),
87           onClose:        this.onConfirmBoxClose.bind(this)
88         });
89       }
90     },
91     
92     onConfirmBoxClose: function() {
93       this._confirmBoxOpen = 0;
94     },
95     
96     removeFromA: function(a) {
97       document.location = a.href+'&valid';
98     }
99
100 });
101 window.addEvent(window.ie ? 'load' : 'domready', function() {
102   varLSview = new LSview();
103 });