PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.1.7
Sight – Professional Image Gallery and Portfolio v1.1.7
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / render / js / _initLightbox.js

_initLightbox.js in Sight – Professional Image Gallery and Portfolio 1.1.7, at render/js/_initLightbox.js

100 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Lightbox
3 */
4
5 import {
6 $,
7 $window,
8 $doc,
9 $body,
10 sight
11 } from './utility';
12
13 ( function( $ ) {
14
15 $.fn.SightLightbox = function( options ) {
16
17 var settings = $.extend( {
18 gallery : false,
19 }, options);
20
21 var containerSelector = this;
22 var imageSelector = null;
23
24 $( containerSelector ).each( function() {
25
26 if ( $( this ).is( 'img' ) ) {
27 imageSelector = this;
28 } else {
29 imageSelector = $( this ).find( 'img' );
30 }
31
32 $( imageSelector ).each( function() {
33
34 var link = $( this ).closest( '.sight-portfolio-entry' ).find( '.sight-portfolio-overlay-link' );
35
36 if ( ! $( link ).is( 'a' ) ) {
37 return;
38 }
39
40 var imagehref = $( link ).attr( 'href' );
41
42 if ( ! imagehref.match( /\.(gif|jpeg|jpg|png)/ ) ) {
43 return;
44 }
45
46 $( link ).addClass( 'sight-image-popup' );
47 });
48
49 if ( $( this ).closest( '.elementor-element' ).length > 0 ) {
50 return;
51 }
52
53 $( containerSelector ).magnificPopup( {
54 delegate: '.sight-image-popup',
55 type: 'image',
56 tClose: sight_lightbox_localize.text_close + '(Esc)',
57 tLoading: sight_lightbox_localize.text_loading,
58 gallery: {
59 enabled: settings.gallery,
60 tPrev: sight_lightbox_localize.text_previous,
61 tNext: sight_lightbox_localize.text_next,
62 tCounter: '<span class="mfp-counter">%curr% ' + sight_lightbox_localize.text_counter + ' %total%</span>'
63 },
64 image: {
65 titleSrc: function( item ) {
66 let entry = item.el.closest( '.sight-portfolio-entry' );
67
68 if ( $( entry ).hasClass( 'sight-portfolio-entry-custom' ) ) {
69
70 return $( entry ).find( '.sight-portfolio-entry__caption' ).text();
71
72 } else if ( $( entry ).hasClass( 'sight-portfolio-entry-post' ) ) {
73
74 return $( entry ).find( '.sight-portfolio-entry__caption' ).text();
75
76 } else {
77 return $( entry ).find( '.sight-portfolio-entry__heading' ).text();
78 }
79 }
80 },
81 } );
82 } );
83
84 };
85
86 function initSightLightbox() {
87 $( '.sight-portfolio-area-lightbox' ).imagesLoaded( function() {
88 $( '.sight-portfolio-area-lightbox' ).SightLightbox( { gallery: true } );
89 } );
90 }
91
92 $( document ).ready( function() {
93 initSightLightbox();
94 $( document.body ).on( 'post-load image-load', function() {
95 initSightLightbox();
96 } );
97 } );
98
99 } )( jQuery );
100