PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.37
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.37
3.37 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 All 142 releases
photonic / include / js / front-end / src / Lightboxes / Fancybox2.js

Fancybox2.js in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.37, at include/js/front-end/src/Lightboxes/Fancybox2.js

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