Annotation of ECHO_content/js/hl_lib.js, revision 1.1
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
! 39: var picsize = getElementSize(target_id);
! 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);
! 60: if (area.type == "area") {
! 61: moveElement("i."+area.id, rect);
! 62: } else {
! 63: moveElement("i."+area.id, rect.getPosition());
! 64: }
! 65: }
! 66: }
! 67: // add z-index (largest value for smallest area)
! 68: for (a in hlAreas) {
! 69: area = hlAreas[a];
! 70: var elem = getElement("i."+area.id);
! 71: if (elem.style) {
! 72: elem.style.zIndex = Math.round(maxsize - area.pxarea);
! 73: }
! 74: }
! 75: }
! 76:
! 77: function highlightPair(id, highlight) {
! 78: // hightlights or unhighlights the link and image of id
! 79: var area = hlAreas[id];
! 80: var img = getElement("i."+id);
! 81: var link = getElement("a."+id);
! 82: if (highlight) {
! 83: link.style.backgroundColor = "#f08080";
! 84: if (area.type == "arrow") {
! 85: img.style.borderStyle = "solid";
! 86: } else if (area.type == "area") {
! 87: img.style.background = "url(area_img)";
! 88: }
! 89: } else {
! 90: link.style.backgroundColor = "";
! 91: if (area.type == "arrow") {
! 92: img.style.borderStyle = "none";
! 93: } else if (area.type == "area") {
! 94: img.style.background = "none";
! 95: }
! 96: }
! 97: }
! 98:
! 99: function init() {
! 100: hlTrafos["overview"] = parseTrafo("overview");
! 101: placeAreas();
! 102: return null;
! 103: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>