//depends on scrollTo plugin var zoom_active = true; $(document).ready( function() { //do not zoom when user is navigating slides $(".nozoom").hover( function() { zoom_active = false; }, function () { zoom_active = true; }); //set up zoom behavior $("#slide") .css("cursor", "pointer") .click(function (e) { var presentation_id; var slideFile; var zoomSrc; var offset; var slideSrc; var slideHeight = 0; var slideSrcPieces = []; var zoomSlideHeight = 0; var zoomSlideWidth = 650; //auto scaled to this width var windowLeftOffset = 0; //proceed or not if (zoom_active != true) { return; } //detemine where to place the zoomed image windowLeftOffset = (($(window).width() - zoomSlideWidth) / 2); if (windowLeftOffset < 0) { windowLeftOffset = 20; } //get position of the title and scroll to the title var slide_zoom_anchor = $('#slide_zoom_anchor').val(); offset = $("#" + slide_zoom_anchor).offset(); //set zoom slide height slideHeight = $('#slide').height(); if (slideHeight == 0) { return; } zoomSlideHeight = zoomSlideWidth * (slideHeight / $('#slide').width()); //determine current slide source slideSrc = $('#slide').css('backgroundImage'); slideSrc = slideSrc.replace(/http:\/\/|url\(|\)/gi, ''); //set full size slide src slideSrcPieces = slideSrc.split('/'); presentation_id = slideSrcPieces[2]; slideFile = slideSrcPieces[5]; zoomSrc = 'http://framewelder.com-cache.s3.amazonaws.com/presentations/' + presentation_id + '/slides/full/' + slideFile; //add zoom div to page $('body').prepend('
'); //style the zoom div $('#zoom') .css({ position: 'absolute', zIndex: 5001, height: zoomSlideHeight + 'px', width: zoomSlideWidth + 'px', top: offset['top'], left: windowLeftOffset + 'px', cursor: 'pointer', backgroundRepeat: 'no-repeat', backgroundImage: 'url(' + zoomSrc + ')' }) .click(function (e) { $("#zoom").remove(); }); }); });