summaryrefslogtreecommitdiff
path: root/xslt/mallard/html/mal2html-ui.xsl
blob: 7fa0a0420f3f9c4a268ca9bd66b7e09c4b414ce1 (plain)
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL.  If not, see <http://www.gnu.org/licenses/>.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/common"
                xmlns:mal="http://projectmallard.org/1.0/"
                xmlns:ui="http://projectmallard.org/ui/1.0/"
                xmlns:uix="http://projectmallard.org/experimental/ui/"
                xmlns:math="http://exslt.org/math"
                xmlns="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="mal ui uix math exsl"
                version="1.0">

<!--!!==========================================================================
Mallard to HTML - UI Extension
Support for Mallard UI extension elements.

This stylesheet contains templates to support features from the Mallard UI
extension.
-->


<!--**==========================================================================
mal2html.ui.expander.class
Output HTML class value for an expander.
@revision[version=3.32 date=2018-10-14 status=final]

[xsl:params]
$node: The source element to output data for.
$hastitle: True if $node has a title or a title can be automatically computed.

This template outputs HTML class attribute values for elements that can be
expanded and collapsed. It outputs the string `ui-expander` only if $node has
a `ui:expanded` attribute and $hastitle is true. By default, $hastitle is true
if $node has a `title` element. Set $hastitle explicitly when calling this
template on elements that have an automatic default title.

This template also outputs `ui-expander-preview` if $node is an expander and
it has the style hint `ui-expander-preview`. This is an alternative style
that shows a scaled down preview of collapsed content.
-->
<xsl:template name="mal2html.ui.expander.class">
  <xsl:param name="node" select="."/>
  <xsl:param name="hastitle" select="$node/mal:title"/>
  <xsl:if test="$hastitle and ($node/@ui:expanded or $node/@uix:expanded)">
    <xsl:text> ui-expander </xsl:text>
    <xsl:if test="contains(concat(' ', $node/@style, ' '), ' ui-expander-preview ')">
      <xsl:text>ui-expander-preview </xsl:text>
    </xsl:if>
  </xsl:if>
</xsl:template>


<!--**==========================================================================
mal2html.ui.expander.data
Output data for an expander.
@revision[version=3.32 date=2018-10-14 status=final]

[xsl:params]
$node: The source element to output data for.
$hastitle: True if $node has a title or a title can be automatically computed.

This template outputs an HTML `div` element with the `class` attribute set to
`"yelp-data yelp-data-ui-expander"`. All `yelp-data` elements are hidden by
the CSS. The div contains information about text directionality, the default
expanded state, and optionally additional titles for the expanded and collapsed
states.

The expander information is only output if $node has a `ui:expanded` attribute
and $hastitle is true. By default, $hastitle is true if $node has a `title`
element. Set $hastitle explicitly when calling this template on elements that
have an automatic default title.
-->
<xsl:template name="mal2html.ui.expander.data">
  <xsl:param name="node" select="."/>
  <xsl:param name="hastitle" select="$node/mal:title"/>
  <xsl:if test="$node/@uix:expanded and not($node/@ui:expanded)">
    <xsl:message>
      <xsl:text>DEPRECATION WARNING: The expanded attribute from the experimental/ui namespace
