jquery.stickyFooter.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*!
  2. * jQuery Sticky Footer 1.1
  3. * Corey Snyder
  4. * http://tangerineindustries.com
  5. * https://github.com/coreysyms/foundationStickyFooter
  6. *
  7. * Released under the MIT license
  8. *
  9. * Copyright 2013 Corey Snyder.
  10. *
  11. * Date: Thu Jan 22 2013 13:34:00 GMT-0630 (Eastern Daylight Time)
  12. * Modification for jquery 1.9+ Tue May 7
  13. */
  14. $(window).load(function() {
  15. stickyFooter();
  16. //IE 6,7,8 does not support mutation events so old skool here
  17. if (!jQuery.support.leadingWhitespace) {
  18. setInterval(checkForDOMChange, 100);
  19. }
  20. });
  21. //check for changes to the DOM
  22. function checkForDOMChange() {
  23. //leading white space will tell us if this is IE 9 or greater
  24. if (jQuery.support.leadingWhitespace) {
  25. $(document).unbind("DOMSubtreeModified");
  26. }
  27. stickyFooter();
  28. }
  29. //check for resize event if not IE 9 or greater
  30. if (jQuery.support.leadingWhitespace) {
  31. $(window).resize(function() {
  32. stickyFooter();
  33. });
  34. }
  35. function stickyFooter() {
  36. if ($("footer").attr('style')) {
  37. $("footer").removeAttr('style');
  38. }
  39. if (window.innerHeight != document.body.offsetHeight) {
  40. var offset = window.innerHeight - document.body.offsetHeight;
  41. var current = parseInt($("footer").css("margin-top"));
  42. if (current+offset > parseInt($("footer").css("margin-top"))) {
  43. $("footer").css({"margin-top":(current+offset)+"px"});
  44. }
  45. }
  46. if (jQuery.support.leadingWhitespace) {
  47. $(document).bind("DOMSubtreeModified", checkForDOMChange);
  48. }
  49. }
  50. /*
  51. ! end sticky footer
  52. */