You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/05/05 16:33:58 UTC
isis git commit: ISIS-1610: adds workaround to allow space bar to be
used to toggle checkbox
Repository: isis
Updated Branches:
refs/heads/master 41f626b3b -> b23765b05
ISIS-1610: adds workaround to allow space bar to be used to toggle checkbox
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/b23765b0
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/b23765b0
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/b23765b0
Branch: refs/heads/master
Commit: b23765b05defe7169a93e2236e9fedfd1ec10195
Parents: 41f626b
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri May 5 17:30:54 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri May 5 17:30:54 2017 +0100
----------------------------------------------------------------------
.../scalars/primitive/BooleanPanel.java | 22 +++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/b23765b0/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
index 3579cac..d132a41 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/primitive/BooleanPanel.java
@@ -22,6 +22,7 @@ package org.apache.isis.viewer.wicket.ui.components.scalars.primitive;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
@@ -127,6 +128,25 @@ public class BooleanPanel extends ScalarPanelAbstract2 {
public CheckBoxXConfig getConfig() {
return config;
}
+
+ @Override protected void onComponentTag(final ComponentTag tag) {
+ super.onComponentTag(tag);
+ //
+ // this is a horrid hack to allow the space bar to work as a way of toggling the checkbox.
+ // this hack works for 1.5.4 of the JS plugin (https://github.com/kartik-v/bootstrap-checkbox-x)
+ //
+ // the problem is that the "change" event is not fired for a keystroke; instead the callback in the
+ // JS code (https://github.com/kartik-v/bootstrap-checkbox-x/blob/v1.5.4/js/checkbox-x.js#L70)
+ // calls self.change(). This in turn calls validateCheckbox(). In that method it is possible to
+ // cause the "change" event to fire, but only if the input element is NOT type="checkbox".
+ // (https://github.com/kartik-v/bootstrap-checkbox-x/blob/v1.5.4/js/checkbox-x.js#L132)
+ //
+ // It's not possible to simply change the associated markup to input type='xx' because it falls foul
+ // of a check in super.onComponentTag(tag). So instead we let that through then hack the tag
+ // afterwards:
+ //
+ tag.put("type", "xx");
+ }
};
checkBox.setOutputMarkupId(true);
checkBox.setEnabled(false); // will be enabled before rendering if
@@ -152,7 +172,7 @@ public class BooleanPanel extends ScalarPanelAbstract2 {
}
};
return config
- .withSize(CheckBoxXConfig.Sizes.xs)
+ .withSize(CheckBoxXConfig.Sizes.sm)
.withEnclosedLabel(false)
.withIconChecked("<i class='fa fa-fw fa-check'></i>")
.withIconNull("<i class='fa fa-fw fa-square'></i>")