From 4d9a3a87d5b164c061eab52843fb4662163fb16c Mon Sep 17 00:00:00 2001 From: Ian Caunce Date: Sun, 14 Dec 2014 22:37:08 +0000 Subject: [PATCH] Added a saftey net of 1px with the calc polyfill --- js/rrssb.js | 4 ++-- js/rrssb.min.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/rrssb.js b/js/rrssb.js index 8c0fcb4..b0fdc6c 100755 --- a/js/rrssb.js +++ b/js/rrssb.js @@ -191,8 +191,8 @@ smallBtnFraction = pixelsOff / regButtonCount; // if calc is not supported. calculate the width on the fly. - if (support.calc === false) { - magicWidth = (self.innerWidth() / regButtonCount) - smallBtnFraction; + if (true ||support.calc === false) { + magicWidth = ((self.innerWidth()-1) / regButtonCount) - smallBtnFraction; magicWidth = Math.floor(magicWidth*1000) / 1000; magicWidth += 'px'; } else { diff --git a/js/rrssb.min.js b/js/rrssb.min.js index 2072635..901da6f 100644 --- a/js/rrssb.min.js +++ b/js/rrssb.min.js @@ -1,4 +1,4 @@ -/* +/*! Ridiculously Responsive Social Sharing Buttons Team: @dbox, @joshuatuscan Site: http://www.kurtnoble.com/labs/rrssb @@ -15,4 +15,4 @@ \ \:\ \ \:\ /__/:/ \ \:\ \ \:\ \__\/ \__\/ \__\/ -*/+function(window,jQuery,undefined){"use strict";var support={calc:false};var detectCalcSupport=function(){var el=$("
");var calcProps=["calc","-webkit-calc","-moz-calc"];$("body").append(el);for(var i=0;i170&&jQuery("li.small",self).length<1){self.addClass("large-format")}else{self.removeClass("large-format")}if(containerWidth<200){self.removeClass("small-format").addClass("tiny-format")}else{self.removeClass("tiny-format")}})};var backUpFromSmall=function(){jQuery(".rrssb-buttons").each(function(index){var self=jQuery(this);var buttons=jQuery("li",self);var smallButtons=buttons.filter(".small");var totalBtnSze=0;var totalTxtSze=0;var upCandidate=smallButtons.first();var nextBackUp=parseFloat(upCandidate.attr("data-size"))+55;var smallBtnCount=smallButtons.length;if(smallBtnCount===buttons.length){var btnCalc=smallBtnCount*42;var containerWidth=self.width();if(btnCalc+nextBackUpbtnWidth){var btn2small=buttons.not(".small").last();jQuery(btn2small).addClass("small");sizeSmallBtns()}}if(!--count)backUpFromSmall()})});if(init===true){rrssbMagicLayout(sizeSmallBtns)}};var sizeSmallBtns=function(){jQuery(".rrssb-buttons").each(function(index){var self=jQuery(this);var regButtonCount;var regPercent;var pixelsOff;var magicWidth;var smallBtnFraction;var buttons=jQuery("li",self);var smallButtons=buttons.filter(".small");var smallBtnCount=smallButtons.length;if(smallBtnCount>0&&smallBtnCount!==buttons.length){self.removeClass("small-format");smallButtons.css("width","42px");pixelsOff=smallBtnCount*42;regButtonCount=buttons.not(".small").length;regPercent=100/regButtonCount;smallBtnFraction=pixelsOff/regButtonCount;if(support.calc===false){magicWidth=self.innerWidth()/regButtonCount-smallBtnFraction;magicWidth=Math.floor(magicWidth*1e3)/1e3;magicWidth+="px"}else{magicWidth=support.calc+"("+regPercent+"% - "+smallBtnFraction+"px)"}buttons.not(".small").css("width",magicWidth)}else if(smallBtnCount===buttons.length){self.addClass("small-format");setPercentBtns()}else{self.removeClass("small-format");setPercentBtns()}});makeExtremityBtns()};var rrssbInit=function(){jQuery(".rrssb-buttons").each(function(index){jQuery(this).addClass("rrssb-"+(index+1))});detectCalcSupport();setPercentBtns();jQuery(".rrssb-buttons li .rrssb-text").each(function(index){var buttonTxt=jQuery(this);var txtWdth=buttonTxt.width();buttonTxt.closest("li").attr("data-size",txtWdth)});checkSize(true)};var rrssbMagicLayout=function(callback){jQuery(".rrssb-buttons li.small").removeClass("small");checkSize();callback()};var popupCenter=function(url,title,w,h){var dualScreenLeft=window.screenLeft!==undefined?window.screenLeft:screen.left;var dualScreenTop=window.screenTop!==undefined?window.screenTop:screen.top;var width=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width;var height=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;var left=width/2-w/2+dualScreenLeft;var top=height/3-h/3+dualScreenTop;var newWindow=window.open(url,title,"scrollbars=yes, width="+w+", height="+h+", top="+top+", left="+left);if(window.focus){newWindow.focus()}};var waitForFinalEvent=function(){var timers={};return function(callback,ms,uniqueId){if(!uniqueId){uniqueId="Don't call this twice without a uniqueId"}if(timers[uniqueId]){clearTimeout(timers[uniqueId])}timers[uniqueId]=setTimeout(callback,ms)}}();jQuery(document).ready(function(){jQuery(".rrssb-buttons a.popup").on("click",function(e){var self=jQuery(this);popupCenter(self.attr("href"),self.find(".rrssb-text").html(),580,470);e.preventDefault()});jQuery(window).resize(function(){rrssbMagicLayout(sizeSmallBtns);waitForFinalEvent(function(){rrssbMagicLayout(sizeSmallBtns)},200,"finished resizing")});rrssbInit()});window.rrssbInit=rrssbInit}(window,jQuery); \ No newline at end of file +*/+function(window,jQuery,undefined){"use strict";var support={calc:false};var detectCalcSupport=function(){var el=$("
");var calcProps=["calc","-webkit-calc","-moz-calc"];$("body").append(el);for(var i=0;i170&&jQuery("li.small",self).length<1){self.addClass("large-format")}else{self.removeClass("large-format")}if(containerWidth<200){self.removeClass("small-format").addClass("tiny-format")}else{self.removeClass("tiny-format")}})};var backUpFromSmall=function(){jQuery(".rrssb-buttons").each(function(index){var self=jQuery(this);var buttons=jQuery("li",self);var smallButtons=buttons.filter(".small");var totalBtnSze=0;var totalTxtSze=0;var upCandidate=smallButtons.first();var nextBackUp=parseFloat(upCandidate.attr("data-size"))+55;var smallBtnCount=smallButtons.length;if(smallBtnCount===buttons.length){var btnCalc=smallBtnCount*42;var containerWidth=self.width();if(btnCalc+nextBackUpbtnWidth){var btn2small=buttons.not(".small").last();jQuery(btn2small).addClass("small");sizeSmallBtns()}}if(!--count)backUpFromSmall()})});if(init===true){rrssbMagicLayout(sizeSmallBtns)}};var sizeSmallBtns=function(){jQuery(".rrssb-buttons").each(function(index){var self=jQuery(this);var regButtonCount;var regPercent;var pixelsOff;var magicWidth;var smallBtnFraction;var buttons=jQuery("li",self);var smallButtons=buttons.filter(".small");var smallBtnCount=smallButtons.length;if(smallBtnCount>0&&smallBtnCount!==buttons.length){self.removeClass("small-format");smallButtons.css("width","42px");pixelsOff=smallBtnCount*42;regButtonCount=buttons.not(".small").length;regPercent=100/regButtonCount;smallBtnFraction=pixelsOff/regButtonCount;if(true||support.calc===false){magicWidth=(self.innerWidth()-1)/regButtonCount-smallBtnFraction;magicWidth=Math.floor(magicWidth*1e3)/1e3;magicWidth+="px"}else{magicWidth=support.calc+"("+regPercent+"% - "+smallBtnFraction+"px)"}buttons.not(".small").css("width",magicWidth)}else if(smallBtnCount===buttons.length){self.addClass("small-format");setPercentBtns()}else{self.removeClass("small-format");setPercentBtns()}});makeExtremityBtns()};var rrssbInit=function(){jQuery(".rrssb-buttons").each(function(index){jQuery(this).addClass("rrssb-"+(index+1))});detectCalcSupport();setPercentBtns();jQuery(".rrssb-buttons li .rrssb-text").each(function(index){var buttonTxt=jQuery(this);var txtWdth=buttonTxt.width();buttonTxt.closest("li").attr("data-size",txtWdth)});checkSize(true)};var rrssbMagicLayout=function(callback){jQuery(".rrssb-buttons li.small").removeClass("small");checkSize();callback()};var popupCenter=function(url,title,w,h){var dualScreenLeft=window.screenLeft!==undefined?window.screenLeft:screen.left;var dualScreenTop=window.screenTop!==undefined?window.screenTop:screen.top;var width=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width;var height=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;var left=width/2-w/2+dualScreenLeft;var top=height/3-h/3+dualScreenTop;var newWindow=window.open(url,title,"scrollbars=yes, width="+w+", height="+h+", top="+top+", left="+left);if(window.focus){newWindow.focus()}};var waitForFinalEvent=function(){var timers={};return function(callback,ms,uniqueId){if(!uniqueId){uniqueId="Don't call this twice without a uniqueId"}if(timers[uniqueId]){clearTimeout(timers[uniqueId])}timers[uniqueId]=setTimeout(callback,ms)}}();jQuery(document).ready(function(){jQuery(".rrssb-buttons a.popup").on("click",function(e){var self=jQuery(this);popupCenter(self.attr("href"),self.find(".rrssb-text").html(),580,470);e.preventDefault()});jQuery(window).resize(function(){rrssbMagicLayout(sizeSmallBtns);waitForFinalEvent(function(){rrssbMagicLayout(sizeSmallBtns)},200,"finished resizing")});rrssbInit()});window.rrssbInit=rrssbInit}(window,jQuery); \ No newline at end of file