Annotation of ECHO_content/js/hl_lib.js, revision 1.2
1.1 casties 1: /* Copyright (C) 2004 itgroup MPIWG
2:
3: This program is free software; you can redistribute it and/or
4: modify it under the terms of the GNU General Public License
5: as published by the Free Software Foundation; either version 2
6: of the License, or (at your option) any later version.
7:
8: This program is distributed in the hope that it will be useful,
9: but WITHOUT ANY WARRANTY; without even the implied warranty of
10: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: GNU General Public License for more details.
12:
13: You should have received a copy of the GNU General Public License
14: along with this program; if not, write to the Free Software
15: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
16:
17: Authors: ROC 6.5.2004
18: */
19:
20: var hlAreas = new Object();
21: var hlTrafos = new Object();
22:
23: // Area class
24: function Area(id, target_id, a_x, a_y, a_w, a_h, type) {
25: this.id = id;
26: this.target_id = target_id;
27: this.rect = new Rectangle(a_x, a_y, a_w, a_h);
28: this.type = type;
29: this.pxarea = 0;
30: return this;
31: }
32:
33: function addArea(id, target_id, a_x, a_y, a_w, a_h, type) {
34: hlAreas[id] = new Area(id, target_id, a_x, a_y, a_w, a_h, type);
35: }
36:
37: function parseTrafo(target_id) {
38: // returns Transform for given target picsize
1.2 ! casties 39: var picsize = getElementRect(getElement(target_id));
1.1 casties 40: var trafo = new Transform();
41: // subtract area offset and size
42: //trafo.concat(getTranslation(new Position(-dlArea.x, -dlArea.y)));
43: //trafo.concat(getScale(new Size(1/dlArea.width, 1/dlArea.height)));
44: // scale to screen size
45: trafo.concat(getScale(picsize));
46: trafo.concat(getTranslation(picsize));
47: return trafo;
48: }
49:
50: function placeAreas() {
51: // positions all area-images
52: var maxsize = 0;
53: for (var a in hlAreas) {
54: var area = hlAreas[a];
55: var trafo = hlTrafos[area.target_id];
56: if (trafo) {
57: var rect = trafo.transform(area.rect);
58: area.pxarea = rect.getArea();
59: maxsize = Math.max(maxsize, area.pxarea);
1.2 ! casties 60: var img = getElement("i."+area.id);
! 61: if (area.type == "arrow") {
! 62: var pos = rect.getPosition();
! 63: var isize = getElementSize(img);
! 64: pos.x += rect.width * 0.5 - isize.width * 0.5;
! 65: pos.y += rect.height * 0.5 - isize.height * 0.5;
! 66: moveElement(img, pos);
! 67: if (img.layers) {
! 68: // N4 grow layer for border
! 69: img.resizeBy(2,2);
! 70: }
1.1 casties 71: } else {
1.2 ! casties 72: if (img.layers) {
! 73: // N4 size transparent image for area
! 74: var li = img.document.images[0];
! 75: li.width = rect.width;
! 76: li.height = rect.height;
! 77: }
! 78: moveElement(img, rect);
! 79: if (browserType.isIEWin) {
! 80: highlightPair(area.id, false);
! 81: }
1.1 casties 82: }
83: }
84: }
85: // add z-index (largest value for smallest area)
86: for (a in hlAreas) {
87: area = hlAreas[a];
88: var elem = getElement("i."+area.id);
89: if (elem.style) {
1.2 ! casties 90: elem.style.zIndex = getInt(maxsize - area.pxarea);
! 91: } else if (elem.layers) {
! 92: elem.zIndex = getInt(maxsize - area.pxarea);
1.1 casties 93: }
94: }
95: }
96:
97: function highlightPair(id, highlight) {
98: // hightlights or unhighlights the link and image of id
1.2 ! casties 99: //alert("highlightpair: "+id+" "+highlight);
1.1 casties 100: var area = hlAreas[id];
101: var img = getElement("i."+id);
102: var link = getElement("a."+id);
103: if (highlight) {
1.2 ! casties 104: if (link.style) {
! 105: link.style.backgroundColor = "#f08080";
! 106: } else if (link.layers) {
! 107: link.bgColor = "#f08080";
! 108: }
1.1 casties 109: if (area.type == "arrow") {
1.2 ! casties 110: if (img.style) {
! 111: img.style.borderStyle = "solid";
! 112: } else if (img.layers) {
! 113: img.bgColor = "#0000ff";
! 114: }
1.1 casties 115: } else if (area.type == "area") {
1.2 ! casties 116: if (img.style) {
! 117: img.style.background = "url(area_img)";
! 118: } else if (img.layers) {
! 119: img.background.src = "area_img";
! 120: }
1.1 casties 121: }
122: } else {
1.2 ! casties 123: if (link.style) {
! 124: link.style.backgroundColor = "";
! 125: } else if (link.layers) {
! 126: link.bgColor = null;
! 127: }
1.1 casties 128: if (area.type == "arrow") {
1.2 ! casties 129: if (img.style) {
! 130: img.style.borderStyle = "none";
! 131: } else if (img.layers) {
! 132: img.bgColor = null;
! 133: }
1.1 casties 134: } else if (area.type == "area") {
1.2 ! casties 135: if (img.style) {
! 136: img.style.background = "url(trans_img)";
! 137: } else if (img.layers) {
! 138: img.background.src = null;
! 139: }
1.1 casties 140: }
141: }
142: }
143:
144: function init() {
145: hlTrafos["overview"] = parseTrafo("overview");
146: placeAreas();
147: return null;
1.2 ! casties 148: }
! 149:
! 150: function showcoordsN4() {
! 151: var s = "";
! 152: for (var l in document.layers) {
! 153: if (l == "length") continue;
! 154: e = document.layers[l];
! 155: if (e) {
! 156: s += " [" + e.name + "]: pageX:" + e.pageX + " pageY:" + e.pageY + " width:" + e.clip.width + " height:" + e.clip.height + " visibility:" + e.visibility + " zindex:" + e.zIndex + "<br>\n";
! 157: } else {
! 158: s += " {" + l + "}<br>\n";
! 159: }
! 160: }
! 161: return s;
1.1 casties 162: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>