Files
holder/holder.js
2014-08-03 03:42:40 -04:00

12 lines
20 KiB
JavaScript

/*!
Holder - client side image placeholders
Version 2.4.0+b2cnc
© 2014 Ivan Malopinsky - http://imsky.co
Site: http://imsky.github.io/holder
Issues: https://github.com/imsky/holder/issues
License: http://opensource.org/licenses/MIT
*/
!function(e,t,n){t[e]=n}("onDomReady",this,function(e){"use strict";function t(e){if(!b){if(!a.body)return i(t);for(b=!0;e=S.shift();)i(e)}}function n(e){(y||e.type===l||a[c]===d)&&(r(),t())}function r(){y?(a[x](p,n,u),e[x](l,n,u)):(a[g](v,n),e[g](h,n))}function i(e,t){setTimeout(e,+t>=0?t:1)}function o(e){b?i(e):S.push(e)}null==document.readyState&&document.addEventListener&&(document.addEventListener("DOMContentLoaded",function A(){document.removeEventListener("DOMContentLoaded",A,!1),document.readyState="complete"},!1),document.readyState="loading");var a=e.document,s=a.documentElement,l="load",u=!1,h="on"+l,d="complete",c="readyState",f="attachEvent",g="detachEvent",m="addEventListener",p="DOMContentLoaded",v="onreadystatechange",x="removeEventListener",y=m in a,w=u,b=u,S=[];if(a[c]===d)i(t);else if(y)a[m](p,n,u),e[m](l,n,u);else{a[f](v,n),e[f](h,n);try{w=null==e.frameElement&&s}catch(C){}w&&w.doScroll&&!function E(){if(!b){try{w.doScroll("left")}catch(e){return i(E,50)}r(),t()}}()}return o.version="1.4.0",o.isReady=function(){return b},o}(this)),document.querySelectorAll||(document.querySelectorAll=function(e){var t,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=e+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)t=document._qsa.shift(),t.style.removeAttribute("x-qsa"),r.push(t);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(e){return e=String(e).replace(/^|\s+/g,"."),document.querySelectorAll(e)}),Object.keys||(Object.keys=function(e){if(e!==Object(e))throw TypeError("Object.keys called on non-object");var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.push(t);return n}),function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.atob=e.atob||function(e){e=String(e);var n,r=0,i=[],o=0,a=0;if(e=e.replace(/\s/g,""),e.length%4===0&&(e=e.replace(/=+$/,"")),e.length%4===1)throw Error("InvalidCharacterError");if(/[^+/0-9A-Za-z]/.test(e))throw Error("InvalidCharacterError");for(;r<e.length;)n=t.indexOf(e.charAt(r)),o=o<<6|n,a+=6,24===a&&(i.push(String.fromCharCode(o>>16&255)),i.push(String.fromCharCode(o>>8&255)),i.push(String.fromCharCode(255&o)),a=0,o=0),r+=1;return 12===a?(o>>=4,i.push(String.fromCharCode(255&o))):18===a&&(o>>=2,i.push(String.fromCharCode(o>>8&255)),i.push(String.fromCharCode(255&o))),i.join("")},e.btoa=e.btoa||function(e){e=String(e);var n,r,i,o,a,s,l,u=0,h=[];if(/[^\x00-\xFF]/.test(e))throw Error("InvalidCharacterError");for(;u<e.length;)n=e.charCodeAt(u++),r=e.charCodeAt(u++),i=e.charCodeAt(u++),o=n>>2,a=(3&n)<<4|r>>4,s=(15&r)<<2|i>>6,l=63&i,u===e.length+2?(s=64,l=64):u===e.length+1&&(l=64),h.push(t.charAt(o),t.charAt(a),t.charAt(s),t.charAt(l));return h.join("")}}(this),function(){function e(t,n,r){t.document;var i,o=t.currentStyle[n].match(/([\d\.]+)(%|cm|em|in|mm|pc|pt|)/)||[0,0,""],a=o[1],s=o[2];return r=r?/%|em/.test(s)&&t.parentElement?e(t.parentElement,"fontSize",null):16:r,i="fontSize"==n?r:/width/i.test(n)?t.clientWidth:t.clientHeight,"%"==s?a/100*i:"cm"==s?.3937*a*96:"em"==s?a*r:"in"==s?96*a:"mm"==s?.3937*a*96/10:"pc"==s?12*a*96/72:"pt"==s?96*a/72:a}function t(e,t){var n="border"==t?"Width":"",r=t+"Top"+n,i=t+"Right"+n,o=t+"Bottom"+n,a=t+"Left"+n;e[t]=(e[r]==e[i]&&e[r]==e[o]&&e[r]==e[a]?[e[r]]:e[r]==e[o]&&e[a]==e[i]?[e[r],e[i]]:e[a]==e[i]?[e[r],e[i],e[o]]:[e[r],e[i],e[o],e[a]]).join(" ")}function n(n){var r,i=this,o=n.currentStyle,a=e(n,"fontSize"),s=function(e){return"-"+e.toLowerCase()};for(r in o)if(Array.prototype.push.call(i,"styleFloat"==r?"float":r.replace(/[A-Z]/,s)),"width"==r)i[r]=n.offsetWidth+"px";else if("height"==r)i[r]=n.offsetHeight+"px";else if("styleFloat"==r)i.float=o[r];else if(/margin.|padding.|border.+W/.test(r)&&"auto"!=i[r])i[r]=Math.round(e(n,r,a))+"px";else if(/^outline/.test(r))try{i[r]=o[r]}catch(l){i.outlineColor=o.color,i.outlineStyle=i.outlineStyle||"none",i.outlineWidth=i.outlineWidth||"0px",i.outline=[i.outlineColor,i.outlineWidth,i.outlineStyle].join(" ")}else i[r]=o[r];t(i,"margin"),t(i,"padding"),t(i,"border"),i.fontSize=Math.round(a)+"px"}window.getComputedStyle||(n.prototype={constructor:n,getPropertyPriority:function(){throw new Error("NotSupportedError: DOM Exception 9")},getPropertyValue:function(e){return this[e.replace(/-\w/g,function(e){return e[1].toUpperCase()})]},item:function(e){return this[e]},removeProperty:function(){throw new Error("NoModificationAllowedError: DOM Exception 7")},setProperty:function(){throw new Error("NoModificationAllowedError: DOM Exception 7")},getPropertyCSSValue:function(){throw new Error("NotSupportedError: DOM Exception 9")}},window.getComputedStyle=Window.prototype.getComputedStyle=function(e){return new n(e)})}(),Object.prototype.hasOwnProperty||(Object.prototype.hasOwnProperty=function(e){var t=this.__proto__||this.constructor.prototype;return e in this&&(!(e in t)||t[e]!==this[e])}),function(e,t){e.augment=t()}(this,function(){"use strict";var e=function(){},t=Array.prototype.slice,n=function(n,r){var i=e.prototype="function"==typeof n?n.prototype:n,o=new e,a=r.apply(o,t.call(arguments,2).concat(i));if("object"==typeof a)for(var s in a)o[s]=a[s];if(!o.hasOwnProperty("constructor"))return o;var l=o.constructor;return l.prototype=o,l};return n.defclass=function(e){var t=e.constructor;return t.prototype=e,t},n.extend=function(e,t){return n(e,function(e){return this.uber=e,t})},n}),function(e,t){function n(e,t,n,o){var a=r(n.substr(n.lastIndexOf(e.domain)),e);a&&i(a.fluid?"fluid":"image",o,a,n,t)}function r(e,t){for(var n={theme:f(w.settings.themes.gray,null),stylesheets:t.stylesheets},r=!1,i=e.split("/"),o=i.length,a=0;o>a;a++){var s=i[a];if(w.flags.dimensions.match(s))r=!0,n.dimensions=w.flags.dimensions.output(s);else if(w.flags.fluid.match(s))r=!0,n.dimensions=w.flags.fluid.output(s),n.fluid=!0;else if(w.flags.textmode.match(s))n.textmode=w.flags.textmode.output(s);else if(w.flags.colors.match(s)){var l=w.flags.colors.output(s);n.theme=f(n.theme,l)}else if(t.themes[s])t.themes.hasOwnProperty(s)&&(n.theme=f(t.themes[s],null));else if(w.flags.font.match(s))n.font=w.flags.font.output(s);else if(w.flags.auto.match(s))n.auto=!0;else if(w.flags.text.match(s))n.text=w.flags.text.output(s);else if(w.flags.random.match(s)){null==w.vars.cache.themeKeys&&(w.vars.cache.themeKeys=Object.keys(t.themes));var u=w.vars.cache.themeKeys[0|Math.random()*w.vars.cache.themeKeys.length];n.theme=f(t.themes[u],null)}}return r?n:!1}function i(e,t,n,r,i){var a=n.dimensions,s=n.theme,u=n.text?decodeURIComponent(n.text):n.text,d=a.width+"x"+a.height,c={};u&&(c.text=u),n.font&&(c.font=n.font),s=f(s,c),"background"==e?null==t.getAttribute("data-background-src")&&t.setAttribute("data-background-src",r):t.setAttribute("data-src",r),n.theme=s,t.holderData={flags:n,renderSettings:i},("image"==e||"fluid"==e)&&t.setAttribute("alt",u?u:s.text?s.text+" ["+d+"]":d),"image"==e?("html"!=i.renderer&&n.auto||(t.style.width=a.width+"px",t.style.height=a.height+"px"),"html"==i.renderer?t.style.backgroundColor=s.background:(o(e,{dimensions:a,theme:s,flags:n},t,i),n.textmode&&"exact"==n.textmode&&(w.vars.resizableImages.push(t),l(t)))):"background"==e&&"html"!=i.renderer?o(e,{dimensions:a,theme:s,flags:n},t,i):"fluid"==e&&("%"==a.height.slice(-1)?t.style.height=a.height:null!=n.auto&&n.auto||(t.style.height=a.height+"px"),"%"==a.width.slice(-1)?t.style.width=a.width:null!=n.auto&&n.auto||(t.style.width=a.width+"px"),("inline"==t.style.display||""===t.style.display||"none"==t.style.display)&&(t.style.display="block"),h(t),"html"==i.renderer?t.style.backgroundColor=s.background:(w.vars.resizableImages.push(t),l(t)))}function o(e,t,n,r){var i=null,o={width:t.dimensions.width,height:t.dimensions.height,theme:t.theme,flags:t.flags},s=a(o),l={text:o.text,width:o.width,height:o.height,textHeight:o.font.size,font:o.font.family,fontWeight:o.font.weight,template:o.theme};switch(r.renderer){case"canvas":i=C(s);break;case"svg":i=A(l);break;default:throw"Holder: invalid renderer: "+r.renderer}if(null==i)throw"Holder: couldn't render placeholder";"background"==e?(n.style.backgroundImage="url("+i+")",n.style.backgroundSize=o.width+"px "+o.height+"px"):n.setAttribute("src",i),n.setAttribute("data-holder-rendered",!0)}function a(e){switch(e.font={family:e.theme.font?e.theme.font:"Arial, Helvetica, Open Sans, sans-serif",size:s(e.width,e.height,e.theme.size?e.theme.size:12),weight:e.theme.fontweight?e.theme.fontweight:"bold"},e.text=e.theme.text?e.theme.text:Math.floor(e.width)+"x"+Math.floor(e.height),e.flags.textmode){case"literal":e.text=e.flags.dimensions.width+"x"+e.flags.dimensions.height;break;case"exact":if(!e.flags.exactDimensions)break;e.text=Math.floor(e.flags.exactDimensions.width)+"x"+Math.floor(e.flags.exactDimensions.height)}var t=new E({width:e.width,height:e.height}),n=t.Shape,r=new n.Rect("holderBg",{fill:e.theme.background});r.resize(e.width,e.height),t.root.add(r);var i=new n.Group("holderTextGroup",{text:e.text,align:"center",font:e.font,fill:e.theme.foreground});i.moveTo(null,null,1),t.root.add(i);var o=i.textPositionData=S(t);if(i.properties.lineHeight=o.boundingBox.height,o.lineCount>1)for(var a=0;a<o.words.length;a++){o.words[a]}else if("center"==i.properties.align){i.moveTo((e.width-o.boundingBox.width)/2,(e.height-o.boundingBox.height)/2,null);var l=new n.Text(e.text);i.add(l)}return t}function s(e,t,n){t=parseInt(t,10),e=parseInt(e,10);var r=Math.max(t,e),i=Math.min(t,e),o=1/12,a=Math.min(.75*i,.75*r*o);return Math.round(Math.max(n,a))}function l(e){var t;t=null==e||null==e.nodeType?w.vars.resizableImages:[e];for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];if(r.holderData){var i=r.holderData.flags,a=u(r,y.invisibleErrorFn(l));if(a){if(i.fluid&&i.auto){var s=r.holderData.fluidConfig;switch(s.mode){case"width":a.height=a.width/s.ratio;break;case"height":a.width=a.height*s.ratio}}var h={dimensions:a,theme:i.theme,flags:i};i.textmode&&"exact"==i.textmode&&(i.exactDimensions=a,h.dimensions=i.dimensions),o("image",h,r,r.holderData.renderSettings)}}}}function u(e,t){var n={height:e.clientHeight,width:e.clientWidth};return n.height||n.width?(e.removeAttribute("data-holder-invisible"),n):(e.setAttribute("data-holder-invisible",!0),void t.call(this,e))}function h(e){if(e.holderData){var t=u(e,y.invisibleErrorFn(h));if(t){var n=e.holderData.flags,r={fluidHeight:"%"==n.dimensions.height.slice(-1),fluidWidth:"%"==n.dimensions.width.slice(-1),mode:null,initialDimensions:t};r.fluidWidth&&!r.fluidHeight?(r.mode="width",r.ratio=r.initialDimensions.width/parseFloat(n.dimensions.height)):!r.fluidWidth&&r.fluidHeight&&(r.mode="height",r.ratio=parseFloat(n.dimensions.width)/r.initialDimensions.height),e.holderData.fluidConfig=r}}}function d(e,t,n){return null==e&&(e=document.createElementNS(b,"svg")),e.webkitMatchesSelector&&e.setAttribute("xmlns",b),e.setAttribute("width",t),e.setAttribute("height",n),e.setAttribute("viewBox","0 0 "+t+" "+n),e.setAttribute("preserveAspectRatio","none"),e}function c(e){if(t.XMLSerializer){var n=new XMLSerializer,r="";return r+n.serializeToString(e)}}function f(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);if(null!=t)for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);return n}function g(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n+":"+e[n]);return t.join(";")}function m(e){w.vars.debounceTimer||e.call(this),w.vars.debounceTimer&&clearTimeout(w.vars.debounceTimer),w.vars.debounceTimer=setTimeout(function(){w.vars.debounceTimer=null,e.call(this)},w.setup.debounce)}function p(){m(function(){l(null)})}function v(e){var n=null;return"string"==typeof e?n=document.querySelectorAll(e):t.NodeList&&e instanceof t.NodeList?n=e:t.Node&&e instanceof t.Node?n=[e]:t.HTMLCollection&&e instanceof t.HTMLCollection&&(n=e),n}function x(e,t){var n=new Image;n.onerror=function(){t.call(this,!1,e)},n.onload=function(){t.call(this,!0,e)},n.src=e.src}var y={addTheme:function(e,t){return null!=e&&null!=t&&(w.settings.themes[e]=t),delete w.vars.cache.themeKeys,this},addImage:function(e,t){var n=document.querySelectorAll(t);if(n.length)for(var r=0,i=n.length;i>r;r++){var o=document.createElement("img");o.setAttribute("data-src",e),n[r].appendChild(o)}return this},run:function(e){var o={};w.vars.preempted=!0;var a=f(w.settings,e),s=[],l=[],u=[];o.renderer=a.renderer?a.renderer:w.setup.renderer,a.use_canvas?o.renderer="canvas":a.use_svg&&(o.renderer="svg"),s=v(a.images),l=v(a.bgnodes),u=v(a.stylenodes);for(var h=new RegExp(a.domain+'/(.*?)"?\\)'),d=0;d<l.length;d++)if("link"!=l[d].tagName.toLowerCase()){var c=t.getComputedStyle(l[d],null).getPropertyValue("background-image"),g=c.match(h),m=null;if(null==g){var p=l[d].getAttribute("data-background-src");null!=p&&(m=p)}else m=a.domain+"/"+g[1];if(null!=m){var y=r(m,a);y&&i("background",l[d],y,m,o)}}for(d=0;d<s.length;d++){var b,S,C;S=b=C=null;var A=null,E=s[d];try{S=E.getAttribute("src"),b=E.getAttribute("data-src"),A=E.getAttribute("data-holder-rendered")}catch(k){}var z=null!=S,D=null!=b,O=D&&0===b.indexOf(a.domain),T=null!=A&&"true"==A;z?0===S.indexOf(a.domain)?n(a,o,S,E):O&&(T?n(a,o,b,E):x({src:S,options:a,renderSettings:o,dataSrc:b,image:E},function(e,t){e||n(t.options,t.renderSettings,t.dataSrc,t.image)})):O&&n(a,o,b,E)}return this},invisibleErrorFn:function(){return function(e){if(e.hasAttribute("data-holder-invisible"))throw"Holder: invisible placeholder"}}},w={settings:{domain:"holder.js",images:"img",bgnodes:".holderjs",stylenodes:"link.holderjs",stylesheets:[],themes:{gray:{background:"#EEEEEE",foreground:"#AAAAAA"},social:{background:"#3a5a97",foreground:"#FFFFFF"},industrial:{background:"#434A52",foreground:"#C2F200"},sky:{background:"#0D8FDB",foreground:"#FFFFFF"},vine:{background:"#39DBAC",foreground:"#1E292C"},lava:{background:"#F8591A",foreground:"#1C2846",size:12}}}},b="http://www.w3.org/2000/svg",S=function(){var e=null,t=null,n=null;return function(r){var i=r.root;if(w.setup.supportsSVG){var o=!1,a=function(e){return document.createTextNode(e)};null==e&&(o=!0),e=d(e,i.properties.width,i.properties.height),o&&(t=document.createElementNS(b,"text"),n=a(null),t.setAttribute("x",0),t.appendChild(n),e.appendChild(t),document.body.appendChild(e),e.style.visibility="hidden",e.style.position="absolute",e.style.top="-100%",e.style.left="-100%");var s=i.children.holderTextGroup,l=s.properties;t.setAttribute("y",l.font.size),t.setAttribute("style",g({"font-weight":l.font.weight,"font-size":l.font.size+"px","font-family":l.font.family,"dominant-baseline":"middle"})),n.nodeValue=l.text;var u=t.getBBox(),h=Math.ceil(u.width/i.properties.width),c=l.text.split(" ");n.nodeValue=l.text.replace(/[ ]+/g,"");var f=t.getComputedTextLength(),m=u.width-f,p=Math.round(m/Math.max(1,c.length-1)),v=[];if(h>1){n.nodeValue="";for(var x=0;x<c.length;x++){n.nodeValue=c[x];var y=t.getBBox();v.push({text:c[x],width:y.width})}}return{spaceWidth:p,lineCount:h,boundingBox:u,words:v}}return!1}}(),C=function(){var e=document.createElement("canvas"),t=e.getContext("2d");return function(n){var r=n.root;e.width=w.dpr(r.properties.width),e.height=w.dpr(r.properties.height),t.textBaseline="middle",t.fillStyle=r.children.holderBg.properties.fill,t.fillRect(0,0,w.dpr(r.children.holderBg.width),w.dpr(r.children.holderBg.height));var i=r.children.holderTextGroup;t.font=i.properties.font.weight+" "+w.dpr(i.properties.font.size)+"px "+i.properties.font.family,t.fillStyle=i.properties.fill;for(var o in i.children){var a=i.children[o],s=w.dpr(i.x+a.x),l=w.dpr(i.y+a.y+i.properties.lineHeight/2);isNaN(s)||1/0==s||isNaN(l)||1/0==l||t.fillText(a.properties.text,s,l)}return e.toDataURL("image/png")}}(),A=(function(){var e=document.createElement("canvas"),t=e.getContext("2d");return function(n){var r=n.width*w.setup.ratio,i=n.height*w.setup.ratio;return e.width=r,e.height=i,t.fillStyle=n.template.background,t.fillRect(0,0,r,i),t.textAlign="center",t.textBaseline="middle",t.font=n.fontWeight+" "+n.textHeight*w.setup.ratio+"px "+n.font,t.fillStyle=n.template.foreground,t.fillText(n.text,r/2,i/2),e.toDataURL("image/png")}}(),function(){if(t.XMLSerializer){var e=d(null,0,0),n=document.createElementNS(b,"rect"),r=document.createElementNS(b,"text"),i=document.createTextNode(null);return r.setAttribute("text-anchor","middle"),r.appendChild(i),e.appendChild(n),e.appendChild(r),function(t){if(isNaN(t.width)||isNaN(t.height)||isNaN(t.textHeight))throw"Holder: incorrect properties passed to SVG constructor";return d(e,t.width,t.height),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttribute("fill",t.template.background),r.setAttribute("x",t.width/2),r.setAttribute("y",t.height/2),i.nodeValue=t.text,r.setAttribute("style",g({fill:t.template.foreground,"font-weight":t.fontWeight,"font-size":t.textHeight+"px","font-family":t.font,"dominant-baseline":"central"})),"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(c(e,null))))}}}()),E=function(e){function t(e,t){for(var n in t)e[n]=t[n];return e}function n(){var e=[];for(var t in i)i.hasOwnProperty(t)&&e.push(i[t]);return i={},e}var r=1,i={},o=augment.defclass({constructor:function(e){r++,this.parent=null,this.children={},this.id=r,this.name="n"+r,null!=e&&(this.name=e),this.x=0,this.y=0,this.z=0,this.width=0,this.height=0},resize:function(e,t){null!=e&&(this.width=e),null!=t&&(this.height=t)},move:function(e,t,n){this.x+=e,this.y+=t,this.z+=n},moveTo:function(e,t,n){this.x=null!=e?e:this.x,this.y=null!=t?t:this.y,this.z=null!=n?n:this.z},add:function(e){var t=e.name;if(null!=this.children[t])throw"SceneGraph: child with that name already exists: "+t;this.children[t]=e,e.parent=this},remove:function(e){if(null==this.children[e])throw"SceneGraph: child with that name doesn't exist: "+e;child.parent=null,delete this.children[e]},removeAll:function(){for(var e in this.children)this.remove(e)}}),a=augment(o,function(t){this.constructor=function(){t.constructor.call(this,"root"),this.properties=e}}),s=augment(o,function(e){function n(n,r){if(e.constructor.call(this,n),this.properties={fill:"#000"},null!=r)t(this.properties,r);else if(null!=n&&"string"!=typeof n)throw"SceneGraph: invalid node name"}this.Group=augment.extend(this,{constructor:n,type:"group"}),this.Rect=augment.extend(this,{constructor:n,type:"rect"}),this.Text=augment.extend(this,{constructor:function(e){n.call(this),this.properties.text=e},type:"text"})}),l=new a;return this.Shape=s,this.root=l,this.flushChangedNodes=n,this};y.add_theme=y.addTheme,y.add_image=y.addImage,y.invisible_error_fn=y.invisibleErrorFn,w.flags={dimensions:{regex:/^(\d+)x(\d+)$/,output:function(e){var t=this.regex.exec(e);return{width:+t[1],height:+t[2]}}},fluid:{regex:/^([0-9%]+)x([0-9%]+)$/,output:function(e){var t=this.regex.exec(e);return{width:t[1],height:t[2]}}},colors:{regex:/#([0-9a-f]{3,})\:#([0-9a-f]{3,})/i,output:function(e){var t=this.regex.exec(e);return{foreground:"#"+t[2],background:"#"+t[1]}}},text:{regex:/text\:(.*)/,output:function(e){return this.regex.exec(e)[1]}},font:{regex:/font\:(.*)/,output:function(e){return this.regex.exec(e)[1]}},auto:{regex:/^auto$/},textmode:{regex:/textmode\:(.*)/,output:function(e){return this.regex.exec(e)[1]}},random:{regex:/^random$/}};for(var k in w.flags)w.flags.hasOwnProperty(k)&&(w.flags[k].match=function(e){return e.match(this.regex)});w.setup={renderer:"html",debounce:100,ratio:1,supportsCanvas:!1,supportsSVG:!1},w.dpr=function(e){return e*w.setup.ratio},w.vars={preempted:!1,resizableImages:[],debounceTimer:null,cache:{}},function(){var e=1,n=1,r=document.createElement("canvas"),i=null;r.getContext&&-1!=r.toDataURL("image/png").indexOf("data:image/png")&&(w.setup.renderer="canvas",i=r.getContext("2d"),w.setup.supportsCanvas=!0),w.setup.supportsCanvas&&(e=t.devicePixelRatio||1,n=i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1),w.setup.ratio=e/n,document.createElementNS&&document.createElementNS(b,"svg").createSVGRect&&(w.setup.renderer="svg",w.setup.supportsSVG=!0)}(),e(y,"Holder",t),t.onDomReady&&t.onDomReady(function(){w.vars.preempted||y.run({}),t.addEventListener?(t.addEventListener("resize",p,!1),t.addEventListener("orientationchange",p,!1)):t.attachEvent("onresize",p),"object"==typeof t.Turbolinks&&t.document.addEventListener("page:change",function(){y.run({})})})}(function(e,t,n){var r="function"==typeof define&&define.amd;r?define(e):n[t]=e},this);