@@ -157,203 +157,82 @@ public T withClasses(String... classes) {
157157 return attr (Attr .CLASS , sb .toString ().trim ());
158158 }
159159
160- public T isAutoComplete () {
161- return attr (Attr .AUTOCOMPLETE , null );
162- }
163-
164- public T isAutoFocus () {
165- return attr (Attr .AUTOFOCUS , null );
166- }
167-
168- public T isHidden () {
169- return attr (Attr .HIDDEN , null );
170- }
171-
172- public T isRequired () {
173- return attr (Attr .REQUIRED , null );
174- }
175-
176- public T withAlt (String alt ) {
177- return attr (Attr .ALT , alt );
178- }
179-
180- public T withAction (String action ) {
181- return attr (Attr .ACTION , action );
182- }
183-
184- public T withCharset (String charset ) {
185- return attr (Attr .CHARSET , charset );
186- }
187-
188- public T withClass (String className ) {
189- return attr (Attr .CLASS , className );
190- }
191-
192- public T withContent (String content ) {
193- return attr (Attr .CONTENT , content );
194- }
195-
196- public T withDir (String dir ) {
197- return attr (Attr .DIR , dir );
198- }
199-
200- public T withHref (String href ) {
201- return attr (Attr .HREF , href );
202- }
203-
204- public T withId (String id ) {
205- return attr (Attr .ID , id );
206- }
207-
208- public T withData (String dataAttr , String value ) {
209- return attr (Attr .DATA + "-" + dataAttr , value );
210- }
211-
212- public T withLang (String lang ) {
213- return attr (Attr .LANG , lang );
214- }
215-
216- public T withMethod (String method ) {
217- return attr (Attr .METHOD , method );
218- }
219-
220- public T withName (String name ) {
221- return attr (Attr .NAME , name );
222- }
223-
224- public T withPlaceholder (String placeholder ) {
225- return attr (Attr .PLACEHOLDER , placeholder );
226- }
227-
228- public T withTarget (String target ) {
229- return attr (Attr .TARGET , target );
230- }
231-
232- public T withTitle (String title ) {
233- return attr (Attr .TITLE , title );
234- }
235-
236- public T withType (String type ) {
237- return attr (Attr .TYPE , type );
238- }
239-
240- public T withRel (String rel ) {
241- return attr (Attr .REL , rel );
242- }
243-
244- public T withRole (String role ) {
245- return attr (Attr .ROLE , role );
246- }
160+ /*
161+ Tag.java contains all Global Attributes, Attributes which are
162+ valid on all HTML Tags. Reference:
163+ https://www.w3schools.com/tags/ref_standardattributes.asp
164+ Attributes:
165+
166+ accesskey
167+ class
168+ contenteditable
169+ data-*
170+ dir
171+ draggable
172+ hidden
173+ id
174+ lang
175+ spellcheck
176+ style
177+ tabindex
178+ title
179+ translate
180+ */
247181
248- public T withSrc (String src ) {
249- return attr (Attr .SRC , src );
250- }
182+ public T withAccesskey (String accesskey ){ return attr (Attr .ACCESSKEY , accesskey ); }
251183
252- public T withStyle (String style ) {
253- return attr (Attr .STYLE , style );
254- }
184+ public T withClass (String className ) { return attr (Attr .CLASS , className ); }
255185
256- public T withStep (String step ) {
257- return attr (Attr .STEP , step );
258- }
186+ public T isContenteditable (){ return attr (Attr .CONTENTEDITABLE , "true" ); }
259187
260- public T withValue (String value ) {
261- return attr (Attr .VALUE , value );
262- }
188+ public T withData (String dataAttr , String value ) { return attr (Attr .DATA + "-" + dataAttr , value ); }
263189
264- public T withCondAutoComplete (boolean condition ) {
265- return condAttr (condition , Attr .AUTOCOMPLETE , null );
266- }
190+ public T withDir (String dir ) { return attr (Attr .DIR , dir ); }
267191
268- public T withCondAutoFocus (boolean condition ) {
269- return condAttr (condition , Attr .AUTOFOCUS , null );
270- }
192+ public T isDraggable (){ return attr (Attr .DRAGGABLE , "true" ); }
271193
272- public T withCondHidden (boolean condition ) {
273- return condAttr (condition , Attr .HIDDEN , null );
274- }
194+ public T isHidden () { return attr (Attr .HIDDEN , null ); }
275195
276- public T withCondRequired (boolean condition ) {
277- return condAttr (condition , Attr .REQUIRED , null );
278- }
196+ public T withId (String id ) { return attr (Attr .ID , id ); }
279197
280- public T withCondAlt (boolean condition , String alt ) {
281- return condAttr (condition , Attr .ALT , alt );
282- }
198+ public T withLang (String lang ) { return attr (Attr .LANG , lang ); }
283199
284- public T withCondAction (boolean condition , String action ) {
285- return condAttr (condition , Attr .ACTION , action );
286- }
200+ public T isSpellcheck (){ return attr (Attr .SPELLCHECK , "true" ); }
287201
288- public T withCharset (boolean condition , String charset ) {
289- return condAttr (condition , Attr .CHARSET , charset );
290- }
202+ public T withStyle (String style ) { return attr (Attr .STYLE , style ); }
291203
292- public T withCondClass (boolean condition , String className ) {
293- return condAttr (condition , Attr .CLASS , className );
294- }
204+ public T withTabindex (int index ){ return attr (Attr .TABINDEX , index ); }
295205
296- public T withCondContent (boolean condition , String content ) {
297- return condAttr (condition , Attr .CONTENT , content );
298- }
206+ public T withTitle (String title ) { return attr (Attr .TITLE , title ); }
299207
300- public T withCondDir (boolean condition , String dir ) {
301- return condAttr (condition , Attr .DIR , dir );
302- }
208+ public T isTranslate (){ return attr (Attr .TRANSLATE , "yes" ); }
303209
304- public T withCondHref (boolean condition , String href ) {
305- return condAttr (condition , Attr .HREF , href );
306- }
210+ // ----- start of withCond$ATTR variants -----
211+ public T withCondAccessKey (boolean condition , String accesskey ){ return condAttr (condition , Attr .ACCESSKEY , accesskey ); }
307212
308- public T withCondId (boolean condition , String id ) {
309- return condAttr (condition , Attr .ID , id );
310- }
213+ public T withCondClass (boolean condition , String className ) { return condAttr (condition , Attr .CLASS , className ); }
311214
312- public T withCondData (boolean condition , String dataAttr , String value ) {
313- return condAttr (condition , Attr .DATA + "-" + dataAttr , value );
314- }
215+ public T withCondContenteditable (boolean condition ){ return attr (Attr .CONTENTEDITABLE , (condition )?"true" :"false" );}
315216
316- public T withCondLang (boolean condition , String lang ) {
317- return condAttr (condition , Attr .LANG , lang );
318- }
217+ public T withCondData (boolean condition , String dataAttr , String value ) { return condAttr (condition , Attr .DATA + "-" + dataAttr , value ); }
319218
320- public T withCondMethod (boolean condition , String method ) {
321- return condAttr (condition , Attr .METHOD , method );
322- }
219+ public T withCondDir (boolean condition , String dir ) { return condAttr (condition , Attr .DIR , dir ); }
323220
324- public T withCondName (boolean condition , String name ) {
325- return condAttr (condition , Attr .NAME , name );
326- }
221+ public T withCondDraggable (boolean condition ){ return attr (Attr .DRAGGABLE , (condition )?"true" :"false" ); }
327222
328- public T withCondPlaceholder (boolean condition , String placeholder ) {
329- return condAttr (condition , Attr .PLACEHOLDER , placeholder );
330- }
223+ public T withCondHidden (boolean condition ) { return condAttr (condition , Attr .HIDDEN , null ); }
331224
332- public T withCondTarget (boolean condition , String target ) {
333- return condAttr (condition , Attr .TARGET , target );
334- }
225+ public T withCondId (boolean condition , String id ) { return condAttr (condition , Attr .ID , id ); }
335226
336- public T withCondTitle (boolean condition , String title ) {
337- return condAttr (condition , Attr .TITLE , title );
338- }
227+ public T withCondLang (boolean condition , String lang ) { return condAttr (condition , Attr .LANG , lang ); }
339228
340- public T withCondType (boolean condition , String type ) {
341- return condAttr (condition , Attr .TYPE , type );
342- }
229+ public T withCondSpellcheck (boolean condition ){ return attr (Attr .SPELLCHECK , (condition )?"true" :"false" ); }
343230
344- public T withCondRel (boolean condition , String rel ) {
345- return condAttr (condition , Attr .REL , rel );
346- }
231+ public T withCondStyle (boolean condition , String style ) { return condAttr (condition , Attr .STYLE , style ); }
347232
348- public T withCondSrc (boolean condition , String src ) {
349- return condAttr (condition , Attr .SRC , src );
350- }
233+ public T withCondTabindex (boolean condition , int index ){ return condAttr (condition , Attr .TABINDEX , index +"" ); }
351234
352- public T withCondStyle (boolean condition , String style ) {
353- return condAttr (condition , Attr .STYLE , style );
354- }
235+ public T withCondTitle (boolean condition , String title ) { return condAttr (condition , Attr .TITLE , title ); }
355236
356- public T withCondValue (boolean condition , String value ) {
357- return condAttr (condition , Attr .VALUE , value );
358- }
237+ public T withCondTranslate (boolean condition ){ return attr (Attr .TRANSLATE , (condition )?"yes" :"no" ); }
359238}
0 commit comments