mirror of
https://github.com/adulau/brouilleursdeblanc.git
synced 2024-11-23 10:37:10 +00:00
1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
window.matchMedia=window.matchMedia||function(e,t){"use strict";var n,r=e.documentElement,i=r.firstElementChild||r.firstChild,s=e.createElement("body"),o=e.createElement("div");o.id="mq-test-1";o.style.cssText="position:absolute;top:-100em";s.style.background="none";s.appendChild(o);return function(e){o.innerHTML='<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>';r.insertBefore(s,i);n=o.offsetWidth===42;r.removeChild(s);return{matches:n,media:e}}}(document);(function(e){"use strict";function x(){w(true)}var t={};e.respond=t;t.update=function(){};t.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(t.mediaQueriesSupported){return}var n=e.document,r=n.documentElement,i=[],s=[],o=[],u={},a=30,f=n.getElementsByTagName("head")[0]||r,l=n.getElementsByTagName("base")[0],c=f.getElementsByTagName("link"),h=[],p=function(){for(var t=0;t<c.length;t++){var n=c[t],r=n.href,i=n.media,s=n.rel&&n.rel.toLowerCase()==="stylesheet";if(!!r&&s&&!u[r]){if(n.styleSheet&&n.styleSheet.rawCssText){v(n.styleSheet.rawCssText,r,i);u[r]=true}else{if(!/^([a-zA-Z:]*\/\/)/.test(r)&&!l||r.replace(RegExp.$1,"").split("/")[0]===e.location.host){h.push({href:r,media:i})}}}}d()},d=function(){if(h.length){var t=h.shift();E(t.href,function(n){v(n,t.href,t.media);u[t.href]=true;e.setTimeout(function(){d()},0)})}},v=function(e,t,n){var r=e.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),o=r&&r.length||0;t=t.substring(0,t.lastIndexOf("/"));var u=function(e){return e.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+t+"$2$3")},a=!o&&n;if(t.length){t+="/"}if(a){o=1}for(var f=0;f<o;f++){var l,c,h,p;if(a){l=n;s.push(u(e))}else{l=r[f].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;s.push(RegExp.$2&&u(RegExp.$2))}h=l.split(",");p=h.length;for(var d=0;d<p;d++){c=h[d];i.push({media:c.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:s.length-1,hasquery:c.indexOf("(")>-1,minw:c.match(/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:c.match(/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}w()},m,g,y=function(){var e,t=n.createElement("div"),i=n.body,s=false;t.style.cssText="position:absolute;font-size:1em;width:1em";if(!i){i=s=n.createElement("body");i.style.background="none"}i.appendChild(t);r.insertBefore(i,r.firstChild);e=t.offsetWidth;if(s){r.removeChild(i)}else{i.removeChild(t)}e=b=parseFloat(e);return e},b,w=function(t){var u="clientWidth",l=r[u],h=n.compatMode==="CSS1Compat"&&l||n.body[u]||l,p={},d=c[c.length-1],v=(new Date).getTime();if(t&&m&&v-m<a){e.clearTimeout(g);g=e.setTimeout(w,a);return}else{m=v}for(var E in i){if(i.hasOwnProperty(E)){var S=i[E],x=S.minw,T=S.maxw,N=x===null,C=T===null,k="em";if(!!x){x=parseFloat(x)*(x.indexOf(k)>-1?b||y():1)}if(!!T){T=parseFloat(T)*(T.indexOf(k)>-1?b||y():1)}if(!S.hasquery||(!N||!C)&&(N||h>=x)&&(C||h<=T)){if(!p[S.media]){p[S.media]=[]}p[S.media].push(s[S.rules])}}}for(var L in o){if(o.hasOwnProperty(L)){if(o[L]&&o[L].parentNode===f){f.removeChild(o[L])}}}for(var A in p){if(p.hasOwnProperty(A)){var O=n.createElement("style"),M=p[A].join("\n");O.type="text/css";O.media=A;f.insertBefore(O,d.nextSibling);if(O.styleSheet){O.styleSheet.cssText=M}else{O.appendChild(n.createTextNode(M))}o.push(O)}}},E=function(e,t){var n=S();if(!n){return}n.open("GET",e,true);n.onreadystatechange=function(){if(n.readyState!==4||n.status!==200&&n.status!==304){return}t(n.responseText)};if(n.readyState===4){return}n.send(null)},S=function(){var t=false;try{t=new e.XMLHttpRequest}catch(n){t=new e.ActiveXObject("Microsoft.XMLHTTP")}return function(){return t}}();p();t.update=p;if(e.addEventListener){e.addEventListener("resize",x,false)}else if(e.attachEvent){e.attachEvent("onresize",x)}})(this);var responsiveNav=function(e,t){function y(e,t){if(!g){g=new m(e,t)}return g}var n=!!e.getComputedStyle;if(!e.getComputedStyle){e.getComputedStyle=function(e){this.el=e;this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;if(t==="float"){t="styleFloat"}if(n.test(t)){t=t.replace(n,function(){return arguments[2].toUpperCase()})}return e.currentStyle[t]?e.currentStyle[t]:null};return this}}var r,i,s,o=t.documentElement,u=t.getElementsByTagName("head")[0],a=t.createElement("style"),f=false,l=function(e,t,n,r){if("addEventListener"in e){try{e.addEventListener(t,n,r)}catch(i){if(typeof n==="object"&&n.handleEvent){e.addEventListener(t,function(e){n.handleEvent.call(n,e)},r)}else{throw i}}}else if("attachEvent"in e){if(typeof n==="object"&&n.handleEvent){e.attachEvent("on"+t,function(){n.handleEvent.call(n)})}else{e.attachEvent("on"+t,n)}}},c=function(e,t,n,r){if("removeEventListener"in e){try{e.removeEventListener(t,n,r)}catch(i){if(typeof n==="object"&&n.handleEvent){e.removeEventListener(t,function(e){n.handleEvent.call(n,e)},r)}else{throw i}}}else if("detachEvent"in e){if(typeof n==="object"&&n.handleEvent){e.detachEvent("on"+t,function(){n.handleEvent.call(n)})}else{e.detachEvent("on"+t,n)}}},h=function(e){var t=e.firstChild;while(t!==null&&t.nodeType!==1){t=t.nextSibling}return t},p=function(e,t){for(var n in t){e.setAttribute(n,t[n])}},d=function(e,t){e.className+=" "+t;e.className=e.className.replace(/(^\s*)|(\s*$)/g,"")},v=function(e,t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").replace(/(^\s*)|(\s*$)/g,"")},m=function(e,n){var s;this.options={animate:true,transition:400,label:"Menu",insert:"after",customToggle:"",openPos:"relative",jsClass:"js",init:function(){},open:function(){},close:function(){}};for(s in n){this.options[s]=n[s]}d(o,this.options.jsClass);this.wrapperEl=e.replace("#","");if(t.getElementById(this.wrapperEl)){this.wrapper=t.getElementById(this.wrapperEl)}else{throw new Error("The nav element you are trying to select doesn't exist")}this.wrapper.inner=h(this.wrapper);i=this.options;r=this.wrapper;this._init(this)};m.prototype={destroy:function(){this._removeStyles();v(r,"closed");v(r,"opened");r.removeAttribute("style");r.removeAttribute("aria-hidden");r=null;g=null;c(e,"load",this,false);c(e,"resize",this,false);c(s,"mousedown",this,false);c(s,"touchstart",this,false);c(s,"touchend",this,false);c(s,"keyup",this,false);c(s,"click",this,false);if(!i.customToggle){s.parentNode.removeChild(s)}else{s.removeAttribute("aria-hidden")}},toggle:function(){if(!f){v(r,"closed");d(r,"opened");r.style.position=i.openPos;p(r,{"aria-hidden":"false"});f=true;i.open()}else{v(r,"opened");d(r,"closed");p(r,{"aria-hidden":"true"});if(i.animate){setTimeout(function(){r.style.position="relative"},i.transition+10)}else{r.style.position="relative"}f=false;i.close()}},handleEvent:function(t){var n=t||e.event;switch(n.type){case"mousedown":this._onmousedown(n);break;case"touchstart":this._ontouchstart(n);break;case"touchend":this._ontouchend(n);break;case"keyup":this._onkeyup(n);break;case"click":this._onclick(n);break;case"load":this._transitions(n);this._resize(n);break;case"resize":this._resize(n);break}},_init:function(){d(r,"closed");this._createToggle();l(e,"load",this,false);l(e,"resize",this,false);l(s,"mousedown",this,false);l(s,"touchstart",this,false);l(s,"touchend",this,false);l(s,"keyup",this,false);l(s,"click",this,false)},_createStyles:function(){if(!a.parentNode){u.appendChild(a)}},_removeStyles:function(){if(a.parentNode){a.parentNode.removeChild(a)}},_createToggle:function(){if(!i.customToggle){var e=t.createElement("a");e.innerHTML=i.label;p(e,{href:"#",id:"nav-toggle"});if(i.insert==="after"){r.parentNode.insertBefore(e,r.nextSibling)}else{r.parentNode.insertBefore(e,r)}s=t.getElementById("nav-toggle")}else{var n=i.customToggle.replace("#","");if(t.getElementById(n)){s=t.getElementById(n)}else{throw new Error("The custom nav toggle you are trying to select doesn't exist")}}},_preventDefault:function(e){if(e.preventDefault){e.preventDefault();e.stopPropagation()}else{e.returnValue=false}},_onmousedown:function(t){var n=t||e.event;if(!(n.which===3||n.button===2)){this._preventDefault(t);this.toggle(t)}},_ontouchstart:function(e){s.onmousedown=null;this._preventDefault(e);this.toggle(e)},_ontouchend:function(){var e=this;r.addEventListener("click",e._preventDefault,true);setTimeout(function(){r.removeEventListener("click",e._preventDefault,true)},i.transition)},_onkeyup:function(t){var n=t||e.event;if(n.keyCode===13){this.toggle(t)}},_onclick:function(e){this._preventDefault(e)},_transitions:function(){if(i.animate){var e=r.style,t="max-height "+i.transition+"ms";e.WebkitTransition=t;e.MozTransition=t;e.OTransition=t;e.transition=t}},_calcHeight:function(){var e=r.inner.offsetHeight,t="#"+this.wrapperEl+".opened{max-height:"+e+"px}";if(n){a.innerHTML=t;t=""}},_resize:function(){if(e.getComputedStyle(s,null).getPropertyValue("display")!=="none"){p(s,{"aria-hidden":"false"});if(r.className.match(/(^|\s)closed(\s|$)/)){p(r,{"aria-hidden":"true"});r.style.position="absolute"}this._createStyles();this._calcHeight()}else{p(s,{"aria-hidden":"true"});p(r,{"aria-hidden":"false"});r.style.position=i.openPos;this._removeStyles()}i.init()}};var g;return y}(window,document);(function(e){"use strict";e.fn.fitVids=function(t){var n={customSelector:null};var r=document.createElement("div"),i=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];r.className="fit-vids-style";r.innerHTML="<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>";i.parentNode.insertBefore(r,i);if(t){e.extend(n,t)}return this.each(function(){var t=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.youtube-nocookie.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(n.customSelector){t.push(n.customSelector)}var r=e(this).find(t.join(","));r.each(function(){var t=e(this);if(this.tagName.toLowerCase()==="embed"&&t.parent("object").length||t.parent(".fluid-width-video-wrapper").length){return}var n=this.tagName.toLowerCase()==="object"||t.attr("height")&&!isNaN(parseInt(t.attr("height"),10))?parseInt(t.attr("height"),10):t.height(),r=!isNaN(parseInt(t.attr("width"),10))?parseInt(t.attr("width"),10):t.width(),i=n/r;if(!t.attr("id")){var s="fitvid"+Math.floor(Math.random()*999999);t.attr("id",s)}t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",i*100+"%");t.removeAttr("height").removeAttr("width")})})}})(jQuery);var navigation=responsiveNav("#site-nav",{animate:true,transition:400,label:"<i class='icon-reorder'></i> Menu",insert:"before",customToggle:"",openPos:"relative",jsClass:"js",init:function(){},open:function(){},close:function(){}});$(function(){$("article").fitVids()}) |