1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package org.apache.myfaces.tobago.renderkit.html; 21 22 /** 23 * Custom data attributes. 24 * These attributes may transport data to DOM which are not standardized. 25 * The format is "data-tobago-*" which is conform to HTML 5, but also works in older browsers. 26 */ 27 public enum DataAttributes implements MarkupLanguageAttributes { 28 29 /** 30 * Contains the closed tree icon or style. 31 */ 32 CLOSED("data-tobago-closed"), 33 34 /** 35 * The index of the column of a sheet. This index means the position of the rendered column. It can differ, if there 36 * are tc:column with rendered=false. 37 */ 38 COLUMN_INDEX("data-tobago-column-index"), 39 40 CONTENT("data-content"), 41 42 /** 43 * The context path of the application, may be needed in the Client. 44 */ 45 CONTEXT_PATH("data-tobago-context-path"), 46 47 DATE_TIME_I18N("data-tobago-date-time-i18n"), 48 49 /** 50 * Holds the day of a calendar control. 51 */ 52 DAY("data-tobago-day"), 53 54 /** 55 * Custom disabled attribute. Use for element, that don't have the disabled attribute. 56 */ 57 DISABLED("data-tobago-disabled"), 58 59 DISMISS("data-dismiss"), 60 61 /** 62 * Custom form attribute. Used to show the virtual form of the component. 63 */ 64 DEFAULT("data-tobago-default"), 65 66 DELAY("data-tobago-delay"), 67 68 FOR("data-tobago-for"), 69 70 /** 71 * Holds the id of the first row in a sheet. 72 */ 73 FIRST("data-tobago-first"), 74 75 /** 76 * Holds the first day of a week of a calendar control. 77 */ 78 FIRST_DAY_OF_WEEK("data-tobago-first-day-of-week"), 79 80 /** 81 * Defines a maximum value. 82 */ 83 LAYOUT("data-tobago-layout"), 84 85 /** 86 * Defines the depth level of a tree node. 87 */ 88 LEVEL("data-tobago-level"), 89 90 /** 91 * Defines a maximum value. 92 */ 93 MAX("data-tobago-max"), 94 95 /** 96 * Holds the month of a calendar control. 97 */ 98 MONTH("data-tobago-month"), 99 100 /** 101 * Holds the names of the months of a calendar control. 102 */ 103 MONTH_NAMES("data-tobago-month-names"), 104 105 /** 106 * Contains the open tree icon or style. 107 */ 108 OPEN("data-tobago-open"), 109 110 PARTIAL_IDS("data-tobago-partial-ids"), 111 112 PARTIAL_ACTION("data-tobago-partial-action"), 113 114 /** 115 * Custom attribute to describe a pattern, e. g. for an date input field. 116 */ 117 PATTERN("data-tobago-pattern"), 118 119 /** 120 * Custom reload attribute. Used to reload a panel. 121 */ 122 RELOAD("data-tobago-reload"), 123 124 SELECTION_MODE("data-tobago-selection-mode"), 125 126 /** 127 * The selectable attribute e. g. for trees. 128 * @deprecated since 5.0.0, please use {@link CustomAttributes#SELECTABLE} 129 */ 130 @Deprecated 131 SELECTABLE("data-tobago-selectable"), 132 133 /** 134 * Reference to a sheet. 135 */ 136 SHEET_ID("data-tobago-sheet-id"), 137 138 /** 139 * A way to transport style data in JSON format to the browser. With CSP the normal style attribute isn't allowed. 140 * @deprecated since 4.0.0. UIStyle now renders itself. 141 */ 142 @Deprecated 143 STYLE("data-tobago-style"), 144 145 SCROLL_PANEL("data-tobago-scroll-panel"), 146 147 SCROLL_POSITION("data-tobago-scroll-position"), 148 149 TARGET("data-target"), 150 151 TITLE("data-title"), 152 153 TO_PAGE("data-tobago-to-page"), 154 155 TODAY("data-tobago-today"), 156 157 TODAY_BUTTON("data-tobago-today-button"), 158 159 TOGGLE("data-toggle"), 160 161 TRANSITION("data-tobago-transition"), 162 163 /** 164 * Id of the parent node in a tree node. 165 * @deprecated since 5.0.0, please use {@link CustomAttributes#PARENT} 166 */ 167 @Deprecated 168 TREE_PARENT("data-tobago-tree-parent"), 169 170 /** 171 * Defines the unit, e. g. to differ between hours, minutes and seconds in a time control. 172 */ 173 UNIT("data-tobago-unit"), 174 175 /** 176 * Holds the value (for tags, that don't have a value in HTML). 177 */ 178 VALUE("data-tobago-value"), 179 180 /** 181 * Holds the year of a calendar control. 182 */ 183 YEAR("data-tobago-year"); 184 185 private final String value; 186 187 DataAttributes(final String value) { 188 this.value = value; 189 } 190 191 @Override 192 public String getValue() { 193 return value; 194 } 195 196 public static MarkupLanguageAttributes dynamic(final String withoutPrefix) { 197 return new MarkupLanguageAttributes() { 198 @Override 199 public String getValue() { 200 return "data-" + withoutPrefix; 201 } 202 }; 203 } 204 205 }