File: ie_hover.js

package info (click to toggle)
flyspray 0.9.8-10
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,444 kB
  • ctags: 3,031
  • sloc: php: 17,634; sh: 301; makefile: 12
file content (82 lines) | stat: -rw-r--r-- 2,228 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
addEvent(window,'load',setUpIEHover);
var g_severityCSSHoverBackground = Array();
var g_severityCSSHoverColor = Array();
var g_severityBackgroundColor;
var g_severityColor;
function setUpIEHover() {

  if (!document.getElementById('tasklist_table')) {
    return;
  }
  styleSheets = document.styleSheets;
  var sheet;
  for (var i = 0; i < styleSheets.length; i++) {
  //alert(styleSheets[i].href);

    if (styleSheets[i].href.indexOf('theme.css')>0) {
      sheet = styleSheets[i].cssText;
      break;
    }
    
  }
  // Remove the line breaks
  sheet = sheet.replace(/[\n\r]/gm,'');
  var arr;
  for (i = 1; i <=5; i++) {
     re = new RegExp('severity' + i +':hover {.*?\}','m');
     arr = re.exec(sheet);
     g_severityCSSHoverBackground['severity' +i] = getBackgroundColor(arr);
     g_severityCSSHoverColor['severity' + i] = getColor(arr);  
  }
  el = document.getElementById('tasklist_table');
  addEvent(el,'mouseover',tasklistTableMouseOver);
  addEvent(el,'mouseout',tasklistTableMouseOut);
}

function getBackgroundColor(str) {
  re = new RegExp('background-color.*?(#......)','i');
  re.exec(str);
  return RegExp.$1;
}
function getColor(str) {
  re = new RegExp('color.*?:.*?(#......)','i');
  re.exec(str);
  return RegExp.$1;
}

function tasklistTableMouseOver() {
  var src = window.event.srcElement;
  src = getRowFromCell(src);
  if (src && (src.parentNode.nodeName != 'THEAD')) {
    var className = src.className;
    g_severityBackgroundColor = src.style.backgroundColor;
    g_severityColor = src.style.color;
    src.style.backgroundColor = g_severityCSSHoverBackground[className];
    src.style.color = g_severityCSSHoverColor[className];
    src.style.cursor = 'pointer';
  }
}
function tasklistTableMouseOut(e) {
  var src = window.event.srcElement;
  src = getRowFromCell(src);
  if (src) {
    src.style.backgroundColor = g_severityBackgroundColor;
    src.style.color = g_severityColor;
    src.style.cursor = '';
  }
}

function getRowFromCell(el) {
  if (el.nodeName == 'TABLE') {
    return;
  }
  // Make sure the event came from a cell
  el = el.parentNode;
  while (el.nodeName != 'TR') {
    if (el.nodeName == 'TABLE') {
      return;
    }
    el = el.parentNode;
  }
  return el;
}