mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 21:53:08 +00:00
[Themes] Match themes from stylesheet loader
This commit is contained in:
parent
226f0932da
commit
bda1bf9f9a
@ -38,8 +38,9 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param {object[]} stylesheets stylesheet extension definitions
|
* @param {object[]} stylesheets stylesheet extension definitions
|
||||||
* @param $document Angular's jqLite-wrapped document element
|
* @param $document Angular's jqLite-wrapped document element
|
||||||
|
* @param {string} activeTheme the theme in use
|
||||||
*/
|
*/
|
||||||
function StyleSheetLoader(stylesheets, $document) {
|
function StyleSheetLoader(stylesheets, $document, activeTheme) {
|
||||||
var head = $document.find('head'),
|
var head = $document.find('head'),
|
||||||
document = $document[0];
|
document = $document[0];
|
||||||
|
|
||||||
@ -62,8 +63,15 @@ define(
|
|||||||
head.append(link);
|
head.append(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stylesheets which specify themes should only be applied
|
||||||
|
// when that theme has been declared.
|
||||||
|
function matchesTheme(stylesheet) {
|
||||||
|
return stylesheet.theme === undefined ||
|
||||||
|
stylesheet.theme === activeTheme;
|
||||||
|
}
|
||||||
|
|
||||||
// Add all stylesheets from extensions
|
// Add all stylesheets from extensions
|
||||||
stylesheets.forEach(addStyleSheet);
|
stylesheets.filter(matchesTheme).forEach(addStyleSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StyleSheetLoader;
|
return StyleSheetLoader;
|
||||||
|
Loading…
Reference in New Issue
Block a user