mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 09:25:29 +00:00
[Stylesheets] Add style sheet loader
Add style sheet loader and move style sheets inclusion out of index.html. WTD-591.
This commit is contained in:
@ -3,6 +3,30 @@
|
||||
"description": "General UI elements, meant to be reused across modes.",
|
||||
"resources": "res",
|
||||
"extensions": {
|
||||
"runs": [
|
||||
{
|
||||
"implementation": "StyleSheetLoader.js",
|
||||
"depends": [ "stylesheets[]", "$document" ]
|
||||
}
|
||||
],
|
||||
"stylesheets": [
|
||||
{
|
||||
"stylesheetUrl": "css/normalize.min.css",
|
||||
"priority": "mandatory"
|
||||
},
|
||||
{
|
||||
"stylesheetUrl": "css/theme-espresso.css",
|
||||
"priority": 1000
|
||||
},
|
||||
{
|
||||
"stylesheetUrl": "css/items.css",
|
||||
"priority": 901
|
||||
},
|
||||
{
|
||||
"stylesheetUrl": "css/tree.css",
|
||||
"priority": 900
|
||||
}
|
||||
],
|
||||
"templates": [
|
||||
{
|
||||
"key": "bottombar",
|
||||
|
31
platform/commonUI/general/src/StyleSheetLoader.js
Normal file
31
platform/commonUI/general/src/StyleSheetLoader.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
["angular"],
|
||||
function (angular) {
|
||||
"use strict";
|
||||
|
||||
function StyleSheetLoader(stylesheets, $document) {
|
||||
var head = $document.find('head');
|
||||
|
||||
function addStyleSheet(stylesheet) {
|
||||
var link = angular.element('<link>'),
|
||||
path = [
|
||||
stylesheet.bundle.path,
|
||||
stylesheet.bundle.resources,
|
||||
stylesheet.stylesheetUrl
|
||||
].join("/");
|
||||
|
||||
link.attr("rel", "stylesheet");
|
||||
link.attr("type", "text/css");
|
||||
link.attr("href", path);
|
||||
|
||||
head.append(link);
|
||||
}
|
||||
|
||||
stylesheets.forEach(addStyleSheet);
|
||||
}
|
||||
|
||||
return StyleSheetLoader;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user