diff --git a/core/Requirements.php b/core/Requirements.php index 98033d57f..62817a366 100644 --- a/core/Requirements.php +++ b/core/Requirements.php @@ -593,7 +593,7 @@ class Requirements_Backend { foreach(array_diff_key($this->css,$this->blocked) as $file => $params) { $path = $this->path_for_file($file); - if($path) $cssRequirements[] = $path; + if($path) $cssRequirements[] = isset($params['media']) ? "$path:##:$params[media]" : $path; } $response->addHeader('X-Include-CSS', implode(',', $cssRequirements)); diff --git a/javascript/core/jquery.ondemand.js b/javascript/core/jquery.ondemand.js index 05780d8f3..b416306c0 100644 --- a/javascript/core/jquery.ondemand.js +++ b/javascript/core/jquery.ondemand.js @@ -115,19 +115,19 @@ } }, - requireCss : function(styleUrl){ + requireCss : function(styleUrl, media){ + if(media == null) media = 'all'; if(document.createStyleSheet){ - document.createStyleSheet($.requireConfig.routeCss + styleUrl); - } - else { - + var ss = document.createStyleSheet($.requireConfig.routeCss + styleUrl); + ss.style.media = media; + + } else { var styleTag = document.createElement('link'); - $(styleTag).attr({ href : $.requireConfig.routeCss + styleUrl, type : 'text/css', - media : 'screen', + media : media, rel : 'stylesheet' }).appendTo($('head').get(0)); @@ -159,38 +159,7 @@ // We remove the success handler and take care of calling it outselves within _ondemandComplete s.success = null; s.complete = function(xml, status) { - var i; - // CSS - if(xml.getResponseHeader('X-Include-CSS')) { - var cssIncludes = xml.getResponseHeader('X-Include-CSS').split(','); - for(i=0;i 0) { - for(i=0;i 0) { for(i=0;i