(function($){ $(document) .on('mouseenter', '.prettyPhotoLink', function(){ var $magnifier = $('#magnifier'); if(!$magnifier.length){ $magnifier = $('body').append('
').find('#magnifier'); } $magnifier.show(); var position = $(this).find('img').offset(); var width = $(this).closest('div').width(); $magnifier.css({'top' : position.top, 'left': position.left + width - 24}); }) .on('mouseleave', '.prettyPhotoLink', function(){ $('#magnifier').hide(); }) .on('mouseenter', '#magnifier', function(){ $('#magnifier').show(); }) .on('mouseleave', '#magnifier', function(){ $('#magnifier').hide(); }) .on('DOMUpdate', function(e){ $('#magnifier').hide(); $(e.target) .find("a[rel^='prettyPhoto']") .prettyPhoto({ allow_resize: false, deeplinking: false, show_title: false, social_tools: false, changepicturecallback: function(){ $('#fullResImage').trigger('DOMUpdate'); } }) .addClass("prettyPhotoLink"); }); })(jQuery);