You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2018/08/15 09:41:28 UTC
[myfaces-tobago] 01/02: TOBAGO-1004: Using custom attributes for
HTML in a HTML5 compliant way (data-*) * refactor tabgroupindex
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 26bfbb8e21a1dbef8cd9fa173207be8215ff9685
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Aug 15 11:30:55 2018 +0200
TOBAGO-1004: Using custom attributes for HTML in a HTML5 compliant way (data-*)
* refactor tabgroupindex
---
.../internal/renderkit/renderer/TabGroupRenderer.java | 4 ++--
.../myfaces/tobago/renderkit/html/DataAttributes.java | 2 ++
.../myfaces/tobago/renderkit/html/HtmlAttributes.java | 3 +++
.../content/40-test/2500-tab/tabgroup-style.test.js | 16 ++++++++--------
.../90000-attic/gridLayout/tabGroup-auto-auto.xhtml | 2 +-
.../40-test/90000-attic/gridLayout/tabGroup-auto.xhtml | 2 +-
.../90000-attic/gridLayout/tabGroup-relative.xhtml | 2 +-
.../standard/tobago-bootstrap/_version/js/tobago-tab.js | 4 ++--
8 files changed, 20 insertions(+), 15 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 9a8e963..320a9b3 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
@@ -258,7 +258,7 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
barFacet != null ? TobagoClass.TAB__BAR_FACET : null,
tab.getCustomClass());
writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.PRESENTATION.toString(), false);
- writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);
+ writer.writeAttribute(DataAttributes.TAB_GROUP_INDEX, index);
final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, tab);
if (title != null) {
writer.writeAttribute(HtmlAttributes.TITLE, title, true);
@@ -352,7 +352,7 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.TABPANEL.toString(), false);
writer.writeIdAttribute(getTabPanelId(facesContext, tab));
- writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);
+ writer.writeAttribute(DataAttributes.TAB_GROUP_INDEX, index);
tab.encodeAll(facesContext);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
index 8125575..f98f28f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
@@ -188,6 +188,8 @@ public enum DataAttributes implements MarkupLanguageAttributes {
SUGGEST_UPDATE("data-tobago-suggest-update"),
+ TAB_GROUP_INDEX("data-tobago-tab-group-index"),
+
TARGET("data-target"),
TITLE("data-title"),
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java
index 5549d81..436609f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java
@@ -123,7 +123,10 @@ public enum HtmlAttributes implements MarkupLanguageAttributes {
/**
* The index of the tab inside the tab group.
+ *
+ * @deprecated since 4.3.0, please use {@link DataAttributes#TAB_GROUP_INDEX}
*/
+ @Deprecated
TABGROUPINDEX("tabgroupindex"),
/**
* The mode of the tab switch: client, reloadTab, reloadPage.
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js
index 4f36139..ddabb54 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-QUnit.test("test numbers of tabgroupindex", function (assert) {
+QUnit.test("test numbers of tab-group-index", function (assert) {
var $tabOne = jQueryFrame("#page\\:mainForm\\:tabOne");
var $tabTwo = jQueryFrame("#page\\:mainForm\\:tabTwo");
var $tabThree = jQueryFrame("#page\\:mainForm\\:tabThree");
@@ -27,16 +27,16 @@ QUnit.test("test numbers of tabgroupindex", function (assert) {
var $tabFourContent = jQueryFrame("#page\\:mainForm\\:tabFour\\:\\:content");
var $tabFiveContent = jQueryFrame("#page\\:mainForm\\:tabFive\\:\\:content");
- assert.equal($tabOne.attr("tabgroupindex"), "0");
- assert.equal($tabTwo.attr("tabgroupindex"), "1");
+ assert.equal($tabOne.data("tobago-tab-group-index"), "0");
+ assert.equal($tabTwo.data("tobago-tab-group-index"), "1");
assert.equal($tabThree.length, 0, "Tab three is not rendered");
- assert.equal($tabFour.attr("tabgroupindex"), "3");
- assert.equal($tabFive.attr("tabgroupindex"), "4");
+ assert.equal($tabFour.data("tobago-tab-group-index"), "3");
+ assert.equal($tabFive.data("tobago-tab-group-index"), "4");
- assert.equal($tabOneContent.attr("tabgroupindex"), "0");
- assert.equal($tabTwoContent.attr("tabgroupindex"), "1");
+ assert.equal($tabOneContent.data("tobago-tab-group-index"), "0");
+ assert.equal($tabTwoContent.data("tobago-tab-group-index"), "1");
assert.equal($tabThreeContent.length, 0, "Tab three content is not rendered");
- assert.equal($tabFiveContent.attr("tabgroupindex"), "4");
+ assert.equal($tabFiveContent.data("tobago-tab-group-index"), "4");
assert.ok($tabOne.hasClass("tobago-tab-markup-selected"));
assert.notOk($tabTwo.hasClass("tobago-tab-markup-selected"));
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto-auto.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto-auto.xhtml
index 7c0d593..45ada47 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto-auto.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto-auto.xhtml
@@ -61,7 +61,7 @@
<tc:script onload="TobagoAssert.assertLayout('page:rows:a-2', 6, 81, 100, 50);"/>
<!--click the tab to display the elements, they can only be measured if they are not hidden.-->
- <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[tabgroupindex=1]').click();"/>
+ <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[data-tobago-tab-group-index=1]').click();"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-3', 6, 26, 100, 50);"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-4', 111, 26, 100, 50);"/>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto.xhtml
index 334ce6f..50b758c 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-auto.xhtml
@@ -61,7 +61,7 @@
<tc:script onload="TobagoAssert.assertLayout('page:rows:a-2', 6, 81, 100, 50);"/>
<!--click the tab to display the elements, they can only be measured if they are not hidden.-->
- <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[tabgroupindex=1]').click();"/>
+ <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[data-tobago-tab-group-index=1]').click();"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-3', 6, 26, 100, 50);"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-4', 111, 26, 100, 50);"/>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-relative.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-relative.xhtml
index a35c2fe..24dcc46 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-relative.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/gridLayout/tabGroup-relative.xhtml
@@ -48,7 +48,7 @@
<tc:script onload="TobagoAssert.assertLayout('page:rows:a-2', 6, 162, 588, 132);"/>
<!--click the tab to display the elements, they can only be measured if they are not hidden.-->
- <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[tabgroupindex=1]').click();"/>
+ <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:tabGroup')).find('.tobago-tab[data-tobago-tab-group-index=1]').click();"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-3', 6, 26, 291, 268);"/>
<tc:script onload="TobagoAssert.assertLayout('page:columns:a-4', 302, 26, 292, 268);"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tab.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tab.js
index 6952ea8..17d5e3a 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tab.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tab.js
@@ -35,7 +35,7 @@ Tobago.TabGroup.init = function (elements) {
$tabGroup.find(".tobago-tabGroup-header:first .tobago-tab .nav-link:not(.disabled)").click(function () {
var $navLink = jQuery(this);
var $tab = $navLink.parent(".tobago-tab");
- var tabGroupIndex = $tab.attr("tabgroupindex");
+ var tabGroupIndex = $tab.data("tobago-tab-group-index");
$hiddenInput.val(tabGroupIndex);
@@ -57,7 +57,7 @@ Tobago.TabGroup.init = function (elements) {
Tobago.Utils.addDataMarkup($tab, markupString);
$tab.addClass(markupCssClass);
$navLink.addClass("active");
- $tabContent.find(".tobago-tab-content.tab-pane[tabgroupindex=" + tabGroupIndex + "]").addClass("active");
+ $tabContent.find(".tobago-tab-content.tab-pane[data-tobago-tab-group-index=" + tabGroupIndex + "]").addClass("active");
}
});
});