is deprecated. Use the expanded attribute from the ui/1.0 namespace instead.
Note that the non-experimental attribute takes true/false instead of yes/no.
http://projectmallard.org/ui/1.0/ui_expanded.html</xsl:text>
    </xsl:message>
  </xsl:if>
  <xsl:if test="$hastitle and ($node/@ui:expanded or $node/@uix:expanded)">
    <xsl:variable name="title_e" select="$node/mal:info/mal:title[@type = 'ui:expanded'][1]"/>
    <xsl:variable name="title_c" select="$node/mal:info/mal:title[@type = 'ui:collapsed'][1]"/>
    <div class="yelp-data yelp-data-ui-expander">
      <xsl:attribute name="dir">
        <xsl:call-template name="l10n.direction"/>
      </xsl:attribute>
      <xsl:attribute name="data-yelp-expanded">
        <xsl:choose>
          <xsl:when test="$node/@ui:expanded = 'false'">
            <xsl:text>false</xsl:text>
          </xsl:when>
          <xsl:when test="$node/@uix:expanded = 'no'">
            <xsl:text>false</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>true</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:if test="$title_e">
        <div class="yelp-title-expanded">
          <xsl:apply-templates mode="mal2html.inline.mode" select="$title_e/node()"/>
        </div>
      </xsl:if>
      <xsl:if test="$title_c">
        <div class="yelp-title-collapsed">
          <xsl:apply-templates mode="mal2html.inline.mode" select="$title_c/node()"/>
        </div>
      </xsl:if>
    </div>
  </xsl:if>
</xsl:template>


<!--**==========================================================================
mal2html.ui.links.tiles
Output links as thumbnail tiles.
@revision[version=3.28 date=2015-10-22 status=volatile]

[xsl:params]
$node: A `links` element to link from.
$links: A list of links, as from a template in {mal-link}.
$role: A link role, used to select the appropriate title and thumbnail.

This template outputs links as thumbnail tiles. For each link, it outputs
a `div` element with a thumbnail, title, and desc (unless the `nodesc`
style hint is used). This template calls {mal2html.ui.links.img} to find
the best-match thumbnail and output the HTML `img` element for each link.

This template handles link sorting.
-->
<xsl:template name="mal2html.ui.links.tiles">
  <xsl:param name="node" select="."/>
  <xsl:param name="links"/>
  <xsl:param name="role"/>
  <div class="links-tiles">
    <xsl:for-each select="$links">
      <xsl:sort data-type="number" select="@groupsort"/>
      <xsl:sort select="mal:title[@type = 'sort']"/>
      <xsl:variable name="link" select="."/>
      <xsl:for-each select="$mal.cache">
        <xsl:variable name="target" select="key('mal.cache.key', $link/@xref)"/>
        <div class="links-tile {$link/@class}">
          <xsl:for-each select="$link/@*">
            <xsl:if test="starts-with(name(.), 'data-')">
              <xsl:copy-of select="."/>
            </xsl:if>
          </xsl:for-each>
          <xsl:variable name="infos" select="$target/mal:info | $link[@href]/mal:info"/>
          <xsl:variable name="thumbs" select="$infos/uix:thumb"/>
          <a>
            <xsl:attribute name="href">
              <xsl:call-template name="mal.link.target">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="xref" select="$link/@xref"/>
                <xsl:with-param name="href" select="$link/@href"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:attribute name="title">
              <xsl:call-template name="mal.link.tooltip">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="xref" select="$link/@xref"/>
                <xsl:with-param name="href" select="$link/@href"/>
                <xsl:with-param name="role" select="$role"/>
                <xsl:with-param name="info" select="$link[@href]/mal:info"/>
              </xsl:call-template>
            </xsl:attribute>
            <span class="links-tile-img">
              <xsl:call-template name="mal2html.ui.links.img">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="thumbs" select="$thumbs"/>
                <xsl:with-param name="role" select="$role"/>
              </xsl:call-template>
            </span>
            <span class="links-tile-text">
              <span class="title">
                <xsl:call-template name="mal.link.content">
                  <xsl:with-param name="node" select="$node"/>
                  <xsl:with-param name="xref" select="$link/@xref"/>
                  <xsl:with-param name="href" select="$link/@href"/>
                  <xsl:with-param name="role" select="$role"/>
                  <xsl:with-param name="info" select="$link[@href]/mal:info"/>
                </xsl:call-template>
              </span>
              <xsl:if test="not(contains(concat(' ', $node/@style, ' '), ' nodesc '))">
                <xsl:variable name="desc">
                  <xsl:call-template name="mal.link.desc">
                    <xsl:with-param name="node" select="$node"/>
                    <xsl:with-param name="xref" select="$link/@xref"/>
                    <xsl:with-param name="href" select="$link/@href"/>
                    <xsl:with-param name="role" select="$role"/>
                    <xsl:with-param name="info" select="$link[@href]/mal:info"/>
                  </xsl:call-template>
                </xsl:variable>
                <xsl:variable name="desc_" select="exsl:node-set($desc)/node()"/>
                <xsl:if test="$desc_/node()">
                  <span class="desc">
                    <xsl:apply-templates mode="_mal2html.links.divs.nolink.mode"
                                         select="$desc_"/>
                  </span>
                </xsl:if>
              </xsl:if>
            </span>
          </a>
        </div>
      </xsl:for-each>
    </xsl:for-each>
    <!-- blank tiles for homogeneous sizing -->
    <div class="links-tile"></div>
    <div class="links-tile"></div>
  </div>
