-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.embiggen.min.js
15 lines (13 loc) · 1.51 KB
/
jquery.embiggen.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
* jQuery Embiggen plugin
*
* Author: Cameron Skene
* Description: jQuery Embiggen Plugin. Displays linked to images center to window.
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function(a){jQuery.fn.embiggen=function(e){defaults={vertical:!0,bgcolor:"#191919",opacity:"0.98"};var h=a.extend(defaults,e);a(this).click(function(e){e.preventDefault();var j=a(window).scrollTop(),i=a("<div>",{css:{"background-image":"url(img/ajax-loader.gif)",position:"fixed",top:0,left:0,width:"100%",height:a(window).height(),"background-color":h.bgcolor,"background-position":"50% 50%","background-repeat":"no-repeat","z-index":"100",opacity:h.opacity},click:function(){a(this).next().remove();
a(this).remove()}}).appendTo("body");a(window).resize(function(){a(i).css({height:a(window).height()})});var g=new Image;a(g).load(function(){var d=a(window).width()-50,f=a(window).height()-50,b=g.width,c=g.height,e=a('<img src="'+g.src+'" width="'+b+'" />');e.insertAfter(i).css({position:"absolute",top:"50%",left:"50%","z-index":"101"}).click(function(){a(this).prev().remove();a(this).remove()});h.vertical&&(b>d?(c*=d/b,b=d,c>f&&(b*=f/c,c=f)):c>f&&(b*=f/c,c=f,b>d&&(c*=d/b,b=d)),e.css({top:"50%",
width:b,height:c,"margin-top":-c/2+j,"margin-left":-b/2}));h.vertical||(b>d&&(b=d),e.css({top:"25px",width:b,height:"auto","margin-top":j,"margin-left":-b/2}));a(i).css("background-image","none")});g.src=this.href});return this}})(jQuery);