Team:Exeter/javascript/backstretch.js

From 2014.igem.org

/*

* jQuery Backstretch 1.0
* http://srobbin.com/jquery-plugins/jquery-backstretch/
*
* Add a dynamically-resized background image to the page
*
* Copyright (c) 2009 Scott Robbin (srobbin.com)
* Dual licensed under the MIT and GPL licenses.
  • /

(function(a){a.backstretch=function(g,c,h){var d={hideUntilReady:true,speed:0},b;if(c&&typeof c=="object"){a.extend(d,c)}a(document).ready(e);return this;function e(){if(g){var i={left:0,top:0},l=a("<div />").attr("id","backstretch-wrap").css(a.extend(i,{position:"absolute",zIndex:-1})),j=a("<div />").attr("id","backstretch").css(a.extend(i,{position:"fixed",overflow:"hidden",zIndex:-1})).appendTo(l),k=a("<img />").attr("src",g).bind("load",function(){var self=a(this);b=self.width()/self.height();f(function(){if(d.hideUntilReady){self.fadeIn(d.speed,function(){if(typeof h=="function"){h()}})}})});if(d.hideUntilReady){k.hide()}k.appendTo(j);a("body").prepend(l);a(window).resize(f)}}function f(k){var j=a(window).width(),i=j/b;if(i<a(window).height()){i=a(window).height();j=i*b}a("#backstretch img").width(j).height(i);if(typeof k=="function"){k()}}}})(jQuery);