/* ########################################################################################################
* Modifiziertes Skript by Reber IT - 2013
* ########################################################################################################
* ORIGINAL-SKRIPT:
* Image preview script
* powered by jQuery (http://www.jquery.com)
*
* written by Alen Grakalic (http://cssglobe.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
* ########################################################################################################
*/
//Hilfsvariablen
var mouseOnThumb = 0;
var mouseOnZoom = 0;
var ivFlag = "";
var iiFlag = "";
this.imagePreview_lbFx_zoom = function(){
var xOffset = 7; //Std: 10
var yOffset = 5; //Std: 30
bind2item = "mouse"; //mouse | img
showTitel = true;
fit2screen = true;
fx = "fade";
fxtime = 120;
onklick = "nix";
//# Funktion zum Bild-Einblenden
$("a.ritLightBox_zoom").bind("mouseenter", function(e){
$(this).addClass("gotIt");
var baseObject = this;
var textLoader = false;
setTimeout(function() {
baseObject.t = baseObject.title;
baseObject.title = "";
if ($(baseObject).hasClass("gotIt")) {
if ($(baseObject).hasClass("rit_tlbz")) {
var picPageX = parseInt($(baseObject).offset().left);
var picPageY = parseInt($(baseObject).offset().top);
var picHeight = parseInt($(baseObject).height());
var picWidth = parseInt($(baseObject).width());
textLoader = true;
} else {
var picPageX = parseInt($(baseObject).find("img").offset().left);
var picPageY = parseInt($(baseObject).find("img").offset().top);
var picHeight = parseInt($(baseObject).find("img").height());
var picWidth = parseInt($(baseObject).find("img").width());
}
removeZoomImage_force();
var c = (baseObject.t != "") ? "
" + baseObject.t : "";
if (showTitel==false) { c=""; }
$("body").append("
"+ c +"
");
$("img#img_fxZoom").load(function() { // ALLES IM READY-HANDLER verstauen
var screenW = parseInt($("body").width() + $(document).scrollLeft() );
var screenH = parseInt($("body").height() + $(document).scrollTop() );
var actualPos_top = e.pageY - $(document).scrollTop();
var actualPos_left = e.pageX - $(document).scrollLeft();
var zoomPicW = parseInt($("div#ritLightBox_zoom_box").width());
var zoomPicH = parseInt($("div#ritLightBox_zoom_box").height());
var cssPaddingY = parseInt($("div#ritLightBox_zoom_box").css("padding-top")) + parseInt($("div#ritLightBox_zoom_box").css("padding-bottom"));
var cssPaddingX = parseInt($("div#ritLightBox_zoom_box").css("padding-left")) + parseInt($("div#ritLightBox_zoom_box").css("padding-right"));
var cssBorderC = parseInt($("#ritLightBox_zoom_box").css("border-left-width")) + parseInt($("#ritLightBox_zoom_box").css("border-right-width"));
alignX =0; alignY = 0;
space_right = screenW - (actualPos_left) // Pixel nach rechts (Standard)
space_left = actualPos_left // Platz nach links
space_top = actualPos_top // Platz nach oben
space_btm = screenH - (actualPos_top) // Platz nach oben
var freeSpaceX = space_right
var freeSpaceY = space_btm
if ((space_right < zoomPicW) && (space_left > space_right)) { alignX = 1; freeSpaceX = space_left; }
if ((space_btm < zoomPicH) && (space_top > space_btm)) { alignY = 1; freeSpaceY = space_top; }
//alert("alignX: " + alignX + " | alignY: " + alignY);
if (freeSpaceX < zoomPicW) {
$("div#ritLightBox_zoom_box").css("width", parseInt(freeSpaceX*0.8) + "px");
} else if (freeSpaceY < zoomPicH) {
$("div#ritLightBox_zoom_box").css("height", parseInt(freeSpaceY*0.8) + "px");
}
// alert("FitScreen: " + freeSpaceX + "<" + zoomPicW + " --> RealW: " + $("div#ritLightBox_zoom_box").css("width") + " (" + parseInt(freeSpaceX*0.8) + ")" );
//
zoomPicW = parseInt($("div#ritLightBox_zoom_box").width());
zoomPicH = parseInt($("div#ritLightBox_zoom_box").height());
if (xOffset==0) { xOffset = -3; }
if (yOffset==0) { yOffset = -3; }
if (xOffset>0) { xOffset = xOffset * -1; }
if (yOffset>0) { yOffset = xOffset * -1; }
var workSetX=0; var workSetY=0; var startEdge=""
if ((alignY==0) && (alignX==0)) { workSetX=-1 * xOffset; workSetY=-1 * yOffset; startEdge="leftTop"; } // von links oben (Std) | x+ | y- |
if ((alignY==0) && (alignX==1)) { workSetX=(-1 * xOffset)+(cssPaddingX+cssBorderC); workSetY=-1 * yOffset; startEdge="rightTop"; } // von rechts oben | x- | y- |
if ((alignX==0) && (alignY==1)) { workSetX=(-1 * xOffset); workSetY=-1*(yOffset)+(cssPaddingY+cssBorderC); startEdge="leftBottom"; } // von links unten | x+ | y+ |
if ((alignX==1) && (alignY==1)) { workSetX=-1 * (xOffset-(cssPaddingX+cssBorderC)); workSetY=-1*(yOffset-(cssPaddingY+cssBorderC)); startEdge="rightBottom"; } // von rechts unten | x- | y+ |
var myOffsetX=workSetX; var myOffsetY=workSetY;
var myOffsetX2=workSetX; var myOffsetY2=workSetY;
if (alignX==1) { myOffsetX = -1 * (workSetX + zoomPicW); }
if (alignY==1) { myOffsetY = -1 * (workSetY + zoomPicH); }
if ((alignY==0) && (alignX==0)) { myOffsetX2=workSetX; myOffsetY2=workSetY; startEdge2="leftTop"; } // von links oben (Std) | x+ | y- |
if ((alignY==0) && (alignX==1)) { myOffsetX2=myOffsetX + picWidth + cssBorderC; myOffsetY2=myOffsetY; startEdge2="rightTop"; } // von rechts oben | x- | y- |
if ((alignX==0) && (alignY==1)) { myOffsetX2=workSetX; myOffsetY2=myOffsetY + picHeight; startEdge2="leftBottom"; } // von links unten | x+ | y+ |
if ((alignX==1) && (alignY==1)) { myOffsetX2=myOffsetX + picWidth + cssBorderC; myOffsetY2=myOffsetY + picHeight; startEdge2="rightBottom"; } // von rechts unten | x- | y+ |
var ll_top = e.pageY + myOffsetY;
var ll_left = e.pageX + myOffsetX;
var ll_topM = picPageY + myOffsetY2;
var ll_leftM= picPageX + myOffsetX2;
$("a.ritLightBox_zoom").bind("click", function (e) { return false; } )
// Item-Bindungen
$("#ritLightBox_zoom_box")
.css("top",(ll_top) + "px")
.css("left",(ll_left) + "px")
.bind("mouseenter", function (e) { mouseOnZoom=1; removeZoomImage_cancel(); } )
.bind("mouseleave", function (e) { mouseOnZoom=0; removeZoomImage(); } );
$(baseObject)
.bind("mouseenter", function (e) { mouseOnThumb=1; removeZoomImage_cancel();} )
.bind("mouseleave", function (e) { mouseOnThumb=0; removeZoomImage(); } );
// Bildaktualisierung bei Cursor-Bewegung (nur bei Maus-Fixierung)
$("a.ritLightBox_zoom").mousemove(function(e){
//$("#debugAddon01b").html("top: " + e.pageY + myOffsetY + " | left: " + e.pageX );
$("#ritLightBox_zoom_box")
.css("top",(e.pageY + myOffsetY) + "px")
.css("left",(e.pageX + myOffsetX) + "px");
});
// Einblend-Effekt
$("#ritLightBox_zoom_box").fadeIn(fxtime, function() {
$("div#waitLoader").remove();
});
});
// READY-Handler ENDE
} //Focus-IF ENDE
},0);
});
$("a.ritLightBox_zoom").mouseleave(function(e){
$(this).removeClass("gotIt");
});
// Hilfsfunktion für Titelanzeige (Tooltip)
// function(){
// if (showTitel==true) {this.title = this.t; }
// //alert("out");
// });
}
// Weitere Hilfsfunktionen
// ***********************
function removeZoomImage_off() { //kleine Verzögerung beim Ausblenden
//ivFlag=window.setTimeout("removeZoomImage_now()", 200);
}
function removeZoomImage_cancel() { //Abbruch der Verzögerung
//window.clearTimeout(ivFlag);
}
function removeZoomImage() { // Entfernen wenn freigegeben
if ((mouseOnZoom==0) && (mouseOnThumb==0)) {
removeZoomImage_force();
}
}
function removeZoomImage_force() { // Entfernen wenn freigegeben
var rmvItem=$("#ritLightBox_zoom_box");
rmvItem.remove();
}
Number.random = function(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
};
// Skript laden
$(document).ready(function(){
imagePreview_lbFx_zoom();
});