From 1a7ebd0446b4e4d47af1b54e9468052e10c66066 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sun, 25 Nov 2001 21:46:25 +0000 Subject: [PATCH] added onClick attributes to LinkItems and name attributes to ImageItems - NRPA Conference Center needs these to support LivePerson in the left menu bar --- .../servlets/format/menus/ImageItem.java | 16 +++++++++++----- .../venice/servlets/format/menus/LinkItem.java | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/com/silverwrist/venice/servlets/format/menus/ImageItem.java b/src/com/silverwrist/venice/servlets/format/menus/ImageItem.java index b11be18..10b65f6 100644 --- a/src/com/silverwrist/venice/servlets/format/menus/ImageItem.java +++ b/src/com/silverwrist/venice/servlets/format/menus/ImageItem.java @@ -40,11 +40,12 @@ class ImageItem implements ComponentRender *-------------------------------------------------------------------------------- */ - private String src; - private String alt = null; - private int width; - private int height; - private boolean fixup; + private String src; // image source URL + private String alt = null; // image alternate text + private String name = null; // image NAME= attribute + private int width; // width of image in pixels + private int height; // height of image in pixels + private boolean fixup; // does image source URL need fixing up? /*-------------------------------------------------------------------------------- * Constructor @@ -81,8 +82,11 @@ class ImageItem implements ComponentRender else throw new ConfigException("height= attribute of element not specified or invalid"); + // get the rest of the attributes if (h.hasAttribute("alt")) alt = elt.getAttribute("alt"); + if (h.hasAttribute("name")) + name = elt.getAttribute("name"); if (h.hasAttribute("fixup")) fixup = true; @@ -106,6 +110,8 @@ class ImageItem implements ComponentRender out.write(src + "\" WIDTH=" + width + " HEIGHT=" + height); if (alt!=null) out.write(" ALT=\"" + alt + "\""); + if (name!=null) + out.write(" NAME=\"" + name + "\""); out.write(" BORDER=0>"); } // end renderHere diff --git a/src/com/silverwrist/venice/servlets/format/menus/LinkItem.java b/src/com/silverwrist/venice/servlets/format/menus/LinkItem.java index acdee30..9d12b5a 100644 --- a/src/com/silverwrist/venice/servlets/format/menus/LinkItem.java +++ b/src/com/silverwrist/venice/servlets/format/menus/LinkItem.java @@ -47,11 +47,12 @@ class LinkItem implements ComponentRender, ColorSelectors *-------------------------------------------------------------------------------- */ - private String href; - private String type; - private boolean enabled = true; - private String target = null; - private ComponentRender contents; + private String href; // what we actually link to + private String type; // the type of item we specify + private boolean enabled = true; // is this item enabled? + private String target = null; // target window for the link + private String on_click = null; // onClick JavaScript for the link + private ComponentRender contents; // what does this link contain? (image vs. text) /*-------------------------------------------------------------------------------- * Constructors @@ -91,6 +92,10 @@ class LinkItem implements ComponentRender, ColorSelectors if (h.hasAttribute("target")) target = elt.getAttribute("target"); + // load the "onClick" script code + if (h.hasAttribute("onClick")) + on_click = elt.getAttribute("onClick"); + // load the "disabled" attribute if (h.hasAttribute("disabled")) enabled = false; @@ -110,6 +115,7 @@ class LinkItem implements ComponentRender, ColorSelectors this.type = other.type; this.enabled = other.enabled; this.target = other.target; + this.on_click = StringUtil.replaceAllVariables(other.on_click,vars); this.contents = other.contents; } // end constructor @@ -133,6 +139,8 @@ class LinkItem implements ComponentRender, ColorSelectors out.write("\" CLASS=\"lbar\""); if (target!=null) out.write(" TARGET=\"" + target + "\""); + if (on_click!=null) + out.write(" onClick=\"" + on_click + "\""); out.write(">"); } // end if else // write the "disabled" indicator