aboutsummaryrefslogtreecommitdiffstats
path: root/template-common/inputfix.htc
blob: b7593293c6a767b52c3e74d6f3845dcca06545b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<public:attach event="oncontentready"  onevent="fixElements()" />

<script langage=javascript>

function setFocusStyle()
{
  this.className += ' focus';
}

function setBlurStyle()
{
  this.className = this.className.replace( ' focus', ' nofocus');
}

function setClassFromType()
{
  this.className += ' ' + this.type;
}

function fixElements()
{
  for ( var i=0; i<this.elements.length; i++ )
  {
    var elem=this.elements[i];
    switch ( elem.tagName )
    {
      case "INPUT":
        elem.className += ' ' + elem.type;
        if ( (elem.type != "radio") && (elem.type != "checkbox") )
        { /* setting focus/nofocus on those is a mess to handle in css */
          elem.onfocus = setFocusStyle;
          elem.onblur = setBlurStyle;
        }
      break;
      case "SELECT":
      case "TEXTAREA":
        elem.onfocus = setFocusStyle;
        elem.onblur = setBlurStyle;
    }
  }
}
</script>