sigal 2.4__py3-none-any.whl → 2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sigal/__main__.py +6 -1
- sigal/gallery.py +24 -9
- sigal/image.py +21 -4
- sigal/plugins/compress_assets.py +4 -3
- sigal/plugins/encrypt/encrypt.py +1 -1
- sigal/plugins/encrypt/endec.py +2 -2
- sigal/plugins/extended_caching.py +5 -1
- sigal/plugins/nomedia.py +1 -1
- sigal/plugins/titleregexp.py +2 -2
- sigal/plugins/zip_gallery.py +1 -1
- sigal/settings.py +12 -1
- sigal/templates/sigal.conf.py +9 -11
- sigal/themes/default/templates/description.html +29 -0
- sigal/themes/default/templates/footer.html +3 -0
- sigal/themes/galleria/templates/album_items.html +2 -23
- sigal/themes/photoswipe/static/photoswipe-dynamic-caption-plugin.esm.js +414 -0
- sigal/themes/photoswipe/static/photoswipe-dynamic-caption-plugin.esm.min.js +5 -0
- sigal/themes/photoswipe/static/photoswipe-fullscreen.esm.js +129 -0
- sigal/themes/photoswipe/static/photoswipe-fullscreen.esm.min.js +8 -0
- sigal/themes/photoswipe/static/photoswipe-lightbox.esm.js +1960 -0
- sigal/themes/photoswipe/static/photoswipe-lightbox.esm.js.map +1 -0
- sigal/themes/photoswipe/static/photoswipe-lightbox.esm.min.js +5 -0
- sigal/themes/photoswipe/static/photoswipe-video-plugin.esm.js +257 -0
- sigal/themes/photoswipe/static/photoswipe-video-plugin.esm.min.js +1 -0
- sigal/themes/photoswipe/static/photoswipe.css +385 -140
- sigal/themes/photoswipe/static/photoswipe.esm.js +7081 -0
- sigal/themes/photoswipe/static/photoswipe.esm.js.map +1 -0
- sigal/themes/photoswipe/static/photoswipe.esm.min.js +5 -0
- sigal/themes/photoswipe/static/styles.css +53 -0
- sigal/themes/photoswipe/templates/album.html +69 -74
- sigal/utils.py +4 -1
- sigal/version.py +16 -3
- sigal/video.py +2 -2
- sigal/writer.py +10 -2
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/METADATA +19 -24
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/RECORD +40 -42
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/WHEEL +1 -1
- sigal/plugins/upload_s3.py +0 -106
- sigal/themes/photoswipe/static/app.js +0 -214
- sigal/themes/photoswipe/static/default-skin/default-skin.css +0 -485
- sigal/themes/photoswipe/static/default-skin/default-skin.css.map +0 -10
- sigal/themes/photoswipe/static/default-skin/default-skin.png +0 -0
- sigal/themes/photoswipe/static/default-skin/default-skin.svg +0 -36
- sigal/themes/photoswipe/static/default-skin/preloader.gif +0 -0
- sigal/themes/photoswipe/static/echo/blank.gif +0 -0
- sigal/themes/photoswipe/static/echo/echo.js +0 -135
- sigal/themes/photoswipe/static/echo/echo.min.js +0 -2
- sigal/themes/photoswipe/static/photoswipe-ui-default.js +0 -871
- sigal/themes/photoswipe/static/photoswipe-ui-default.min.js +0 -1
- sigal/themes/photoswipe/static/photoswipe.css.map +0 -10
- sigal/themes/photoswipe/static/photoswipe.js +0 -3592
- sigal/themes/photoswipe/static/photoswipe.min.js +0 -1
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/LICENSE +0 -0
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/entry_points.txt +0 -0
- {sigal-2.4.dist-info → sigal-2.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PhotoSwipe Dynamic Caption plugin v1.2.7
|
|
3
|
+
* https://github.com/dimsemenov/photoswipe-dynamic-caption-plugin
|
|
4
|
+
*
|
|
5
|
+
* By https://dimsemenov.com
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const defaultOptions = {
|
|
9
|
+
captionContent: '.pswp-caption-content',
|
|
10
|
+
type: 'auto',
|
|
11
|
+
horizontalEdgeThreshold: 20,
|
|
12
|
+
mobileCaptionOverlapRatio: 0.3,
|
|
13
|
+
mobileLayoutBreakpoint: 600,
|
|
14
|
+
verticallyCenterImage: false
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class PhotoSwipeDynamicCaption {
|
|
18
|
+
constructor(lightbox, options) {
|
|
19
|
+
this.options = {
|
|
20
|
+
...defaultOptions,
|
|
21
|
+
...options
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
this.lightbox = lightbox;
|
|
25
|
+
|
|
26
|
+
this.lightbox.on('init', () => {
|
|
27
|
+
this.pswp = this.lightbox.pswp;
|
|
28
|
+
this.initCaption();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
initCaption() {
|
|
33
|
+
const { pswp } = this;
|
|
34
|
+
|
|
35
|
+
pswp.on('change', () => {
|
|
36
|
+
// make sure caption is displayed after slides are switched
|
|
37
|
+
this.showCaption(this.pswp.currSlide);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
pswp.on('calcSlideSize', (e) => this.onCalcSlideSize(e));
|
|
41
|
+
|
|
42
|
+
pswp.on('slideDestroy', (e) => {
|
|
43
|
+
if (e.slide.dynamicCaption) {
|
|
44
|
+
if (e.slide.dynamicCaption.element) {
|
|
45
|
+
e.slide.dynamicCaption.element.remove();
|
|
46
|
+
}
|
|
47
|
+
delete e.slide.dynamicCaption;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// hide caption if zoomed
|
|
52
|
+
pswp.on('zoomPanUpdate', ({ slide }) => {
|
|
53
|
+
if (pswp.opener.isOpen && slide.dynamicCaption) {
|
|
54
|
+
if (slide.currZoomLevel > slide.zoomLevels.initial) {
|
|
55
|
+
this.hideCaption(slide);
|
|
56
|
+
} else {
|
|
57
|
+
this.showCaption(slide);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// move caption on vertical drag
|
|
61
|
+
if (slide.dynamicCaption.element) {
|
|
62
|
+
let captionYOffset = 0;
|
|
63
|
+
if (slide.currZoomLevel <= slide.zoomLevels.initial) {
|
|
64
|
+
const shiftedAmount = slide.pan.y - slide.bounds.center.y;
|
|
65
|
+
if (Math.abs(shiftedAmount) > 1) {
|
|
66
|
+
captionYOffset = shiftedAmount;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.setCaptionYOffset(slide.dynamicCaption.element, captionYOffset);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.adjustPanArea(slide, slide.currZoomLevel);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
pswp.on('beforeZoomTo', (e) => {
|
|
78
|
+
this.adjustPanArea(pswp.currSlide, e.destZoomLevel);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Stop default action of tap when tapping on the caption
|
|
82
|
+
pswp.on('tapAction', (e) => {
|
|
83
|
+
if (e.originalEvent.target.closest('.pswp__dynamic-caption')) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
adjustPanArea(slide, zoomLevel) {
|
|
90
|
+
if (slide.dynamicCaption && slide.dynamicCaption.adjustedPanAreaSize) {
|
|
91
|
+
if (zoomLevel > slide.zoomLevels.initial) {
|
|
92
|
+
slide.panAreaSize.x = slide.dynamicCaption.originalPanAreaSize.x;
|
|
93
|
+
slide.panAreaSize.y = slide.dynamicCaption.originalPanAreaSize.y;
|
|
94
|
+
} else {
|
|
95
|
+
// Restore panAreaSize after we zoom back to initial position
|
|
96
|
+
slide.panAreaSize.x = slide.dynamicCaption.adjustedPanAreaSize.x;
|
|
97
|
+
slide.panAreaSize.y = slide.dynamicCaption.adjustedPanAreaSize.y;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
useMobileLayout() {
|
|
103
|
+
const { mobileLayoutBreakpoint } = this.options;
|
|
104
|
+
|
|
105
|
+
if (typeof mobileLayoutBreakpoint === 'function') {
|
|
106
|
+
return mobileLayoutBreakpoint.call(this);
|
|
107
|
+
} else if (typeof mobileLayoutBreakpoint === 'number') {
|
|
108
|
+
if (window.innerWidth < mobileLayoutBreakpoint) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
hideCaption(slide) {
|
|
117
|
+
if (slide.dynamicCaption && !slide.dynamicCaption.hidden) {
|
|
118
|
+
const captionElement = slide.dynamicCaption.element;
|
|
119
|
+
|
|
120
|
+
if (!captionElement) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
slide.dynamicCaption.hidden = true;
|
|
125
|
+
captionElement.classList.add('pswp__dynamic-caption--faded');
|
|
126
|
+
|
|
127
|
+
// Disable caption visibility with the delay, so it's not interactable
|
|
128
|
+
if (slide.captionFadeTimeout) {
|
|
129
|
+
clearTimeout(slide.captionFadeTimeout);
|
|
130
|
+
}
|
|
131
|
+
slide.captionFadeTimeout = setTimeout(() => {
|
|
132
|
+
captionElement.style.visibility = 'hidden';
|
|
133
|
+
delete slide.captionFadeTimeout;
|
|
134
|
+
}, 400);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setCaptionYOffset(el, y) {
|
|
139
|
+
el.style.transform = `translateY(${y}px)`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
showCaption(slide) {
|
|
143
|
+
if (slide.dynamicCaption && slide.dynamicCaption.hidden) {
|
|
144
|
+
const captionElement = slide.dynamicCaption.element;
|
|
145
|
+
|
|
146
|
+
if (!captionElement) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
slide.dynamicCaption.hidden = false;
|
|
151
|
+
captionElement.style.visibility = 'visible';
|
|
152
|
+
|
|
153
|
+
clearTimeout(slide.captionFadeTimeout);
|
|
154
|
+
slide.captionFadeTimeout = setTimeout(() => {
|
|
155
|
+
captionElement.classList.remove('pswp__dynamic-caption--faded');
|
|
156
|
+
delete slide.captionFadeTimeout;;
|
|
157
|
+
}, 50);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
setCaptionPosition(captionEl, x, y) {
|
|
162
|
+
const isOnHorizontalEdge = (x <= this.options.horizontalEdgeThreshold);
|
|
163
|
+
captionEl.classList[
|
|
164
|
+
isOnHorizontalEdge ? 'add' : 'remove'
|
|
165
|
+
]('pswp__dynamic-caption--on-hor-edge');
|
|
166
|
+
|
|
167
|
+
captionEl.style.left = x + 'px';
|
|
168
|
+
captionEl.style.top = y + 'px';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
setCaptionWidth(captionEl, width) {
|
|
172
|
+
if (!width) {
|
|
173
|
+
captionEl.style.removeProperty('width');
|
|
174
|
+
} else {
|
|
175
|
+
captionEl.style.width = width + 'px';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
setCaptionType(captionEl, type) {
|
|
180
|
+
const prevType = captionEl.dataset.pswpCaptionType;
|
|
181
|
+
if (type !== prevType) {
|
|
182
|
+
captionEl.classList.add('pswp__dynamic-caption--' + type);
|
|
183
|
+
captionEl.classList.remove('pswp__dynamic-caption--' + prevType);
|
|
184
|
+
captionEl.dataset.pswpCaptionType = type;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
updateCaptionPosition(slide) {
|
|
189
|
+
if (!slide.dynamicCaption || !slide.dynamicCaption.type || !slide.dynamicCaption.element) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (slide.dynamicCaption.type === 'mobile') {
|
|
194
|
+
this.setCaptionType(
|
|
195
|
+
slide.dynamicCaption.element,
|
|
196
|
+
slide.dynamicCaption.type
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
slide.dynamicCaption.element.style.removeProperty('left');
|
|
200
|
+
slide.dynamicCaption.element.style.removeProperty('top');
|
|
201
|
+
this.setCaptionWidth(slide.dynamicCaption.element, false);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const zoomLevel = slide.zoomLevels.initial;
|
|
206
|
+
const imageWidth = Math.ceil(slide.width * zoomLevel);
|
|
207
|
+
const imageHeight = Math.ceil(slide.height * zoomLevel);
|
|
208
|
+
|
|
209
|
+
this.setCaptionType(slide.dynamicCaption.element, slide.dynamicCaption.type);
|
|
210
|
+
if (slide.dynamicCaption.type === 'aside') {
|
|
211
|
+
this.setCaptionPosition(
|
|
212
|
+
slide.dynamicCaption.element,
|
|
213
|
+
slide.bounds.center.x + imageWidth,
|
|
214
|
+
slide.bounds.center.y
|
|
215
|
+
);
|
|
216
|
+
this.setCaptionWidth(slide.dynamicCaption.element, false);
|
|
217
|
+
} else if (slide.dynamicCaption.type === 'below') {
|
|
218
|
+
this.setCaptionPosition(
|
|
219
|
+
slide.dynamicCaption.element,
|
|
220
|
+
slide.bounds.center.x,
|
|
221
|
+
slide.bounds.center.y + imageHeight
|
|
222
|
+
);
|
|
223
|
+
this.setCaptionWidth(slide.dynamicCaption.element, imageWidth);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
onCalcSlideSize(e) {
|
|
228
|
+
const { slide } = e;
|
|
229
|
+
let captionSize;
|
|
230
|
+
let useMobileVersion;
|
|
231
|
+
|
|
232
|
+
if (!slide.dynamicCaption) {
|
|
233
|
+
slide.dynamicCaption = {
|
|
234
|
+
element: undefined,
|
|
235
|
+
type: false,
|
|
236
|
+
hidden: false
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const captionHTML = this.getCaptionHTML(slide);
|
|
240
|
+
|
|
241
|
+
if (!captionHTML) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
slide.dynamicCaption.element = document.createElement('div');
|
|
246
|
+
slide.dynamicCaption.element.className = 'pswp__dynamic-caption pswp__hide-on-close';
|
|
247
|
+
slide.dynamicCaption.element.innerHTML = captionHTML;
|
|
248
|
+
|
|
249
|
+
this.pswp.dispatch('dynamicCaptionUpdateHTML', {
|
|
250
|
+
captionElement: slide.dynamicCaption.element,
|
|
251
|
+
slide
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
slide.holderElement.appendChild(slide.dynamicCaption.element);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (!slide.dynamicCaption.element) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.storeOriginalPanAreaSize(slide);
|
|
262
|
+
|
|
263
|
+
slide.bounds.update(slide.zoomLevels.initial);
|
|
264
|
+
|
|
265
|
+
if (this.useMobileLayout()) {
|
|
266
|
+
slide.dynamicCaption.type = 'mobile';
|
|
267
|
+
useMobileVersion = true;
|
|
268
|
+
} else {
|
|
269
|
+
if (this.options.type === 'auto') {
|
|
270
|
+
if (slide.bounds.center.x > slide.bounds.center.y) {
|
|
271
|
+
slide.dynamicCaption.type = 'aside';
|
|
272
|
+
} else {
|
|
273
|
+
slide.dynamicCaption.type = 'below';
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
slide.dynamicCaption.type = this.options.type;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const imageWidth = Math.ceil(slide.width * slide.zoomLevels.initial);
|
|
281
|
+
const imageHeight = Math.ceil(slide.height * slide.zoomLevels.initial);
|
|
282
|
+
|
|
283
|
+
this.setCaptionType(
|
|
284
|
+
slide.dynamicCaption.element,
|
|
285
|
+
slide.dynamicCaption.type
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
if (slide.dynamicCaption.type === 'aside') {
|
|
289
|
+
this.setCaptionWidth(slide.dynamicCaption.element, false);
|
|
290
|
+
captionSize = this.measureCaptionSize(slide.dynamicCaption.element, e.slide);
|
|
291
|
+
|
|
292
|
+
const captionWidth = captionSize.x;
|
|
293
|
+
|
|
294
|
+
const horizontalEnding = imageWidth + slide.bounds.center.x;
|
|
295
|
+
const horizontalLeftover = (slide.panAreaSize.x - horizontalEnding);
|
|
296
|
+
|
|
297
|
+
if (horizontalLeftover <= captionWidth) {
|
|
298
|
+
slide.panAreaSize.x -= captionWidth;
|
|
299
|
+
this.recalculateZoomLevelAndBounds(slide);
|
|
300
|
+
} else {
|
|
301
|
+
// do nothing, caption will fit aside without any adjustments
|
|
302
|
+
}
|
|
303
|
+
} else if (slide.dynamicCaption.type === 'below' || useMobileVersion) {
|
|
304
|
+
this.setCaptionWidth(
|
|
305
|
+
slide.dynamicCaption.element,
|
|
306
|
+
useMobileVersion ? this.pswp.viewportSize.x : imageWidth
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
captionSize = this.measureCaptionSize(slide.dynamicCaption.element, e.slide);
|
|
310
|
+
const captionHeight = captionSize.y;
|
|
311
|
+
|
|
312
|
+
if (this.options.verticallyCenterImage) {
|
|
313
|
+
slide.panAreaSize.y -= captionHeight;
|
|
314
|
+
this.recalculateZoomLevelAndBounds(slide);
|
|
315
|
+
} else {
|
|
316
|
+
// Lift up the image only by caption height
|
|
317
|
+
|
|
318
|
+
// vertical ending of the image
|
|
319
|
+
const verticalEnding = imageHeight + slide.bounds.center.y;
|
|
320
|
+
|
|
321
|
+
// height between bottom of the screen and ending of the image
|
|
322
|
+
// (before any adjustments applied)
|
|
323
|
+
const verticalLeftover = slide.panAreaSize.y - verticalEnding;
|
|
324
|
+
const initialPanAreaHeight = slide.panAreaSize.y;
|
|
325
|
+
|
|
326
|
+
if (verticalLeftover <= captionHeight) {
|
|
327
|
+
// lift up the image to give more space for caption
|
|
328
|
+
slide.panAreaSize.y -= Math.min((captionHeight - verticalLeftover) * 2, captionHeight);
|
|
329
|
+
|
|
330
|
+
// we reduce viewport size, thus we need to update zoom level and pan bounds
|
|
331
|
+
this.recalculateZoomLevelAndBounds(slide);
|
|
332
|
+
|
|
333
|
+
const maxPositionX = slide.panAreaSize.x * this.options.mobileCaptionOverlapRatio / 2;
|
|
334
|
+
|
|
335
|
+
// Do not reduce viewport height if too few space available
|
|
336
|
+
if (useMobileVersion
|
|
337
|
+
&& slide.bounds.center.x > maxPositionX) {
|
|
338
|
+
// Restore the default position
|
|
339
|
+
slide.panAreaSize.y = initialPanAreaHeight;
|
|
340
|
+
this.recalculateZoomLevelAndBounds(slide);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
// mobile
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
this.storeAdjustedPanAreaSize(slide);
|
|
349
|
+
this.updateCaptionPosition(slide);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
measureCaptionSize(captionEl, slide) {
|
|
353
|
+
const rect = captionEl.getBoundingClientRect();
|
|
354
|
+
const event = this.pswp.dispatch('dynamicCaptionMeasureSize', {
|
|
355
|
+
captionEl,
|
|
356
|
+
slide,
|
|
357
|
+
captionSize: {
|
|
358
|
+
x: rect.width,
|
|
359
|
+
y: rect.height
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
return event.captionSize;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
recalculateZoomLevelAndBounds(slide) {
|
|
366
|
+
slide.zoomLevels.update(slide.width, slide.height, slide.panAreaSize);
|
|
367
|
+
slide.bounds.update(slide.zoomLevels.initial);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
storeAdjustedPanAreaSize(slide) {
|
|
371
|
+
if (slide.dynamicCaption) {
|
|
372
|
+
if (!slide.dynamicCaption.adjustedPanAreaSize) {
|
|
373
|
+
slide.dynamicCaption.adjustedPanAreaSize = {};
|
|
374
|
+
}
|
|
375
|
+
slide.dynamicCaption.adjustedPanAreaSize.x = slide.panAreaSize.x;
|
|
376
|
+
slide.dynamicCaption.adjustedPanAreaSize.y = slide.panAreaSize.y;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
storeOriginalPanAreaSize(slide) {
|
|
381
|
+
if (slide.dynamicCaption) {
|
|
382
|
+
if (!slide.dynamicCaption.originalPanAreaSize) {
|
|
383
|
+
slide.dynamicCaption.originalPanAreaSize = {};
|
|
384
|
+
}
|
|
385
|
+
slide.dynamicCaption.originalPanAreaSize.x = slide.panAreaSize.x;
|
|
386
|
+
slide.dynamicCaption.originalPanAreaSize.y = slide.panAreaSize.y;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
getCaptionHTML(slide) {
|
|
391
|
+
if (typeof this.options.captionContent === 'function') {
|
|
392
|
+
return this.options.captionContent.call(this, slide);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const currSlideElement = slide.data.element;
|
|
396
|
+
let captionHTML = '';
|
|
397
|
+
if (currSlideElement) {
|
|
398
|
+
const hiddenCaption = currSlideElement.querySelector(this.options.captionContent);
|
|
399
|
+
if (hiddenCaption) {
|
|
400
|
+
// get caption from element with class pswp-caption-content
|
|
401
|
+
captionHTML = hiddenCaption.innerHTML;
|
|
402
|
+
} else {
|
|
403
|
+
const img = currSlideElement.querySelector('img');
|
|
404
|
+
if (img) {
|
|
405
|
+
// get caption from alt attribute
|
|
406
|
+
captionHTML = img.getAttribute('alt');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return captionHTML;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export default PhotoSwipeDynamicCaption;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* PhotoSwipe Dynamic Caption plugin 1.2.7 - https://photoswipe.com
|
|
3
|
+
* (c) 2022 Dmytro Semenov
|
|
4
|
+
*/
|
|
5
|
+
const t={captionContent:".pswp-caption-content",type:"auto",horizontalEdgeThreshold:20,mobileCaptionOverlapRatio:.3,mobileLayoutBreakpoint:600,verticallyCenterImage:!1};class i{constructor(i,e){this.options={...t,...e},this.lightbox=i,this.lightbox.on("init",(()=>{this.pswp=this.lightbox.pswp,this.initCaption()}))}initCaption(){const{pswp:t}=this;t.on("change",(()=>{this.showCaption(this.pswp.currSlide)})),t.on("calcSlideSize",(t=>this.onCalcSlideSize(t))),t.on("slideDestroy",(t=>{t.slide.dynamicCaption&&(t.slide.dynamicCaption.element&&t.slide.dynamicCaption.element.remove(),delete t.slide.dynamicCaption)})),t.on("zoomPanUpdate",(({slide:i})=>{if(t.opener.isOpen&&i.dynamicCaption){if(i.currZoomLevel>i.zoomLevels.initial?this.hideCaption(i):this.showCaption(i),i.dynamicCaption.element){let t=0;if(i.currZoomLevel<=i.zoomLevels.initial){const e=i.pan.y-i.bounds.center.y;Math.abs(e)>1&&(t=e)}this.setCaptionYOffset(i.dynamicCaption.element,t)}this.adjustPanArea(i,i.currZoomLevel)}})),t.on("beforeZoomTo",(i=>{this.adjustPanArea(t.currSlide,i.destZoomLevel)})),t.on("tapAction",(t=>{t.originalEvent.target.closest(".pswp__dynamic-caption")&&t.preventDefault()}))}adjustPanArea(t,i){t.dynamicCaption&&t.dynamicCaption.adjustedPanAreaSize&&(i>t.zoomLevels.initial?(t.panAreaSize.x=t.dynamicCaption.originalPanAreaSize.x,t.panAreaSize.y=t.dynamicCaption.originalPanAreaSize.y):(t.panAreaSize.x=t.dynamicCaption.adjustedPanAreaSize.x,t.panAreaSize.y=t.dynamicCaption.adjustedPanAreaSize.y))}useMobileLayout(){const{mobileLayoutBreakpoint:t}=this.options;return"function"==typeof t?t.call(this):"number"==typeof t&&window.innerWidth<t}hideCaption(t){if(t.dynamicCaption&&!t.dynamicCaption.hidden){const i=t.dynamicCaption.element;if(!i)return;t.dynamicCaption.hidden=!0,i.classList.add("pswp__dynamic-caption--faded"),t.captionFadeTimeout&&clearTimeout(t.captionFadeTimeout),t.captionFadeTimeout=setTimeout((()=>{i.style.visibility="hidden",delete t.captionFadeTimeout}),400)}}setCaptionYOffset(t,i){t.style.transform=`translateY(${i}px)`}showCaption(t){if(t.dynamicCaption&&t.dynamicCaption.hidden){const i=t.dynamicCaption.element;if(!i)return;t.dynamicCaption.hidden=!1,i.style.visibility="visible",clearTimeout(t.captionFadeTimeout),t.captionFadeTimeout=setTimeout((()=>{i.classList.remove("pswp__dynamic-caption--faded"),delete t.captionFadeTimeout}),50)}}setCaptionPosition(t,i,e){const s=i<=this.options.horizontalEdgeThreshold;t.classList[s?"add":"remove"]("pswp__dynamic-caption--on-hor-edge"),t.style.left=i+"px",t.style.top=e+"px"}setCaptionWidth(t,i){i?t.style.width=i+"px":t.style.removeProperty("width")}setCaptionType(t,i){const e=t.dataset.pswpCaptionType;i!==e&&(t.classList.add("pswp__dynamic-caption--"+i),t.classList.remove("pswp__dynamic-caption--"+e),t.dataset.pswpCaptionType=i)}updateCaptionPosition(t){if(!t.dynamicCaption||!t.dynamicCaption.type||!t.dynamicCaption.element)return;if("mobile"===t.dynamicCaption.type)return this.setCaptionType(t.dynamicCaption.element,t.dynamicCaption.type),t.dynamicCaption.element.style.removeProperty("left"),t.dynamicCaption.element.style.removeProperty("top"),void this.setCaptionWidth(t.dynamicCaption.element,!1);const i=t.zoomLevels.initial,e=Math.ceil(t.width*i),s=Math.ceil(t.height*i);this.setCaptionType(t.dynamicCaption.element,t.dynamicCaption.type),"aside"===t.dynamicCaption.type?(this.setCaptionPosition(t.dynamicCaption.element,t.bounds.center.x+e,t.bounds.center.y),this.setCaptionWidth(t.dynamicCaption.element,!1)):"below"===t.dynamicCaption.type&&(this.setCaptionPosition(t.dynamicCaption.element,t.bounds.center.x,t.bounds.center.y+s),this.setCaptionWidth(t.dynamicCaption.element,e))}onCalcSlideSize(t){const{slide:i}=t;let e,s;if(!i.dynamicCaption){i.dynamicCaption={element:void 0,type:!1,hidden:!1};const t=this.getCaptionHTML(i);if(!t)return;i.dynamicCaption.element=document.createElement("div"),i.dynamicCaption.element.className="pswp__dynamic-caption pswp__hide-on-close",i.dynamicCaption.element.innerHTML=t,this.pswp.dispatch("dynamicCaptionUpdateHTML",{captionElement:i.dynamicCaption.element,slide:i}),i.holderElement.appendChild(i.dynamicCaption.element)}if(!i.dynamicCaption.element)return;this.storeOriginalPanAreaSize(i),i.bounds.update(i.zoomLevels.initial),this.useMobileLayout()?(i.dynamicCaption.type="mobile",s=!0):"auto"===this.options.type?i.bounds.center.x>i.bounds.center.y?i.dynamicCaption.type="aside":i.dynamicCaption.type="below":i.dynamicCaption.type=this.options.type;const o=Math.ceil(i.width*i.zoomLevels.initial),n=Math.ceil(i.height*i.zoomLevels.initial);if(this.setCaptionType(i.dynamicCaption.element,i.dynamicCaption.type),"aside"===i.dynamicCaption.type){this.setCaptionWidth(i.dynamicCaption.element,!1),e=this.measureCaptionSize(i.dynamicCaption.element,t.slide);const s=e.x,n=o+i.bounds.center.x;i.panAreaSize.x-n<=s&&(i.panAreaSize.x-=s,this.recalculateZoomLevelAndBounds(i))}else if("below"===i.dynamicCaption.type||s){this.setCaptionWidth(i.dynamicCaption.element,s?this.pswp.viewportSize.x:o),e=this.measureCaptionSize(i.dynamicCaption.element,t.slide);const a=e.y;if(this.options.verticallyCenterImage)i.panAreaSize.y-=a,this.recalculateZoomLevelAndBounds(i);else{const t=n+i.bounds.center.y,e=i.panAreaSize.y-t,o=i.panAreaSize.y;if(e<=a){i.panAreaSize.y-=Math.min(2*(a-e),a),this.recalculateZoomLevelAndBounds(i);const t=i.panAreaSize.x*this.options.mobileCaptionOverlapRatio/2;s&&i.bounds.center.x>t&&(i.panAreaSize.y=o,this.recalculateZoomLevelAndBounds(i))}}}this.storeAdjustedPanAreaSize(i),this.updateCaptionPosition(i)}measureCaptionSize(t,i){const e=t.getBoundingClientRect();return this.pswp.dispatch("dynamicCaptionMeasureSize",{captionEl:t,slide:i,captionSize:{x:e.width,y:e.height}}).captionSize}recalculateZoomLevelAndBounds(t){t.zoomLevels.update(t.width,t.height,t.panAreaSize),t.bounds.update(t.zoomLevels.initial)}storeAdjustedPanAreaSize(t){t.dynamicCaption&&(t.dynamicCaption.adjustedPanAreaSize||(t.dynamicCaption.adjustedPanAreaSize={}),t.dynamicCaption.adjustedPanAreaSize.x=t.panAreaSize.x,t.dynamicCaption.adjustedPanAreaSize.y=t.panAreaSize.y)}storeOriginalPanAreaSize(t){t.dynamicCaption&&(t.dynamicCaption.originalPanAreaSize||(t.dynamicCaption.originalPanAreaSize={}),t.dynamicCaption.originalPanAreaSize.x=t.panAreaSize.x,t.dynamicCaption.originalPanAreaSize.y=t.panAreaSize.y)}getCaptionHTML(t){if("function"==typeof this.options.captionContent)return this.options.captionContent.call(this,t);const i=t.data.element;let e="";if(i){const t=i.querySelector(this.options.captionContent);if(t)e=t.innerHTML;else{const t=i.querySelector("img");t&&(e=t.getAttribute("alt"))}}return e}}export{i as default};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PhotoSwipe fullscreen plugin v1.0.5
|
|
3
|
+
*
|
|
4
|
+
* Inspired by https://github.com/dimsemenov/PhotoSwipe/issues/1759
|
|
5
|
+
*
|
|
6
|
+
* By https://arnowelzel.de
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
fullscreenTitle: 'Toggle fullscreen'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
class PhotoSwipeFullscreen {
|
|
14
|
+
constructor(lightbox, options) {
|
|
15
|
+
this.options = {
|
|
16
|
+
...defaultOptions,
|
|
17
|
+
...options
|
|
18
|
+
};
|
|
19
|
+
this.lightbox = lightbox;
|
|
20
|
+
this.lightbox.on('init', () => {
|
|
21
|
+
this.initPlugin(this.lightbox.pswp);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initPlugin(pswp) {
|
|
26
|
+
this.fullscreenAPI = this.getFullscreenAPI();
|
|
27
|
+
const fullscreenSVG = '<svg aria-hidden="true" class="pswp__icn" viewBox="0 0 32 32" width="32" height="32">' +
|
|
28
|
+
'<use class="pswp__icn-shadow" xlink:href="#pswp__icn-fullscreen-exit"/>' +
|
|
29
|
+
'<use class="pswp__icn-shadow" xlink:href="#pswp__icn-fullscreen-request"/>' +
|
|
30
|
+
'<path id="pswp__icn-fullscreen-request" transform="translate(4,4)" d="M20 3h2v6h-2V5h-4V3h4zM4 3h4v2H4v4H2V3h2zm16 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z" /></g>' +
|
|
31
|
+
'<path id="pswp__icn-fullscreen-exit" style="display:none" transform="translate(4,4)" d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"/>' +
|
|
32
|
+
'</svg>';
|
|
33
|
+
|
|
34
|
+
if (this.fullscreenAPI) {
|
|
35
|
+
pswp.on('uiRegister', () => {
|
|
36
|
+
pswp.ui.registerElement({
|
|
37
|
+
name: 'fullscreen-button',
|
|
38
|
+
title: this.options.fullscreenTitle,
|
|
39
|
+
order: 9,
|
|
40
|
+
isButton: true,
|
|
41
|
+
html: fullscreenSVG,
|
|
42
|
+
onClick: (event, el) => {
|
|
43
|
+
this.toggleFullscreen();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
pswp.events.add(document, 'keydown', (e) => {
|
|
48
|
+
if (e.keyCode == 70) { // 'f'
|
|
49
|
+
this.toggleFullscreen();
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.lightbox.on('close', () => {
|
|
57
|
+
if (this.fullscreenAPI && this.fullscreenAPI.isFullscreen()) {
|
|
58
|
+
this.fullscreenAPI.exit();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toggleFullscreen() {
|
|
64
|
+
if (this.fullscreenAPI) {
|
|
65
|
+
if (this.fullscreenAPI.isFullscreen()) {
|
|
66
|
+
// Exit full-screen mode
|
|
67
|
+
this.fullscreenAPI.exit();
|
|
68
|
+
// Toggle "Exit" and "Enter" full-screen SVG icon display
|
|
69
|
+
setTimeout(function() {
|
|
70
|
+
document.getElementById('pswp__icn-fullscreen-exit').style.display = 'none';
|
|
71
|
+
document.getElementById('pswp__icn-fullscreen-request').style.display = 'inline';
|
|
72
|
+
}, 300);
|
|
73
|
+
} else {
|
|
74
|
+
// Enter full-screen mode
|
|
75
|
+
this.fullscreenAPI.request(document.querySelector(`.pswp`));
|
|
76
|
+
// Toggle "Exit" and "Enter" full-screen SVG icon display
|
|
77
|
+
setTimeout(function() {
|
|
78
|
+
document.getElementById('pswp__icn-fullscreen-exit').style.display = 'inline';
|
|
79
|
+
document.getElementById('pswp__icn-fullscreen-request').style.display = 'none';
|
|
80
|
+
}, 300);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getFullscreenAPI() {
|
|
86
|
+
let api;
|
|
87
|
+
let enterFS;
|
|
88
|
+
let exitFS;
|
|
89
|
+
let elementFS;
|
|
90
|
+
let changeEvent;
|
|
91
|
+
let errorEvent;
|
|
92
|
+
|
|
93
|
+
if (document.fullscreenEnabled) {
|
|
94
|
+
enterFS = 'requestFullscreen';
|
|
95
|
+
exitFS = 'exitFullscreen';
|
|
96
|
+
elementFS = 'fullscreenElement';
|
|
97
|
+
changeEvent = 'fullscreenchange';
|
|
98
|
+
errorEvent = 'fullscreenerror';
|
|
99
|
+
} else if (document.webkitFullscreenEnabled) {
|
|
100
|
+
enterFS = 'webkitRequestFullscreen';
|
|
101
|
+
exitFS = 'webkitExitFullscreen';
|
|
102
|
+
elementFS = 'webkitFullscreenElement';
|
|
103
|
+
changeEvent = 'webkitfullscreenchange';
|
|
104
|
+
errorEvent = 'webkitfullscreenerror';
|
|
105
|
+
}
|
|
106
|
+
if (enterFS) {
|
|
107
|
+
api = {
|
|
108
|
+
request: function (el) {
|
|
109
|
+
if (enterFS === 'webkitRequestFullscreen') {
|
|
110
|
+
el[enterFS](Element.ALLOW_KEYBOARD_INPUT);
|
|
111
|
+
} else {
|
|
112
|
+
el[enterFS]();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
exit: function () {
|
|
116
|
+
return document[exitFS]();
|
|
117
|
+
},
|
|
118
|
+
isFullscreen: function () {
|
|
119
|
+
return document[elementFS];
|
|
120
|
+
},
|
|
121
|
+
change: changeEvent,
|
|
122
|
+
error: errorEvent
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return api;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default PhotoSwipeFullscreen;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const defaultOptions={fullscreenTitle:'Toggle fullscreen'};class PhotoSwipeFullscreen{constructor(lightbox,options){this.options={...defaultOptions,...options};this.lightbox=lightbox;this.lightbox.on('init',()=>{this.initPlugin(this.lightbox.pswp)})}
|
|
2
|
+
initPlugin(pswp){this.fullscreenAPI=this.getFullscreenAPI();const fullscreenSVG='<svg aria-hidden="true" class="pswp__icn" viewBox="0 0 32 32" width="32" height="32">'+'<use class="pswp__icn-shadow" xlink:href="#pswp__icn-fullscreen-exit"/>'+'<use class="pswp__icn-shadow" xlink:href="#pswp__icn-fullscreen-request"/>'+'<path id="pswp__icn-fullscreen-request" transform="translate(4,4)" d="M20 3h2v6h-2V5h-4V3h4zM4 3h4v2H4v4H2V3h2zm16 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z" /></g>'+'<path id="pswp__icn-fullscreen-exit" style="display:none" transform="translate(4,4)" d="M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z"/>'+'</svg>';if(this.fullscreenAPI){pswp.on('uiRegister',()=>{pswp.ui.registerElement({name:'fullscreen-button',title:this.options.fullscreenTitle,order:9,isButton:!0,html:fullscreenSVG,onClick:(event,el)=>{this.toggleFullscreen()}});pswp.events.add(document,'keydown',(e)=>{if(e.keyCode==70){this.toggleFullscreen();e.preventDefault()}})})}
|
|
3
|
+
this.lightbox.on('close',()=>{if(this.fullscreenAPI&&this.fullscreenAPI.isFullscreen()){this.fullscreenAPI.exit()}})}
|
|
4
|
+
toggleFullscreen(){if(this.fullscreenAPI){if(this.fullscreenAPI.isFullscreen()){this.fullscreenAPI.exit();setTimeout(function(){document.getElementById('pswp__icn-fullscreen-exit').style.display='none';document.getElementById('pswp__icn-fullscreen-request').style.display='inline'},300)}else{this.fullscreenAPI.request(document.querySelector(`.pswp`));setTimeout(function(){document.getElementById('pswp__icn-fullscreen-exit').style.display='inline';document.getElementById('pswp__icn-fullscreen-request').style.display='none'},300)}}}
|
|
5
|
+
getFullscreenAPI(){let api;let enterFS;let exitFS;let elementFS;let changeEvent;let errorEvent;if(document.fullscreenEnabled){enterFS='requestFullscreen';exitFS='exitFullscreen';elementFS='fullscreenElement';changeEvent='fullscreenchange';errorEvent='fullscreenerror'}else if(document.webkitFullscreenEnabled){enterFS='webkitRequestFullscreen';exitFS='webkitExitFullscreen';elementFS='webkitFullscreenElement';changeEvent='webkitfullscreenchange';errorEvent='webkitfullscreenerror'}
|
|
6
|
+
if(enterFS){api={request:function(el){if(enterFS==='webkitRequestFullscreen'){el[enterFS](Element.ALLOW_KEYBOARD_INPUT)}else{el[enterFS]()}},exit:function(){return document[exitFS]()},isFullscreen:function(){return document[elementFS]},change:changeEvent,error:errorEvent}}
|
|
7
|
+
return api}}
|
|
8
|
+
export default PhotoSwipeFullscreen
|