LSformElement_select : Fixed clear button action in recent browser.
[ldapsaisie.git] / public_html / includes / js / LSformElement_select.js
1 var LSformElement_select = new Class({
2     initialize: function(){
3       this.initialiseLSformElement_select();
4     },
5     
6     initialiseLSformElement_select: function() {
7       $$('select.LSformElement_select').each(function(el) {
8         var btn = new Element('img');
9         btn.setProperties({
10           src:    varLSdefault.imagePath('clear.png'),
11           alt:    'Reset',
12           title:  'Reset'
13         });
14         btn.addClass('btn');
15         btn.setStyle('vertical-align','top');
16         btn.addEvent('click',this.onClearBtnClick.bind(this,el));
17         btn.injectAfter(el);
18         varLSdefault.addHelpInfo(btn,'LSformElement_select','clear');
19       }, this);
20     },
21     
22     onClearBtnClick: function(select) {
23       this.resetSelect(select);
24     },
25     
26     resetSelect: function(select) {
27       if ($type(select)!='select') {
28         select=select.getParent('select');
29       }
30       select.selectedIndex=-1;
31     }
32 });
33 window.addEvent(window.ie ? 'load' : 'domready', function() {
34   varLSformElement_select = new LSformElement_select();
35 });