source: extensions/Fotorama/template/fotorama-content.tpl @ 30048

Last change on this file since 30048 was 29984, checked in by JanisV, 10 years ago

Improve JS code

  • Property svn:executable set to *
File size: 5.4 KB
Line 
1{combine_css path="plugins/Fotorama/fotorama/fotorama.css"}
2{combine_script id='fotorama' require='jquery' load='header' path='plugins/Fotorama/fotorama/fotorama.js'}
3
4{if $Fotorama.close_button}
5{combine_css path="plugins/Fotorama/template/close_button.css"}
6{/if}
7{if $Fotorama.info_button}
8{combine_css path="plugins/Fotorama/template/info_button.css"}
9{/if}
10
11<div class="fotorama" data-startindex="{$current_rank}" data-ratio="16/9" data-auto="false"
12  data-width="100%" data-maxheight="100%" data-minheight="200" data-height="{$item_height}"
13  data-shadows="{if $Fotorama.shadows}true{else}false{/if}" data-nav="{$Fotorama.nav}" data-fit="{$Fotorama.fit}"
14  data-allowfullscreen="{$Fotorama.allowfullscreen}" data-autoplay="{if $Fotorama.autoplay}{$Fotorama.period}{else}false{/if}"
15  data-transition="{$Fotorama.transition}" data-stopautoplayontouch="{if $Fotorama.stopautoplayontouch}true{else}false{/if}"
16  data-loop="{if $Fotorama.loop}true{else}false{/if}" data-captions="false" data-thumbheight="{$Fotorama.thumbheight}"
17  data-thumbwidth="{$Fotorama.thumbheight}"{if $Fotorama.clicktransition_crossfade} data-clicktransition="crossfade"{/if}
18  data-keyboard="true">
19</div>
20
21{if isset($U_SLIDESHOW_STOP)}
22<a href="{$U_SLIDESHOW_STOP}" class="fotorama__close-icon"></a>
23{/if}
24<a class="fotorama__info-icon"></a>
25
26{footer_script require='jquery'}
27  window.blockFotoramaData = true;
28 
29  function update_picture(fotorama) {
30    {if isset($replace_picture)}
31    if (history.replaceState)
32      history.replaceState(null, null, fotorama.activeFrame['url']);
33    {else}
34    if (history.replaceState)
35      history.replaceState(null, null, fotorama.activeFrame['url']+(fotorama.activeFrame['url'].indexOf('?')==-1 ? '?' : '&')+'slideshow=');
36    jQuery('#slideshow .browsePath a').attr('href', fotorama.activeFrame['url']);
37    {/if}
38
39    jQuery('a.fotorama__info-icon').attr('href', fotorama.activeFrame['url']+(fotorama.activeFrame['url'].indexOf('?')==-1 ? '?' : '&')+'slidestop=');
40
41    jQuery('#slideshow .showtitle').text(fotorama.activeFrame['caption']);
42    jQuery('#slideshow .imageNumber').text((fotorama.activeFrame['i'])+'/{count($items)}');
43    document.title = fotorama.activeFrame['caption'] + ' | {$GALLERY_TITLE|escape:javascript}';
44  }
45
46  var fullscreen = false;
47  jQuery().ready(function() {
48    jQuery('.fotorama')
49        // Listen to the events
50        .on('fotorama:showend ',
51            function (e, fotorama, extra) {
52              if (!fullscreen) {
53                update_picture(fotorama);
54              }
55            }
56        )
57        .on('fotorama:fullscreenenter',
58            function (e, fotorama, extra) {
59              fotorama.setOptions({
60                nav: "{$Fotorama.fullscreen_nav}",
61                {if $Fotorama.enable_caption}
62                captions: "true",
63                {/if}
64              });
65              {if $Fotorama.autoplay}
66              fotorama.startAutoplay();
67              {/if}
68
69              if (jQuery('.fotorama').attr('data-allowfullscreen') == 'native')
70                fullscreen = true;
71            }
72        )
73        .on('fotorama:fullscreenexit',
74            function (e, fotorama, extra) {
75              {if $Fotorama.only_fullscreen}
76              {if isset($replace_picture)}
77              window.location.replace('{$U_SLIDESHOW_STOP}');
78              {else}
79              window.location.replace(fotorama.activeFrame['url']);
80              {/if}
81              {else}
82
83              fotorama.setOptions({
84                nav: "{$Fotorama.nav}",
85                {if $Fotorama.enable_caption}
86                captions: "false",
87                {/if}
88              });
89
90              update_picture(fotorama);
91
92              fullscreen = false;
93              {/if}
94            }
95        )
96        // Initialize fotorama manually
97        .fotorama({
98          data: [
99{foreach from=$items item=thumbnail}
100{
101caption: "{$thumbnail.TITLE|escape:javascript}",
102full: "{str_replace('&amp;', '&', $thumbnail.derivative_big->get_url())}",
103img: "{str_replace('&amp;', '&', $thumbnail.derivative->get_url())}",
104{if $Fotorama_has_thumbs}
105thumb: "{$thumbnail.derivative_thumb->get_url()}",
106{assign var=thumb_size value=$thumbnail.derivative_thumb->get_size()}
107thumbratio: {$thumb_size[0]/$thumb_size[1]},
108{/if}
109url: "{$thumbnail.url}"
110},{/foreach}
111          ]
112        });
113
114    {if $Fotorama.only_fullscreen}
115    jQuery('.fotorama').data('fotorama').requestFullScreen();
116    {else}
117      {if $Fotorama.resize}
118      jQuery('.fotorama').data('fotorama').resize({
119        height: jQuery(window).height()
120      });
121      jQuery('html,body').animate({ scrollTop: jQuery('.fotorama').offset().top }, 'slow');
122      {/if}
123    {/if}
124 
125  });
126
127  {if $Fotorama.close_button}
128  jQuery('.fotorama').on('fotorama:ready', function (e, fotorama) {
129    jQuery('.fotorama__close-icon').detach().insertAfter('.fotorama__fullscreen-icon');
130  });
131  {/if}
132  {if $Fotorama.info_button}
133  jQuery('.fotorama').on('fotorama:ready', function (e, fotorama) {
134    jQuery('.fotorama__info-icon').detach().insertAfter('.fotorama__fullscreen-icon');
135  });
136  {/if}
137 
138  {if $Fotorama.autoplay}
139  $(document).keypress(function(e) {
140    if(e.which == 43) {
141      jQuery('.fotorama').data('fotorama').setOptions({
142        autoplay: jQuery('.fotorama').data('fotorama').options['autoplay'] * 1.4
143      });
144    }
145    if(e.which == 45) {
146      jQuery('.fotorama').data('fotorama').setOptions({
147        autoplay: jQuery('.fotorama').data('fotorama').options['autoplay'] / 1.4
148      });
149    }
150  });
151  {/if}
152{/footer_script}
Note: See TracBrowser for help on using the repository browser.