-
Notifications
You must be signed in to change notification settings - Fork 2
/
inLarge.min.js
1 lines (1 loc) · 2.04 KB
/
inLarge.min.js
1
!function(i){function e(){window_h=i(window).height(),window_w=i(window).width(),iframe_h=.5625*i("#inlarge-iframe").outerWidth(),iframe_w=1.7777*window_h,img_w=i("#inlarge-img").outerWidth(),i("#inlarge-inside").css("height",window_h),i("#inlarge-iframe").css("height",iframe_h),iframe_h>=window_h?i("#inlarge-iframe").css("width",iframe_w):i("#inlarge-iframe").css("width","100%"),img_w>window_w?i("#inlarge-img").css("width","100%"):i("#inlarge-img").css("width","auto")}i.fn.inLarge=function(a){var r=i.extend({speed:1e3,autoplay:!1,max_width:"100%",esc_close:!0},a);return 1==r.esc_close&&i(document).keyup(function(e){27==e.keyCode&&(i("#inlarge-container").fadeOut(r.speed),setTimeout(function(){i("#inlarge-iframe").attr("src","")},r.speed))}),i("body").append('<div id="inlarge-container"><a id="inlarge-close" href="javascript:;">X</a><div id="inlarge-wrapper"><div id="inlarge-inside"></div></div></div>'),this.each(function(){var a=i(this).attr("src"),n=i(this).attr("data-large"),t=i(this).attr("data-mobile"),l=i(this).attr("data-iframe");i(this).click(function(){var d=i(window).width();if(i("#inlarge-container").fadeIn(r.speed),l)i("#inlarge-inside").html(l.match(/(youtube|vimeo)/)?'<iframe id="inlarge-iframe" src="'+l+"?rel=0"+(r.autoplay?"&autoplay=1":"")+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>':'<iframe id="inlarge-iframe" src="'+l+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');else{if(n&&!t)var s=n;else if(n&&t&&d>=768)var s=n;else if(t&&768>d)var s=t;else if(n&&t&&768>d)var s=t;else var s=a;i("#inlarge-inside").html('<img id="inlarge-img" src="'+s+'" alt="" />')}var o=r.max_width.replace(/\D/g,"");d>o?i("#inlarge-inside iframe, #inlarge-inside img").css("max-width",r.max_width):i("#inlarge-inside iframe, #inlarge-inside img").css("max-width","100%"),e()}),i("#inlarge-wrapper, #inlarge-close").click(function(){i("#inlarge-container").fadeOut(r.speed),setTimeout(function(){i("#inlarge-iframe").attr("src","")},r.speed)})})},i(window).resize(function(){e()})}(jQuery);