</xsl:template>


<!--DEPRECATED==================================================================
_mal2html.ui.links.hover
Output links with thumbnails shown on hover.
@revision[version=3.4 date=2012-02-26 status=final]

[xsl:params]
$node: A `links` element to link from.
$links: A list of links, as from a template in {mal-link}.
$role: A link role, used to select the appropriate title and thumbnail.

This template outputs links alongside thumbnail images, using the UI extension.
The thumbnail image for each link is shown when the user hovers over that link.
This template calls {mal2html.ui.links.img} to find the best-match thumbnail
and output the HTML `img` element for each link.

If $node contains a `ui:thumb` element, that image is used when no links
are hovered.

This template handles link sorting.
-->
<!--#* _mal2html.ui.links.hover -->
<xsl:template name="_mal2html.ui.links.hover">
  <xsl:param name="node"/>
  <xsl:param name="links"/>
  <xsl:param name="role"/>
  <xsl:variable name="width">
    <xsl:choose>
      <xsl:when test="$node/@uix:width">
        <xsl:value-of select="$node/@uix:width"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>250</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="height">
    <xsl:choose>
      <xsl:when test="$node/@uix:height">
        <xsl:value-of select="$node/@uix:height"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>200</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:message>
    <xsl:text>DEPRECATION WARNING: The uix:thumbs attribute on the links element is deprecated.</xsl:text>
  </xsl:message>
  <div class="links-uix-hover">
  <div class="links-uix-hover-img" style="width: {$width}px; height: {$height}px;">
    <xsl:for-each select="$node/uix:thumb[1]">
      <img>
        <xsl:call-template name="mal2html.ui.links.img.src">
          <xsl:with-param name="node" select="$node"/>
          <xsl:with-param name="thumb" select="."/>
        </xsl:call-template>
        <xsl:call-template name="mal2html.ui.links.img.attrs">
          <xsl:with-param name="node" select="$node"/>
          <xsl:with-param name="thumb" select="."/>
          <xsl:with-param name="width" select="$width"/>
          <xsl:with-param name="height" select="$height"/>
        </xsl:call-template>
      </img>
    </xsl:for-each>
  </div>
  <ul class="links-uix-hover">
    <xsl:for-each select="$links">
      <xsl:sort data-type="number" select="@groupsort"/>
      <xsl:sort select="mal:title[@type = 'sort']"/>
      <xsl:variable name="link" select="."/>
      <xsl:variable name="xref" select="@xref"/>
      <xsl:for-each select="$mal.cache">
        <xsl:variable name="target" select="key('mal.cache.key', $xref)"/>
        <xsl:variable name="infos" select="$target/mal:info | $link[@href]/mal:info"/>
        <xsl:variable name="thumbs" select="$infos/uix:thumb"/>
        <li class="links {$link/@class}">
          <xsl:for-each select="$link/@*">
            <xsl:if test="starts-with(name(.), 'data-')">
              <xsl:copy-of select="."/>
            </xsl:if>
          </xsl:for-each>
          <a class="bold">
            <xsl:attribute name="href">
              <xsl:call-template name="mal.link.target">
                <xsl:with-param name="xref" select="$xref"/>
                <xsl:with-param name="href" select="$link/@href"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:attribute name="title">
              <xsl:call-template name="mal.link.tooltip">
                <xsl:with-param name="xref" select="$xref"/>
                <xsl:with-param name="href" select="$link/@href"/>
                <xsl:with-param name="role" select="$role"/>
                <xsl:with-param name="info" select="$link[@href]/mal:info"/>
              </xsl:call-template>
            </xsl:attribute>
            <span class="links-uix-hover-img" style="width: {$width}px; height: {$height}px;">
              <xsl:call-template name="mal2html.ui.links.img">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="thumbs" select="$thumbs"/>
                <xsl:with-param name="role" select="$role"/>
                <xsl:with-param name="width" select="$width"/>
                <xsl:with-param name="height" select="$height"/>
              </xsl:call-template>
            </span>
            <span class="title">
              <xsl:call-template name="mal.link.content">
                <xsl:with-param name="node" select="."/>
                <xsl:with-param name="xref" select="$xref"/>
                <xsl:with-param name="href" select="$link/@href"/>
                <xsl:with-param name="role" select="$role"/>
                <xsl:with-param name="info" select="$link[@href]/mal:info"/>
              </xsl:call-template>
            </span>
          </a>
        </li>
      </xsl:for-each>
    </xsl:for-each>
  </ul>
  </div>
