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 / Fancybox3.js

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

121 lines 3.7 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 PhotonicFancybox3 extends Lightbox {
5 constructor($) {
6 super();
7
8 this.$ = $;
9 this.buttons = [];
10 if (Photonic_JS.fb3_zoom) {
11 this.buttons.push('zoom');
12 }
13 if (Photonic_JS.fb3_slideshow) {
14 this.buttons.push('slideShow');
15 }
16 if (Photonic_JS.fb3_fullscreen_button) {
17 this.buttons.push('fullScreen');
18 }
19 if (Photonic_JS.fb3_download) {
20 this.buttons.push('download');
21 }
22 if (Photonic_JS.fb3_thumbs_button) {
23 this.buttons.push('thumbs');
24 }
25 this.buttons.push('close');
26 }
27
28 soloImages() {
29 const $ = this.$;
30 $('a[href]').filter(function() {
31 return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href'));
32 }).addClass("photonic-fancybox").addClass(Photonic_JS.lightbox_library);
33 };
34
35 hostedVideo(a) {
36 const html5 = a.getAttribute('href').match(new RegExp(/(\.mp4|\.webm|\.ogg)/i)),
37 css = a.classList.contains('photonic-lb');
38
39 if (html5 !== null && !css) {
40 a.classList.add(Photonic_JS.lightbox_library + "-html5-video");
41 this.videoIndex++;
42 }
43 };
44
45 changeVideoURL(element, regular, embed) {
46 element.setAttribute('href', embed); // Don't need this for Fancybox3, but short URLs don't support "start" or "t" parameters; embed and regular URLs do.
47 };
48
49 initialize(selector, group) {
50 this.handleSolos();
51 const self = this;
52 const $ = self.$;
53
54 let lightbox_selector;
55 if (group !== null && group !== undefined) {
56 lightbox_selector = 'a[data-fancybox="' + group + '"]';
57 }
58 else if (selector !== null && selector !== undefined) {
59 lightbox_selector = selector + ' a.photonic-fancybox';
60 }
61 else {
62 lightbox_selector = 'a.photonic-fancybox';
63 }
64
65 $(lightbox_selector).fancybox({
66 defaultType: 'image',
67 hash: false,
68 caption: function(instance, item) {
69 return Util.HTMLSanitizer.SanitizeHTML($(this).data('title'));
70 },
71 loop: Photonic_JS.lightbox_loop === '1',
72 buttons: self.buttons,
73 slideShow: {
74 autoStart: Photonic_JS.slideshow_mode,
75 speed: parseInt(Photonic_JS.slideshow_interval, 10)
76 },
77 thumbs: {
78 autoStart: Photonic_JS.fb3_thumbs === '1',
79 hideOnClose: true
80 },
81 fullScreen: {
82 autoStart: Photonic_JS.fb3_fullscreen === '1'
83 },
84 protect: Photonic_JS.fb3_disable_right_click === '1',
85 transitionEffect: Photonic_JS.fb3_transition_effect,
86 transitionDuration: Photonic_JS.fb3_transition_speed,
87 afterShow: function(instance, slide) {
88 const shareable = {
89 'url': location.href,
90 'title': $(slide).length > 0 && $(slide)[0].opts !== undefined && $(slide)[0].opts.$orig !== undefined ? Util.getText($(slide)[0].opts.$orig.attr('title')) : '',
91 'image': $(slide).length > 0 && $(slide)[0].opts !== undefined && $(slide)[0].opts.$orig !== undefined ? $(slide)[0].opts.$orig.attr('href') : ''
92 };
93 self.addSocial('.fancybox-toolbar', shareable, 'afterbegin');
94 },
95 beforeShow: function() {
96 const videoID = this.src,
97 videoURL = this.opts.html5Href;
98 if (videoURL !== undefined) {
99 self.getVideoSize(videoURL, {height: window.innerHeight * 0.85, width: window.innerWidth * 0.85}).then(function(dimensions) {
100 $(videoID).find('video').attr('width', dimensions.newWidth).attr('height', dimensions.newHeight);
101 $(videoID).css({width: dimensions.newWidth, height: dimensions.newHeight});
102 });
103 }
104 self.setHash(this.opts.photonicDeep);
105 },
106 afterClose: function() {
107 self.unsetHash();
108 }
109 });
110
111 $('a.fancybox3-video,a.fancybox3-html5-video').fancybox({
112 youtube: { }
113 });
114 };
115
116 initializeForNewContainer(containerId) {
117 this.initialize(containerId);
118 };
119
120 }
121