--- ECHO_content/js/hl_lib.js 2004/05/18 22:30:09 1.2 +++ ECHO_content/js/hl_lib.js 2005/06/09 16:35:51 1.7 @@ -14,29 +14,31 @@ You should have received a copy of the G along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -Authors: ROC 6.5.2004 +Authors: ROC 23.11.2004 */ +var hllibVersion = "1.0.1"; var hlAreas = new Object(); var hlTrafos = new Object(); // Area class -function Area(id, target_id, a_x, a_y, a_w, a_h, type) { +function Area(id, target_id, a_x, a_y, a_w, a_h, type, perm) { this.id = id; this.target_id = target_id; this.rect = new Rectangle(a_x, a_y, a_w, a_h); this.type = type; + this.permanent = (perm.toLowerCase() == 'true'); this.pxarea = 0; return this; } -function addArea(id, target_id, a_x, a_y, a_w, a_h, type) { - hlAreas[id] = new Area(id, target_id, a_x, a_y, a_w, a_h, type); +function addArea(id, target_id, a_x, a_y, a_w, a_h, type, perm) { + hlAreas[id] = new Area(id, target_id, a_x, a_y, a_w, a_h, type, perm); } -function parseTrafo(target_id) { +function parseTrafo(target) { // returns Transform for given target picsize - var picsize = getElementRect(getElement(target_id)); + var picsize = getElementRect(target); var trafo = new Transform(); // subtract area offset and size //trafo.concat(getTranslation(new Position(-dlArea.x, -dlArea.y))); @@ -65,21 +67,29 @@ function placeAreas() { pos.y += rect.height * 0.5 - isize.height * 0.5; moveElement(img, pos); if (img.layers) { - // N4 grow layer for border + // N4: grow layer for border img.resizeBy(2,2); } - } else { + } else if (area.type == "text") { + var txt = getElement("t."+area.id); if (img.layers) { - // N4 size transparent image for area + // for N4 we size a transparent image as the area var li = img.document.images[0]; li.width = rect.width; li.height = rect.height; } moveElement(img, rect); - if (browserType.isIEWin) { - highlightPair(area.id, false); + moveElement(txt, rect); + } else { + if (img.layers) { + // for N4 we size a transparent image as the area + var li = img.document.images[0]; + li.width = rect.width; + li.height = rect.height; } + moveElement(img, rect); } + highlightPair(area.id, area.permanent); } } // add z-index (largest value for smallest area) @@ -112,6 +122,16 @@ function highlightPair(id, highlight) { } else if (img.layers) { img.bgColor = "#0000ff"; } + } else if (area.type == "text") { + if (img.style) { + img.style.background = "url(area_img)"; + } else if (img.layers) { + img.background.src = "area_img"; + } + var txt = getElement("t."+id); + if (txt.style) { + txt.style.visibility = "visible"; + } } else if (area.type == "area") { if (img.style) { img.style.background = "url(area_img)"; @@ -120,29 +140,54 @@ function highlightPair(id, highlight) { } } } else { + // unhighlight if (link.style) { link.style.backgroundColor = ""; } else if (link.layers) { link.bgColor = null; } - if (area.type == "arrow") { - if (img.style) { - img.style.borderStyle = "none"; - } else if (img.layers) { - img.bgColor = null; - } - } else if (area.type == "area") { - if (img.style) { - img.style.background = "url(trans_img)"; - } else if (img.layers) { - img.background.src = null; + if (! area.permanent) { + if (area.type == "arrow") { + if (img.style) { + img.style.borderStyle = "none"; + } else if (img.layers) { + img.bgColor = null; + } + } else if (area.type == "text") { + if (img.style) { + img.style.background = "url(trans_img)"; + } else if (img.layers) { + img.background.src = null; + } + var txt = getElement("t."+id); + if (txt.style) { + txt.style.visibility = "hidden"; + } + } else if (area.type == "area") { + if (img.style) { + img.style.background = "url(trans_img)"; + } else if (img.layers) { + img.background.src = null; + } } } } } function init() { - hlTrafos["overview"] = parseTrafo("overview"); + map_init(); +} + +var elemScaler; +var dlTrafo; + +function map_init() { + // initialise baselib + base_init(); + //alert("huhu4!"); + elemScaler = getElement("overview"); + dlTrafo = parseTrafo(elemScaler); + hlTrafos["overview"] = dlTrafo; placeAreas(); return null; }