Skip to content

Commit cca4301

Browse files
committed
Switched to plain js imagelightbox
1 parent a5d5a2e commit cca4301

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/php/frontend/class-shortcode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public static function init() {
5050

5151
Script_And_Style_Helpers::register_script(
5252
'sgdg_imagelightbox_script',
53-
'bundled/imagelightbox.umd.js',
54-
array( 'jquery' )
53+
'bundled/imagelightbox.umd.js'
5554
);
5655
Script_And_Style_Helpers::register_style( 'sgdg_imagelightbox_style', 'bundled/imagelightbox.css' );
5756
Script_And_Style_Helpers::register_script(

src/ts/frontend/shortcode/Shortcode.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// <reference types="imagelightbox" />
2-
1+
import { ImageLightbox } from 'imagelightbox';
32
import { default as justifiedLayout } from 'justified-layout';
43

54
import { isError } from '../../isError';
@@ -15,7 +14,19 @@ export class Shortcode {
1514
private readonly pageQueryParameter: QueryParameter;
1615
private readonly pathQueryParameter: QueryParameter;
1716

18-
private lightbox: JQuery = $();
17+
private readonly lightbox = new ImageLightbox([], {
18+
allowedTypes: '',
19+
animationSpeed: parseInt(sgdgShortcodeLocalize.preview_speed, 10),
20+
activity: 'true' === sgdgShortcodeLocalize.preview_activity,
21+
arrows: 'true' === sgdgShortcodeLocalize.preview_arrows,
22+
button: 'true' === sgdgShortcodeLocalize.preview_closebutton,
23+
fullscreen: true,
24+
gutter: 0,
25+
history: true,
26+
overlay: true,
27+
caption: 'true' === sgdgShortcodeLocalize.preview_captions,
28+
quitOnEnd: 'true' === sgdgShortcodeLocalize.preview_quitOnEnd,
29+
});
1930
private hasMore = false;
2031
private path = '';
2132
private lastPage = 1;
@@ -152,19 +163,6 @@ export class Shortcode {
152163
private get(): void {
153164
this.path = this.pathQueryParameter.get();
154165
this.lastPage = parseInt(this.pageQueryParameter.get()) || 1;
155-
this.lightbox = $().imageLightbox({
156-
allowedTypes: '',
157-
animationSpeed: parseInt(sgdgShortcodeLocalize.preview_speed, 10),
158-
activity: 'true' === sgdgShortcodeLocalize.preview_activity,
159-
arrows: 'true' === sgdgShortcodeLocalize.preview_arrows,
160-
button: 'true' === sgdgShortcodeLocalize.preview_closebutton,
161-
fullscreen: true,
162-
gutter: 0,
163-
history: true,
164-
overlay: true,
165-
caption: 'true' === sgdgShortcodeLocalize.preview_captions,
166-
quitOnEnd: 'true' === sgdgShortcodeLocalize.preview_quitOnEnd,
167-
});
168166
this.container
169167
.find('.sgdg-gallery')
170168
.replaceWith('<div class="sgdg-loading"><div></div></div>');
@@ -347,8 +345,10 @@ export class Shortcode {
347345
});
348346
this.reflowTimer();
349347

350-
this.lightbox.addToImageLightbox(
351-
this.container.find('a[data-imagelightbox]')
348+
this.lightbox.addImages(
349+
this.container
350+
.find('a[data-imagelightbox]')
351+
.get() as Array<HTMLAnchorElement>
352352
);
353353
if ('true' === sgdgShortcodeLocalize.page_autoload) {
354354
$(window)

webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export default {
2323
'@wordpress/components': 'var wp.components',
2424
'@wordpress/editor': 'var wp.editor',
2525
'@wordpress/element': 'var wp.element',
26-
jquery: 'commonjs jQuery',
26+
imagelightbox: 'var imagelightbox',
27+
jquery: 'var jQuery',
2728
'justified-layout': 'commonjs justified-layout',
2829
tinymce: 'var tinymce',
2930
},

0 commit comments

Comments
 (0)