-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokra.gallery.fancy.js
193 lines (181 loc) · 6.64 KB
/
tokra.gallery.fancy.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
var cleanup = function() {
$(".item .item").unwrap();
$(".msg").fadeIn().delay(1000).fadeOut();
$("#progress").fadeOut();
$('.tagName:empty').parents('.fbPhotosPhotoTagboxBase').remove();
$('.fbPhotosPhotoTagboxBase:has(.faceboxSuggestion)').remove();
$("img[src*='_o.jpg']").each(function() {
$(this).parentsUntil('#container').eq(3).addClass('oImg')
});
$(".fancybox").fancybox({
type: 'image',
playSpeed: 2000, closeBtn: false, helpers: {buttons: {}},
openEffect: 'none', closeEffect: 'none', prevEffect: 'none', nextEffect: 'none',
beforeShow: function() {
try {
var t = $(this.element[0].nextSibling).text().slice(0, 80);
this.title = t.length == 80 ? t + "..." : t;
var $e = $(this.element[0].parentNode).find('.loadedTag');
if ($e.length)$('.fancybox-image').after($e.html());
} catch (e) {
}
}
});
$('.largeAlbum').click(function(e) {
$(e.target).find('.fancybox').click();
});
var newCaption = !$('.captions>a').length && !$('.caption>a').length;
var $caption = newCaption ? $(".captions:not(:empty)") : $("a.captions");
$caption.fancybox({
autoWidth: true, maxWidth: '500px',
openEffect: 'none', closeEffect: 'none', prevEffect: 'none', nextEffect: 'none',
afterLoad: function() {
this.content = $(this.element[0]).parents('.item').find('.fancybox').html() + (newCaption ? this.content.html().replace(/\n/g, '<br>') : $(this.element[0].parentNode).html().replace(/\n/g, '<br>'));
}
});
$(document).on('mousewheel', ".fancybox-overlay", function(e, delta) {
var F = $.fancybox;
if (!e.target.className.match('fancybox-overlay') && $('.fancybox-inner .captions').length) {
return;
}
if (delta !== 0) {
e.preventDefault();
if (delta > 0) {
F.prev();
} else {
F.next();
}
}
});
$('#container').on('click', 'div.dateInd', function() {
$('div.dateInd>span').add('p.date').toggleClass('vis');
});
$('#container').on('click', 'div.commentInd', function(e) {
e.preventDefault();
$('div.dateInd>span').toggleClass('vis');
});
$("a[rel='comments']").fancybox({
title: null, autoWidth: true, maxWidth: '500px',
openEffect: 'none', closeEffect: 'none', prevEffect: 'none', nextEffect: 'none',
afterLoad: function() {
var $item = $(this.element[0]).parents('.item');
this.content = $item.find('.fancybox').html() + $item.find('.loadedComment').html().replace(/\n/g, '<br>');
},
afterShow: function() {
$('.fancybox-inner').css('overflow-y', 'auto');
}
});
$('body').on('keydown', '.fancybox-overlay', function(e) {
if (e.ctrlKey)$('.fancybox-inner .fbPhotosPhotoTagboxBase').not(document.querySelector('.fbPhotosPhotoTagboxBase:hover')).hide();
});
$('body').on('keyup', '.fancybox-overlay', function(e) {
if (e.which == 17)$('.fancybox-inner .fbPhotosPhotoTagboxBase').show();
});
if ($('#filterBar').length && window.Core == undefined) {
try {
var $t = $('.item:eq(0)');
var i = $t.find('img').attr('src');
var b = $t.find('div.img');
if (b.css('background-image').match(/\((.*)\)/)[1] != i || $t.html().match(/akamaihd\.net/)) {
$('div.img').each(function(i, e) {
var n = $(e).parent().parent()[0].href;
$(e).css('background-image', 'url("' + (n + '') + '")');
$(e).find('img').attr('src', n);
});
}
} catch (e) {
}
window.Core = {
filter: {},
filterTimer: 0,
filterInited: false,
filterInit: function() {
if (!Core.filterInited) {
Core.filterInited = true;
$('.filterBar').show().on('click keyup', Core.handleFilter);
$('#addFilter').click(Core.addFilter);
$('#resetFilter').click(Core.resetFilter);
} else {
$('.filterBar').toggle();
}
},
addFilter: function() {
$('.filter:last').after($('.filter:first').clone());
$('.filter:last input').val('');
},
resetFilter: function() {
$('.filter:gt(0)').remove();
$('#container').find('.row>div').add('.tab-content div').removeClass('hide');
},
handleFilter: function() {
if (Core.filterTimer) {
clearTimeout(Core.filterTimer);
Core.filterTimer = 0;
}
Core.filterTimer = setTimeout(Core.applyFilter, 500);
},
applyFilter: function() {
var switches = {}, filter = {};
$('.switch .col-4').each(function(i, e) {
var type = $(e).find('input[type="checkbox"]').prop("checked");
if (type) {
var s = $(e).find('input:checked[type="radio"]');
switches[s.attr('name')] = s.val() == 'with';
}
});
$('.filter').each(function(i, e) {
var s = $(e).find('input').val();
if (s && s.length) {
var type = $(e).find('select').val();
if (!filter[type])filter[type] = s;
else {
filter[type] += "|" + s;
}
}
});
if (JSON.stringify(filter).length > 2)switches.filter = filter;
if (JSON.stringify(Core.filter) === JSON.stringify(switches) || JSON.stringify(switches).length == 2)return;
Core.filter = switches;
$('.item').each(function(i, e) {
var need = true;
if (switches.caption !== undefined || filter["Caption"]) {
var caption = $(e).find('.caption').text();
need = Core.filterSub(switches.caption, caption, filter["Caption"]);
}
if (switches.comment !== undefined || filter["Comment"]) {
var comment = $(e).find('.loadedComment').text();
need = Core.filterSub(switches.comment, comment, filter["Comment"]);
}
if (switches.tag !== undefined || filter["Tag"]) {
var tag = '';
$(e).find('.loadedTag .tagName').each(function(i, e) {
if (!tag.length)tag = $(e).text();
else {
tag += "|" + $(e).text();
}
});
need = Core.filterSub(switches.tag, tag, filter["Tag"]);
}
$(e).parent().toggleClass('hide', !need);
});
},
filterSub: function(switches, test, filter) {
var need = true;
if (switches !== undefined) {
var s = test ? !!test.length : false;
need = (switches == s);
}
try {
if (filter)need = !!test.match(new RegExp(filter, "i"));
} catch (e) {
}
return need;
}
}
$('#filterBar').click(Core.filterInit);
}
}
$(function() {
$("#cleanup").click(cleanup);
});
setTimeout(cleanup, 2000);