PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.34
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.34
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 / ImageLightbox.js

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

79 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {Core} from "../Core";
2 import {Lightbox} from "./Lightbox";
3 import * as Util from "../Util";
4
5 export class PhotonicImageLightbox extends Lightbox {
6 constructor($) {
7 super();
8 this.$ = $;
9 }
10
11 soloImages() {
12 const $ = this.$;
13 $('a[href]').filter(function() {
14 return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href'));
15 }).filter(function() {
16 const res = new RegExp('photonic-lb').test($(this).attr('class'));
17 return !res;
18 }).attr("rel", 'photonic-' + Photonic_JS.lightbox_library);
19 };
20
21 initialize(selector, group) {
22 const $ = this.$;
23 this.handleSolos();
24 const self = this;
25
26 $(selector).each(function(i, current) {
27 let lightbox_selector;
28 let rel = $(current).find('a.photonic-imagelightbox');
29 if (rel.length > 0) {
30 rel = $(rel[0]).attr('rel');
31 }
32
33 lightbox_selector = selector.indexOf('rel') > -1 ? selector : 'a[rel="' + rel + '"]';
34
35 const photonicImageLightbox = $(lightbox_selector).imageLightbox(lightbox_selector, {
36 onLoadStart: function () {
37 imageLightboxCaptionOff();
38 imageLightboxLoadingOn();
39 },
40 onLoadEnd: function () {
41 imageLightboxCaptionOn();
42 $('#imagelightbox-loading').remove();
43 $('.imagelightbox-arrow').css('display', 'block');
44 const lightbox = $('#imagelightbox');
45 const base = $(current).find('a[href="' + lightbox.attr('src') + '"]');
46 if (base.length > 0) {
47 self.setHash(base[0]);
48 }
49 const shareable = {
50 'url': location.href,
51 'title': Util.getText($(base).data('title')),
52 'image': lightbox.attr('src')
53 };
54 self.addSocial('#imagelightbox-overlay', shareable);
55 },
56 onStart: function () {
57 $('<div id="imagelightbox-overlay"></div>').appendTo('body');
58 imageLightboxArrowsOn(photonicImageLightbox, lightbox_selector);
59 imageLightboxCloseButtonOn(photonicImageLightbox);
60 },
61 onEnd: function () {
62 imageLightboxCaptionOff();
63 $('#imagelightbox-overlay').remove();
64 $('#imagelightbox-loading').remove();
65 imageLightboxArrowsOff();
66 imageLightboxCloseButtonOff();
67 self.unsetHash();
68 }
69 });
70 Core.addToLightboxList(lightbox_selector, photonicImageLightbox);
71 });
72 };
73
74 initializeForNewContainer(containerId) {
75 this.initialize(containerId);
76 };
77
78 }
79