Repository: wicket Updated Branches: refs/heads/master 9f08f5674 -> 549827f9f
Added DebugBar improvements: - Add `positionBottom` method to position it at the bottom of the screen - Remember expanded/collapsed state Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/49714c0d Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/49714c0d Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/49714c0d Branch: refs/heads/master Commit: 49714c0dee16447d083f5de2f795a34b8671e1a9 Parents: 3c17e8c Author: Robert Gruendler <rob...@dubture.com> Authored: Tue May 26 20:11:05 2015 +0200 Committer: Robert Gruendler <rob...@dubture.com> Committed: Tue May 26 20:11:05 2015 +0200 ---------------------------------------------------------------------- .../wicket/devutils/debugbar/DebugBar.java | 13 +++++++ .../devutils/debugbar/wicket-debugbar.css | 11 ++++++ .../wicket/devutils/debugbar/wicket-debugbar.js | 40 ++++++++++++++++++++ 3 files changed, 64 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/49714c0d/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java ---------------------------------------------------------------------- diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java index c839d64..46c4c87 100644 --- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java +++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java @@ -27,6 +27,7 @@ import org.apache.wicket.devutils.DevUtilsPanel; import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.image.Image; import org.apache.wicket.markup.html.list.ListItem; @@ -119,6 +120,17 @@ public class DebugBar extends DevUtilsPanel add(contentSection("content", initiallyExpanded)); } + + /** + * Positions the DebugBar at the bottom of the page + * @return + */ + public DebugBar positionBottom() + { + add(AttributeModifier.append("class", "bottom")); + return this; + } + private Component contentSection(final String id, boolean initiallyExpanded) { WebMarkupContainer section = new WebMarkupContainer(id); @@ -169,6 +181,7 @@ public class DebugBar extends DevUtilsPanel "wicket-debugbar.css"))); response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference( DebugBar.class, "wicket-debugbar.js"))); + response.render(OnDomReadyHeaderItem.forScript("wicketDebugBarCheckState()")); } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/49714c0d/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.css ---------------------------------------------------------------------- diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.css b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.css index 08c429a..b5cb09a 100644 --- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.css +++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.css @@ -22,6 +22,12 @@ top: 0; padding: 0px 10px 0px 5px; } + +#wicketDebugBar.bottom { + top: auto; + bottom: 0px; +} + #wicketDebugBar img { margin: 4px 10px -3px 0px; height: 16px; @@ -31,6 +37,7 @@ #wicketDebugBarRemove img { margin-left: 10px; margin-right: 0px; + cursor: pointer; } #wicketDebugBar .contributor a { margin-right: 10px; @@ -56,3 +63,7 @@ background-color: #DDDDDD; opacity: 0.8; } + +#wicketDebugBarCollapse { + cursor: pointer; +} http://git-wip-us.apache.org/repos/asf/wicket/blob/49714c0d/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.js ---------------------------------------------------------------------- diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.js b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.js index 6f1b287..3a05021 100644 --- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.js +++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/wicket-debugbar.js @@ -26,5 +26,45 @@ function wicketDebugBarToggleVisibility(elemID) { var elem = document.getElementById(elemID); var vis = elem.style.display != 'none'; elem.style.display = (vis ? 'none' : ''); + // alter the state cookie so we can initialize it properly on domReady + wicketDebugBarSetExpandedCookie(vis ? 'collapsed' : 'expanded') } +function wicketDebugBarSetExpandedCookie(value) { + document.cookie = "wicketDebugBarState=" + window.escape(value); +} + +function wicketDebugBarGetExpandedCookie() { + var name = 'wicketDebugBarState'; + if (document.cookie.length > 0) { + var start = document.cookie.indexOf (name + "="); + if (start !== -1) { + start = start + name.length + 1; + var end = document.cookie.indexOf(";", start); + if (end === -1) { + end = document.cookie.length; + } + return window.unescape(document.cookie.substring(start,end)); + } else { + return null; + } + } else { + return null; + } +} + +function wicketDebugBarCheckState() { + var state = wicketDebugBarGetExpandedCookie(); + // state cookie has not been set. determine state and set it + if (state === null) { + var isVisible = $('#wicketDebugBarContents').is(':visible'); + wicketDebugBarSetExpandedCookie(isVisible ? 'expanded' : 'collapsed'); + // set state of debug bar according to cookie + } else { + if (state === 'expanded') { + $('#wicketDebugBarContents').css('display', 'inherit'); + } else { + $('#wicketDebugBarContents').css('display', 'none'); + } + } +}