myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1886 Markup CSS classes are not rendered for tab-content
Date Wed, 04 Apr 2018 09:59:58 GMT
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 9743019  TOBAGO-1886 Markup CSS classes are not rendered for tab-content
9743019 is described below

commit 9743019a931418274df38fecf39a5144bedec3fc
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Wed Apr 4 11:59:50 2018 +0200

    TOBAGO-1886 Markup CSS classes are not rendered for tab-content
    
    * fix: markup CSS classes are now rendered for tab-content
    * add a test
---
 .../renderkit/renderer/TabGroupRenderer.java       | 12 ++++++-----
 .../content/20-component/070-tab/tab.test.js       | 18 +++++++++++++---
 .../webapp/content/20-component/070-tab/tab.xhtml  | 24 +++++++++++-----------
 3 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
index 21088ce..9a8e963 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
@@ -337,18 +337,20 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
     writer.startElement(HtmlElements.DIV);
     writer.writeClassAttribute(BootstrapClass.CARD_BODY, BootstrapClass.TAB_CONTENT);
     int index = 0;
-    for (final UIComponent tab : tabGroup.getChildren()) {
-      if (tab instanceof UITab) {
-        if (tab.isRendered() && (switchType == SwitchType.client || index == activeIndex)
-            && !((UITab) tab).isDisabled()) {
+    for (final UIComponent child : tabGroup.getChildren()) {
+      if (child instanceof UITab) {
+        final UITab tab = (UITab) child;
+        if (tab.isRendered() && (switchType == SwitchType.client || index == activeIndex)
&& !tab.isDisabled()) {
+          final Markup markup = tab.getMarkup();
 
           writer.startElement(HtmlElements.DIV);
           writer.writeClassAttribute(
               TobagoClass.TAB__CONTENT,
+              TobagoClass.TAB__CONTENT.createMarkup(markup),
               BootstrapClass.TAB_PANE,
               index == activeIndex ? BootstrapClass.ACTIVE : null);
           writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.TABPANEL.toString(),
false);
-          writer.writeIdAttribute(getTabPanelId(facesContext, (UITab) tab));
+          writer.writeIdAttribute(getTabPanelId(facesContext, tab));
 
           writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.test.js
b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.test.js
index 46d9599..e3ec8fc 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.test.js
@@ -16,7 +16,7 @@
  */
 
 QUnit.test("Client: Select Tab 3", function (assert) {
-  assert.expect(6);
+  assert.expect(10);
 
   var $hiddenInput = jQueryFrame("#page\\:mainForm\\:tabGroupClient\\:\\:activeIndex");
   var $tab1 = jQueryFrame("#page\\:mainForm\\:tab1Client");
@@ -26,16 +26,20 @@ QUnit.test("Client: Select Tab 3", function (assert) {
   assert.equal($hiddenInput.val(), 0);
   assert.ok($tab1.hasClass("tobago-tab-markup-selected"));
   assert.notOk($tab3.hasClass("tobago-tab-markup-selected"));
+  assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+  assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 
   $tab3link.click();
 
   assert.equal($hiddenInput.val(), 3);
   assert.notOk($tab1.hasClass("tobago-tab-markup-selected"));
   assert.ok($tab3.hasClass("tobago-tab-markup-selected"));
+  assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+  assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 });
 
 QUnit.test("Ajax: Select Tab 3", function (assert) {
-  assert.expect(6);
+  assert.expect(10);
   var done = assert.async();
   var step = 1;
 
@@ -47,6 +51,8 @@ QUnit.test("Ajax: Select Tab 3", function (assert) {
   assert.equal($hiddenInput.val(), 0);
   assert.ok($tab1.hasClass("tobago-tab-markup-selected"));
   assert.notOk($tab3.hasClass("tobago-tab-markup-selected"));
+  assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+  assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 
   $tab3link.click();
 
@@ -61,6 +67,8 @@ QUnit.test("Ajax: Select Tab 3", function (assert) {
     assert.equal($hiddenInput.val(), 3);
     assert.notOk($tab1.hasClass("tobago-tab-markup-selected"));
     assert.ok($tab3.hasClass("tobago-tab-markup-selected"));
+    assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+    assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 
     step++;
     done();
@@ -68,7 +76,7 @@ QUnit.test("Ajax: Select Tab 3", function (assert) {
 });
 
 QUnit.test("FullReload: Select Tab 3", function (assert) {
-  assert.expect(6);
+  assert.expect(10);
   var done = assert.async();
   var step = 1;
 
@@ -80,6 +88,8 @@ QUnit.test("FullReload: Select Tab 3", function (assert) {
   assert.equal($hiddenInput.val(), 0);
   assert.ok($tab1.hasClass("tobago-tab-markup-selected"));
   assert.notOk($tab3.hasClass("tobago-tab-markup-selected"));
+  assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+  assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 
   $tab3link.click();
 
@@ -92,6 +102,8 @@ QUnit.test("FullReload: Select Tab 3", function (assert) {
       assert.equal($hiddenInput.val(), 3);
       assert.notOk($tab1.hasClass("tobago-tab-markup-selected"));
       assert.ok($tab3.hasClass("tobago-tab-markup-selected"));
+      assert.ok($tab1.hasClass("tobago-tab-markup-one"));
+      assert.ok($tab3.hasClass("tobago-tab-markup-three"));
 
       step++;
       done();
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.xhtml
index 7308463..045e171 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/tab.xhtml
@@ -32,16 +32,16 @@
   <tc:section label="#{demoBundle.tab_client}">
     <pre><code class="language-markup">&lt;tc:tabGroup></code></pre>
     <tc:tabGroup id="tabGroupClient">
-      <tc:tab id="tab1Client" label="Tab One">
+      <tc:tab id="tab1Client" label="Tab One" markup="one">
         Content of tab one.
       </tc:tab>
-      <tc:tab id="tab2Client" label="Tab Two" disabled="true">
+      <tc:tab id="tab2Client" label="Tab Two" disabled="true" markup="two">
         Content of tab two.
       </tc:tab>
-      <tc:tab id="tabNoneClient" label="Tab Not Rendered" rendered="false">
+      <tc:tab id="tabNoneClient" label="Tab Not Rendered" rendered="false" markup="none">
         This tab shouldn't be rendered.
       </tc:tab>
-      <tc:tab id="tab3Client" label="Tab Three">
+      <tc:tab id="tab3Client" label="Tab Three" markup="three">
         Content of tab three.
       </tc:tab>
     </tc:tabGroup>
@@ -50,16 +50,16 @@
   <tc:section label="#{demoBundle.tab_ajax}">
     <pre><code class="language-markup">&lt;tabGroup switchType="reloadTab"></code></pre>
     <tc:tabGroup id="tabGroupAjax" switchType="reloadTab">
-      <tc:tab id="tab1Ajax" label="Tab One">
+      <tc:tab id="tab1Ajax" label="Tab One" markup="one">
         Content of tab one.
       </tc:tab>
-      <tc:tab id="tab2Ajax" label="Tab Two" disabled="true">
+      <tc:tab id="tab2Ajax" label="Tab Two" disabled="true" markup="two">
         Content of tab two.
       </tc:tab>
-      <tc:tab id="tabNoneAjax" label="Tab Not Rendered" rendered="false">
+      <tc:tab id="tabNoneAjax" label="Tab Not Rendered" rendered="false" markup="none">
         This tab shouldn't be rendered.
       </tc:tab>
-      <tc:tab id="tab3Ajax" label="Tab Three">
+      <tc:tab id="tab3Ajax" label="Tab Three" markup="three">
         Content of tab three.
       </tc:tab>
     </tc:tabGroup>
@@ -68,16 +68,16 @@
   <tc:section label="#{demoBundle.tab_server}">
     <pre><code class="language-markup">&lt;tabGroup switchType="reloadPage"></code></pre>
     <tc:tabGroup id="tabGroupFullReload" switchType="reloadPage">
-      <tc:tab id="tab1FullReload" label="Tab One">
+      <tc:tab id="tab1FullReload" label="Tab One" markup="one">
         Content of tab one.
       </tc:tab>
-      <tc:tab id="tab2FullReload" label="Tab Two" disabled="true">
+      <tc:tab id="tab2FullReload" label="Tab Two" disabled="true" markup="two">
         Content of tab two.
       </tc:tab>
-      <tc:tab id="tabNoneFullReload" label="Tab Not Rendered" rendered="false">
+      <tc:tab id="tabNoneFullReload" label="Tab Not Rendered" rendered="false" markup="none">
         This tab shouldn't be rendered.
       </tc:tab>
-      <tc:tab id="tab3FullReload" label="Tab Three">
+      <tc:tab id="tab3FullReload" label="Tab Three" markup="three">
         <f:facet name="bar">
           <tc:link image="fa-remove" omit="true">
             <tc:dataAttribute name="alert-text" value="Not implemented yet!"/>

-- 
To stop receiving notification emails like this one, please contact
hnoeth@apache.org.

Mime
View raw message