--- ECHO_content/js/hl_lib.js 2004/12/02 12:01:08 1.4 +++ ECHO_content/js/hl_lib.js 2005/06/13 10:35:04 1.8 @@ -14,25 +14,26 @@ 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 23.11.2004 +Authors: ROC 10.6.2005 */ -var hllibVersion = "1.0.1"; +var hllibVersion = "1.0.2"; 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) { @@ -69,7 +70,8 @@ function placeAreas() { // N4: grow layer for border img.resizeBy(2,2); } - } else { + } else if (area.type == "text") { + var txt = getElement("t."+area.id); if (img.layers) { // for N4 we size a transparent image as the area var li = img.document.images[0]; @@ -77,11 +79,17 @@ function placeAreas() { li.height = rect.height; } moveElement(img, rect); - if (browserType.isIEWin) { - // IE/Win needs to set the area once - 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); } + highlightMark(area.id, area.permanent); } } // add z-index (largest value for smallest area) @@ -96,24 +104,48 @@ function placeAreas() { } } -function highlightPair(id, highlight) { - // hightlights or unhighlights the link and image of id - //alert("highlightpair: "+id+" "+highlight); - var area = hlAreas[id]; - var img = getElement("i."+id); +function highlightLink(id, highlight) { + // hightlights or unhighlights the link of id var link = getElement("a."+id); if (highlight) { + // highlight if (link.style) { link.style.backgroundColor = "#f08080"; } else if (link.layers) { link.bgColor = "#f08080"; } + } else { + // unhighlight + if (link.style) { + link.style.backgroundColor = ""; + } else if (link.layers) { + link.bgColor = null; + } + } +} + +function highlightMark(id, highlight) { + // hightlights or unhighlights the area/img of id + var area = hlAreas[id]; + var img = getElement("i."+id); + if (highlight) { + // highlight if (area.type == "arrow") { if (img.style) { img.style.borderStyle = "solid"; } 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)"; @@ -122,17 +154,23 @@ function highlightPair(id, highlight) { } } } else { - if (link.style) { - link.style.backgroundColor = ""; - } else if (link.layers) { - link.bgColor = null; - } + // unhighlight if (area.type == "arrow") { if (img.style) { img.style.borderStyle = "none"; } else if (img.layers) { img.bgColor = null; } + } else if (area.type == "text") { + var txt = getElement("t."+id); + if (img.style) { + img.style.background = "url(trans_img)"; + } else if (img.layers) { + img.background.src = null; + } + if (txt.style) { + txt.style.visibility = "hidden"; + } } else if (area.type == "area") { if (img.style) { img.style.background = "url(trans_img)"; @@ -143,6 +181,16 @@ function highlightPair(id, highlight) { } } +function highlightPair(id, highlight) { + // hightlights or unhighlights the link and image of id + //alert("highlightpair: "+id+" "+highlight); + var area = hlAreas[id]; + highlightLink(id, highlight); + if (!area.permanent) { + highlightMark(id, highlight); + } +} + function init() { map_init(); }