diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:25:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:25:40 +0000 |
commit | cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a (patch) | |
tree | 18dcde1a8d1f5570a77cd0c361de3b490d02c789 /sphinx/themes/bizstyle/static | |
parent | Initial commit. (diff) | |
download | sphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.tar.xz sphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.zip |
Adding upstream version 7.2.6.upstream/7.2.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sphinx/themes/bizstyle/static')
-rw-r--r-- | sphinx/themes/bizstyle/static/background_b01.png | bin | 0 -> 78 bytes | |||
-rw-r--r-- | sphinx/themes/bizstyle/static/bizstyle.css_t | 523 | ||||
-rw-r--r-- | sphinx/themes/bizstyle/static/bizstyle.js_t | 30 | ||||
-rw-r--r-- | sphinx/themes/bizstyle/static/css3-mediaqueries.js | 1 | ||||
-rw-r--r-- | sphinx/themes/bizstyle/static/css3-mediaqueries_src.js | 1104 |
5 files changed, 1658 insertions, 0 deletions
diff --git a/sphinx/themes/bizstyle/static/background_b01.png b/sphinx/themes/bizstyle/static/background_b01.png Binary files differnew file mode 100644 index 0000000..353f26d --- /dev/null +++ b/sphinx/themes/bizstyle/static/background_b01.png diff --git a/sphinx/themes/bizstyle/static/bizstyle.css_t b/sphinx/themes/bizstyle/static/bizstyle.css_t new file mode 100644 index 0000000..3cf7832 --- /dev/null +++ b/sphinx/themes/bizstyle/static/bizstyle.css_t @@ -0,0 +1,523 @@ +/* + * bizstyle.css_t + * ~~~~~~~~~~~~~~ + * + * Sphinx stylesheet -- business style theme. + * + * :copyright: Copyright 2007-2023 by Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +@import url("basic.css"); + +/* -- page layout ----------------------------------------------------------- */ + +body { + font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; + font-size: 14px; + letter-spacing: -0.01em; + line-height: 150%; + text-align: center; + background-color: white; + background-image: url(background_b01.png); + color: black; + padding: 0; + border-right: 1px solid {{ theme_maincolor }}; + border-left: 1px solid {{ theme_maincolor }}; + + margin: 0px 40px 0px 40px; +} + +div.document { + background-color: white; + text-align: left; + background-repeat: repeat-x; + + -moz-box-shadow: 2px 2px 5px #000; + -webkit-box-shadow: 2px 2px 5px #000; +} + +div.documentwrapper { + float: left; + width: 100%; +} + +div.bodywrapper { + margin: 0 0 0 240px; + border-left: 1px solid #ccc; +} + +div.body { + margin: 0; + padding: 0.5em 20px 20px 20px; +} + +{%- if theme_rightsidebar|tobool %} +div.bodywrapper { + margin: 0 calc({{ theme_sidebarwidth|todim }} + 30px) 0 0; + border-right: 1px solid #ccc; +} +{%- else %} +div.bodywrapper { + margin: 0 0 0 calc({{ theme_sidebarwidth|todim }} + 30px); +} +{%- endif %} + +div.related { + font-size: 1em; + + -moz-box-shadow: 2px 2px 5px #000; + -webkit-box-shadow: 2px 2px 5px #000; +} + +div.related ul { + background-color: {{ theme_maincolor }}; + height: 100%; + overflow: hidden; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; +} + +div.related ul li { + color: white; + margin: 0; + padding: 0; + height: 2em; + float: left; +} + +div.related ul li.right { + float: right; + margin-right: 5px; +} + +div.related ul li a { + margin: 0; + padding: 0 5px 0 5px; + line-height: 1.75em; + color: #fff; +} + +div.related ul li a:hover { + color: #fff; + text-decoration: underline; +} + +div.sphinxsidebarwrapper { + padding: 0; +} + +div.sphinxsidebar { + padding: 0.5em 12px 12px 12px; + width: {{ theme_sidebarwidth|todim }}; + {%- if theme_rightsidebar|tobool %} + float: right; + {%- endif %} + font-size: 1em; + text-align: left; +} + +div.sphinxsidebar h3, div.sphinxsidebar h4 { + margin: 1em 0 0.5em 0; + font-size: 1em; + padding: 0.1em 0 0.1em 0.5em; + color: white; + border: 1px solid {{ theme_maincolor }}; + background-color: {{ theme_maincolor }}; +} + +div.sphinxsidebar h3 a { + color: white; +} + +div.sphinxsidebar ul { + padding-left: 1.5em; + margin-top: 7px; + padding: 0; + line-height: 130%; +} + +div.sphinxsidebar ul ul { + margin-left: 20px; +} + +div.sphinxsidebar input { + border: 1px solid {{ theme_maincolor }}; +} + +div.footer { + background-color: white; + color: {{ theme_maincolor }}; + padding: 3px 8px 3px 0; + clear: both; + font-size: 0.8em; + text-align: right; + border-bottom: 1px solid {{ theme_maincolor }}; + + -moz-box-shadow: 2px 2px 5px #000; + -webkit-box-shadow: 2px 2px 5px #000; +} + +div.footer a { + color: {{ theme_maincolor }}; + text-decoration: underline; +} + +/* -- body styles ----------------------------------------------------------- */ + +p { + margin: 0.8em 0 0.5em 0; +} + +a { + color: {{ theme_maincolor }}; + text-decoration: none; +} + +a:hover { + color: {{ theme_maincolor }}; + text-decoration: underline; +} + +a:visited { + color: #551a8b; +} + +div.body a { + text-decoration: underline; +} + +h1, h2, h3 { + color: {{ theme_maincolor }}; +} + +h1 { + margin: 0; + padding: 0.7em 0 0.3em 0; + font-size: 1.5em; +} + +h2 { + margin: 1.3em 0 0.2em 0; + font-size: 1.35em; + padding-bottom: .5em; + border-bottom: 1px solid {{ theme_maincolor }}; +} + +h3 { + margin: 1em 0 -0.3em 0; + font-size: 1.2em; + padding-bottom: .3em; + border-bottom: 1px solid #CCCCCC; +} + +div.body h1 a, div.body h2 a, div.body h3 a, +div.body h4 a, div.body h5 a, div.body h6 a { + color: black!important; +} + +h1 a.anchor, h2 a.anchor, h3 a.anchor, +h4 a.anchor, h5 a.anchor, h6 a.anchor { + display: none; + margin: 0 0 0 0.3em; + padding: 0 0.2em 0 0.2em; + color: #aaa!important; +} + +h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, +h5:hover a.anchor, h6:hover a.anchor { + display: inline; +} + +h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover, +h5 a.anchor:hover, h6 a.anchor:hover { + color: #777; + background-color: #eee; +} + +a.headerlink { + color: #c60f0f!important; + font-size: 1em; + margin-left: 6px; + padding: 0 4px 0 4px; + text-decoration: none!important; +} + +a.headerlink:hover { + background-color: #ccc; + color: white!important; +} + +cite, code, tt { + font-family: 'Consolas', 'Deja Vu Sans Mono', + 'Bitstream Vera Sans Mono', monospace; + font-size: 0.95em; + letter-spacing: 0.01em; +} + +code { + background-color: #F2F2F2; + border-bottom: 1px solid #ddd; + color: #333; +} + +code.descname, code.descclassname, code.xref { + border: 0; +} + +hr { + border: 1px solid #abc; + margin: 2em; +} + +a code { + border: 0; + color: #CA7900; +} + +a code:hover { + color: #2491CF; +} + +pre { + background-color: transparent !important; + font-family: 'Consolas', 'Deja Vu Sans Mono', + 'Bitstream Vera Sans Mono', monospace; + font-size: 0.95em; + letter-spacing: 0.015em; + line-height: 120%; + padding: 0.5em; + border-right: 5px solid #ccc; + border-left: 5px solid #ccc; +} + +pre a { + color: inherit; + text-decoration: underline; +} + +td.linenos pre { + padding: 0.5em 0; +} + +div.quotebar { + background-color: #f8f8f8; + max-width: 250px; + float: right; + padding: 2px 7px; + border: 1px solid #ccc; +} + +nav.contents, +aside.topic, +div.topic { + background-color: #f8f8f8; +} + +table { + border-collapse: collapse; + margin: 0 -0.5em 0 -0.5em; +} + +table td, table th { + padding: 0.2em 0.5em 0.2em 0.5em; +} + +div.admonition { + font-size: 0.9em; + margin: 1em 0 1em 0; + border: 3px solid #cccccc; + background-color: #f7f7f7; + padding: 0; +} + +div.admonition p { + margin: 0.5em 1em 0.5em 1em; + padding: 0; +} + +div.admonition li p { + margin-left: 0; +} + +div.admonition pre, div.warning pre { + margin: 0; +} + +div.highlight { + margin: 0.4em 1em; +} + +div.admonition p.admonition-title { + margin: 0; + padding: 0.1em 0 0.1em 0.5em; + color: white; + border-bottom: 3px solid #cccccc; + font-weight: bold; + background-color: #165e83; +} + +div.danger { border: 3px solid #f0908d; background-color: #f0cfa0; } +div.error { border: 3px solid #f0908d; background-color: #ede4cd; } +div.warning { border: 3px solid #f8b862; background-color: #f0cfa0; } +div.caution { border: 3px solid #f8b862; background-color: #ede4cd; } +div.attention { border: 3px solid #f8b862; background-color: #f3f3f3; } +div.important { border: 3px solid #f0cfa0; background-color: #ede4cd; } +div.note { border: 3px solid #f0cfa0; background-color: #f3f3f3; } +div.hint { border: 3px solid #bed2c3; background-color: #f3f3f3; } +div.tip { border: 3px solid #bed2c3; background-color: #f3f3f3; } + +div.danger p.admonition-title, div.error p.admonition-title { + background-color: #b7282e; + border-bottom: 3px solid #f0908d; +} + +div.caution p.admonition-title, +div.warning p.admonition-title, +div.attention p.admonition-title { + background-color: #f19072; + border-bottom: 3px solid #f8b862; +} + +div.note p.admonition-title, div.important p.admonition-title { + background-color: #f8b862; + border-bottom: 3px solid #f0cfa0; +} + +div.hint p.admonition-title, div.tip p.admonition-title { + background-color: #7ebea5; + border-bottom: 3px solid #bed2c3; +} + +div.admonition ul, div.admonition ol, +div.warning ul, div.warning ol { + margin: 0.1em 0.5em 0.5em 3em; + padding: 0; +} + +div.versioninfo { + margin: 1em 0 0 0; + border: 1px solid #ccc; + background-color: #DDEAF0; + padding: 8px; + line-height: 1.3em; + font-size: 0.9em; +} + +.viewcode-back { + font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; +} + +div.viewcode-block:target { + background-color: #f4debf; + border-top: 1px solid #ac9; + border-bottom: 1px solid #ac9; +} + +p.versionchanged span.versionmodified { + font-size: 0.9em; + margin-right: 0.2em; + padding: 0.1em; + background-color: #DCE6A0; +} + +dl.field-list > dt { + color: white; + background-color: #82A0BE; +} + +dl.field-list > dd { + background-color: #f7f7f7; +} + +/* -- table styles ---------------------------------------------------------- */ + +table.docutils { + margin: 1em 0; + padding: 0; + border: 1px solid white; + background-color: #f7f7f7; +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 5px; + border-top: 0; + border-left: 0; + border-right: 1px solid white; + border-bottom: 1px solid white; +} + +table.docutils td p { + margin-top: 0; + margin-bottom: 0.3em; +} + +table.field-list td, table.field-list th { + border: 0 !important; + word-break: break-word; +} + +table.footnote td, table.footnote th { + border: 0 !important; +} + +th { + color: white; + text-align: left; + padding-right: 5px; + background-color: #82A0BE; +} + +div.literal-block-wrapper div.code-block-caption { + background-color: #EEE; + border-style: solid; + border-color: #CCC; + border-width: 1px 5px; +} + +/* WIDE DESKTOP STYLE */ +@media only screen and (min-width: 1176px) { +body { + margin: 0 40px 0 40px; +} +} + +/* TABLET STYLE */ +@media only screen and (min-width: 768px) and (max-width: 991px) { +body { + margin: 0 40px 0 40px; +} +} + +/* MOBILE LAYOUT (PORTRAIT/320px) */ +@media only screen and (max-width: 767px) { +body { + margin: 0; +} +div.bodywrapper { + margin: 0; + width: 100%; + border: none; +} +div.sphinxsidebar { + display: none; +} +} + +/* MOBILE LAYOUT (LANDSCAPE/480px) */ +@media only screen and (min-width: 480px) and (max-width: 767px) { +body { + margin: 0 20px 0 20px; +} +} + +/* RETINA OVERRIDES */ +@media +only screen and (-webkit-min-device-pixel-ratio: 2), +only screen and (min-device-pixel-ratio: 2) { +} + +/* -- end ------------------------------------------------------------------- */ diff --git a/sphinx/themes/bizstyle/static/bizstyle.js_t b/sphinx/themes/bizstyle/static/bizstyle.js_t new file mode 100644 index 0000000..fd0865e --- /dev/null +++ b/sphinx/themes/bizstyle/static/bizstyle.js_t @@ -0,0 +1,30 @@ +// +// bizstyle.js +// ~~~~~~~~~~~ +// +// Sphinx javascript -- for bizstyle theme. +// +// This theme was created by referring to 'sphinxdoc' +// +// :copyright: Copyright 2007-2023 by Sphinx team, see AUTHORS. +// :license: BSD, see LICENSE for details. +// +const initialiseBizStyle = () => { + if (navigator.userAgent.indexOf("iPhone") > 0 || navigator.userAgent.indexOf("Android") > 0) { + document.querySelector("li.nav-item-0 a").innerText = "Top" + } + const truncator = item => {if (item.textContent.length > 20) { + item.title = item.innerText + item.innerText = item.innerText.substr(0, 17) + "..." + } + } + document.querySelectorAll("div.related:first ul li:not(.right) a").slice(1).forEach(truncator); + document.querySelectorAll("div.related:last ul li:not(.right) a").slice(1).forEach(truncator); +} + +window.addEventListener("resize", + () => (document.querySelector("li.nav-item-0 a").innerText = (window.innerWidth <= 776) ? "Top" : "{{ shorttitle|e }}") +) + +if (document.readyState !== "loading") initialiseBizStyle() +else document.addEventListener("DOMContentLoaded", initialiseBizStyle) diff --git a/sphinx/themes/bizstyle/static/css3-mediaqueries.js b/sphinx/themes/bizstyle/static/css3-mediaqueries.js new file mode 100644 index 0000000..59735f5 --- /dev/null +++ b/sphinx/themes/bizstyle/static/css3-mediaqueries.js @@ -0,0 +1 @@ +if(typeof Object.create!=="function"){Object.create=function(e){function t(){}t.prototype=e;return new t}}var ua={toString:function(){return navigator.userAgent},test:function(e){return this.toString().toLowerCase().indexOf(e.toLowerCase())>-1}};ua.version=(ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];ua.webkit=ua.test("webkit");ua.gecko=ua.test("gecko")&&!ua.webkit;ua.opera=ua.test("opera");ua.ie=ua.test("msie")&&!ua.opera;ua.ie6=ua.ie&&document.compatMode&&typeof document.documentElement.style.maxHeight==="undefined";ua.ie7=ua.ie&&document.documentElement&&typeof document.documentElement.style.maxHeight!=="undefined"&&typeof XDomainRequest==="undefined";ua.ie8=ua.ie&&typeof XDomainRequest!=="undefined";var domReady=function(){var e=[];var t=function(){if(!arguments.callee.done){arguments.callee.done=true;for(var t=0;t<e.length;t++){e[t]()}}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",t,false)}if(ua.ie){(function(){try{document.documentElement.doScroll("left")}catch(e){setTimeout(arguments.callee,50);return}t()})();document.onreadystatechange=function(){if(document.readyState==="complete"){document.onreadystatechange=null;t()}}}if(ua.webkit&&document.readyState){(function(){if(document.readyState!=="loading"){t()}else{setTimeout(arguments.callee,10)}})()}window.onload=t;return function(t){if(typeof t==="function"){e[e.length]=t}return t}}();var cssHelper=function(){var e={BLOCKS:/[^\s{;][^{;]*\{(?:[^{}]*\{[^{}]*\}[^{}]*|[^{}]*)*\}/g,BLOCKS_INSIDE:/[^\s{][^{]*\{[^{}]*\}/g,DECLARATIONS:/[a-zA-Z\-]+[^;]*:[^;]+;/g,RELATIVE_URLS:/url\(['"]?([^\/\)'"][^:\)'"]+)['"]?\)/g,REDUNDANT_COMPONENTS:/(?:\/\*([^*\\\\]|\*(?!\/))+\*\/|@import[^;]+;)/g,REDUNDANT_WHITESPACE:/\s*(,|:|;|\{|\})\s*/g,WHITESPACE_IN_PARENTHESES:/\(\s*(\S*)\s*\)/g,MORE_WHITESPACE:/\s{2,}/g,FINAL_SEMICOLONS:/;\}/g,NOT_WHITESPACE:/\S+/g};var t,n=false;var r=[];var s=function(e){if(typeof e==="function"){r[r.length]=e}};var o=function(){for(var e=0;e<r.length;e++){r[e](t)}};var u={};var a=function(e,t){if(u[e]){var n=u[e].listeners;if(n){for(var r=0;r<n.length;r++){n[r](t)}}}};var f=function(e,t,n){if(ua.ie&&!window.XMLHttpRequest){window.XMLHttpRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}if(!XMLHttpRequest){return""}var r=new XMLHttpRequest;try{r.open("get",e,true);r.setRequestHeader("X_REQUESTED_WITH","XMLHttpRequest")}catch(i){n();return}var s=false;setTimeout(function(){s=true},5e3);document.documentElement.style.cursor="progress";r.onreadystatechange=function(){if(r.readyState===4&&!s){if(!r.status&&location.protocol==="file:"||r.status>=200&&r.status<300||r.status===304||navigator.userAgent.indexOf("Safari")>-1&&typeof r.status==="undefined"){t(r.responseText)}else{n()}document.documentElement.style.cursor="";r=null}};r.send("")};var l=function(t){t=t.replace(e.REDUNDANT_COMPONENTS,"");t=t.replace(e.REDUNDANT_WHITESPACE,"$1");t=t.replace(e.WHITESPACE_IN_PARENTHESES,"($1)");t=t.replace(e.MORE_WHITESPACE," ");t=t.replace(e.FINAL_SEMICOLONS,"}");return t};var c={stylesheet:function(t){var n={};var r=[],i=[],s=[],o=[];var u=t.cssHelperText;var a=t.getAttribute("media");if(a){var f=a.toLowerCase().split(",")}else{var f=["all"]}for(var l=0;l<f.length;l++){r[r.length]=c.mediaQuery(f[l],n)}var h=u.match(e.BLOCKS);if(h!==null){for(var l=0;l<h.length;l++){if(h[l].substring(0,7)==="@media "){var p=c.mediaQueryList(h[l],n);s=s.concat(p.getRules());i[i.length]=p}else{s[s.length]=o[o.length]=c.rule(h[l],n,null)}}}n.element=t;n.getCssText=function(){return u};n.getAttrMediaQueries=function(){return r};n.getMediaQueryLists=function(){return i};n.getRules=function(){return s};n.getRulesWithoutMQ=function(){return o};return n},mediaQueryList:function(t,n){var r={};var i=t.indexOf("{");var s=t.substring(0,i);t=t.substring(i+1,t.length-1);var o=[],u=[];var a=s.toLowerCase().substring(7).split(",");for(var f=0;f<a.length;f++){o[o.length]=c.mediaQuery(a[f],r)}var l=t.match(e.BLOCKS_INSIDE);if(l!==null){for(f=0;f<l.length;f++){u[u.length]=c.rule(l[f],n,r)}}r.type="mediaQueryList";r.getMediaQueries=function(){return o};r.getRules=function(){return u};r.getListText=function(){return s};r.getCssText=function(){return t};return r},mediaQuery:function(t,n){t=t||"";var r,i;if(n.type==="mediaQueryList"){r=n}else{i=n}var s=false,o;var u=[];var a=true;var f=t.match(e.NOT_WHITESPACE);for(var l=0;l<f.length;l++){var c=f[l];if(!o&&(c==="not"||c==="only")){if(c==="not"){s=true}}else if(!o){o=c}else if(c.charAt(0)==="("){var h=c.substring(1,c.length-1).split(":");u[u.length]={mediaFeature:h[0],value:h[1]||null}}}return{getQueryText:function(){return t},getAttrStyleSheet:function(){return i||null},getList:function(){return r||null},getValid:function(){return a},getNot:function(){return s},getMediaType:function(){return o},getExpressions:function(){return u}}},rule:function(e,t,n){var r={};var i=e.indexOf("{");var s=e.substring(0,i);var o=s.split(",");var u=[];var a=e.substring(i+1,e.length-1).split(";");for(var f=0;f<a.length;f++){u[u.length]=c.declaration(a[f],r)}r.getStylesheet=function(){return t||null};r.getMediaQueryList=function(){return n||null};r.getSelectors=function(){return o};r.getSelectorText=function(){return s};r.getDeclarations=function(){return u};r.getPropertyValue=function(e){for(var t=0;t<u.length;t++){if(u[t].getProperty()===e){return u[t].getValue()}}return null};return r},declaration:function(e,t){var n=e.indexOf(":");var r=e.substring(0,n);var i=e.substring(n+1);return{getRule:function(){return t||null},getProperty:function(){return r},getValue:function(){return i}}}};var h=function(e){if(typeof e.cssHelperText!=="string"){return}var n={stylesheet:null,mediaQueryLists:[],rules:[],selectors:{},declarations:[],properties:{}};var r=n.stylesheet=c.stylesheet(e);var s=n.mediaQueryLists=r.getMediaQueryLists();var o=n.rules=r.getRules();var u=n.selectors;var a=function(e){var t=e.getSelectors();for(var n=0;n<t.length;n++){var r=t[n];if(!u[r]){u[r]=[]}u[r][u[r].length]=e}};for(i=0;i<o.length;i++){a(o[i])}var f=n.declarations;for(i=0;i<o.length;i++){f=n.declarations=f.concat(o[i].getDeclarations())}var l=n.properties;for(i=0;i<f.length;i++){var h=f[i].getProperty();if(!l[h]){l[h]=[]}l[h][l[h].length]=f[i]}e.cssHelperParsed=n;t[t.length]=e;return n};var p=function(e,t){return;e.cssHelperText=l(t||e.innerHTML);return h(e)};var d=function(){n=true;t=[];var r=[];var i=function(){for(var e=0;e<r.length;e++){h(r[e])}var t=document.getElementsByTagName("style");for(e=0;e<t.length;e++){p(t[e])}n=false;o()};var s=document.getElementsByTagName("link");for(var u=0;u<s.length;u++){var a=s[u];if(a.getAttribute("rel").indexOf("style")>-1&&a.href&&a.href.length!==0&&!a.disabled){r[r.length]=a}}if(r.length>0){var c=0;var d=function(){c++;if(c===r.length){i()}};var v=function(t){var n=t.href;f(n,function(r){r=l(r).replace(e.RELATIVE_URLS,"url("+n.substring(0,n.lastIndexOf("/"))+"/$1)");t.cssHelperText=r;d()},d)};for(u=0;u<r.length;u++){v(r[u])}}else{i()}};var v={stylesheets:"array",mediaQueryLists:"array",rules:"array",selectors:"object",declarations:"array",properties:"object"};var m={stylesheets:null,mediaQueryLists:null,rules:null,selectors:null,declarations:null,properties:null};var g=function(e,t){if(m[e]!==null){if(v[e]==="array"){return m[e]=m[e].concat(t)}else{var n=m[e];for(var r in t){if(t.hasOwnProperty(r)){if(!n[r]){n[r]=t[r]}else{n[r]=n[r].concat(t[r])}}}return n}}};var y=function(e){m[e]=v[e]==="array"?[]:{};for(var n=0;n<t.length;n++){var r=e==="stylesheets"?"stylesheet":e;g(e,t[n].cssHelperParsed[r])}return m[e]};var b=function(e){if(typeof window.innerWidth!="undefined"){return window["inner"+e]}else if(typeof document.documentElement!=="undefined"&&typeof document.documentElement.clientWidth!=="undefined"&&document.documentElement.clientWidth!=0){return document.documentElement["client"+e]}};return{addStyle:function(e,t,n){var r=document.createElement("style");r.setAttribute("type","text/css");if(t&&t.length>0){r.setAttribute("media",t.join(","))}document.getElementsByTagName("head")[0].appendChild(r);if(r.styleSheet){r.styleSheet.cssText=e}else{r.appendChild(document.createTextNode(e))}r.addedWithCssHelper=true;if(typeof n==="undefined"||n===true){cssHelper.parsed(function(t){var n=p(r,e);for(var i in n){if(n.hasOwnProperty(i)){g(i,n[i])}}a("newStyleParsed",r)})}else{r.parsingDisallowed=true}return r},removeStyle:function(e){return e.parentNode.removeChild(e)},parsed:function(e){if(n){s(e)}else{if(typeof t!=="undefined"){if(typeof e==="function"){e(t)}}else{s(e);d()}}},stylesheets:function(e){cssHelper.parsed(function(t){e(m.stylesheets||y("stylesheets"))})},mediaQueryLists:function(e){cssHelper.parsed(function(t){e(m.mediaQueryLists||y("mediaQueryLists"))})},rules:function(e){cssHelper.parsed(function(t){e(m.rules||y("rules"))})},selectors:function(e){cssHelper.parsed(function(t){e(m.selectors||y("selectors"))})},declarations:function(e){cssHelper.parsed(function(t){e(m.declarations||y("declarations"))})},properties:function(e){cssHelper.parsed(function(t){e(m.properties||y("properties"))})},broadcast:a,addListener:function(e,t){if(typeof t==="function"){if(!u[e]){u[e]={listeners:[]}}u[e].listeners[u[e].listeners.length]=t}},removeListener:function(e,t){if(typeof t==="function"&&u[e]){var n=u[e].listeners;for(var r=0;r<n.length;r++){if(n[r]===t){n.splice(r,1);r-=1}}}},getViewportWidth:function(){return b("Width")},getViewportHeight:function(){return b("Height")}}}();domReady(function(){var t;var n={LENGTH_UNIT:/[0-9]+(em|ex|px|in|cm|mm|pt|pc)$/,RESOLUTION_UNIT:/[0-9]+(dpi|dpcm)$/,ASPECT_RATIO:/^[0-9]+\/[0-9]+$/,ABSOLUTE_VALUE:/^[0-9]*(\.[0-9]+)*$/};var r=[];var i=function(){var e="css3-mediaqueries-test";var t=document.createElement("div");t.id=e;var n=cssHelper.addStyle("@media all and (width) { #"+e+" { width: 1px !important; } }",[],false);document.body.appendChild(t);var r=t.offsetWidth===1;n.parentNode.removeChild(n);t.parentNode.removeChild(t);i=function(){return r};return r};var s=function(){t=document.createElement("div");t.style.cssText="position:absolute;top:-9999em;left:-9999em;"+"margin:0;border:none;padding:0;width:1em;font-size:1em;";document.body.appendChild(t);if(t.offsetWidth!==16){t.style.fontSize=16/t.offsetWidth+"em"}t.style.width=""};var o=function(e){t.style.width=e;var n=t.offsetWidth;t.style.width="";return n};var u=function(e,t){var r=e.length;var i=e.substring(0,4)==="min-";var s=!i&&e.substring(0,4)==="max-";if(t!==null){var u;var a;if(n.LENGTH_UNIT.exec(t)){u="length";a=o(t)}else if(n.RESOLUTION_UNIT.exec(t)){u="resolution";a=parseInt(t,10);var f=t.substring((a+"").length)}else if(n.ASPECT_RATIO.exec(t)){u="aspect-ratio";a=t.split("/")}else if(n.ABSOLUTE_VALUE){u="absolute";a=t}else{u="unknown"}}var l,c;if("device-width"===e.substring(r-12,r)){l=screen.width;if(t!==null){if(u==="length"){return i&&l>=a||s&&l<a||!i&&!s&&l===a}else{return false}}else{return l>0}}else if("device-height"===e.substring(r-13,r)){c=screen.height;if(t!==null){if(u==="length"){return i&&c>=a||s&&c<a||!i&&!s&&c===a}else{return false}}else{return c>0}}else if("width"===e.substring(r-5,r)){l=document.documentElement.clientWidth||document.body.clientWidth;if(t!==null){if(u==="length"){return i&&l>=a||s&&l<a||!i&&!s&&l===a}else{return false}}else{return l>0}}else if("height"===e.substring(r-6,r)){c=document.documentElement.clientHeight||document.body.clientHeight;if(t!==null){if(u==="length"){return i&&c>=a||s&&c<a||!i&&!s&&c===a}else{return false}}else{return c>0}}else if("device-aspect-ratio"===e.substring(r-19,r)){return u==="aspect-ratio"&&screen.width*a[1]===screen.height*a[0]}else if("color-index"===e.substring(r-11,r)){var h=Math.pow(2,screen.colorDepth);if(t!==null){if(u==="absolute"){return i&&h>=a||s&&h<a||!i&&!s&&h===a}else{return false}}else{return h>0}}else if("color"===e.substring(r-5,r)){var p=screen.colorDepth;if(t!==null){if(u==="absolute"){return i&&p>=a||s&&p<a||!i&&!s&&p===a}else{return false}}else{return p>0}}else if("resolution"===e.substring(r-10,r)){var d;if(f==="dpcm"){d=o("1cm")}else{d=o("1in")}if(t!==null){if(u==="resolution"){return i&&d>=a||s&&d<a||!i&&!s&&d===a}else{return false}}else{return d>0}}else{return false}};var a=function(e){var t=e.getValid();var n=e.getExpressions();var r=n.length;if(r>0){for(var i=0;i<r&&t;i++){t=u(n[i].mediaFeature,n[i].value)}var s=e.getNot();return t&&!s||s&&!t}return t};var f=function(e,t){var n=e.getMediaQueries();var i={};for(var s=0;s<n.length;s++){var o=n[s].getMediaType();if(n[s].getExpressions().length===0){continue}var u=true;if(o!=="all"&&t&&t.length>0){u=false;for(var f=0;f<t.length;f++){if(t[f]===o){u=true}}}if(u&&a(n[s])){i[o]=true}}var l=[],c=0;for(var h in i){if(i.hasOwnProperty(h)){if(c>0){l[c++]=","}l[c++]=h}}if(l.length>0){r[r.length]=cssHelper.addStyle("@media "+l.join("")+"{"+e.getCssText()+"}",t,false)}};var l=function(e,t){for(var n=0;n<e.length;n++){f(e[n],t)}};var c=function(e){var t=e.getAttrMediaQueries();var n=false;var i={};for(var s=0;s<t.length;s++){if(a(t[s])){i[t[s].getMediaType()]=t[s].getExpressions().length>0}}var o=[],u=[];for(var f in i){if(i.hasOwnProperty(f)){o[o.length]=f;if(i[f]){u[u.length]=f}if(f==="all"){n=true}}}if(u.length>0){r[r.length]=cssHelper.addStyle(e.getCssText(),u,false)}var c=e.getMediaQueryLists();if(n){l(c)}else{l(c,o)}};var h=function(e){for(var t=0;t<e.length;t++){c(e[t])}if(ua.ie){document.documentElement.style.display="block";setTimeout(function(){document.documentElement.style.display=""},0);setTimeout(function(){cssHelper.broadcast("cssMediaQueriesTested")},100)}else{cssHelper.broadcast("cssMediaQueriesTested")}};var p=function(){for(var e=0;e<r.length;e++){cssHelper.removeStyle(r[e])}r=[];cssHelper.stylesheets(h)};var d=0;var v=function(){var e=cssHelper.getViewportWidth();var t=cssHelper.getViewportHeight();if(ua.ie){var n=document.createElement("div");n.style.position="absolute";n.style.top="-9999em";n.style.overflow="scroll";document.body.appendChild(n);d=n.offsetWidth-n.clientWidth;document.body.removeChild(n)}var r;var s=function(){var n=cssHelper.getViewportWidth();var s=cssHelper.getViewportHeight();if(Math.abs(n-e)>d||Math.abs(s-t)>d){e=n;t=s;clearTimeout(r);r=setTimeout(function(){if(!i()){p()}else{cssHelper.broadcast("cssMediaQueriesTested")}},500)}};window.onresize=function(){var e=window.onresize||function(){};return function(){e();s()}}()};var m=document.documentElement;m.style.marginLeft="-32767px";setTimeout(function(){m.style.marginLeft=""},5e3);return function(){if(!i()){cssHelper.addListener("newStyleParsed",function(e){c(e.cssHelperParsed.stylesheet)});cssHelper.addListener("cssMediaQueriesTested",function(){if(ua.ie){m.style.width="1px"}setTimeout(function(){m.style.width="";m.style.marginLeft=""},0);cssHelper.removeListener("cssMediaQueriesTested",arguments.callee)});s();p()}else{m.style.marginLeft=""}v()}}());try{document.execCommand("BackgroundImageCache",false,true)}catch(e){} diff --git a/sphinx/themes/bizstyle/static/css3-mediaqueries_src.js b/sphinx/themes/bizstyle/static/css3-mediaqueries_src.js new file mode 100644 index 0000000..7878620 --- /dev/null +++ b/sphinx/themes/bizstyle/static/css3-mediaqueries_src.js @@ -0,0 +1,1104 @@ +/* +css3-mediaqueries.js - CSS Helper and CSS3 Media Queries Enabler + +author: Wouter van der Graaf <wouter at dynora nl> +version: 1.0 (20110330) +license: MIT +website: http://code.google.com/p/css3-mediaqueries-js/ + +W3C spec: http://www.w3.org/TR/css3-mediaqueries/ + +Note: use of embedded <style> is not recommended when using media queries, because IE has no way of returning the raw literal css text from a <style> element. +*/ + + +// true prototypal inheritance (http://javascript.crockford.com/prototypal.html) +if (typeof Object.create !== 'function') { + Object.create = function (o) { + function F() {} + F.prototype = o; + return new F(); + }; +} + + +// user agent sniffing shortcuts +var ua = { + toString: function () { + return navigator.userAgent; + }, + test: function (s) { + return this.toString().toLowerCase().indexOf(s.toLowerCase()) > -1; + } +}; +ua.version = (ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1]; +ua.webkit = ua.test('webkit'); +ua.gecko = ua.test('gecko') && !ua.webkit; +ua.opera = ua.test('opera'); +ua.ie = ua.test('msie') && !ua.opera; +ua.ie6 = ua.ie && document.compatMode && typeof document.documentElement.style.maxHeight === 'undefined'; +ua.ie7 = ua.ie && document.documentElement && typeof document.documentElement.style.maxHeight !== 'undefined' && typeof XDomainRequest === 'undefined'; +ua.ie8 = ua.ie && typeof XDomainRequest !== 'undefined'; + + + +// initialize when DOM content is loaded +var domReady = function () { + var fns = []; + var init = function () { + if (!arguments.callee.done) { // run init functions once + arguments.callee.done = true; + for (var i = 0; i < fns.length; i++) { + fns[i](); + } + } + }; + + // listeners for different browsers + if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', init, false); + } + if (ua.ie) { + (function () { + try { + // throws errors until after ondocumentready + document.documentElement.doScroll('left'); + } + catch (e) { + setTimeout(arguments.callee, 50); + return; + } + // no errors, fire + init(); + })(); + // trying to always fire before onload + document.onreadystatechange = function () { + if (document.readyState === 'complete') { + document.onreadystatechange = null; + init(); + } + }; + } + if (ua.webkit && document.readyState) { + (function () { + if (document.readyState !== 'loading') { + init(); + } + else { + setTimeout(arguments.callee, 10); + } + })(); + } + window.onload = init; // fallback + + return function (fn) { // add fn to init functions + if (typeof fn === 'function') { + fns[fns.length] = fn; + } + return fn; + }; +}(); + + + +// helper library for parsing css to objects +var cssHelper = function () { + + var regExp = { + BLOCKS: /[^\s{;][^{;]*\{(?:[^{}]*\{[^{}]*\}[^{}]*|[^{}]*)*\}/g, + BLOCKS_INSIDE: /[^\s{][^{]*\{[^{}]*\}/g, + DECLARATIONS: /[a-zA-Z\-]+[^;]*:[^;]+;/g, + RELATIVE_URLS: /url\(['"]?([^\/\)'"][^:\)'"]+)['"]?\)/g, + // strip whitespace and comments, @import is evil + REDUNDANT_COMPONENTS: /(?:\/\*([^*\\\\]|\*(?!\/))+\*\/|@import[^;]+;)/g, + REDUNDANT_WHITESPACE: /\s*(,|:|;|\{|\})\s*/g, + WHITESPACE_IN_PARENTHESES: /\(\s*(\S*)\s*\)/g, + MORE_WHITESPACE: /\s{2,}/g, + FINAL_SEMICOLONS: /;\}/g, + NOT_WHITESPACE: /\S+/g + }; + + var parsed, parsing = false; + + var waiting = []; + var wait = function (fn) { + if (typeof fn === 'function') { + waiting[waiting.length] = fn; + } + }; + var ready = function () { + for (var i = 0; i < waiting.length; i++) { + waiting[i](parsed); + } + }; + var events = {}; + var broadcast = function (n, v) { + if (events[n]) { + var listeners = events[n].listeners; + if (listeners) { + for (var i = 0; i < listeners.length; i++) { + listeners[i](v); + } + } + } + }; + + var requestText = function (url, fnSuccess, fnFailure) { + if (ua.ie && !window.XMLHttpRequest) { + window.XMLHttpRequest = function () { + return new ActiveXObject('Microsoft.XMLHTTP'); + }; + } + if (!XMLHttpRequest) { + return ''; + } + var r = new XMLHttpRequest(); + try { + r.open('get', url, true); + r.setRequestHeader('X_REQUESTED_WITH', 'XMLHttpRequest'); + } + catch (e) { + fnFailure(); + return; + } + var done = false; + setTimeout(function () { + done = true; + }, 5000); + document.documentElement.style.cursor = 'progress'; + r.onreadystatechange = function () { + if (r.readyState === 4 && !done) { + if (!r.status && location.protocol === 'file:' || + (r.status >= 200 && r.status < 300) || + r.status === 304 || + navigator.userAgent.indexOf('Safari') > -1 && typeof r.status === 'undefined') { + fnSuccess(r.responseText); + } + else { + fnFailure(); + } + document.documentElement.style.cursor = ''; + r = null; // avoid memory leaks + } + }; + r.send(''); + }; + + var sanitize = function (text) { + text = text.replace(regExp.REDUNDANT_COMPONENTS, ''); + text = text.replace(regExp.REDUNDANT_WHITESPACE, '$1'); + text = text.replace(regExp.WHITESPACE_IN_PARENTHESES, '($1)'); + text = text.replace(regExp.MORE_WHITESPACE, ' '); + text = text.replace(regExp.FINAL_SEMICOLONS, '}'); // optional final semicolons + return text; + }; + + var objects = { + stylesheet: function (el) { + var o = {}; + var amqs = [], mqls = [], rs = [], rsw = []; + var s = el.cssHelperText; + + // add attribute media queries + var attr = el.getAttribute('media'); + if (attr) { + var qts = attr.toLowerCase().split(',') + } + else { + var qts = ['all'] // imply 'all' + } + for (var i = 0; i < qts.length; i++) { + amqs[amqs.length] = objects.mediaQuery(qts[i], o); + } + + // add media query lists and rules (top down order) + var blocks = s.match(regExp.BLOCKS); // @charset is not a block + if (blocks !== null) { + for (var i = 0; i < blocks.length; i++) { + if (blocks[i].substring(0, 7) === '@media ') { // media query (list) + var mql = objects.mediaQueryList(blocks[i], o); + rs = rs.concat(mql.getRules()); + mqls[mqls.length] = mql; + } + else { // regular rule set, page context (@page) or font description (@font-face) + rs[rs.length] = rsw[rsw.length] = objects.rule(blocks[i], o, null); + } + } + } + + o.element = el; + o.getCssText = function () { + return s; + }; + o.getAttrMediaQueries = function () { + return amqs; + }; + o.getMediaQueryLists = function () { + return mqls; + }; + o.getRules = function () { + return rs; + }; + o.getRulesWithoutMQ = function () { + return rsw; + }; + return o; + }, + + mediaQueryList: function (s, stsh) { + var o = {}; + var idx = s.indexOf('{'); + var lt = s.substring(0, idx); + s = s.substring(idx + 1, s.length - 1); + var mqs = [], rs = []; + + // add media queries + var qts = lt.toLowerCase().substring(7).split(','); + for (var i = 0; i < qts.length; i++) { // parse each media query + mqs[mqs.length] = objects.mediaQuery(qts[i], o); + } + + // add rule sets + var rts = s.match(regExp.BLOCKS_INSIDE); + if (rts !== null) { + for (i = 0; i < rts.length; i++) { + rs[rs.length] = objects.rule(rts[i], stsh, o); + } + } + + o.type = 'mediaQueryList'; + o.getMediaQueries = function () { + return mqs; + }; + o.getRules = function () { + return rs; + }; + o.getListText = function () { + return lt; + }; + o.getCssText = function () { + return s; + }; + return o; + }, + + mediaQuery: function (s, listOrSheet) { + s = s || ''; + var mql, stsh; + if (listOrSheet.type === 'mediaQueryList') { + mql = listOrSheet; + } + else { + stsh = listOrSheet; + } + var not = false, type; + var expr = []; + var valid = true; + var tokens = s.match(regExp.NOT_WHITESPACE); + + + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (!type && (token === 'not' || token === 'only')) { // 'not' and 'only' keywords + // keyword 'only' does nothing, as if it was not present + if (token === 'not') { + not = true; + } + } + else if (!type) { // media type + type = token; + } + else if (token.charAt(0) === '(') { // media feature expression + var pair = token.substring(1, token.length - 1).split(':'); + expr[expr.length] = { + mediaFeature: pair[0], + value: pair[1] || null + }; + } + } + + return { + getQueryText: function () { + return s; + }, + getAttrStyleSheet: function () { + return stsh || null; + }, + getList: function () { + return mql || null; + }, + getValid: function () { + return valid; + }, + getNot: function () { + return not; + }, + getMediaType: function () { + return type; + }, + getExpressions: function () { + return expr; + } + }; + }, + + rule: function (s, stsh, mql) { + var o = {}; + var idx = s.indexOf('{'); + var st = s.substring(0, idx); + var ss = st.split(','); + var ds = []; + var dts = s.substring(idx + 1, s.length - 1).split(';'); + for (var i = 0; i < dts.length; i++) { + ds[ds.length] = objects.declaration(dts[i], o); + } + + o.getStylesheet = function () { + return stsh || null; + }; + o.getMediaQueryList = function () { + return mql || null; + }; + o.getSelectors = function () { + return ss; + }; + o.getSelectorText = function () { + return st; + }; + o.getDeclarations = function () { + return ds; + }; + o.getPropertyValue = function (n) { + for (var i = 0; i < ds.length; i++) { + if (ds[i].getProperty() === n) { + return ds[i].getValue(); + } + } + return null; + }; + return o; + }, + + declaration: function (s, r) { + var idx = s.indexOf(':'); + var p = s.substring(0, idx); + var v = s.substring(idx + 1); + return { + getRule: function () { + return r || null; + }, + getProperty: function () { + return p; + }, + getValue: function () { + return v; + } + }; + } + }; + + var parseText = function (el) { + if (typeof el.cssHelperText !== 'string') { + return; + } + var o = { + stylesheet: null, + mediaQueryLists: [], + rules: [], + selectors: {}, + declarations: [], + properties: {} + }; + + // build stylesheet object + var stsh = o.stylesheet = objects.stylesheet(el); + + // collect media query lists + var mqls = o.mediaQueryLists = stsh.getMediaQueryLists(); + + // collect all rules + var ors = o.rules = stsh.getRules(); + + // collect all selectors + var oss = o.selectors; + var collectSelectors = function (r) { + var ss = r.getSelectors(); + for (var i = 0; i < ss.length; i++) { + var n = ss[i]; + if (!oss[n]) { + oss[n] = []; + } + oss[n][oss[n].length] = r; + } + }; + for (var i = 0; i < ors.length; i++) { + collectSelectors(ors[i]); + } + + // collect all declarations + var ods = o.declarations; + for (i = 0; i < ors.length; i++) { + ods = o.declarations = ods.concat(ors[i].getDeclarations()); + } + + // collect all properties + var ops = o.properties; + for (i = 0; i < ods.length; i++) { + var n = ods[i].getProperty(); + if (!ops[n]) { + ops[n] = []; + } + ops[n][ops[n].length] = ods[i]; + } + + el.cssHelperParsed = o; + parsed[parsed.length] = el; + return o; + }; + + var parseEmbedded = function (el, s) { + return; + // This function doesn't work because of a bug in IE, where innerHTML gives us parsed css instead of raw literal. + el.cssHelperText = sanitize(s || el.innerHTML); + return parseText(el); + }; + + var parse = function () { + parsing = true; + parsed = []; + var linked = []; + var finish = function () { + for (var i = 0; i < linked.length; i++) { + parseText(linked[i]); + } + var styles = document.getElementsByTagName('style'); + for (i = 0; i < styles.length; i++) { + parseEmbedded(styles[i]); + } + parsing = false; + ready(); + }; + var links = document.getElementsByTagName('link'); + for (var i = 0; i < links.length; i++) { + var link = links[i]; + if (link.getAttribute('rel').indexOf('style') > -1 && link.href && link.href.length !== 0 && !link.disabled) { + linked[linked.length] = link; + } + } + if (linked.length > 0) { + var c = 0; + var checkForFinish = function () { + c++; + if (c === linked.length) { // parse in right order, so after last link is read + finish(); + } + }; + var processLink = function (link) { + var href = link.href; + requestText(href, function (text) { + // fix url's + text = sanitize(text).replace(regExp.RELATIVE_URLS, 'url(' + href.substring(0, href.lastIndexOf('/')) + '/$1)'); + link.cssHelperText = text; + checkForFinish(); + }, checkForFinish); + }; + for (i = 0; i < linked.length; i++) { + processLink(linked[i]); + } + } + else { + finish(); + } + }; + + var types = { + stylesheets: 'array', + mediaQueryLists: 'array', + rules: 'array', + selectors: 'object', + declarations: 'array', + properties: 'object' + }; + + var collections = { + stylesheets: null, + mediaQueryLists: null, + rules: null, + selectors: null, + declarations: null, + properties: null + }; + + var addToCollection = function (name, v) { + if (collections[name] !== null) { + if (types[name] === 'array') { + return (collections[name] = collections[name].concat(v)); + } + else { + var c = collections[name]; + for (var n in v) { + if (v.hasOwnProperty(n)) { + if (!c[n]) { + c[n] = v[n]; + } + else { + c[n] = c[n].concat(v[n]); + } + } + } + return c; + } + } + }; + + var collect = function (name) { + collections[name] = (types[name] === 'array') ? [] : {}; + for (var i = 0; i < parsed.length; i++) { + var pname = name === 'stylesheets' ? 'stylesheet' : name; // the exception + addToCollection(name, parsed[i].cssHelperParsed[pname]); + } + return collections[name]; + }; + + // viewport size + var getViewportSize = function (d) { + if (typeof window.innerWidth != 'undefined') { + return window['inner' + d]; + } + else if (typeof document.documentElement !== 'undefined' + && typeof document.documentElement.clientWidth !== 'undefined' + && document.documentElement.clientWidth != 0) { + return document.documentElement['client' + d]; + } + }; + + // public static functions + return { + addStyle: function (s, mediaTypes, process) { + var el = document.createElement('style'); + el.setAttribute('type', 'text/css'); + if (mediaTypes && mediaTypes.length > 0) { + el.setAttribute('media', mediaTypes.join(',')); + } + document.getElementsByTagName('head')[0].appendChild(el); + if (el.styleSheet) { // IE + el.styleSheet.cssText = s; + } + else { + el.appendChild(document.createTextNode(s)); + } + el.addedWithCssHelper = true; + if (typeof process === 'undefined' || process === true) { + cssHelper.parsed(function (parsed) { + var o = parseEmbedded(el, s); + for (var n in o) { + if (o.hasOwnProperty(n)) { + addToCollection(n, o[n]); + } + } + broadcast('newStyleParsed', el); + }); + } + else { + el.parsingDisallowed = true; + } + return el; + }, + + removeStyle: function (el) { + return el.parentNode.removeChild(el); + }, + + parsed: function (fn) { + if (parsing) { + wait(fn); + } + else { + if (typeof parsed !== 'undefined') { + if (typeof fn === 'function') { + fn(parsed); + } + } + else { + wait(fn); + parse(); + } + } + }, + + stylesheets: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.stylesheets || collect('stylesheets')); + }); + }, + + mediaQueryLists: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.mediaQueryLists || collect('mediaQueryLists')); + }); + }, + + rules: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.rules || collect('rules')); + }); + }, + + selectors: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.selectors || collect('selectors')); + }); + }, + + declarations: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.declarations || collect('declarations')); + }); + }, + + properties: function (fn) { + cssHelper.parsed(function (parsed) { + fn(collections.properties || collect('properties')); + }); + }, + + broadcast: broadcast, + + addListener: function (n, fn) { // in case n is 'styleadd': added function is called everytime style is added and parsed + if (typeof fn === 'function') { + if (!events[n]) { + events[n] = { + listeners: [] + }; + } + events[n].listeners[events[n].listeners.length] = fn; + } + }, + + removeListener: function (n, fn) { + if (typeof fn === 'function' && events[n]) { + var ls = events[n].listeners; + for (var i = 0; i < ls.length; i++) { + if (ls[i] === fn) { + ls.splice(i, 1); + i -= 1; + } + } + } + }, + + getViewportWidth: function () { + return getViewportSize('Width'); + }, + + getViewportHeight: function () { + return getViewportSize('Height'); + } + }; +}(); + + + +// function to test and apply parsed media queries against browser capabilities +domReady(function enableCssMediaQueries() { + var meter; + + var regExp = { + LENGTH_UNIT: /[0-9]+(em|ex|px|in|cm|mm|pt|pc)$/, + RESOLUTION_UNIT: /[0-9]+(dpi|dpcm)$/, + ASPECT_RATIO: /^[0-9]+\/[0-9]+$/, + ABSOLUTE_VALUE: /^[0-9]*(\.[0-9]+)*$/ + }; + + var styles = []; + + var nativeSupport = function () { + // check support for media queries + var id = 'css3-mediaqueries-test'; + var el = document.createElement('div'); + el.id = id; + var style = cssHelper.addStyle('@media all and (width) { #' + id + + ' { width: 1px !important; } }', [], false); // false means don't parse this temp style + document.body.appendChild(el); + var ret = el.offsetWidth === 1; + style.parentNode.removeChild(style); + el.parentNode.removeChild(el); + nativeSupport = function () { + return ret; + }; + return ret; + }; + + var createMeter = function () { // create measuring element + meter = document.createElement('div'); + meter.style.cssText = 'position:absolute;top:-9999em;left:-9999em;' + + 'margin:0;border:none;padding:0;width:1em;font-size:1em;'; // cssText is needed for IE, works for the others + document.body.appendChild(meter); + // meter must have browser default font size of 16px + if (meter.offsetWidth !== 16) { + meter.style.fontSize = 16 / meter.offsetWidth + 'em'; + } + meter.style.width = ''; + }; + + var measure = function (value) { + meter.style.width = value; + var amount = meter.offsetWidth; + meter.style.width = ''; + return amount; + }; + + var testMediaFeature = function (feature, value) { + // non-testable features: monochrome|min-monochrome|max-monochrome|scan|grid + var l = feature.length; + var min = (feature.substring(0, 4) === 'min-'); + var max = (!min && feature.substring(0, 4) === 'max-'); + + if (value !== null) { // determine value type and parse to usable amount + var valueType; + var amount; + if (regExp.LENGTH_UNIT.exec(value)) { + valueType = 'length'; + amount = measure(value); + } + else if (regExp.RESOLUTION_UNIT.exec(value)) { + valueType = 'resolution'; + amount = parseInt(value, 10); + var unit = value.substring((amount + '').length); + } + else if (regExp.ASPECT_RATIO.exec(value)) { + valueType = 'aspect-ratio'; + amount = value.split('/'); + } + else if (regExp.ABSOLUTE_VALUE) { + valueType = 'absolute'; + amount = value; + } + else { + valueType = 'unknown'; + } + } + + var width, height; + if ('device-width' === feature.substring(l - 12, l)) { // screen width + width = screen.width; + if (value !== null) { + if (valueType === 'length') { + return ((min && width >= amount) || (max && width < amount) || (!min && !max && width === amount)); + } + else { + return false; + } + } + else { // test width without value + return width > 0; + } + } + else if ('device-height' === feature.substring(l - 13, l)) { // screen height + height = screen.height; + if (value !== null) { + if (valueType === 'length') { + return ((min && height >= amount) || (max && height < amount) || (!min && !max && height === amount)); + } + else { + return false; + } + } + else { // test height without value + return height > 0; + } + } + else if ('width' === feature.substring(l - 5, l)) { // viewport width + width = document.documentElement.clientWidth || document.body.clientWidth; // the latter for IE quirks mode + if (value !== null) { + if (valueType === 'length') { + return ((min && width >= amount) || (max && width < amount) || (!min && !max && width === amount)); + } + else { + return false; + } + } + else { // test width without value + return width > 0; + } + } + else if ('height' === feature.substring(l - 6, l)) { // viewport height + height = document.documentElement.clientHeight || document.body.clientHeight; // the latter for IE quirks mode + if (value !== null) { + if (valueType === 'length') { + return ((min && height >= amount) || (max && height < amount) || (!min && !max && height === amount)); + } + else { + return false; + } + } + else { // test height without value + return height > 0; + } + } + else if ('device-aspect-ratio' === feature.substring(l - 19, l)) { // screen aspect ratio + return valueType === 'aspect-ratio' && screen.width * amount[1] === screen.height * amount[0]; + } + else if ('color-index' === feature.substring(l - 11, l)) { // number of colors + var colors = Math.pow(2, screen.colorDepth); + if (value !== null) { + if (valueType === 'absolute') { + return ((min && colors >= amount) || (max && colors < amount) || (!min && !max && colors === amount)); + } + else { + return false; + } + } + else { // test height without value + return colors > 0; + } + } + else if ('color' === feature.substring(l - 5, l)) { // bits per color component + var color = screen.colorDepth; + if (value !== null) { + if (valueType === 'absolute') { + return ((min && color >= amount) || (max && color < amount) || (!min && !max && color === amount)); + } + else { + return false; + } + } + else { // test height without value + return color > 0; + } + } + else if ('resolution' === feature.substring(l - 10, l)) { + var res; + if (unit === 'dpcm') { + res = measure('1cm'); + } + else { + res = measure('1in'); + } + if (value !== null) { + if (valueType === 'resolution') { + return ((min && res >= amount) || (max && res < amount) || (!min && !max && res === amount)); + } + else { + return false; + } + } + else { // test height without value + return res > 0; + } + } + else { + return false; + } + }; + + var testMediaQuery = function (mq) { + var test = mq.getValid(); + var expressions = mq.getExpressions(); + var l = expressions.length; + if (l > 0) { + for (var i = 0; i < l && test; i++) { + test = testMediaFeature(expressions[i].mediaFeature, expressions[i].value); + } + var not = mq.getNot(); + return (test && !not || not && !test); + } + return test; + }; + + var testMediaQueryList = function (mql, ts) { + // ts is null or an array with any media type but 'all'. + var mqs = mql.getMediaQueries(); + var t = {}; + for (var i = 0; i < mqs.length; i++) { + var type = mqs[i].getMediaType(); + if (mqs[i].getExpressions().length === 0) { + continue; + // TODO: Browser check! Assuming old browsers do apply the bare media types, even in a list with media queries. + } + var typeAllowed = true; + if (type !== 'all' && ts && ts.length > 0) { + typeAllowed = false; + for (var j = 0; j < ts.length; j++) { + if (ts[j] === type) { + typeAllowed = true; + } + } + } + if (typeAllowed && testMediaQuery(mqs[i])) { + t[type] = true; + } + } + var s = [], c = 0; + for (var n in t) { + if (t.hasOwnProperty(n)) { + if (c > 0) { + s[c++] = ','; + } + s[c++] = n; + } + } + if (s.length > 0) { + styles[styles.length] = cssHelper.addStyle('@media ' + s.join('') + '{' + mql.getCssText() + '}', ts, false); + } + }; + + var testMediaQueryLists = function (mqls, ts) { + for (var i = 0; i < mqls.length; i++) { + testMediaQueryList(mqls[i], ts); + } + }; + + var testStylesheet = function (stsh) { + var amqs = stsh.getAttrMediaQueries(); + var allPassed = false; + var t = {}; + for (var i = 0; i < amqs.length; i++) { + if (testMediaQuery(amqs[i])) { + t[amqs[i].getMediaType()] = amqs[i].getExpressions().length > 0; + } + } + var ts = [], tswe = []; + for (var n in t) { + if (t.hasOwnProperty(n)) { + ts[ts.length] = n; + if (t[n]) { + tswe[tswe.length] = n + } + if (n === 'all') { + allPassed = true; + } + } + } + if (tswe.length > 0) { // types with query expressions that passed the test + styles[styles.length] = cssHelper.addStyle(stsh.getCssText(), tswe, false); + } + var mqls = stsh.getMediaQueryLists(); + if (allPassed) { + // If 'all' in media attribute passed the test, then test all @media types in linked CSS and create style with those types. + testMediaQueryLists(mqls); + } + else { + // Or else, test only media attribute types that passed the test and also 'all'. + // For positive '@media all', create style with attribute types that passed their test. + testMediaQueryLists(mqls, ts); + } + }; + + var testStylesheets = function (stshs) { + for (var i = 0; i < stshs.length; i++) { + testStylesheet(stshs[i]); + } + if (ua.ie) { + // force repaint in IE + document.documentElement.style.display = 'block'; + setTimeout(function () { + document.documentElement.style.display = ''; + }, 0); + // delay broadcast somewhat for IE + setTimeout(function () { + cssHelper.broadcast('cssMediaQueriesTested'); + }, 100); + } + else { + cssHelper.broadcast('cssMediaQueriesTested'); + } + }; + + var test = function () { + for (var i = 0; i < styles.length; i++) { + cssHelper.removeStyle(styles[i]); + } + styles = []; + cssHelper.stylesheets(testStylesheets); + }; + + var scrollbarWidth = 0; + var checkForResize = function () { + var cvpw = cssHelper.getViewportWidth(); + var cvph = cssHelper.getViewportHeight(); + + // determine scrollbar width in IE, see resizeHandler + if (ua.ie) { + var el = document.createElement('div'); + el.style.position = 'absolute'; + el.style.top = '-9999em'; + el.style.overflow = 'scroll'; + document.body.appendChild(el); + scrollbarWidth = el.offsetWidth - el.clientWidth; + document.body.removeChild(el); + } + + var timer; + var resizeHandler = function () { + var vpw = cssHelper.getViewportWidth(); + var vph = cssHelper.getViewportHeight(); + // check whether vp size has really changed, because IE also triggers resize event when body size changes + // 20px allowance to accommodate short appearance of scrollbars in IE in some cases + if (Math.abs(vpw - cvpw) > scrollbarWidth || Math.abs(vph - cvph) > scrollbarWidth) { + cvpw = vpw; + cvph = vph; + clearTimeout(timer); + timer = setTimeout(function () { + if (!nativeSupport()) { + test(); + } + else { + cssHelper.broadcast('cssMediaQueriesTested'); + } + }, 500); + } + }; + + window.onresize = function () { + var x = window.onresize || function () {}; // save original + return function () { + x(); + resizeHandler(); + }; + }(); + }; + + // prevent jumping of layout by hiding everything before painting <body> + var docEl = document.documentElement; + docEl.style.marginLeft = '-32767px'; + + // make sure it comes back after a while + setTimeout(function () { + docEl.style.marginLeft = ''; + }, 5000); + + return function () { + if (!nativeSupport()) { // if browser doesn't support media queries + cssHelper.addListener('newStyleParsed', function (el) { + testStylesheet(el.cssHelperParsed.stylesheet); + }); + // return visibility after media queries are tested + cssHelper.addListener('cssMediaQueriesTested', function () { + // force repaint in IE by changing width + if (ua.ie) { + docEl.style.width = '1px'; + } + setTimeout(function () { + docEl.style.width = ''; // undo width + docEl.style.marginLeft = ''; // undo hide + }, 0); + // remove this listener to prevent following execution + cssHelper.removeListener('cssMediaQueriesTested', arguments.callee); + }); + createMeter(); + test(); + } + else { + docEl.style.marginLeft = ''; // undo visibility hidden + } + checkForResize(); + }; +}()); + + +// bonus: hotfix for IE6 SP1 (bug KB823727) +try { + document.execCommand('BackgroundImageCache', false, true); +} catch (e) {} |