</xsl:template>


<!--**==========================================================================
mal2html.ui.links.img
Output an image for a link using UI thumbnails.
@revision[version=3.28 date=2017-08-11 status=final]

[xsl:params]
$node: A `links` element to link from.
$thumbs: A list of candidate `uix:thumb` elements.
$role: A link role, used to select the appropriate thumbnail.
$width: The width to fit thumbnails into.
$height: The height to fit thumbnails into.

This template selects the best-fit thumbnail from $thumbs, based on how well
the aspect ratio and dimensions of each image matches the $width and $height
parameters. It outputs an HTML `img` element for the best-fit thumbnail. It
calls $mal2thml.ui.links.img.src to output the `src` attribute, and calls
$mal2html.ui.links.img.attrs to output `width` and `height` attributes.

Before checking for a best-fit thumbnail on dimensions, this template first
looks for `uix:thumb` elements with the `type` attribute set to `"links"`.
Within those, it looks for `uix:thumb` elements whose `role` attribute
matches the $role parameter. This is similar to how link titles are
selected.

If the $thumbs parameter is empty, this template attempts to use a default
thumbnail provided by a `uix:thumb` child element of $node.

The $width and $height parameters can be computed automatically from the
$node element.
-->
<xsl:template name="mal2html.ui.links.img">
  <xsl:param name="node"/>
  <xsl:param name="thumbs"/>
  <xsl:param name="role"/>
  <xsl:param name="width" select="$node/@uix:width"/>
  <xsl:param name="height" select="$node/@uix:height"/>
  <xsl:choose>
  <xsl:when test="$thumbs">
    <img>
      <xsl:for-each select="$thumbs[not(@type) or (
                            @type = 'link' and (not(@role) or @role = $role))]">
        <xsl:sort data-type="number" select="number(not(@type = 'link'))"/>
        <xsl:sort data-type="number" select="number(not(@role = $role))"/>
        <xsl:sort data-type="number" select="number(not(@width))"/>
        <xsl:sort data-type="number" select="number(not(@height))"/>
        <xsl:sort data-type="number" select="($width div $height) div (@width div @height)"/>
        <xsl:sort data-type="number" select="math:abs($width - @width)"/>
        <xsl:sort data-type="number" select="math:abs($height - @height)"/>
        <xsl:if test="position() = 1">
          <xsl:call-template name="mal2html.ui.links.img.src">
            <xsl:with-param name="node" select="$node"/>
            <xsl:with-param name="thumb" select="."/>
          </xsl:call-template>
          <xsl:call-template name="mal2html.ui.links.img.attrs">
            <xsl:with-param name="node" select="$node"/>
            <xsl:with-param name="thumb" select="."/>
            <xsl:with-param name="width" select="$width"/>
            <xsl:with-param name="height" select="$height"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:for-each>
    </img>
  </xsl:when>
  <xsl:when test="$node/uix:thumb">
    <img>
      <xsl:call-template name="mal2html.ui.links.img.src">
        <xsl:with-param name="node" select="$node"/>
        <xsl:with-param name="thumb" select="$node/uix:thumb"/>
      </xsl:call-template>
      <xsl:call-template name="mal2html.ui.links.img.attrs">
        <xsl:with-param name="node" select="$node"/>
        <xsl:with-param name="thumb" select="$node/uix:thumb"/>
        <xsl:with-param name="width" select="$width"/>
        <xsl:with-param name="height" select="$height"/>
      </xsl:call-template>
    </img>
  </xsl:when>
  </xsl:choose>
