-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
112 lines (82 loc) · 2.2 KB
/
script.js
File metadata and controls
112 lines (82 loc) · 2.2 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
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
// main js funcs are here
var timer;
$(document).ready(function()
{
$(".result").on("clicks", function()
{
var id = $(this).attr("data-linkId");
var url = $(this).attr("href");
if(!id)
{ alert("data-linkId attribute not found"); }
increaseLinkClicks(id, url);
return false;
});
var grid =$(".imageResults");
grid.on("layoutComplete", function()
{
$(".gridItem img").css("visibility", "visible");
});
grid.masonry({
itemSelected: ".gridItem",
columnWidth: 200,
getter: 5,
// transitionDuration: '0.2s',
isInitLayout: false
});
$("[data-fancybox]").fancybox({
caption : function( instance, item ) {
var caption = $(this).data('caption') || '';
var siteUrl = $(this).data('siteurl') || '';
if ( item.type === 'image' ) {
caption = (caption.length ? caption + '<br />' : '')
+ '<a href="' + item.src + '"> View image </a>'
+ '<a href="' + siteUrl + '">| Visit page </a>'
}
return caption;
},
afterShow : function (instance, item)
{
increaseImageClicks(item.src);
}
});
});
function loadImage(src, className)
{
var image = $("<img>");
image.on("load", function()
{
$("." + className + " a").append(image);
clearTimeout(timer); //
timer = setTimeout(function()
{ $(".imageResults").masonry();}, 500);
});
image.on("error", function() {
$("." + className).remove();
$.post("setBroken.php", {src :src});
} );
image.attr("src", src);
}
function increaseLinkClicks(linkId, url)
{
$.post("updateLinkCount.php", {linkId: linkId})
.done( function(result)
{
if(result != "")
{
alert(result);
return;
}
});
}
function increaseImageClicks(imageUrl)
{
$.post("updateImageCount.php", {imageUrl:imageUrl})
.done( function(result)
{
if(result != "")
{
alert(result);
return;
}
});
}