PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.0.4
Sight – Professional Image Gallery and Portfolio v1.0.4
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.0.4, at render/js/_initLightbox.js

96 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 $( containerSelector ).magnificPopup( {
50 delegate: '.sight-image-popup',
51 type: 'image',
52 tClose: sight_lightbox_localize.text_close + '(Esc)',
53 tLoading: sight_lightbox_localize.text_loading,
54 gallery: {
55 enabled: settings.gallery,
56 tPrev: sight_lightbox_localize.text_previous,
57 tNext: sight_lightbox_localize.text_next,
58 tCounter: '<span class="mfp-counter">%curr% ' + sight_lightbox_localize.text_counter + ' %total%</span>'
59 },
60 image: {
61 titleSrc: function( item ) {
62 let entry = item.el.closest( '.sight-portfolio-entry' );
63
64 if ( $( entry ).hasClass( 'sight-portfolio-entry-custom' ) ) {
65
66 return $( entry ).find( '.sight-portfolio-entry__caption' ).text();
67
68 } else if ( $( entry ).hasClass( 'sight-portfolio-entry-post' ) ) {
69
70 return $( entry ).find( '.sight-portfolio-entry__caption' ).text();
71
72 } else {
73 return $( entry ).find( '.sight-portfolio-entry__heading' ).text();
74 }
75 }
76 },
77 } );
78 } );
79
80 };
81
82 function initSightLightbox() {
83 $( '.sight-portfolio-area-lightbox' ).imagesLoaded( function() {
84 $( '.sight-portfolio-area-lightbox' ).SightLightbox( { gallery: true } );
85 } );
86 }
87
88 $( document ).ready( function() {
89 initSightLightbox();
90 $( document.body ).on( 'post-load image-load', function() {
91 initSightLightbox();
92 } );
93 } );
94
95 } )( jQuery );
96