Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minified the box-sizing.htc #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions boxsizing-min.htc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @copyright 2012 Christian Schepp Schaefer*/
<component lightWeight="true">
<attach event="onpropertychange" onevent="checkPropertyChange()" />
<attach event="ondetach" onevent="restore()" />
<attach event="onresize" for="window" onevent="update()" />
<script type="text/javascript">
//<![CDATA[
var viewportwidth="undefined"!=typeof window.innerWidth?window.innerWidth:element.document.documentElement.clientWidth,doc=element.document,resizetimeout=null,apply=!1;switch(element.nodeName){case "#comment":case "HTML":case "HEAD":case "TITLE":case "SCRIPT":case "STYLE":case "LINK":case "META":break;default:apply=!0}function update(){null!==resizetimeout&&window.clearTimeout(resizetimeout);resizetimeout=window.setTimeout(function(){try{restore(),init()}catch(a){}resizetimeout=null},100)}
function restore(){if(apply)try{element.runtimeStyle.removeAttribute("width"),element.runtimeStyle.removeAttribute("height")}catch(a){}}function init(){apply&&(updateBorderBoxWidth(),updateBorderBoxHeight())}
function checkPropertyChange(){if(apply){var a=event.propertyName;"style.boxSizing"===a&&""===element.style.boxSizing&&(element.style.removeAttribute("boxSizing"),element.runtimeStyle.removeAttribute("boxSizing"),element.runtimeStyle.removeAttribute("width"),element.runtimeStyle.removeAttribute("height"));switch(a){case "style.width":case "style.minWidth":case "style.maxWidth":case "style.borderLeftWidth":case "style.borderLeftStyle":case "style.borderRightWidth":case "style.borderRightStyle":case "style.paddingLeft":case "style.paddingRight":updateBorderBoxWidth();
break;case "style.height":case "style.minHeight":case "style.maxHeight":case "style.borderTopWidth":case "style.borderTopStyle":case "style.borderBottomWidth":case "style.borderBottomStyle":case "style.paddingTop":case "style.paddingBottom":updateBorderBoxHeight();break;case "className":case "style.boxSizing":updateBorderBoxWidth(),updateBorderBoxHeight()}}}
function getPixelValue(a){if(/^\d+(px)?$/i.test(a))return parseInt(a);var b=element.style.left,c=element.runtimeStyle.left;element.runtimeStyle.left=element.currentStyle.left;element.style.left=a||0;a=parseInt(element.style.pixelLeft);element.style.left=b;element.runtimeStyle.left=c;return a}
function getPixelWidth(a,b){if(/^\d+(px)?$/i.test(b))return parseInt(b);if(/^[\d\.]+%$/i.test(b)){try{var c=getPixelWidth(a.parentElement,a.parentElement.currentStyle.paddingLeft),d=getPixelWidth(a.parentElement,a.parentElement.currentStyle.paddingRight),f=getPixelWidth(a.parentElement,a.parentElement.currentStyle.borderLeft),g=getPixelWidth(a.parentElement,a.parentElement.currentStyle.borderRight),e=a.parentElement.offsetWidth-c-d-f-g;b=parseFloat(b)/100*e}catch(h){b=parseFloat(b)/100*element.document.documentElement.clientWidth}return parseInt(b)}c=
a.style.left;d=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=b||0;b=parseInt(a.style.pixelLeft);a.style.left=c;a.runtimeStyle.left=d;return b}
function getPixelHeight(a,b){if(/^\d+(px)?$/i.test(b))return parseInt(b);if(/^[\d\.]+%$/i.test(b)){try{if("auto"!=a.parentElement.currentStyle.height){switch(a.parentElement.nodeName){default:if("auto"!==a.parentElement.currentStyle.height){var c=getPixelWidth(a.parentElement,a.parentElement.currentStyle.paddingTop),d=getPixelWidth(a.parentElement,a.parentElement.currentStyle.paddingBottom),f=getPixelWidth(a.parentElement,a.parentElement.currentStyle.borderTop),g=getPixelWidth(a.parentElement,a.parentElement.currentStyle.borderBottom),
e=a.parentElement.offsetHeight-c-d-f-g;b=parseFloat(b)/100*e}else b="auto";break;case "HTML":e=element.document.documentElement.clientHeight,b="auto"!==e?parseFloat(b)/100*e:"auto"}"auto"!==b&&(b=parseInt(b))}else b="auto"}catch(h){b="auto"}return b}c=a.style.left;d=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=b||0;b=parseInt(a.style.pixelLeft);a.style.left=c;a.runtimeStyle.left=d;return b}
function getBorderWidth(a){return"none"==element.currentStyle["border"+a+"Style"]?0:getPixelValue(element.currentStyle["border"+a+"Width"])||0}function getBorderLeftWidth(){return getBorderWidth("Left")}function getBorderRightWidth(){return getBorderWidth("Right")}function getBorderTopWidth(){return getBorderWidth("Top")}function getBorderBottomWidth(){return getBorderWidth("Bottom")}function getPadding(a){return getPixelValue(element.currentStyle["padding"+a])||0}
function getPaddingLeft(){return getPadding("Left")}function getPaddingRight(){return getPadding("Right")}function getPaddingTop(){return getPadding("Top")}function getPaddingBottom(){return getPadding("Bottom")}
function getBoxSizing(){var a=element.style,b=element.currentStyle;return"undefined"!=typeof a.boxSizing&&""!=a.boxSizing?a.boxSizing:"undefined"!=typeof a["box-sizing"]&&""!=a["box-sizing"]?a["box-sizing"]:"undefined"!=typeof b.boxSizing&&""!=b.boxSizing?b.boxSizing:"undefined"!=typeof b["box-sizing"]&&""!=b["box-sizing"]?b["box-sizing"]:getDocumentBoxSizing()}function getDocumentBoxSizing(){return null===doc.compatMode||"BackCompat"===doc.compatMode?"border-box":"content-box"}
function setBorderBoxWidth(a){element.runtimeStyle.width=Math.max(0,a-getBorderLeftWidth()-getPaddingLeft()-getPaddingRight()-getBorderRightWidth())+"px"}function setBorderBoxMinWidth(a){element.runtimeStyle.minWidth=Math.max(0,a-getBorderLeftWidth()-getPaddingLeft()-getPaddingRight()-getBorderRightWidth())+"px"}function setBorderBoxMaxWidth(a){element.runtimeStyle.maxWidth=Math.max(0,a-getBorderLeftWidth()-getPaddingLeft()-getPaddingRight()-getBorderRightWidth())+"px"}
function setBorderBoxHeight(a){element.runtimeStyle.height=Math.max(0,a-getBorderTopWidth()-getPaddingTop()-getPaddingBottom()-getBorderBottomWidth())+"px"}function setBorderBoxMinHeight(a){element.runtimeStyle.minHeight=Math.max(0,a-getBorderTopWidth()-getPaddingTop()-getPaddingBottom()-getBorderBottomWidth())+"px"}function setBorderBoxMaxHeight(a){element.runtimeStyle.maxHeight=Math.max(0,a-getBorderTopWidth()-getPaddingTop()-getPaddingBottom()-getBorderBottomWidth())+"px"}
function setContentBoxWidth(a){element.runtimeStyle.width=Math.max(0,a+getBorderLeftWidth()+getPaddingLeft()+getPaddingRight()+getBorderRightWidth())+"px"}function setContentBoxMinWidth(a){element.runtimeStyle.minWidth=Math.max(0,a+getBorderLeftWidth()+getPaddingLeft()+getPaddingRight()+getBorderRightWidth())+"px"}function setContentBoxMaxWidth(a){element.runtimeStyle.maxWidth=Math.max(0,a+getBorderLeftWidth()+getPaddingLeft()+getPaddingRight()+getBorderRightWidth())+"px"}
function setContentBoxHeight(a){element.runtimeStyle.height=Math.max(0,a+getBorderTopWidth()+getPaddingTop()+getPaddingBottom()+getBorderBottomWidth())+"px"}function setContentBoxMinHeight(a){element.runtimeStyle.minHeight=Math.max(0,a+getBorderTopWidth()+getPaddingTop()+getPaddingBottom()+getBorderBottomWidth())+"px"}function setContentBoxMaxHeight(a){element.runtimeStyle.maxHeight=Math.max(0,a+getBorderTopWidth()+getPaddingTop()+getPaddingBottom()+getBorderBottomWidth())+"px"}
function updateBorderBoxWidth(){if(getDocumentBoxSizing()!=getBoxSizing()){var a=element.currentStyle.width;"auto"!=a&&(a=getPixelWidth(element,a),"border-box"==getBoxSizing()?setBorderBoxWidth(parseInt(a)):setContentBoxWidth(parseInt(a)));a=element.currentStyle.minWidth;"none"!=a&&(a=getPixelWidth(element,a),"border-box"==getBoxSizing()?setBorderBoxMinWidth(parseInt(a)):setContentBoxMinWidth(parseInt(a)));a=element.currentStyle.maxWidth;"none"!=a&&(a=getPixelWidth(element,a),"border-box"==getBoxSizing()?
setBorderBoxMaxWidth(parseInt(a)):setContentBoxMaxWidth(parseInt(a)))}}
function updateBorderBoxHeight(){if(getDocumentBoxSizing()!=getBoxSizing()){var a=element.currentStyle.height;"auto"!=a&&(a=getPixelHeight(element,a),"auto"!==a&&("border-box"==getBoxSizing()?setBorderBoxHeight(parseInt(a)):setContentBoxHeight(parseInt(a))));a=element.currentStyle.minHeight;"none"!=a&&(a=getPixelHeight(element,a),"none"!==a&&("border-box"==getBoxSizing()?setBorderBoxMinHeight(parseInt(a)):setContentBoxMinHeight(parseInt(a))));a=element.currentStyle.maxHeight;"none"!=a&&(a=getPixelHeight(element,
a),"none"!==a&&("border-box"==getBoxSizing()?setBorderBoxMaxHeight(parseInt(a)):setContentBoxMaxHeight(parseInt(a))))}}init();
//]]>
</script>
</component>