1 | (function(window, $, PhotoSwipe){ |
---|
2 | $(document).ready(function(){ |
---|
3 | var more_link |
---|
4 | var options = { |
---|
5 | jQueryMobile: true, |
---|
6 | loop: var_loop, |
---|
7 | captionAndToolbarAutoHideDelay: var_autohide, |
---|
8 | imageScaleMethod: "fitNoUpscale", |
---|
9 | getToolbar: function(){ |
---|
10 | return '<div class="ps-toolbar-close"><div class="ps-toolbar-content"></div></div><div class="ps-toolbar-play"><div class="ps-toolbar-content"></div></div><div id="more_link">'+var_trad+'</div><div class="ps-toolbar-previous"><div class="ps-toolbar-content"></div></div><div class="ps-toolbar-next"><div class="ps-toolbar-content"></div></div>';}, |
---|
11 | getImageMetaData:function(el){ |
---|
12 | return { |
---|
13 | picture_url: $(el).attr('data-picture-url') |
---|
14 | };} |
---|
15 | }; |
---|
16 | var myPhotoSwipe = $(".thumbnails a").photoSwipe(options); |
---|
17 | // onShow - store a reference to our "more_link" button |
---|
18 | myPhotoSwipe.addEventHandler(PhotoSwipe.EventTypes.onShow, function(e){ |
---|
19 | more_link = window.document.querySelectorAll('#more_link')[0]; |
---|
20 | }); |
---|
21 | // onToolbarTap - listen out for when the toolbar is tapped |
---|
22 | myPhotoSwipe.addEventHandler(PhotoSwipe.EventTypes.onToolbarTap, function(e){ |
---|
23 | if (e.toolbarAction === PhotoSwipe.Toolbar.ToolbarAction.none){ |
---|
24 | if (e.tapTarget === more_link || Util.DOM.isChildOf(e.tapTarget, more_link)){ |
---|
25 | var currentImage = myPhotoSwipe.getCurrentImage(); |
---|
26 | window.location=currentImage.metaData.picture_url; |
---|
27 | } |
---|
28 | } |
---|
29 | }); $(document).bind('orientationchange', set_thumbnails_width); |
---|
30 | set_thumbnails_width(); |
---|
31 | }); |
---|
32 | }(window, window.jQuery, window.Code.PhotoSwipe)); |
---|
33 | |
---|
34 | function set_thumbnails_width() { |
---|
35 | nb_thumbs = Math.max(3, Math.ceil($('.thumbnails').width() / 130)); |
---|
36 | width = Math.floor(1000000 / nb_thumbs) / 10000; |
---|
37 | $('.thumbnails li').css('width', width+'%'); |
---|
38 | } |
---|
39 | |
---|