Improve image thumbnail
And auto download apk for android
This commit is contained in:
52
js/imagepreview.js
Normal file
52
js/imagepreview.js
Normal file
@ -0,0 +1,52 @@
|
||||
!(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 = 'thumbnail.php'
|
||||
var blobUrl;
|
||||
|
||||
$.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'
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user