Skip to content

Commit

Permalink
make whole panel title clickable + refactor writeLink
Browse files Browse the repository at this point in the history
fixes #372
  • Loading branch information
zhedar committed May 8, 2016
1 parent 13807cc commit 27f4ccd
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/main/java/net/bootsfaces/component/panel/PanelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
rw.writeAttribute("class", "panel-title", "class");
}
if (isCollapsible) {
rw.startElement("a", panel);
rw.writeAttribute("data-toggle", "collapse", "null");
rw.writeAttribute("data-target", "#" + jQueryClientID + "content", "null");
rw.writeAttribute("href", "javascript:;", "null");
if (panel.isCollapsed()) {
rw.writeAttribute("class", "collapsed", null);
}
if(null != accordionParent) {
rw.writeAttribute("data-parent", "#" + accordionParent, null);
}
writeTitleLink(panel, rw, jQueryClientID, accordionParent);
}

rw.writeText(_title, null);
Expand All @@ -164,16 +155,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
rw.endElement("h4");
} else {
if (isCollapsible) {
rw.startElement("a", panel);
rw.writeAttribute("data-toggle", "collapse", "null");
rw.writeAttribute("data-target", "#" + jQueryClientID + "content", "null");
rw.writeAttribute("href", "javascript:;", "null");
if (panel.isCollapsed()) {
rw.writeAttribute("class", "collapsed", null);
}
if(null != accordionParent) {
rw.writeAttribute("data-parent", "#" + accordionParent, null);
}
writeTitleLink(panel, rw, jQueryClientID, accordionParent);
}
head.encodeAll(context);
if (isCollapsible) {
Expand Down Expand Up @@ -208,6 +190,21 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
rw.writeAttribute("class", "panel-body", "class");
}

private void writeTitleLink(Panel panel, ResponseWriter rw, String jQueryClientID, String accordionParent)
throws IOException {
rw.startElement("a", panel);
rw.writeAttribute("data-toggle", "collapse", "null");
rw.writeAttribute("data-target", "#" + jQueryClientID + "content", "null");
rw.writeAttribute("style", "display: block", "style"); //let the anchor
rw.writeAttribute("href", "javascript:;", "null");
if (panel.isCollapsed()) {
rw.writeAttribute("class", "collapsed", null);
}
if(null != accordionParent) {
rw.writeAttribute("data-parent", "#" + accordionParent, null);
}
}

/**
* This methods generates the HTML code of the current b:panel.
* <code>encodeBegin</code> generates the start of the component. After the,
Expand Down

0 comments on commit 27f4ccd

Please sign in to comment.