You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/10/23 08:00:41 UTC
[myfaces-tobago] branch master updated: TOBAGO-1817 Reimplement old
(Bootstrap) offset concept for tc:segmentLayout * old offset concept
reimplemented
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 3c39aa8 TOBAGO-1817 Reimplement old (Bootstrap) offset concept for tc:segmentLayout * old offset concept reimplemented
3c39aa8 is described below
commit 3c39aa8284ef9ae6f212dcfc96047527753d0399
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Oct 23 10:00:10 2017 +0200
TOBAGO-1817 Reimplement old (Bootstrap) offset concept for tc:segmentLayout
* old offset concept reimplemented
---
.../myfaces/tobago/component/Attributes.java | 20 +++++
.../facelets/SegmentLayoutConstraintHandler.java | 16 ++++
.../SegmentLayoutConstraintTagDeclaration.java | 30 +++++++
.../tobago/renderkit/css/BootstrapClass.java | 96 ++++++++++++++++++++++
.../50-migration/96-migration/migration40.xhtml | 10 ---
.../16-layout/30-segment/segment-layout.xhtml | 35 ++++++++
6 files changed, 197 insertions(+), 10 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
index 9a581dd..654803b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
@@ -201,6 +201,26 @@ public enum Attributes {
/**
* Used by a layout manager
*/
+ offsetExtraSmall,
+ /**
+ * Used by a layout manager
+ */
+ offsetExtraLarge,
+ /**
+ * Used by a layout manager
+ */
+ offsetLarge,
+ /**
+ * Used by a layout manager
+ */
+ offsetMedium,
+ /**
+ * Used by a layout manager
+ */
+ offsetSmall,
+ /**
+ * Used by a layout manager
+ */
overwriteExtraLarge,
/**
* Used by a layout manager
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
index 87208a3..f5c3398 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
@@ -40,6 +40,11 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
private final TagAttribute overwriteMarginMedium;
private final TagAttribute overwriteMarginLarge;
private final TagAttribute overwriteMarginExtraLarge;
+ private final TagAttribute offsetExtraSmall;
+ private final TagAttribute offsetSmall;
+ private final TagAttribute offsetMedium;
+ private final TagAttribute offsetLarge;
+ private final TagAttribute offsetExtraLarge;
public SegmentLayoutConstraintHandler(TagConfig config) {
super(config);
@@ -53,6 +58,11 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
overwriteMarginMedium = getAttribute(Attributes.marginMedium.getName());
overwriteMarginLarge = getAttribute(Attributes.marginLarge.getName());
overwriteMarginExtraLarge = getAttribute(Attributes.marginExtraLarge.getName());
+ offsetExtraSmall = getAttribute(Attributes.offsetExtraSmall.getName());
+ offsetSmall = getAttribute(Attributes.offsetSmall.getName());
+ offsetMedium = getAttribute(Attributes.offsetMedium.getName());
+ offsetLarge = getAttribute(Attributes.offsetLarge.getName());
+ offsetExtraLarge = getAttribute(Attributes.offsetExtraLarge.getName());
}
@Override
@@ -68,6 +78,12 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
apply(faceletContext, parent, overwriteMarginMedium, Attributes.overwriteMarginMedium, String.class);
apply(faceletContext, parent, overwriteMarginLarge, Attributes.overwriteMarginLarge, String.class);
apply(faceletContext, parent, overwriteMarginExtraLarge, Attributes.overwriteMarginExtraLarge, String.class);
+
+ apply(faceletContext, parent, offsetExtraSmall, Attributes.offsetExtraSmall, Integer.TYPE);
+ apply(faceletContext, parent, offsetSmall, Attributes.offsetSmall, Integer.TYPE);
+ apply(faceletContext, parent, offsetMedium, Attributes.offsetMedium, Integer.TYPE);
+ apply(faceletContext, parent, offsetLarge, Attributes.offsetLarge, Integer.TYPE);
+ apply(faceletContext, parent, offsetExtraLarge, Attributes.offsetExtraLarge, Integer.TYPE);
}
private void apply(FaceletContext faceletContext, UIComponent parent, final TagAttribute tagAttribute,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
index 92f3309..ace719d 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
@@ -103,4 +103,34 @@ public interface SegmentLayoutConstraintTagDeclaration {
@TagAttribute
@UIComponentTagAttribute(allowedValues = {Margin.NONE, Margin.LEFT, Margin.RIGHT, Margin.BOTH})
void setMarginExtraLarge(final ValueExpression overwriteMarginExtraLarge);
+
+ /**
+ * The number of columns this component moves to the right for extra small devices.
+ */
+ @TagAttribute(type = "java.lang.Integer")
+ void setOffsetExtraSmall(final ValueExpression offsetExtraSmall);
+
+ /**
+ * The number of columns this component moves to the right for small devices.
+ */
+ @TagAttribute(type = "java.lang.Integer")
+ void setOffsetSmall(final ValueExpression offsetSmall);
+
+ /**
+ * The number of columns this component moves to the right for medium devices.
+ */
+ @TagAttribute(type = "java.lang.Integer")
+ void setOffsetMedium(final ValueExpression offsetMedium);
+
+ /**
+ * The number of columns this component moves to the right for large devices.
+ */
+ @TagAttribute(type = "java.lang.Integer")
+ void setOffsetLarge(final ValueExpression offsetLarge);
+
+ /**
+ * The number of columns this component moves to the right for extra large devices.
+ */
+ @TagAttribute(type = "java.lang.Integer")
+ void setOffsetExtraLarge(final ValueExpression offsetLarge);
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
index 71a35c1..ff6ab55 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
@@ -373,6 +373,65 @@ public enum BootstrapClass implements CssItem {
*/
@Deprecated
NAVBAR_TOGGLER_RIGHT("navbar-toggler-right"),
+ OFFSET_1("offset-1"),
+ OFFSET_2("offset-2"),
+ OFFSET_3("offset-3"),
+ OFFSET_4("offset-4"),
+ OFFSET_5("offset-5"),
+ OFFSET_6("offset-6"),
+ OFFSET_7("offset-7"),
+ OFFSET_8("offset-8"),
+ OFFSET_9("offset-9"),
+ OFFSET_10("offset-10"),
+ OFFSET_11("offset-11"),
+ OFFSET_LG_0("offset-lg-0"),
+ OFFSET_LG_1("offset-lg-1"),
+ OFFSET_LG_2("offset-lg-2"),
+ OFFSET_LG_3("offset-lg-3"),
+ OFFSET_LG_4("offset-lg-4"),
+ OFFSET_LG_5("offset-lg-5"),
+ OFFSET_LG_6("offset-lg-6"),
+ OFFSET_LG_7("offset-lg-7"),
+ OFFSET_LG_8("offset-lg-8"),
+ OFFSET_LG_9("offset-lg-9"),
+ OFFSET_LG_10("offset-lg-10"),
+ OFFSET_LG_11("offset-lg-11"),
+ OFFSET_MD_0("offset-md-0"),
+ OFFSET_MD_1("offset-md-1"),
+ OFFSET_MD_2("offset-md-2"),
+ OFFSET_MD_3("offset-md-3"),
+ OFFSET_MD_4("offset-md-4"),
+ OFFSET_MD_5("offset-md-5"),
+ OFFSET_MD_6("offset-md-6"),
+ OFFSET_MD_7("offset-md-7"),
+ OFFSET_MD_8("offset-md-8"),
+ OFFSET_MD_9("offset-md-9"),
+ OFFSET_MD_10("offset-md-10"),
+ OFFSET_MD_11("offset-md-11"),
+ OFFSET_SM_0("offset-sm-0"),
+ OFFSET_SM_1("offset-sm-1"),
+ OFFSET_SM_2("offset-sm-2"),
+ OFFSET_SM_3("offset-sm-3"),
+ OFFSET_SM_4("offset-sm-4"),
+ OFFSET_SM_5("offset-sm-5"),
+ OFFSET_SM_6("offset-sm-6"),
+ OFFSET_SM_7("offset-sm-7"),
+ OFFSET_SM_8("offset-sm-8"),
+ OFFSET_SM_9("offset-sm-9"),
+ OFFSET_SM_10("offset-sm-10"),
+ OFFSET_SM_11("offset-sm-11"),
+ OFFSET_XL_0("offset-xl-0"),
+ OFFSET_XL_1("offset-xl-1"),
+ OFFSET_XL_2("offset-xl-2"),
+ OFFSET_XL_3("offset-xl-3"),
+ OFFSET_XL_4("offset-xl-4"),
+ OFFSET_XL_5("offset-xl-5"),
+ OFFSET_XL_6("offset-xl-6"),
+ OFFSET_XL_7("offset-xl-7"),
+ OFFSET_XL_8("offset-xl-8"),
+ OFFSET_XL_9("offset-xl-9"),
+ OFFSET_XL_10("offset-xl-10"),
+ OFFSET_XL_11("offset-xl-11"),
/**
* @deprecated since 4.0.0, please use {@link #SHOW}
*/
@@ -512,6 +571,27 @@ public enum BootstrapClass implements CssItem {
public static class Generator {
+ private static final BootstrapClass[] OFFSET_EXTRA_SMALL = new BootstrapClass[]{
+ null, OFFSET_1, OFFSET_2, OFFSET_3, OFFSET_4, OFFSET_5,
+ OFFSET_6, OFFSET_7, OFFSET_8, OFFSET_9, OFFSET_10, OFFSET_11
+ };
+ private static final BootstrapClass[] OFFSET_SMALL = new BootstrapClass[]{
+ OFFSET_SM_0, OFFSET_SM_1, OFFSET_SM_2, OFFSET_SM_3, OFFSET_SM_4, OFFSET_SM_5,
+ OFFSET_SM_6, OFFSET_SM_7, OFFSET_SM_8, OFFSET_SM_9, OFFSET_SM_10, OFFSET_SM_11
+ };
+ private static final BootstrapClass[] OFFSET_MEDIUM = new BootstrapClass[]{
+ OFFSET_MD_0, OFFSET_MD_1, OFFSET_MD_2, OFFSET_MD_3, OFFSET_MD_4, OFFSET_MD_5,
+ OFFSET_MD_6, OFFSET_MD_7, OFFSET_MD_8, OFFSET_MD_9, OFFSET_MD_10, OFFSET_MD_11
+ };
+ private static final BootstrapClass[] OFFSET_LARGE = new BootstrapClass[]{
+ OFFSET_LG_0, OFFSET_LG_1, OFFSET_LG_2, OFFSET_LG_3, OFFSET_LG_4, OFFSET_LG_5,
+ OFFSET_LG_6, OFFSET_LG_7, OFFSET_LG_8, OFFSET_LG_9, OFFSET_LG_10, OFFSET_LG_11
+ };
+ private static final BootstrapClass[] OFFSET_EXTRA_LARGE = new BootstrapClass[]{
+ OFFSET_XL_0, OFFSET_XL_1, OFFSET_XL_2, OFFSET_XL_3, OFFSET_XL_4, OFFSET_XL_5,
+ OFFSET_XL_6, OFFSET_XL_7, OFFSET_XL_8, OFFSET_XL_9, OFFSET_XL_10, OFFSET_XL_11
+ };
+
private final LayoutTokens extraSmall;
private final LayoutTokens small;
private final LayoutTokens medium;
@@ -567,6 +647,12 @@ public enum BootstrapClass implements CssItem {
generate(result, marginMedium, attributes, Attributes.overwriteMarginMedium);
generate(result, marginLarge, attributes, Attributes.overwriteMarginLarge);
generate(result, marginExtraLarge, attributes, Attributes.overwriteMarginExtraLarge);
+
+ generateOffset(result, attributes.get(Attributes.offsetExtraSmall.name()), OFFSET_EXTRA_SMALL);
+ generateOffset(result, attributes.get(Attributes.offsetSmall.name()), OFFSET_SMALL);
+ generateOffset(result, attributes.get(Attributes.offsetMedium.name()), OFFSET_MEDIUM);
+ generateOffset(result, attributes.get(Attributes.offsetLarge.name()), OFFSET_LARGE);
+ generateOffset(result, attributes.get(Attributes.offsetExtraLarge.name()), OFFSET_EXTRA_LARGE);
return result.toArray(new BootstrapClass[result.size()]);
}
@@ -599,6 +685,16 @@ public enum BootstrapClass implements CssItem {
result.add(bootstrapClass);
}
}
+
+ private void generateOffset(final List<BootstrapClass> result, final Object offset, final BootstrapClass[] values) {
+ if (offset != null) {
+ int offsetIndex = Integer.valueOf((String) offset);
+ if (offsetIndex >= 0) {
+ offsetIndex = offsetIndex > 11 ? 11 : offsetIndex;
+ result.add(values[offsetIndex]);
+ }
+ }
+ }
}
public static BootstrapClass valueOf(LayoutToken layoutToken, Attributes attributes) {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/50-migration/96-migration/migration40.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/50-migration/96-migration/migration40.xhtml
index 49ceb51..9e09860 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/50-migration/96-migration/migration40.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/50-migration/96-migration/migration40.xhtml
@@ -103,16 +103,6 @@
For more information have a look at
<tc:link label="tc:bar" outcome="/content/20-component/050-container/60-bar/bar.xhtml"/></p>
</tc:section>
- <tc:section label="<tc:segmentLayoutConstraint>">
- <p>The offset concept changed in Bootstrap Beta.
- The attributes <code>offsetExtraSmall</code>, <code>offsetSmall</code>, <code>offsetMedium</code> and
- <code>offsetLarge</code> are <b>removed</b>
- from <code class="language-markup"><tc:segmentLayoutConstraint/></code>.</p>
- <p>Instead use the new
- <tc:link label="margin concept"
- link="/content/30-concept/16-layout/30-segment/segment-layout.xhtml#page:mainForm:marginConcept"/>.
- </p>
- </tc:section>
</tc:section>
<tc:section id="css" label="CSS / Bootstrap">
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
index 6a4a473..3b3a3ff 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
@@ -124,6 +124,41 @@
</tc:segmentLayout>
</tc:section>
+ <tc:section label="Offset">
+ <p>An offset can be set for the different proportions with the
+ <code class="language-markup"><tc:segmentLayoutConstraint/></code> tag which can have the attributes
+ <code>offsetExtraSmall</code>, <code>offsetSmall</code>,<code>offsetMedium</code>, <code>offsetLarge</code> and
+ <code>offsetExtraLarge</code>.</p>
+ <p>Possible values are from 1 to 11 for <code>offsetExtraSmall</code>.<br/>
+ For the other attributes possible values are from 0 to 11.<br/>
+ A <code>offsetMedium="0"</code> overwrite the offset from smaller proportions.</p>
+ <pre><code class="language-markup"><tc:segmentLayout extraSmall="2;2;2;2;2;2">
+ <tc:in value="1"/>
+ <tc:in value="2">
+ <tc:segmentLayoutConstraint offsetExtraSmall="1" offsetSmall="2"
+ offsetMedium="3" offsetLarge="4" offsetExtraLarge="5"/>
+ </tc:in>
+ ...
+</tc:segmentLayout></code></pre>
+ <tc:segmentLayout extraSmall="2;2;2;2;2;2">
+ <tc:in value="1"/>
+ <tc:in value="2">
+ <tc:segmentLayoutConstraint offsetExtraSmall="1" offsetSmall="2" offsetMedium="3" offsetLarge="4"
+ offsetExtraLarge="5"/>
+ </tc:in>
+ <tc:in value="3"/>
+ <tc:in value="4"/>
+ <tc:in value="5"/>
+ <tc:in value="6"/>
+ <tc:in value="7"/>
+ <tc:in value="8"/>
+ <tc:in value="9"/>
+ <tc:in value="10"/>
+ <tc:in value="11"/>
+ <tc:in value="12"/>
+ </tc:segmentLayout>
+ </tc:section>
+
<tc:section label="Overwrite default layout">
<p>The default layout and margins can be overwritten by the
<code class="language-markup"><tc:segmentLayoutConstraint/></code> tag.
--
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].