PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.41
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.41
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / include / scripts / front-end / src / lightboxes / Lightbox_Fancybox2.js

Lightbox_Fancybox2.js in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 2.41, at include/scripts/front-end/src/lightboxes/Lightbox_Fancybox2.js

123 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function Photonic_Lightbox_Fancybox2() {
2 Photonic_Lightbox.call(this);
3 }
4 Photonic_Lightbox_Fancybox2.prototype = Object.create(Photonic_Lightbox.prototype);
5
6 Photonic_Lightbox_Fancybox2.prototype.swipe = function(e) {
7 $("#fancybox-wrap, .fancybox-wrap")
8 .on('swipeleft', function() { $.fancybox.next(); })
9 .on('swiperight', function() { $.fancybox.prev(); });
10 };
11
12 Photonic_Lightbox_Fancybox2.prototype.soloImages = function() {
13 $('a[href]').filter(function() {
14 return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href'));
15 }).addClass("launch-gallery-fancybox").addClass(Photonic_JS.slideshow_library);
16 };
17
18 Photonic_Lightbox_Fancybox2.prototype.changeVideoURL = function(element, regular, embed) {
19 $(element).attr('href', embed);
20 };
21
22 Photonic_Lightbox_Fancybox2.prototype.hostedVideo = function(a) {
23 var html5 = $(a).attr('href').match(new RegExp(/(\.mp4|\.webm|\.ogg)/i));
24 var css = $(a).attr('class');
25 css = css !== undefined && css.includes('photonic-launch-gallery');
26
27 if (html5 !== null && !css) {
28 $(a).addClass(Photonic_JS.slideshow_library + "-html5-video");
29 var $videos = $('#photonic-html5-videos');
30 $videos = $videos.length ? $videos : $('<div style="display:none;" id="photonic-html5-videos"></div>').appendTo(document.body);
31 $videos.append('<div id="photonic-html5-video-' + this.videoIndex + '"><video controls preload="none"><source src="' + $(a).attr('href') + '" type="video/mp4">Your browser does not support HTML5 video.</video></div>');
32 $(a).attr('data-html5-href', $(a).attr('href'));
33 $(a).attr('href', '#photonic-html5-video-' + this.videoIndex);
34 this.videoIndex++;
35 }
36 };
37
38 Photonic_Lightbox_Fancybox2.prototype.initialize = function(selector, group) {
39 this.handleSolos();
40 var self = this;
41
42 if (Photonic_JS.slideshow_mode) {
43 setInterval($.fancybox.next, parseInt(Photonic_JS.slideshow_interval, 10));
44 }
45
46 $('a.launch-gallery-fancybox').fancybox({
47 wrapCSS: 'photonic-fancybox',
48 autoPlay: Photonic_JS.slideshow_mode,
49 playSpeed: parseInt(Photonic_JS.slideshow_interval, 10),
50 //type: 'image',
51 autoScale: true,
52 autoResize: true,
53 scrolling: 'no',
54 afterShow: function(current, previous) {
55 self.swipe();
56 var shareable = {
57 'url': location.href,
58 'title': photonicHtmlDecode($(this.element).data('title')),
59 'image': $(this.element).attr('href')
60 };
61 self.addSocial('.fancybox-title', shareable);
62
63 var videoID = $(this.element).attr('href');
64 var videoURL = $(this.element).attr('data-html5-href');
65 if (videoURL !== undefined) {
66 self.getVideoSize(videoURL, {height: window.innerHeight * 0.85 - 30 - 40, width: window.innerWidth * 0.85 - 30}).then(function(dimensions) {
67 $(videoID).find('video').attr('width', dimensions.newWidth).attr('height', dimensions.newHeight);
68 $(videoID).css({width: dimensions.newWidth, height: dimensions.newHeight});
69 $('.fancybox-skin .fancybox-inner').css({overflow: 'hidden'});
70 });
71 }
72 },
73 beforeLoad: function() {
74 if (Photonic_JS.fbox_show_title) {
75 this.title = $(this.element).data('title');
76 }
77 self.setHash(this.element);
78 },
79 afterClose: function() {
80 self.unsetHash();
81 },
82 helpers: {
83 title: {
84 type: Photonic_JS.fbox_title_position
85 },
86 thumbs : {
87 width : 50,
88 height : 50
89 },
90 overlay: {
91 css: {
92 'background': 'rgba(0, 0, 0, 0.8)'
93 }
94 },
95 buttons : {}
96 }
97 });
98 $('a.fancybox2-video').fancybox({type: 'iframe'});
99 $('a.fancybox2-html5-video').each(function() {
100 var videoID = $(this).attr('href');
101 var videoURL = $(this).attr('data-html5-href');
102 $(this).fancybox({
103 type: 'inline',
104 wrapCSS: 'photonic-fancybox',
105 autoScale: true,
106 scrolling: 'no',
107 beforeLoad: function() {
108 self.getVideoSize(videoURL, {height: window.innerHeight - 30 - 40, width: window.innerWidth - 30}).then(function(dimensions) {
109 $(videoID).find('video').attr('width', dimensions.newWidth).attr('height', dimensions.newHeight);
110 $(videoID).css({width: dimensions.newWidth, height: dimensions.newHeight});
111 $('.fancybox-skin .fancybox-inner').css({overflow: 'hidden'});
112 });
113 },
114 onComplete: function() {
115 $.fancybox.update();
116 }
117 });
118 });
119 };
120
121 photonicLightbox = new Photonic_Lightbox_Fancybox2();
122 photonicLightbox.initialize();
123