1 | {if !empty($thumbnails)}{strip} |
---|
2 | {*define_derivative name='derivative_params' width=160 height=90 crop=true*} |
---|
3 | {html_style} |
---|
4 | {*Set some sizes according to maximum thumbnail width and height*} |
---|
5 | .thumbnails SPAN, |
---|
6 | .thumbnails .wrap2 A, |
---|
7 | .thumbnails LABEL{ldelim} |
---|
8 | width: {$derivative_params->max_width()+2}px; |
---|
9 | } |
---|
10 | |
---|
11 | .thumbnails .wrap2{ldelim} |
---|
12 | height: {$derivative_params->max_height()+3}px; |
---|
13 | } |
---|
14 | {if $derivative_params->max_width() > 600} |
---|
15 | .thumbLegend {ldelim}font-size: 130%} |
---|
16 | {else} |
---|
17 | {if $derivative_params->max_width() > 400} |
---|
18 | .thumbLegend {ldelim}font-size: 110%} |
---|
19 | {else} |
---|
20 | .thumbLegend {ldelim}font-size: 90%} |
---|
21 | {/if} |
---|
22 | {/if} |
---|
23 | {/html_style} |
---|
24 | {foreach from=$thumbnails item=thumbnail} |
---|
25 | {assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)} |
---|
26 | {if !$derivative->is_cached() and !$js_loaded} |
---|
27 | {combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'} |
---|
28 | {*combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'*} |
---|
29 | {footer_script}{literal} |
---|
30 | var thumbnails_queue = jQuery.manageAjax.create('queued', { |
---|
31 | queue: true, |
---|
32 | cacheResponse: false, |
---|
33 | maxRequests: {/literal}{$maxRequests}{literal}, |
---|
34 | preventDoubleRequests: false |
---|
35 | }); |
---|
36 | |
---|
37 | function add_thumbnail_to_queue(img, loop) { |
---|
38 | thumbnails_queue.add({ |
---|
39 | type: 'GET', |
---|
40 | url: img.data('src'), |
---|
41 | data: { ajaxload: 'true' }, |
---|
42 | dataType: 'json', |
---|
43 | beforeSend: function(){jQuery('.loader').show()}, |
---|
44 | success: function(result) { |
---|
45 | img.attr('src', result.url); |
---|
46 | jQuery('.loader').hide(); |
---|
47 | }, |
---|
48 | error: function() { |
---|
49 | if (loop < 3) |
---|
50 | add_thumbnail_to_queue(img, ++loop); // Retry 3 times |
---|
51 | img.attr('src', {/literal}"{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{literal}); |
---|
52 | jQuery('.loader').hide(); |
---|
53 | } |
---|
54 | }); |
---|
55 | } |
---|
56 | |
---|
57 | function pwg_ajax_thumbnails_loader() { |
---|
58 | jQuery('img[data-src]').each(function() { |
---|
59 | add_thumbnail_to_queue(jQuery(this), 0); |
---|
60 | }); |
---|
61 | } |
---|
62 | jQuery(document).ready(pwg_ajax_thumbnails_loader); |
---|
63 | {/literal}{/footer_script} |
---|
64 | {assign var=js_loaded value=true} |
---|
65 | {/if} |
---|
66 | <li> |
---|
67 | <span class="wrap1"> |
---|
68 | <span class="wrap2"> |
---|
69 | <a href="{$thumbnail.URL}"> |
---|
70 | <img class="thumbnail" {if $derivative->is_cached()}src="{$derivative->get_url()}"{else}src="{$ROOT_URL}{$themeconf.icon_dir}/img_small.png" data-src="{$derivative->get_url()}"{/if} alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}"> |
---|
71 | </a> |
---|
72 | </span> |
---|
73 | {if $SHOW_THUMBNAIL_CAPTION } |
---|
74 | <span class="thumbLegend"> |
---|
75 | <span class="thumbName">{$thumbnail.NAME}</span> |
---|
76 | {if !empty($thumbnail.icon_ts)} |
---|
77 | <img title="{$thumbnail.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent.png" alt="(!)"> |
---|
78 | {/if} |
---|
79 | {if isset($thumbnail.NB_COMMENTS)} |
---|
80 | <span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments"> |
---|
81 | <br> |
---|
82 | {$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.NB_COMMENTS)} |
---|
83 | </span> |
---|
84 | {/if} |
---|
85 | |
---|
86 | {if isset($thumbnail.NB_HITS)} |
---|
87 | <span class="{if 0==$thumbnail.NB_HITS}zero {/if}nb-hits"> |
---|
88 | <br> |
---|
89 | {$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.NB_HITS)} |
---|
90 | </span> |
---|
91 | {/if} |
---|
92 | </span> |
---|
93 | {/if} |
---|
94 | </span> |
---|
95 | </li> |
---|
96 | {/foreach}{/strip} |
---|
97 | {/if} |
---|