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:29 UTC
[myfaces-tobago] 02/02: TOBAGO-1004: Using custom attributes for
HTML in a HTML5 compliant way (data-*) * refactor switchtype
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 938cfaa9c2d66776a826840b51feb58b9709422d
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Aug 15 11:41:18 2018 +0200
TOBAGO-1004: Using custom attributes for HTML in a HTML5 compliant way (data-*)
* refactor switchtype
---
.../tobago/internal/renderkit/renderer/TabGroupRenderer.java | 2 +-
.../org/apache/myfaces/tobago/renderkit/html/DataAttributes.java | 8 ++++++++
.../org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java | 3 +++
.../tobago/standard/tobago-bootstrap/_version/js/tobago-tab.js | 2 +-
4 files changed, 13 insertions(+), 2 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 320a9b3..1b36788 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
@@ -157,7 +157,7 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
tabGroup.getCustomClass(),
markup != null && markup.contains(Markup.SPREAD) ? TobagoClass.SPREAD : null);
HtmlRendererUtils.writeDataAttributes(facesContext, writer, tabGroup);
- writer.writeAttribute(HtmlAttributes.SWITCHTYPE, switchType.name(), false);
+ writer.writeAttribute(DataAttributes.SWITCH_TYPE, switchType.name(), false);
writer.startElement(HtmlElements.INPUT);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
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 f98f28f..b1cd0a7 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,14 @@ public enum DataAttributes implements MarkupLanguageAttributes {
SUGGEST_UPDATE("data-tobago-suggest-update"),
+ /**
+ * The mode of the tab switch: client, reloadTab, reloadPage.
+ */
+ SWITCH_TYPE("data-tobago-switch-type"),
+
+ /**
+ * The index of the tab inside the tab group.
+ */
TAB_GROUP_INDEX("data-tobago-tab-group-index"),
TARGET("data-target"),
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 436609f..69279c5 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
@@ -130,7 +130,10 @@ public enum HtmlAttributes implements MarkupLanguageAttributes {
TABGROUPINDEX("tabgroupindex"),
/**
* The mode of the tab switch: client, reloadTab, reloadPage.
+ *
+ * @deprecated since 4.3.0, please use {@link DataAttributes#SWITCH_TYPE}
*/
+ @Deprecated
SWITCHTYPE("switchtype");
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 17d5e3a..e6f0997 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
@@ -39,7 +39,7 @@ Tobago.TabGroup.init = function (elements) {
$hiddenInput.val(tabGroupIndex);
- if ($tabGroup.attr("switchtype") === "client") {
+ if ($tabGroup.data("tobago-switch-type") === "client") {
//remove data-markup, markup-css-class and .active from tabs/tab-content
$tabGroup.find(".tobago-tab .nav-link.active").each(function () {