-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfancybox.js
49 lines (47 loc) · 1.15 KB
/
fancybox.js
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
$(function () {
var imgList = $('.recent-post-item img').not('.no-fancybox')
if (imgList.length === 0) {
imgList = $('#post-content img').not('.no-fancybox')
}
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
})
})