</xsl:template>


<!--**==========================================================================
mal2html.ui.links.img.src
Output the `src` attribute for a thumbnail image.
@revision[version=3.28 date=2017-08-11 status=final]

[xsl:params]
$node: A `links` element to link from.
$thumb: A `uix:thumb` element.
$width: The width to fit thumbnails into.
$height: The height to fit thumbnails into.

This template outputs `src` attribute for the HTML `img` element created
from $thumb. By default, it just copies the `src` attribute of $thumb.
Override this template if you need to support multi-directory output.
-->
<xsl:template name="mal2html.ui.links.img.src">
  <xsl:param name="node"/>
  <xsl:param name="thumb"/>
  <xsl:attribute name="src">
    <xsl:value-of select="$thumb/@src"/>
  </xsl:attribute>
</xsl:template>


<!--**==========================================================================
mal2html.ui.links.img.attrs
Output the `width` and `height` attributes for a thumbnail image.
@revision[version=3.28 date=2017-08-11 status=final]

[xsl:params]
$node: A `links` element to link from.
$thumb: A `uix:thumb` element.
$width: The width to fit thumbnails into.
$height: The height to fit thumbnails into.

This template outputs `width` and `height` attributes for the HTML `img`
element created from $thumb, based on the `uix:overflow` attribute on $node.
The $width and $height parameters can be computed automatically from the
$node element.
-->
<xsl:template name="mal2html.ui.links.img.attrs">
  <xsl:param name="node"/>
  <xsl:param name="thumb"/>
  <xsl:param name="width" select="$node/@uix:width"/>
  <xsl:param name="height" select="$node/@uix:height"/>
  <xsl:choose>
    <xsl:when test="$node/@uix:overflow = 'crop'"/>
    <xsl:when test="$node/@uix:overflow = 'width'">
      <xsl:attribute name="width">
        <xsl:value-of select="$width"/>
      </xsl:attribute>
    </xsl:when>
    <xsl:when test="$node/@uix:overflow = 'height'">
      <xsl:attribute name="height">
        <xsl:value-of select="$height"/>
      </xsl:attribute>
    </xsl:when>
    <xsl:when test="$node/@uix:overflow = 'scale'">
      <xsl:attribute name="width">
        <xsl:value-of select="$width"/>
      </xsl:attribute>
      <xsl:attribute name="height">
        <xsl:value-of select="$height"/>
      </xsl:attribute>
    </xsl:when>
    <xsl:when test="$thumb/@width and $thumb/@height">
      <xsl:variable name="ratio" select="$width div $height"/>
      <xsl:variable name="tratio" select="$thumb/@width div $thumb/@height"/>
      <xsl:choose>
        <xsl:when test="$thumb/@width &lt; $width and $thumb/@height &lt; $height">
          <xsl:copy-of select="$thumb/@width | $thumb/@height"/>
        </xsl:when>
        <xsl:when test="$ratio &lt; $tratio">
          <xsl:attribute name="width">
            <xsl:value-of select="$width"/>
          </xsl:attribute>
          <xsl:attribute name="height">
            <xsl:value-of select="round($width * ($thumb/@height div $thumb/@width))"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="width">
            <xsl:value-of select="round($height * ($thumb/@width div $thumb/@height))"/>
          </xsl:attribute>
          <xsl:attribute name="height">
            <xsl:value-of select="$height"/>
          </xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:attribute name="width">
        <xsl:value-of select="$width"/>
      </xsl:attribute>
      <xsl:attribute name="height">
        <xsl:value-of select="$height"/>
      </xsl:attribute>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- == Matched Templates == -->

