54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
!(function (a) {
|
|
"use strict";
|
|
a.fn.anarchytip = function (b) {
|
|
var c = a.extend({ xOffset: 10, yOffset: 30 }, b);
|
|
return this.each(function () {
|
|
var b = a(this);
|
|
b.hover(
|
|
function (b) {
|
|
(this.t = this.title), (this.title = "");
|
|
var d = "" != this.t ? "<br/>" + this.t : "";
|
|
a("body").append("<p id='preview'><img src='' alt='Image preview' />" + d + "</p>"),
|
|
a("#preview")
|
|
.css({ top: b.pageY - c.xOffset + "px", left: b.pageX + c.yOffset + "px" })
|
|
.fadeIn();
|
|
downloadThumbnail(this.pathname);
|
|
},
|
|
function () {
|
|
(this.title = this.t), a("#preview").remove();
|
|
}
|
|
),
|
|
b.mousemove(function (b) {
|
|
a("#preview")
|
|
.css("top", b.pageY - c.xOffset + "px")
|
|
.css("left", b.pageX + c.yOffset + "px");
|
|
});
|
|
});
|
|
};
|
|
})(jQuery);
|
|
|
|
function downloadThumbnail(file) {
|
|
var href = 'php/thumbnail.php'
|
|
var blobUrl;
|
|
console.log(file);
|
|
|
|
$.ajax({
|
|
url: href,
|
|
data: {
|
|
"file": file,
|
|
"size": '200'
|
|
},
|
|
xhrFields:{
|
|
responseType: 'blob'
|
|
},
|
|
success: function(data){
|
|
var blob = data;
|
|
blobUrl = window.URL.createObjectURL(new Blob([blob], {type: blob.type}));
|
|
console.log(blobUrl);
|
|
$('#preview img').attr('src', blobUrl);
|
|
},
|
|
error: error,
|
|
dataType: 'binary'
|
|
});
|
|
};
|