-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfancybox.js
More file actions
56 lines (54 loc) · 1.37 KB
/
fancybox.js
File metadata and controls
56 lines (54 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$(function () {
var imgList = $('.recent-post-item img')
if (imgList.length === 0) {
imgList = $('#post-content img')
}
for (var i = 0; i < imgList.length; i++) {
var $a = $(
'<a href="' +
imgList[i].src +
'" data-fancybox="group" data-caption="' +
imgList[i].alt +
'" class="fancybox"></a>'
)
var alt = imgList[i].alt
var $wrap = $(imgList[i]).wrap($a)
if (alt) {
$wrap.after('<div class="img-alt">' + alt + '</div>')
}
}
$().fancybox({
selector: '[data-fancybox]',
loop: true,
transitionEffect: 'slide',
buttons: [
"share",
"slideShow",
"fullScreen",
"download",
"thumbs",
"close"
],
})
var galleryItem = $('.gallery-item')
var galleryList = []
galleryItem.each(function (idx, elem) {
galleryList.push({
src: $(elem).data('url'),
opts: {
caption: $(elem).data('title')
}
})
})
galleryItem.on('click', function () {
$.fancybox.open(
galleryList,
{
loop: true,
transitionEffect: 'slide'
},
galleryItem.index(this)
)
return false
})
})