1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.primefaces.extensions.component.keynote;
23
24 import java.io.IOException;
25
26 import javax.faces.component.UIComponent;
27 import javax.faces.context.FacesContext;
28 import javax.faces.context.ResponseWriter;
29
30 import org.primefaces.extensions.util.Attrs;
31 import org.primefaces.renderkit.CoreRenderer;
32
33 public class KeynoteItemRenderer extends CoreRenderer {
34
35 public static final String ITEM_CLASS = "ui-keynote-item";
36 public static final String SPEAKER_NOTE_CLASS = "notes";
37
38 @Override
39 public void encodeEnd(final FacesContext context, final UIComponent component) throws IOException {
40 final ResponseWriter writer = context.getResponseWriter();
41 final UIKeynoteItem uiKeynoteItem = (UIKeynoteItem) component;
42
43 writer.startElement("section", null);
44
45 if (uiKeynoteItem.isMarkdown()) {
46 writer.writeAttribute("data-markdown", "", null);
47 writer.writeAttribute("data-separator", uiKeynoteItem.getSeparator(), null);
48 writer.writeAttribute("data-separator-vertical", uiKeynoteItem.getSeparatorVertical(), null);
49 }
50
51 if (uiKeynoteItem.getBackgroundColor() != null) {
52 writer.writeAttribute("data-background-color", uiKeynoteItem.getBackgroundColor(), null);
53 }
54 if (uiKeynoteItem.getBackgroundImage() != null) {
55 writer.writeAttribute("data-background-image", uiKeynoteItem.getBackgroundImage(), null);
56 }
57 if (uiKeynoteItem.getBackgroundSize() != null) {
58 writer.writeAttribute("data-background-size", uiKeynoteItem.getBackgroundSize(), null);
59 }
60 if (uiKeynoteItem.getBackgroundPosition() != null) {
61 writer.writeAttribute("data-background-position", uiKeynoteItem.getBackgroundPosition(), null);
62 }
63 if (uiKeynoteItem.getBackgroundRepeat() != null) {
64 writer.writeAttribute("data-background-repeat", uiKeynoteItem.getBackgroundRepeat(), null);
65 }
66 if (uiKeynoteItem.getBackgroundOpacity() != null) {
67 writer.writeAttribute("data-background-opacity", uiKeynoteItem.getBackgroundOpacity(), null);
68 }
69 if (uiKeynoteItem.getBackgroundVideo() != null) {
70 writer.writeAttribute("data-background-video", uiKeynoteItem.getBackgroundVideo(), null);
71 }
72 if (uiKeynoteItem.isBackgroundVideoLoop()) {
73 writer.writeAttribute("data-background-video-loop", "", null);
74 }
75 if (uiKeynoteItem.isBackgroundVideoMuted()) {
76 writer.writeAttribute("data-background-video-muted", "", null);
77 }
78 if (uiKeynoteItem.getVisibility() != null) {
79 writer.writeAttribute("data-visibility", uiKeynoteItem.getVisibility(), null);
80 }
81
82 if (uiKeynoteItem.getStyleClass() != null) {
83 writer.writeAttribute(Attrs.CLASS, ITEM_CLASS + " " + uiKeynoteItem.getStyleClass(), null);
84 }
85 else {
86 writer.writeAttribute(Attrs.CLASS, ITEM_CLASS, null);
87 }
88
89 if (uiKeynoteItem.isMarkdown()) {
90 writer.startElement("textarea", null);
91 writer.writeAttribute("data-template", "", null);
92 }
93
94
95 renderChildren(context, uiKeynoteItem);
96
97 if (uiKeynoteItem.isMarkdown()) {
98 writer.endElement("textarea");
99 }
100
101 if (uiKeynoteItem.getNote() != null) {
102 writer.startElement("aside", null);
103 writer.writeAttribute(Attrs.CLASS, SPEAKER_NOTE_CLASS, null);
104 writer.writeText(uiKeynoteItem.getNote(), null);
105 writer.endElement("aside");
106 }
107
108 writer.endElement("section");
109 }
110
111 @Override
112 public boolean getRendersChildren() {
113 return true;
114 }
115
116 @Override
117 public void encodeChildren(final FacesContext fc, final UIComponent component) {
118
119 }
120 }