<!-- = ui:thumb = -->
<xsl:template mode="mal2html.block.mode" match="uix:thumb"/>

<!-- = ui:overlay = -->
<xsl:template mode="mal2html.block.mode" match="uix:overlay">
        <xsl:variable name="media" select="mal:media[1]"/>
        <xsl:variable name="width">
          <xsl:choose>
            <xsl:when test="@width">
              <xsl:value-of select="@width"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>280</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:variable name="height">
          <xsl:choose>
            <xsl:when test="@height">
              <xsl:value-of select="@height"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>280</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <div class="links-tile">
          <a href="{$media/@src}" class="ui-overlay">
            <span class="links-tile-img">
              <xsl:choose>
                <xsl:when test="$media/uix:thumb">
                  <img src="{$media/uix:thumb[1]/@src}" width="{$width}"/>
                </xsl:when>
                <!-- FIXME: audio/video with image child -->
                <!--
                    <xsl:when test="($media/@type = 'video' or $media/@type = 'audio') and
                    $media/mal:media[not(@type) or @type = 'image']">
                    </xsl:when>
                -->
                <xsl:when test="$media/@type = 'video'">
                  <video src="{$media/@src}" width="{$width}"/>
                </xsl:when>
                <xsl:otherwise>
                  <img src="{$media/@src}" width="{$width}"/>
                </xsl:otherwise>
              </xsl:choose>
            </span>
            <xsl:if test="$media/uix:thumb/uix:caption">
              <span class="links-tile-text">
                <xsl:variable name="title" select="$media/uix:thumb/uix:caption/mal:title[1]"/>
                <xsl:if test="$title">
                  <span>
                    <xsl:attribute name="class">
                      <xsl:text>title</xsl:text>
                      <xsl:if test="contains(concat(' ', $title/@style, ' '), ' center ')">
                        <xsl:text> center</xsl:text>
                      </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates mode="mal2html.inline.mode" select="$title/node()"/>
                  </span>
                </xsl:if>
                <xsl:variable name="desc" select="$media/uix:thumb/uix:caption/mal:desc[1]"/>
                <xsl:if test="$desc">
                  <span>
                    <xsl:attribute name="class">
                      <xsl:text>desc</xsl:text>
                      <xsl:if test="contains(concat(' ', $desc/@style, ' '), ' center ')">
                        <xsl:text> center</xsl:text>
                      </xsl:if>
                    </xsl:attribute>
                    <xsl:apply-templates mode="mal2html.inline.mode" select="$desc/node()"/>
                  </span>
                </xsl:if>
              </span>
            </xsl:if>
          </a>
          <div class="ui-overlay">
            <div class="inner">
              <a href="#" class="ui-overlay-close">
                <xsl:attribute name="title">
                  <xsl:call-template name="l10n.gettext">
                    <xsl:with-param name="msgid" select="'Close'"/>
                  </xsl:call-template>
                </xsl:attribute>
                <xsl:text>тип</xsl:text>
              </a>
              <xsl:apply-templates mode="mal2html.block.mode" select="uix:caption/mal:title[1]"/>
              <div class="contents">
                <xsl:apply-templates mode="mal2html.block.mode" select="$media"/>
              </div>
              <xsl:apply-templates mode="mal2html.block.mode" select="uix:caption/mal:desc[1]"/>
            </div>
          </div>
        </div>
</xsl:template>

</xsl:stylesheet>