From 13c097f42efecc1d97bfa20d9b0adfc93cb724ed Mon Sep 17 00:00:00 2001 From: andrewmbacon Date: Fri, 9 Jan 2015 14:28:29 -0500 Subject: [PATCH] Finally fixed StickyFooter For Real Had to calculate in heights for UC Header and Wp Admin bar. --- js/cs.js | 24 +++++++++++++++--------- js/min/cs.min.js | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/js/cs.js b/js/cs.js index 1f81c13..3a7a63c 100644 --- a/js/cs.js +++ b/js/cs.js @@ -219,25 +219,31 @@ jQuery(document).ready(function($) { // measures height of the page, and applies a class to absolute position the footer, or not. // on short pages, it sticks; on tall pages, it doesn't. -var wrapperH = $('#page').height(); +var wrapperH = $('#page').outerHeight(); +var wpadminbarH = $('#wpadminbar').outerHeight(); +var ucheaderH = $('#uc-header').outerHeight(); function stickyFoot(wrapperHeight){ + console.log('wrapperh: '+wrapperH); if (document.getElementById('page')!=null && document.getElementById('footers') !=null){ - var footerH = document.getElementById('footers').clientHeight + var footerH = $('#footers').outerHeight(); + console.log('footerH: '+footerH); + var windowH = window.innerHeight; + console.log('windowH: '+windowH); + windowH = windowH - wpadminbarH - ucheaderH; +console.log('windowH: '+windowH); if(windowH>=wrapperHeight){ + console.log('window frame TALLER than page contents'); $('body').addClass('sticky'); } else { + console.log('window frame SMALLER than page contents'); + $('body').removeClass('sticky'); } } } window.onload = function (){ - placeholderSupport = ("placeholder" in document.createElement("input")); - if(placeholderSupport!=false){ - var d = $('main'); - d.addClass("supports-placeholder"); - } stickyFoot(wrapperH); } window.onresize = function() { @@ -245,10 +251,10 @@ window.onresize = function() { } $('.panel').on('shown.bs.collapse', function (e) { - stickyFoot(); + stickyFoot(wrapperH); }) $('.panel').on('hidden.bs.collapse', function (e) { - stickyFoot(); + stickyFoot(wrapperH); }) }) \ No newline at end of file diff --git a/js/min/cs.min.js b/js/min/cs.min.js index b06fd2a..503c78c 100644 --- a/js/min/cs.min.js +++ b/js/min/cs.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){function t(){var t=a(this).attr("href").toLowerCase(),i=a(this).children("img").length,e=null,n=null,l=null,p=null;if("#"!=t.charAt(0)&&0==i&&"/"!=t.charAt(0)){var o=t.split("/");e=o[2],n=o[o.length-1]||"";var c=n.split(".");if(c[1]&&a.each(d,function(t,i){i==c[1]&&(p=a(''),l=c[1],p.append("."+l))}),null!=p&&a(this).append(p),e!=s&&null!=e){var h='';a(this).addClass("external").append(h)}}}function i(t){var i=a("
");i.addClass("alert alert-danger accessibility-fail-msg"),i.width(t.width+"px");var e=a("");e.addClass("glyphicon glyphicon-ban-circle");var n=a("");n.append(' This image needs a valid Alt tag. '),i.append(e).append(n),a(t).after(i)}function e(){if(null!=document.getElementById("page")&&null!=document.getElementById("footers")){var t=document.getElementById("page").clientHeight,i=(document.getElementById("footers").clientHeight,window.innerHeight);i>=t?a("body").addClass("sticky"):a("body").removeClass("sticky")}}var n=location.href,l=n.split("/"),s=l[2],d=["3g2","3gp","avi","doc","docx","dotx","gif","jpg","jpeg","m4a","mid","midi","mov","mp3","mp4","mpg","odt","ogg","ogv","pdf","png","ppt","pptx","xls","xlsx","wav","wmv","zip","vsd"],p=["#comments","#site-navigation","article.page"];a.each(p,function(i,e){a(e+" a").each(t)}),a(".uup-list .has-image").each(function(){var t=a(this).find(".uup-text"),i=a(this).find("img:first"),e=t.height(),n=i.outerHeight();if(n>e){var l=n-e;t.css("padding-top",l/2)}}),a(".uup-index-table .table-has-image").each(function(){var t=a(this).find(".uup-name"),i=a(this).find(".uup-table-thumbnail"),e=t.height(),n=i.outerHeight();if(n>e){var l=n-e;t.css("cssText","padding-bottom:"+l+"px!important")}}),a("#page img").each(function(){alt=a(this).attr("alt"),alt?(alt=alt.toLowerCase(),(alt.indexOf(".jpg")>=0||alt.indexOf(".png")>=0||alt.indexOf(".gif")>=0)&&(a(this).addClass("accessibility-fail"),i(this))):(a(this).addClass("accessibility-fail"),i(this))}),a("#page table").each(function(){a(this).addClass("table")}),window.onload=function(){if(placeholderSupport="placeholder"in document.createElement("input"),0!=placeholderSupport){var t=a("main");t.addClass("supports-placeholder")}e()},window.onresize=function(){e()}}); \ No newline at end of file +jQuery(document).ready(function(a){function t(){if(void 0!=a(this).attr("href")){var t=a(this).attr("href").toLowerCase(),i=a(this).children("img").length,e=null,n=null,o=null,d=null;if("#"!=t.charAt(0)&&0==i&&"/"!=t.charAt(0)){var c=t.split("/");e=c[2],n=c[c.length-1]||"";var p=n.split(".");if(p[1]&&a.each(s,function(t,i){i==p[1]&&(d=a(''),o=p[1],d.append("."+o))}),null!=d&&a(this).append(d),e!=l&&null!=e){var h='';a(this).addClass("external").append(h)}}}}function i(t){var i=a("
");i.addClass("alert alert-danger accessibility-fail-msg"),i.width(t.width+"px");var e=a("");e.addClass("glyphicon glyphicon-ban-circle");var n=a("");n.append(' This image needs a valid Alt tag. '),i.append(e).append(n),a(t).after(i)}function e(t){if(console.log("wrapperh: "+c),null!=document.getElementById("page")&&null!=document.getElementById("footers")){var i=a("#footers").outerHeight();console.log("footerH: "+i);var e=window.innerHeight;console.log("windowH: "+e),e=e-p-h,console.log("windowH: "+e),e>=t?(console.log("window frame TALLER than page contents"),a("body").addClass("sticky")):(console.log("window frame SMALLER than page contents"),a("body").removeClass("sticky"))}}var n=location.href,o=n.split("/"),l=o[2],s=["3g2","3gp","avi","doc","docx","dotx","gif","jpg","jpeg","m4a","mid","midi","mov","mp3","mp4","mpg","odt","ogg","ogv","pdf","png","ppt","pptx","xls","xlsx","wav","wmv","zip","vsd"],d=["#comments","#site-navigation","article.page"];a.each(d,function(i,e){a(e+" a").each(t)}),a(".uup-list .has-image").each(function(){var t=a(this).find(".uup-text"),i=a(this).find("img:first"),e=t.height(),n=i.outerHeight();if(n>e){var o=n-e;t.css("padding-top",o/2)}}),a(".uup-index-table .table-has-image").each(function(){var t=a(this).find(".uup-name"),i=a(this).find(".uup-table-thumbnail"),e=t.height(),n=i.outerHeight();if(n>e){var o=n-e;t.css("cssText","padding-bottom:"+o+"px!important")}}),a("#page img").each(function(){alt=a(this).attr("alt"),alt?(alt=alt.toLowerCase(),(alt.indexOf(".jpg")>=0||alt.indexOf(".png")>=0||alt.indexOf(".gif")>=0)&&(a(this).addClass("accessibility-fail"),i(this))):(a(this).addClass("accessibility-fail"),i(this))}),a("#page table").each(function(){a(this).addClass("table")});var c=a("#page").outerHeight(),p=a("#wpadminbar").outerHeight(),h=a("#uc-header").outerHeight();window.onload=function(){e(c)},window.onresize=function(){e(c)},a(".panel").on("shown.bs.collapse",function(){e(c)}),a(".panel").on("hidden.bs.collapse",function(){e(c)})}); \ No newline at end of file