{"version":3,"sources":["asyncStyles.min.js"],"names":["loadCSS","href","before","media","ready","cb","doc","body","setTimeout","ref","window","document","ss","createElement","newMedia","refs","getElementsByTagName","childNodes","length","sheets","styleSheets","rel","parentNode","insertBefore","nextSibling","onloadcssdefined","resolvedHref","i","addEventListener","this","loadAllCSS","loadStyleSheets","$","grep","value","key","inArray","loadedStyleSheets","concat"],"mappings":"AAQA,GAAIA,SAAU,SAAUC,EAAMC,EAAQC,GAyBrC,QAASC,GAAOC,GACf,MAAIC,GAAIC,KACAF,QAERG,YAAW,WACVJ,EAAOC,KAxBT,GAGII,GAHAH,EAAMI,OAAOC,SACbC,EAAKN,EAAIO,cAAe,QACxBC,EAAWX,GAAS,KAExB,IAAID,EACHO,EAAMP,MAEF,CACJ,GAAIa,IAAST,EAAIC,MAAQD,EAAIU,qBAAsB,QAAU,IAAMC,UACnER,GAAMM,EAAMA,EAAKG,OAAS,GAG3B,GAAIC,GAASb,EAAIc,WACjBR,GAAGS,IAAM,aACTT,EAAGX,KAAOA,EAEVW,EAAGT,MAAQ,SAcXC,EAAO,WACNK,EAAIa,WAAWC,aAAcX,EAAMV,EAASO,EAAMA,EAAIe,cAGvD,IAAIC,GAAmB,SAAUpB,GAGhC,IAFA,GAAIqB,GAAed,EAAGX,KAClB0B,EAAIR,EAAOD,OACRS,KACN,GAAIR,EAAQQ,GAAI1B,OAASyB,EACxB,MAAOrB,IAGTG,YAAW,WACViB,EAAkBpB,KAgBpB,OAXIO,GAAGgB,kBACNhB,EAAGgB,iBAAkB,OAAQ,WAC5BC,KAAK1B,MAAQW,IAGfF,EAAGa,iBAAmBA,EACtBA,EAAiB,WACZb,EAAGT,QAAUW,IAChBF,EAAGT,MAAQW,KAGNF,GAGJkB,WAAa,WAEhBC,gBAAkBC,EAAEC,KAAMF,gBAAiB,SAAUG,EAAOC,GAC3D,MAAOH,GAAEI,QAASF,EAAOH,mBAAsBI,GAIhD,KAAK,GAAIR,GAAI,EAAGA,EAAII,gBAAgBb,OAAQS,IAC3C3B,QAAQ+B,gBAAgBJ,GAGzB,IAAkC,mBAAxB,GACT,GAAIU,KAGLA,GAAkBC,OAAOP,iBAEzBA,mBAGDD","file":"asyncStyles.min.js","sourcesContent":["/**************************************************************************\r\nName: asyncStyles.js\r\nDescription: Code for loading styles asynchronously\r\nDate Created: 2015-02-03 by Sophie Orta\r\nModified:\r\n**************************************************************************/\r\n\r\n// From https://github.com/filamentgroup/loadCSS/\r\nvar loadCSS = function( href, before, media ){\r\n\t// Arguments explained:\r\n\t// `href` [REQUIRED] is the URL for your CSS file.\r\n\t// `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet before\r\n\t\t// By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document.\r\n\t// `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'\r\n\tvar doc = window.document;\r\n\tvar ss = doc.createElement( \"link\" );\r\n\tvar newMedia = media || \"all\";\r\n\tvar ref;\r\n\tif( before ){\r\n\t\tref = before;\r\n\t}\r\n\telse {\r\n\t\tvar refs = ( doc.body || doc.getElementsByTagName( \"head\" )[ 0 ] ).childNodes;\r\n\t\tref = refs[ refs.length - 1];\r\n\t}\r\n\r\n\tvar sheets = doc.styleSheets;\r\n\tss.rel = \"stylesheet\";\r\n\tss.href = href;\r\n\t// temporarily set media to something inapplicable to ensure it'll fetch without blocking render\r\n\tss.media = \"only x\";\r\n\r\n\t// wait until body is defined before injecting link. This ensures a non-blocking load in IE11.\r\n\tfunction ready( cb ){\r\n\t\tif( doc.body ){\r\n\t\t\treturn cb();\r\n\t\t}\r\n\t\tsetTimeout(function(){\r\n\t\t\tready( cb );\r\n\t\t});\r\n\t}\r\n\t// Inject link\r\n\t\t// Note: the ternary preserves the existing behavior of \"before\" argument, but we could choose to change the argument to \"after\" in a later release and standardize on ref.nextSibling for all refs\r\n\t\t// Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/\r\n\tready( function(){\r\n\t\tref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );\r\n\t});\r\n\t// A method (exposed on return object for external use) that mimics onload by polling until document.styleSheets until it includes the new sheet.\r\n\tvar onloadcssdefined = function( cb ){\r\n\t\tvar resolvedHref = ss.href;\r\n\t\tvar i = sheets.length;\r\n\t\twhile( i-- ){\r\n\t\t\tif( sheets[ i ].href === resolvedHref ){\r\n\t\t\t\treturn cb();\r\n\t\t\t}\r\n\t\t}\r\n\t\tsetTimeout(function() {\r\n\t\t\tonloadcssdefined( cb );\r\n\t\t});\r\n\t};\r\n\r\n\t// once loaded, set link's media back to `all` so that the stylesheet applies once it loads\r\n\tif( ss.addEventListener ){\r\n\t\tss.addEventListener( \"load\", function(){\r\n\t\t\tthis.media = newMedia;\r\n\t\t});\r\n\t}\r\n\tss.onloadcssdefined = onloadcssdefined;\r\n\tonloadcssdefined(function() {\r\n\t\tif( ss.media !== newMedia ){\r\n\t\t\tss.media = newMedia;\r\n\t\t}\r\n\t});\r\n\treturn ss;\r\n};\r\n\r\nvar loadAllCSS = function() {\r\n\t/* http://www.paulirish.com/2010/duck-punching-with-jquery/ */\r\n\tloadStyleSheets = $.grep( loadStyleSheets, function( value, key ){\r\n\t\treturn $.inArray( value, loadStyleSheets ) === key;\r\n\t});\r\n\r\n\t// Start loading style sheets a little early\r\n\tfor (var i = 0; i < loadStyleSheets.length; i++) {\r\n\t\tloadCSS(loadStyleSheets[i]);\r\n\t};\r\n\r\n\tif (typeof(loadedStyleSheets) === 'undefined') {\r\n\t\tvar loadedStyleSheets = [];\r\n\t}\r\n\r\n\tloadedStyleSheets.concat(loadStyleSheets);\r\n\r\n\tloadStyleSheets = [];\r\n};\r\n\r\nloadAllCSS();\r\n"]}