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_Featherlight.js

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

135 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function Photonic_Lightbox_Featherlight() {
2 Photonic_Lightbox.call(this);
3 }
4 Photonic_Lightbox_Featherlight.prototype = Object.create(Photonic_Lightbox.prototype);
5
6 Photonic_Lightbox_Featherlight.prototype.resizeContainer = function(elem) {
7 var target = elem;
8 var video = $(target.attr('data-featherlight'));
9 var videoURL = $(video.children()[0]).attr('src');
10 if (videoURL === undefined) {
11 //videoURL = target.attr('data-html5-href');
12 }
13 this.getVideoSize(videoURL, {width: window.innerWidth * 0.85 - 50, height: window.innerHeight * 0.85 - 50}).then(function(dimensions) {
14 $('.featherlight-content').find('video').attr('width', dimensions.newWidth).attr('height', dimensions.newHeight);
15 target.attr('data-featherlight', $('<div/>').append(video).html());
16 });
17 };
18
19 Photonic_Lightbox_Featherlight.prototype.resizeImageContainer = function(elem) {
20 var imageURL = $(elem).attr('href');
21 this.getImageSize(imageURL, {width: window.innerWidth * 0.85 - 50, height: window.innerHeight * 0.85 - 50}).then(function(dimensions) {
22 $('.featherlight-content').find('img').css({ width: dimensions.newWidth + 'px', height: dimensions.newHeight + 'px'});
23 });
24 };
25
26 Photonic_Lightbox_Featherlight.prototype.soloImages = function() {
27 $('a[href]').filter(function() {
28 return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href'));
29 }).filter(function() {
30 var res = new RegExp('photonic-launch-gallery').test($(this).attr('class'));
31 return !res;
32 }).addClass("photonic-featherlight-solo");
33 };
34
35 Photonic_Lightbox_Featherlight.prototype.changeVideoURL = function(element, regular, embed) {
36 $(element).attr('href', embed);
37 $(element).attr("data-featherlight", 'iframe').addClass('featherlight-video');
38 };
39
40 Photonic_Lightbox_Featherlight.prototype.hostedVideo = function(a) {
41 var html5 = $(a).attr('href').match(new RegExp(/(\.mp4|\.webm|\.ogg)/i));
42 var css = $(a).attr('class');
43 css = css !== undefined && css.includes('photonic-launch-gallery');
44
45 if (html5 !== null && !css) {
46 $(a).addClass(Photonic_JS.slideshow_library + "-html5-video");
47 $(a).attr('data-featherlight', '<video controls preload="none"><source src="' + $(a).attr('href') + '" type="video/mp4">Your browser does not support HTML5 video.</video>');
48
49 this.videoIndex++;
50 }
51 };
52
53 Photonic_Lightbox_Featherlight.prototype.initializeGallery = function(selector, self) {
54 $(selector).featherlightGallery({
55 gallery: {
56 fadeIn: 300,
57 fadeOut: 300
58 },
59 openSpeed: 300,
60 closeSpeed: 300,
61 afterContent: function() {
62 this.$legend = this.$legend || $('<div class="legend"/>').insertAfter(this.$content.parent());
63 this.$legend.html(this.$currentTarget.data('title'));
64 this.$instance.find('.featherlight-previous img').remove();
65 this.$instance.find('.featherlight-next img').remove();
66 self.setHash(this.$currentTarget);
67 var shareable = {
68 'url': location.href,
69 'title': photonicHtmlDecode(this.$currentTarget.data('title')),
70 'image': this.$content.attr('src')
71 };
72 self.addSocial('.photonic-featherlight', shareable);
73 $(window).resize();
74 },
75 afterClose: function() {
76 self.unsetHash();
77 },
78 onResize: function() {
79 //if ($(this.$currentTarget).attr('data-featherlight-type') == 'video' || $(this.$currentTarget).attr('data-html5-href') != undefined) {
80 if ($(this.$currentTarget).attr('data-featherlight-type') === 'video') {
81 self.resizeContainer($(this.$currentTarget));
82 }
83 else {
84 self.resizeImageContainer($(this.$currentTarget));
85 }
86 },
87 variant: 'photonic-featherlight'
88 });
89 };
90
91 Photonic_Lightbox_Featherlight.prototype.initialize = function(selector, group) {
92 this.handleSolos();
93 var self = this;
94
95 $(selector).each(function() {
96 var current = $(this);
97 var thumbs = current.find('a.launch-gallery-featherlight');
98 var rel = '';
99 if (thumbs.length > 0) {
100 rel = $(thumbs[0]).attr('rel');
101 }
102 self.initializeGallery('a[rel="' + rel + '"]', self);
103 });
104
105 $('a.photonic-featherlight-solo').featherlight({
106 afterContent: function() {
107 this.$legend = this.$legend || $('<div class="legend"/>').insertAfter(this.$content.parent());
108 this.$legend.html(this.$currentTarget.data('title') || this.$currentTarget.attr('title') || this.$currentTarget.find('img').attr('title') || this.$currentTarget.find('img').attr('alt'));
109 },
110 type: 'image',
111 variant: 'photonic-featherlight'
112 });
113
114 $('a.featherlight-video').featherlight({
115 iframeWidth: 640,
116 iframeHeight: 480,
117 iframeFrameborder: 0,
118 variant: 'photonic-featherlight'
119 });
120
121 $('a.featherlight-html5-video').featherlight({
122 onResize: function() {
123 self.resizeContainer($(this.$currentTarget));
124 },
125 variant: 'photonic-featherlight'
126 });
127 };
128
129 Photonic_Lightbox_Featherlight.prototype.initializeForNewContainer = function(containerId) {
130 this.initialize(containerId);
131 };
132
133 photonicLightbox = new Photonic_Lightbox_Featherlight();
134 photonicLightbox.initialize('.photonic-standard-layout,.photonic-random-layout,.photonic-masonry-layout,.photonic-mosaic-layout');
135