-
Notifications
You must be signed in to change notification settings - Fork 33
/
Image.xhtml
188 lines (161 loc) · 10.6 KB
/
Image.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition template="/applayout/pageTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="jakarta.faces.html"
xmlns:f="jakarta.faces.core"
xmlns:b="http://bootsfaces.net/ui"
xmlns:ui="jakarta.faces.facelets">
<ui:define name="content-navigator">
<b:listLinks>
<b:navLink href="#image" value="Image (<b:image />)" />
<b:navLink href="#basic_usage" value="Basic usage" />
<b:navLink href="#progress_bar" value="Progress bar" />
<b:navLink href="#advanced_usage" value="Advanced usage" />
<b:navLink href="#don" value="Don't use both" />
<b:navLink href="#responsive_attributes" value="Responsive attributes" />
<b:navLink href="#reference_section" value="Reference section" />
</b:listLinks>
</ui:define>
<ui:define name="content">
<style>
td {
padding: 8px;
}
</style>
<h1><a id="image">Image (<b:image />)</a><b:badge value="since 0.8.0" /></h1>
<p>The <code><b:image /></code> component is just that: an image. Plus the unified AJAX engine of BootsFaces, and Bootstrap tooltips.</p>
<h2><a id="basic_usage">Basic usage</a></h2>
<b:panel title="Live preview" look="info" collapsible="false">
<b:image name="images/bootstrap/carousel/Valladolid-parque-3.jpg" tooltip="Ain't he a beauty?" tooltipPosition="right"/>
<f:facet name="footer">
<strong>JSF markup: </strong>
<b:panel>
<script type="syntaxhighlighter" class="brush: xml; toolbar: false;gutter: false; first-line: 1">
<![CDATA[
<b:image name="bootstrap/carousel/Valladolid-parque-3.jpg" tooltip="Ain't he a beauty?" tooltipPosition="right"/>
]]>
</script>
</b:panel>
</f:facet>
</b:panel>
<p>Alternatively, you can use the JSF resource libraries, just the way you're used to from <code><h:graphicImage /></code>;</p>
<b:panel title="Live preview" look="info" collapsible="false">
<b:image library="images" name="bootstrap/Valladolid4.png" tooltip="Great water fountain in Valladolid, Spain" />
<f:facet name="footer">
<strong>JSF markup: </strong>
<b:panel>
<script type="syntaxhighlighter" class="brush: xml; toolbar: false;gutter: false; first-line: 1">
<![CDATA[
<b:image library="images" name="bootstrap/Valladolid4.png" tooltip="Great water fountain in Valladolid, Spain" />
]]>
</script>
</b:panel>
</f:facet>
</b:panel>
<h2><a id="progress_bar">Progress bar</a></h2>
<p>Sometime your images load slowly. BootsFaces offers a JavaScript API tracking the progress. You can use it to implement
a progress bar. If you benefit from a fast internet connection, the example below is to fast to show a progress bar.
However, you can track the progress by opening your browser's web developer tools: </p>
<ul>
<li>The console window should display at least threee progress messages (and probably more).</li>
<li>If you're using Chrome, open the network tab, deactivate the cache and activate throttling. Set the speed of the
connection to "fast 3G". Now this page loads very slow (more than 10 seconds until the page starts to be rendered),
so you can watch the progress bar moving slowly to 100%. (Other browsers probably have similar features).</li>
</ul>
<b:panel title="Live preview" look="info" collapsible="false">
<b:image library="images" name="bootstrap/Valladolid3.png" tooltip="Slow loading image" tooltipPosition="right"
onloadstart="console.log('start loading ' + img.completedPercentage + '%');"
onloadend="console.log('finished loading ' + img.completedPercentage + '%');;$('.imageProgressBar').parent().hide();"
onprogress="console.log('continue loading ' + img.completedPercentage + '%');$('.imageProgressBar')[0].setAttribute('style', 'width:' + img.completedPercentage + '%');$('.imageProgressBar')[0].innerText= img.completedPercentage + '%';"
/>
<b:progressBar value="90" look="info" content-class="imageProgressBar"/>
<f:facet name="footer">
<strong>JSF markup: </strong>
<b:panel>
<script type="syntaxhighlighter" class="brush: xml; toolbar: false;gutter: false; first-line: 1">
<![CDATA[
<b:image library="images" name="bootstrap/Valladolid3.png" tooltip="Slow loading image" tooltipPosition="right"
onloadstart="console.log('start loading ' + img.completedPercentage + '%');"
onloadend="console.log('finished loading ' + img.completedPercentage + '%');;$('.imageProgressBar').parent().hide();"
onprogress="console.log('continue loading ' + img.completedPercentage + '%');$('.imageProgressBar')[0].setAttribute('style', 'width:' + img.completedPercentage + '%');$('.imageProgressBar')[0].innerText= img.completedPercentage + '%';"
style="width:100%"
/>
<b:progressBar value="90" look="info" content-class="imageProgressBar"/>
]]>
</script>
</b:panel>
</f:facet>
</b:panel>
<h2><a id="advanced_usage">Advanced usage</a></h2>
<p>You can use the standard JavaScript callbacks to call both JavaScript function and Java methods (via AJAX).
See <a target="#" href="http://www.angularfaces.net/BootsFacesChess-1.0.0-SNAPSHOT/">BootsFaces chess</a>
for a full-blown demo. These following demonstrate how BootsFaces chess uses AJAX to implement drag and drop:</p>
<b:panel title="Live preview" look="info" collapsible="false">
Missing live preview
<f:facet name="footer">
<strong>JSF markup: </strong>
<b:panel>
<script type="syntaxhighlighter" class="brush: xml; toolbar: false;gutter: false; first-line: 1">
<![CDATA[
<b:image value="#{image}"
style="position: absolute; top: 0px; left: 0px;width: 68px; height: 68px;#{board.getOpacity(rowStatus.index,columnStatus.index)}"
onclick="ajax:board.onclick(rowStatus.index,columnStatus.index)"
oncomplete="document.getElementById('form:opponent').click()"
ondragstart="ajax:board.ondragstart(rowStatus.index,columnStatus.index)"
ondragover="if (targets.indexOf('(#{rowStatus.index},#{columnStatus.index})')>=0) event.preventDefault();"
ondrop="ajax:board.ondragdrop(rowStatus.index,columnStatus.index)"
update="@form :messages" />
]]>
</script>
</b:panel>
</f:facet>
</b:panel>
<b:well>
</b:well>
<h1><a id="don">Don't use both</a><code>value</code> and <code>name/library</code></h1>
<p>Until BootsFaces 0.8.5, there was an error in the documentation which lead some developers to use both
<code>name</code> and <code>value</code>. Both attributes belong to different resource loading mechanisms,
so this caused <code>RES_NOT_FOUND</code> errors. Since BootsFaces 0.8.6, the value attributes is evaluated first.
If both attributes are provided, BootsFaces displays a warning in the logfile (only in the development stage).</p>
<h1><a id="responsive_attributes">Responsive attributes</a><b:badge value="since 0.9.0" /></h1>
<p>The image supports the full range of responsive attributes, such as <code>col-*</code>, <code>visible</code>
and <code>hidden</code>:</p>
<b:panel title="Live preview" look="info" collapsible="false">
<b:row>
<b:image small-screen="one-third" library="images" name="bootstrap/carousel/Valladolid-parque-1.jpg"
tooltip="small-screen='one-third'"/>
<b:image small-screen="one-third" library="images" name="bootstrap/carousel/Valladolid-parque-2.jpg"
tooltip="small-screen='one-third'"/>
<b:image small-screen="one-third" hidden="tiny-screen" library="images" name="bootstrap/carousel/Valladolid-parque-3.jpg"
tooltip="small-screen='one-third' hidden='tiny-screen'"/>
</b:row>
<f:facet name="footer">
<strong>JSF markup: </strong>
<b:panel>
<script type="syntaxhighlighter" class="brush: xml; toolbar: false;gutter: false; first-line: 1">
<![CDATA[
<b:row>
<b:image small-screen="one-third" library="images" name="bootstrap/carousel/Valladolid-parque-1.jpg" tooltip="small-screen='one-third'"/>
<b:image small-screen="one-third" library="images" name="bootstrap/carousel/Valladolid-parque-2.jpg" tooltip="small-screen='one-third'"/>
<b:image small-screen="one-third" hidden="tiny-screen" library="images" name="bootstrap/carousel/Valladolid-parque-3.jpg" tooltip="small-screen='one-third' hidden='tiny-screen'"/>
</b:row>
]]>
</script>
</b:panel>
</f:facet>
</b:panel>
<h2><a id="reference_section">Reference section</a></h2>
<ui:include src="ImageAttributes.xhtml" />
<b:panel look="info">
<f:facet name="heading">
<b>Skinning</b>
</f:facet>
<p>BootsFaces generates pretty simple code for the <code><b:image></code>. In particular, there's no extra CSS class. You can modify the appearance of the
image using the standard JSF attributes <code>styleClass</code> and <code>style</code>.</p>
</b:panel>
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
</ui:define>
</ui:composition>