mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 19:38:20 -07:00
1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
define(function(){"use strict";function isLoaded(url){return importedCss.indexOf(url)!==-1}function removeFromLoadHistory(url){url=url.toLowerCase(),importedCss=importedCss.filter(function(c){return url.indexOf(c.toLowerCase())===-1})}var requireCss={};requireCss.normalize=function(name,normalize){return".css"===name.substr(name.length-4,4)&&(name=name.substr(0,name.length-4)),normalize(name)};var importedCss=[];return requireCss.load=function(cssId,req,load,config){var srch="/emby-webcomponents/require/requirecss",index=cssId.indexOf(srch);index!==-1&&(cssId="css"+cssId.substring(index+srch.length));var url=cssId+".css";if(url.indexOf("://")===-1&&(url=config.baseUrl+url),isLoaded(url))load();else{importedCss.push(url);var link=document.createElement("link");link.setAttribute("rel","stylesheet"),link.setAttribute("type","text/css"),link.onload=load;var linkUrl=url;config.urlArgs&&(linkUrl+=config.urlArgs(cssId,url)),link.setAttribute("href",linkUrl),document.head.appendChild(link)}},window.requireCss={removeStylesheet:function(stylesheet){stylesheet.parentNode.removeChild(stylesheet),removeFromLoadHistory(stylesheet.href)}},requireCss}); |