You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.0 KiB
JavaScript


this.imagePreview = function() {
/* Cursor to image offset vars: */
xOffset = 20;
yOffset = 20;
/* Preview on hover code: */
$("a.preview").hover(
function(e) {
var link = $(this);
var titleHtml = "";
if(link.data("previewPopup") == undefined)
{
if(this.title != "")
{
link.data("titleStore", this.title);
this.title = "";
titleHtml = "<br/>" + link.data("titleStore");
}
var popup = $("<p id='preview' style='color:#a31022; background:#d1d1d1; padding:3px 3px 0 3px;'><img src='" + this.href + "' alt='Image preview' style='border:1px solid #fff' />" + titleHtml + "</p>");
link.data("previewPopup", popup)
link.append(popup);
var doFlip = e.pageX < ($(window).width() / 2);
if(doFlip)
{
popup
.css("top", (e.pageY - yOffset) + "px")
.css("left", (e.pageX + xOffset) + "px")
.fadeIn("fast");
}
else
{
popup
.css("top", (e.pageY - yOffset) + "px")
.css("right", ($(window).width() - (e.pageX - xOffset)) + "px")
.fadeIn("fast");
}
}
},
function() {
var link = $(this);
if(link.data("previewPopup") != undefined)
{
var popup = link.data("previewPopup");
if(link.data("titleStore") != undefined)
{
this.title = link.data("titleStore");
link.removeData("titleStore");
}
popup.remove();
link.removeData("previewPopup");
}
}
);
$("a.preview").mousemove(function(e) {
var link = $(this);
if(link.data("previewPopup") != undefined)
{
var doFlip = e.pageX < ($(window).width() / 2);
var popup = link.data("previewPopup");
if(doFlip)
{
popup
.css("top", (e.pageY - yOffset) + "px")
.css("left", (e.pageX + xOffset) + "px");
}
else
{
popup
.css("top", (e.pageY - yOffset) + "px")
.css("right", ($(window).width() - (e.pageX - xOffset)) + "px");
}
}
});
};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();